-
Notifications
You must be signed in to change notification settings - Fork 805
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/ble_anp' into 'master'
feat(ble_anp): Add alert notification profile and examples Closes AEG-621 See merge request ae_group/esp-iot-solution!760
- Loading branch information
Showing
24 changed files
with
1,594 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
## v0.1.0 | ||
|
||
This is the first release version for Alert Notification Profile component in Espressif Component Registry, more detailed descriptions about the project, please refer to [User_Guide](https://docs.espressif.com/projects/espressif-esp-iot-solution/en/latest/bluetooth/ble_profiles.html). | ||
|
||
Features: | ||
- ANP: Support Alert Notification Profile. |
16 changes: 16 additions & 0 deletions
16
components/bluetooth/ble_profiles/std/ble_anp/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
set(srcs "") | ||
set(req "") | ||
set(include "") | ||
set(priv_includes "") | ||
set(priv_req "ble_conn_mgr") | ||
|
||
if(CONFIG_BLE_ALERT_NOTIFICATION_PROFILES) | ||
list(APPEND srcs "src/esp_anp.c") | ||
list(APPEND include "include") | ||
endif() | ||
|
||
idf_component_register(SRCS "${srcs}" | ||
INCLUDE_DIRS "${include}" | ||
PRIV_INCLUDE_DIRS "${priv_includes}" | ||
REQUIRES "${req}" | ||
PRIV_REQUIRES "${priv_req}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
menu "BLE Profile: Alert Notification" | ||
config BLE_ALERT_NOTIFICATION_PROFILES | ||
bool "Enable Alert Notification Profile" | ||
default n | ||
help | ||
Enable support for Alert Notification Profile. | ||
endmenu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
## Alert Notification Profile Component | ||
|
||
[![Component Registry](https://components.espressif.com/components/espressif/ble_anp/badge.svg)](https://components.espressif.com/components/espressif/ble_anp) | ||
|
||
- [User Guide](https://docs.espressif.com/projects/espressif-esp-iot-solution/en/latest/bluetooth/ble_profiles.html) | ||
|
||
``ble_anp`` is a component which provide a simplified API interface for accessing the commonly used BLE alert notification profile functionality on a GATT Client. | ||
|
||
### Add component to your project | ||
|
||
Please use the component manager command `add-dependency` to add the `ble_anp` to your project's dependency, during the `CMake` step the component will be downloaded automatically | ||
|
||
``` | ||
idf.py add-dependency "espressif/ble_anp=*" | ||
``` | ||
|
||
### Examples | ||
|
||
Please use the component manager command `create-project-from-example` to create the project from example template | ||
|
||
``` | ||
idf.py create-project-from-example "espressif/ble_anp=*:ble_anp" | ||
``` | ||
|
||
Then the example will be downloaded in current folder, you can check into it for build and flash. | ||
|
||
> You can use this command to download other examples. Or you can download examples from esp-iot-solution repository: | ||
1. [ble_anp](https://github.com/espressif/esp-iot-solution/tree/master/examples/bluetooth/ble_profiles/ble_anp) | ||
|
||
### Q&A | ||
|
||
Q1. I encountered the following problems when using the package manager | ||
|
||
``` | ||
HINT: Please check manifest file of the following component(s): main | ||
ERROR: Because project depends on esp-now (2.*) which doesn't match any | ||
versions, version solving failed. | ||
``` | ||
|
||
A1. For the examples downloaded by using this command, you need to comment out the override_path line in the main/idf_component.yml of each example. | ||
|
||
Q2. I encountered the following problems when using the package manager | ||
|
||
``` | ||
Executing action: create-project-from-example | ||
CMakeLists.txt not found in project directory /home/username | ||
``` | ||
|
||
A2. This is because an older version packege manager was used, please run `pip install -U idf-component-manager` in ESP-IDF environment to update. |
6 changes: 6 additions & 0 deletions
6
components/bluetooth/ble_profiles/std/ble_anp/idf_component.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
version: "0.1.0" | ||
description: BLE standard profile support Alert Notification | ||
url: https://github.com/espressif/esp-iot-solution/tree/master/components/bluetooth/ble_profiles/std/ble_anp | ||
issues: https://github.com/espressif/esp-iot-solution/issues | ||
examples: | ||
- path: ../../../../../examples/bluetooth/ble_profiles |
184 changes: 184 additions & 0 deletions
184
components/bluetooth/ble_profiles/std/ble_anp/include/esp_anp.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,184 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "esp_event.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" | ||
{ | ||
#endif | ||
|
||
/** @cond **/ | ||
/* BLE ANP EVENTS BASE */ | ||
ESP_EVENT_DECLARE_BASE(BLE_ANP_EVENTS); | ||
/** @endcond **/ | ||
|
||
/* 16 Bit Alert Notification Service UUID */ | ||
#define BLE_ANP_UUID16 0x1811 | ||
|
||
/* 16 Bit Alert Notification Service Characteristic UUIDs */ | ||
#define BLE_ANP_CHR_UUID16_SUP_NEW_ALERT_CAT 0x2A47 | ||
#define BLE_ANP_CHR_UUID16_NEW_ALERT 0x2A46 | ||
#define BLE_ANP_CHR_UUID16_SUP_UNR_ALERT_CAT 0x2A48 | ||
#define BLE_ANP_CHR_UUID16_UNR_ALERT_STAT 0x2A45 | ||
#define BLE_ANP_CHR_UUID16_ALERT_NOT_CTRL_PT 0x2A44 | ||
|
||
/* Alert Notification Service Category ID Bit Masks | ||
* | ||
* TODO: Add remaining 2 optional categories */ | ||
#define BLE_ANP_CAT_BM_NONE 0x00 | ||
#define BLE_ANP_CAT_BM_SIMPLE_ALERT 0x01 | ||
#define BLE_ANP_CAT_BM_EMAIL 0x02 | ||
#define BLE_ANP_CAT_BM_NEWS 0x04 | ||
#define BLE_ANP_CAT_BM_CALL 0x08 | ||
#define BLE_ANP_CAT_BM_MISSED_CALL 0x10 | ||
#define BLE_ANP_CAT_BM_SMS 0x20 | ||
#define BLE_ANP_CAT_BM_VOICE_MAIL 0x40 | ||
#define BLE_ANP_CAT_BM_SCHEDULE 0x80 | ||
|
||
/* Alert Notification Service Category IDs | ||
* | ||
* TODO: Add remaining 2 optional categories */ | ||
#define BLE_ANP_CAT_ID_SIMPLE_ALERT 0 | ||
#define BLE_ANP_CAT_ID_EMAIL 1 | ||
#define BLE_ANP_CAT_ID_NEWS 2 | ||
#define BLE_ANP_CAT_ID_CALL 3 | ||
#define BLE_ANP_CAT_ID_MISSED_CALL 4 | ||
#define BLE_ANP_CAT_ID_SMS 5 | ||
#define BLE_ANP_CAT_ID_VOICE_MAIL 6 | ||
#define BLE_ANP_CAT_ID_SCHEDULE 7 | ||
|
||
/* Number of valid ANS categories | ||
* | ||
* TODO: Add remaining 2 optional categories */ | ||
#define BLE_ANP_CAT_NUM 8 | ||
|
||
/* Alert Notification Control Point Command IDs */ | ||
#define BLE_ANP_CMD_EN_NEW_ALERT_CAT 0 | ||
#define BLE_ANP_CMD_EN_UNR_ALERT_CAT 1 | ||
#define BLE_ANP_CMD_DIS_NEW_ALERT_CAT 2 | ||
#define BLE_ANP_CMD_DIS_UNR_ALERT_CAT 3 | ||
#define BLE_ANP_CMD_NOT_NEW_ALERT_IMMEDIATE 4 | ||
#define BLE_ANP_CMD_NOT_UNR_ALERT_IMMEDIATE 5 | ||
|
||
/* Max length of new alert info string */ | ||
#define BLE_ANP_INFO_STR_MAX_LEN 18 | ||
|
||
/* Max length of a new alert notification, max string length + 2 bytes for category ID and count. */ | ||
#define BLE_ANP_NEW_ALERT_MAX_LEN (BLE_ANP_INFO_STR_MAX_LEN + 2) | ||
|
||
/** | ||
* @brief The status of the new or unread alert | ||
*/ | ||
typedef struct { | ||
union { | ||
struct { | ||
uint8_t cat_id; /*!< The predefined categories of unread alerts and messages */ | ||
uint8_t count; /*!< The number of unread alerts in the server ranging from 0 to 255 */ | ||
} unr_alert_stat; /*!< The status of unread alerts */ | ||
|
||
struct { | ||
uint8_t cat_id; /*!< The predefined categories of new alerts and messages */ | ||
uint8_t count; /*!< The number of new alerts in the server ranging from 0 to 255 */ | ||
uint8_t cat_info[BLE_ANP_INFO_STR_MAX_LEN]; /*!< The brief text information for the last alert */ | ||
} new_alert_val; /*!< The status of new alerts */ | ||
}; /*!< Alert notification status */ | ||
} esp_ble_anp_data_t; | ||
|
||
/** | ||
* @brief The option of the new or unread alert | ||
*/ | ||
typedef enum { | ||
BLE_ANP_OPT_ENABLE, | ||
BLE_ANP_OPT_DISABLE, | ||
BLE_ANP_OPT_RECOVER, | ||
} esp_ble_anp_option_t; | ||
|
||
/** | ||
* @brief Read the value of or check supported new alert category. | ||
* | ||
* @attention 1. When cat_id is 0xFF, read the value of supported new alert category. | ||
* @attention 2. When cat_id isn't 0xFF, check supported new alert category is enable or disable. | ||
* | ||
* @param[in] cat_id The ID of the category to read or check | ||
* @param[out] cat_val The value of read or check supported new alert category | ||
* | ||
* @return | ||
* - ESP_OK on successful | ||
* - ESP_ERR_INVALID_ARG on wrong category of the alert | ||
*/ | ||
esp_err_t esp_ble_anp_get_new_alert(uint8_t cat_id, uint8_t *cat_val); | ||
|
||
/** | ||
* @brief Request or recovery supported new alert notification to the given category. | ||
* | ||
* @attention 1. When cat_id is 0xFF, recover for all supported new alert category to get the current message counts. | ||
* @attention 2. When cat_id isn't 0xFF, request for a supported new alert category to get the current message counts. | ||
* | ||
* @param[in] cat_id The ID of the category to request or recover the notification to | ||
* @param[in] option Disable or enable supported new alert category | ||
* | ||
* @return | ||
* - ESP_OK on successful | ||
* - ESP_ERR_INVALID_ARG on wrong category of the alert | ||
*/ | ||
esp_err_t esp_ble_anp_set_new_alert(uint8_t cat_id, esp_ble_anp_option_t option); | ||
|
||
/** | ||
* @brief Read the value of or check supported unread alert status category. | ||
* | ||
* @attention 1. When cat_id is 0xFF, read the value of supported unread alert status category. | ||
* @attention 2. When cat_id isn't 0xFF, check supported unread alert status category is enable or disable. | ||
* | ||
* @param[in] cat_id The ID of the category to read or check | ||
* @param[out] cat_val The value of read or check supported unread alert status category | ||
* | ||
* @return | ||
* - ESP_OK on successful | ||
* - ESP_ERR_INVALID_ARG on wrong category of the alert | ||
*/ | ||
esp_err_t esp_ble_anp_get_unr_alert(uint8_t cat_id, uint8_t *cat_val); | ||
|
||
/** | ||
* @brief Request or recovery supported unread alert status notification to the given category. | ||
* | ||
* @attention 1. When cat_id is 0xFF, recover for all supported unread alert status category to get the current message counts. | ||
* @attention 2. When cat_id isn't 0xFF, request for an supported unread alert status category to get the current message counts. | ||
* | ||
* @param[in] cat_id The ID of the category to request or recover the notification to | ||
* @param[in] option Disable or enable supported unread alert status category | ||
* | ||
* @return | ||
* - ESP_OK on successful | ||
* - ESP_ERR_INVALID_ARG on wrong category of the alert | ||
*/ | ||
esp_err_t esp_ble_anp_set_unr_alert(uint8_t cat_id, esp_ble_anp_option_t option); | ||
|
||
/** | ||
* @brief Initialization GATT Alert Notification Profile | ||
* | ||
* @return | ||
* - ESP_OK on successful | ||
* - ESP_ERR_INVALID_ARG on wrong initialization | ||
* - ESP_FAIL on error | ||
*/ | ||
esp_err_t esp_ble_anp_init(void); | ||
|
||
/** | ||
* @brief Deinitialization GATT Alert Notification Profile | ||
* | ||
* @return | ||
* - ESP_OK on successful | ||
* - ESP_ERR_INVALID_ARG on wrong initialization | ||
* - ESP_FAIL on error | ||
*/ | ||
esp_err_t esp_ble_anp_deinit(void); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif |
Oops, something went wrong.