espressif/ble_conn_mgr
uploaded 5 months ago

0.1.0

A common layer to manage the BLE connection, support both Bluedroid and Nimble

readme

## BLE Connection Management Component [![Component Registry](https://components.espressif.com/components/espressif/ble_conn_mgr/badge.svg)](https://components.espressif.com/components/espressif/ble_conn_mgr) - [User Guide](https://docs.espressif.com/projects/espressif-esp-iot-solution/en/latest/bluetooth/ble_conn_mgr.html) The ``ble_conn_mgr`` is a BLE connection management component that provides a simplified API interface for accessing commonly used BLE functionalities. It supports various scenarios such as peripheral and central. Any application layer profile, such as GAP, GATT, GATT characteristics, and services, can be executed on top of this layer. > Note: only Nimble is supported, the support for Bluedroid will be added in later release version. ### Adding the component to your project To add the `ble_conn_mgr` to your project's dependencies, please use the command `idf.py add-dependency`. During the `CMake` step, the component will be downloaded automatically. ``` idf.py add-dependency "espressif/ble_conn_mgr=*" ``` ### Examples To create a project using the example template, please use the command `idf.py create-project-from-example`. * BLE SPP Central ``` idf.py create-project-from-example "espressif/ble_conn_mgr=*:spp_client" ``` * BLE SPP Peripheral ``` idf.py create-project-from-example "espressif/ble_conn_mgr=*:spp_server" ``` The example will be downloaded into the current folder. You can navigate to it for building and flashing. > You can use this command to download other examples as well. Alternatively, you can download examples from the esp-iot-solution repository: 1. [ble_periodic_adv](https://github.com/espressif/esp-iot-solution/tree/master/examples/bluetooth/ble_conn_mgr/ble_periodic_adv) 2. [ble_periodic_sync](https://github.com/espressif/esp-iot-solution/tree/master/examples/bluetooth/ble_conn_mgr/ble_periodic_sync) 3. [ble_spp](https://github.com/espressif/esp-iot-solution/tree/master/examples/bluetooth/ble_conn_mgr/ble_spp) ### Q&A Q1. 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 ``` A1. This is because an older version packege manager was used, please run `pip install -U idf-component-manager` in ESP-IDF environment to update.

changelog

## v0.1.0 This is the first release version for BLE connection management 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_conn_mgr.html). Features: - Roles: Support peripheral and central, client and server - Operations: Support GAP, GATT, GATT characteristic and services - Periodic: Support periodic advertising and sync with the advertiser

readme of ble_conn_mgr/ble_periodic_adv example

| Supported Targets | ESP32-C3 | ESP32-C2 | ESP32-S3 | | ----------------- | -------- | -------- | -------- | # BLE Periodic Advertiser Example (See the README.md file in the upper level 'examples' directory for more information about examples.) This example starts periodic advertising with non resolvable private address. It uses Bluetooth controller based on BLE connection management. This example aims at understanding periodic advertisement and related BLE connection management APIs. To test this demo, any BLE Periodic Sync app can be used. ## How to Use Example Before project configuration and build, be sure to set the correct chip target using: ```bash idf.py set-target <chip_name> ``` ### Hardware Required * A development board with ESP32-C3/ESP32-C2/ESP32-S3 SoC * A USB cable for Power supply and programming See [Development Boards](https://www.espressif.com/en/products/devkits) for more information about it. ### Configure the project Open the project configuration menu: ```bash idf.py menuconfig ``` In the `Example Configuration` menu: * Select advertisement name of device from `Example Configuration --> Advertisement name`, default is `ESP_PERIODIC_ADV`. * Select set extended advertisement data of device from `Example Configuration --> Enable Set Extended Adv Data`, default is `n`. ### Build and Flash Run `idf.py -p PORT flash monitor` to build, flash and monitor the project. (To exit the serial monitor, type ``Ctrl-]``.) See the [Getting Started Guide](https://idf.espressif.com/) for full steps to configure and use ESP-IDF to build projects. ## Example Output There is this console output when periodic_adv is started: ``` I (316) BTDM_INIT: BT controller compile version [80abacd] I (316) phy_init: phy_version 950,11a46e9,Oct 21 2022,08:56:12 I (366) system_api: Base MAC address is not set I (366) system_api: read default base MAC address from EFUSE I (376) BTDM_INIT: Bluetooth MAC: 84:f7:03:08:21:1a I (376) blecm_nimble: BLE Host Task Started I (386) blecm_nimble: getting characteristic(0x2a00) I (386) blecm_nimble: getting characteristic(0x2a01) I (396) blecm_nimble: getting characteristic(0x2a05) I (406) blecm_nimble: Instance 1 started (periodic) I (406) blecm_nimble: Instance 1 started (extended) ``` ## Troubleshooting For any technical queries, please open an [issue](https://github.com/espressif/esp-iot-solution/issues) on GitHub. We will get back to you soon.

readme of ble_conn_mgr/ble_periodic_sync example

| Supported Targets | ESP32-C3 | ESP32-C2 | ESP32-S3 | | ----------------- | -------- | -------- | -------- | # BLE Periodic Sync Example (See the README.md file in the upper level 'examples' directory for more information about examples.) This example performs passive scan for non-connectable non-scannable extended advertisement, it then establishes the periodic sync with the advertiser and then listens to the periodic advertisements. It uses Bluetooth controller based on BLE connection management. This example aims at understanding BLE periodic sync establishment and periodic advertisement reports. To test this demo, use any periodic advertiser with uses extended adv data as "ESP_PERIODIC_ADV". ## How to Use Example Before project configuration and build, be sure to set the correct chip target using: ```bash idf.py set-target <chip_name> ``` ### Hardware Required * A development board with ESP32-C3/ESP32-C2/ESP32-S3 SoC * A USB cable for Power supply and programming See [Development Boards](https://www.espressif.com/en/products/devkits) for more information about it. ### Configure the Project Open the project configuration menu: ```bash idf.py menuconfig ``` In the `Example Configuration` menu: * Select advertisement name of device from `Example Configuration --> Advertisement name`, default is `ESP_PERIODIC_ADV`. ### Build and Flash Run `idf.py -p PORT flash monitor` to build, flash and monitor the project. (To exit the serial monitor, type ``Ctrl-]``.) See the [Getting Started Guide](https://idf.espressif.com/) for full steps to configure and use ESP-IDF to build projects. ## Example Output This is the console output on successful periodic sync: ``` I (318) BTDM_INIT: BT controller compile version [80abacd] I (318) phy_init: phy_version 950,11a46e9,Oct 21 2022,08:56:12 I (368) system_api: Base MAC address is not set I (368) system_api: read default base MAC address from EFUSE I (368) BTDM_INIT: Bluetooth MAC: 84:f7:03:09:09:ca I (378) blecm_nimble: BLE Host Task Started I (578) blecm_nimble: BLE_GAP_EVENT_PERIODIC_SYNC I (578) app_main: ESP_BLE_CONN_EVENT_PERIODIC_SYNC I (578) app_main: status : 0, periodic_sync_handle : 1, sid : 2 I (578) app_main: adv addr : da:c0:3f:c6:52:0f I (588) app_main: adv_phy : 2m I (588) app_main: per_adv_ival : 240 I (598) app_main: adv_clk_accuracy : 0 I (598) app_main: ESP_BLE_CONN_EVENT_PERIODIC_REPORT I (608) app_main: sync_handle : 1 I (608) app_main: tx_power : 0 I (608) app_main: rssi : -31 I (618) app_main: data_status : 1 I (618) app_main: data_length : 241 I (628) app_main: data : I (628) app_main: de 04 e0 04 e2 04 e4 04 e6 04 e8 04 ea 04 ec 04 I (638) app_main: ee 04 f0 04 f2 04 f4 04 f6 04 f8 04 fa 04 fc 04 I (638) app_main: fe 05 01 05 03 05 05 05 07 05 09 05 0b 05 0d 05 I (648) app_main: 0f 05 11 05 13 05 15 05 17 05 19 05 1b 05 1d 05 I (658) app_main: 1f 05 21 05 23 05 25 05 27 05 29 05 2b 05 2d 05 I (658) app_main: 2f 05 31 05 33 05 35 05 37 05 39 05 3b 05 3d 05 I (668) app_main: 3f 05 41 05 43 05 45 05 47 05 49 05 4b 05 4d 05 I (678) app_main: 4f 05 51 05 53 05 55 05 57 05 59 05 5b 05 5d 05 I (678) app_main: 5f 05 61 05 63 05 65 05 67 05 69 05 6b 05 6d 05 I (688) app_main: 6f 05 71 05 73 05 75 05 77 05 79 05 7b 05 7d 05 I (698) app_main: 7f 05 81 05 83 05 85 05 87 05 89 05 8b 05 8d 05 I (698) app_main: 8f 05 91 05 93 05 95 05 97 05 99 05 9b 05 9d 05 I (708) app_main: 9f 05 a1 05 a3 05 a5 05 a7 05 a9 05 ab 05 ad 05 I (718) app_main: af 05 b1 05 b3 05 b5 05 b7 05 b9 05 bb 05 bd 05 I (718) app_main: bf 05 c1 05 c3 05 c5 05 c7 05 c9 05 cb 05 cd 05 I (728) app_main: cf I (728) app_main: ESP_BLE_CONN_EVENT_PERIODIC_REPORT I (738) app_main: sync_handle : 1 I (738) app_main: tx_power : 0 I (748) app_main: rssi : -31 I (748) app_main: data_status : 1 I (758) app_main: data_length : 247 I (758) app_main: data : I (758) app_main: de 04 e0 04 e2 04 e4 04 e6 04 e8 04 ea 04 ec 04 I (768) app_main: ee 04 f0 04 f2 04 f4 04 f6 04 f8 04 fa 04 fc 04 I (778) app_main: fe 05 01 05 03 05 05 05 07 05 09 05 0b 05 0d 05 I (778) app_main: 0f 05 11 05 13 05 15 05 17 05 19 05 1b 05 1d 05 I (788) app_main: 1f 05 21 05 23 05 25 05 27 05 29 05 2b 05 2d 05 I (798) app_main: 2f 05 31 05 33 05 35 05 37 05 39 05 3b 05 3d 05 I (798) app_main: 3f 05 41 05 43 05 45 05 47 05 49 05 4b 05 4d 05 I (808) app_main: 4f 05 51 05 53 05 55 05 57 05 59 05 5b 05 5d 05 I (818) app_main: 5f 05 61 05 63 05 65 05 67 05 69 05 6b 05 6d 05 I (818) app_main: 6f 05 71 05 73 05 75 05 77 05 79 05 7b 05 7d 05 I (828) app_main: 7f 05 81 05 83 05 85 05 87 05 89 05 8b 05 8d 05 I (838) app_main: 8f 05 91 05 93 05 95 05 97 05 99 05 9b 05 9d 05 I (848) app_main: 9f 05 a1 05 a3 05 a5 05 a7 05 a9 05 ab 05 ad 05 I (848) app_main: af 05 b1 05 b3 05 b5 05 b7 05 b9 05 bb 05 bd 05 I (858) app_main: bf 05 c1 05 c3 05 c5 05 c7 05 c9 05 cb 05 cd 05 I (868) app_main: cf 05 d1 05 d3 05 d5 I (868) app_main: ESP_BLE_CONN_EVENT_PERIODIC_REPORT I (878) app_main: sync_handle : 1 I (878) app_main: tx_power : 0 I (878) app_main: rssi : -31 I (888) app_main: data_status : 1 I (888) app_main: data_length : 3 I (898) app_main: data : I (898) app_main: d9 05 db I (898) app_main: ESP_BLE_CONN_EVENT_PERIODIC_REPORT I (908) app_main: sync_handle : 1 I (908) app_main: tx_power : 0 I (918) app_main: rssi : -31 I (918) app_main: data_status : 1 I (918) app_main: data_length : 247 I (928) app_main: data : I (928) app_main: d9 05 db 05 dd 05 df 05 e1 05 e3 05 e5 05 e7 05 I (938) app_main: e9 05 eb 05 ed 05 ef 05 f1 05 f3 05 f5 05 f7 05 I (938) app_main: f9 05 fb 05 fd 06 00 06 02 06 04 06 06 06 08 06 I (948) app_main: 0a 06 0c 06 0e 06 10 06 12 06 14 06 16 06 18 06 I (958) app_main: 1a 06 1c 06 1e 06 20 06 22 06 24 06 26 06 28 06 I (958) app_main: 2a 06 2c 06 2e 06 30 06 32 06 34 06 36 06 38 06 I (968) app_main: 3a 06 3c 06 3e 06 40 06 42 06 44 06 46 06 48 06 I (978) app_main: 4a 06 4c 06 4e 06 50 06 52 06 54 06 56 06 58 06 I (988) app_main: 5a 06 5c 06 5e 06 60 06 62 06 64 06 66 06 68 06 I (988) app_main: 6a 06 6c 06 6e 06 70 06 72 06 74 06 76 06 78 04 I (998) app_main: 84 04 86 04 88 04 8a 04 8c 04 8e 04 90 04 92 04 I (1008) app_main: 94 04 96 04 98 04 9a 04 9c 04 9e 04 a0 04 a2 04 I (1008) app_main: a4 04 a6 04 a8 04 aa 04 ac 04 ae 04 b0 04 b2 04 I (1018) app_main: b4 04 b6 04 b8 04 ba 04 bc 04 be 04 c0 04 c2 04 I (1028) app_main: c4 04 c6 04 c8 04 ca 04 cc 04 ce 04 d0 04 d2 04 I (1028) app_main: d4 04 d6 04 d8 04 da I (1038) app_main: ESP_BLE_CONN_EVENT_PERIODIC_REPORT I (1038) app_main: sync_handle : 1 I (1048) app_main: tx_power : 0 I (1048) app_main: rssi : -31 I (1058) app_main: data_status : 1 I (1058) app_main: data_length : 3 I (1058) app_main: data : I (1068) app_main: de 04 e0 I (1068) app_main: ESP_BLE_CONN_EVENT_PERIODIC_REPORT I (1078) app_main: sync_handle : 1 I (1078) app_main: tx_power : 0 I (1078) app_main: rssi : -31 I (1088) app_main: data_status : 1 I (1088) app_main: data_length : 247 I (1098) app_main: data : I (1098) app_main: de 04 e0 04 e2 04 e4 04 e6 04 e8 04 ea 04 ec 04 I (1108) app_main: ee 04 f0 04 f2 04 f4 04 f6 04 f8 04 fa 04 fc 04 I (1108) app_main: fe 05 01 05 03 05 05 05 07 05 09 05 0b 05 0d 05 I (1118) app_main: 0f 05 11 05 13 05 15 05 17 05 19 05 1b 05 1d 05 I (1128) app_main: 1f 05 21 05 23 05 25 05 27 05 29 05 2b 05 2d 05 I (1128) app_main: 2f 05 31 05 33 05 35 05 37 05 39 05 3b 05 3d 05 I (1138) app_main: 3f 05 41 05 43 05 45 05 47 05 49 05 4b 05 4d 05 I (1148) app_main: 4f 05 51 05 53 05 55 05 57 05 59 05 5b 05 5d 05 I (1158) app_main: 5f 05 61 05 63 05 65 05 67 05 69 05 6b 05 6d 05 I (1158) app_main: 6f 05 71 05 73 05 75 05 77 05 79 05 7b 05 7d 05 I (1168) app_main: 7f 05 81 05 83 05 85 05 87 05 89 05 8b 05 8d 05 I (1178) app_main: 8f 05 91 05 93 05 95 05 97 05 99 05 9b 05 9d 05 I (1178) app_main: 9f 05 a1 05 a3 05 a5 05 a7 05 a9 05 ab 05 ad 05 I (1188) app_main: af 05 b1 05 b3 05 b5 05 b7 05 b9 05 bb 05 bd 05 I (1198) app_main: bf 05 c1 05 c3 05 c5 05 c7 05 c9 05 cb 05 cd 05 I (1198) app_main: cf 05 d1 05 d3 05 d5 I (1208) app_main: ESP_BLE_CONN_EVENT_PERIODIC_REPORT I (1208) app_main: sync_handle : 1 I (1218) app_main: tx_power : 0 I (1218) app_main: rssi : -31 I (1228) app_main: data_status : 1 I (1228) app_main: data_length : 3 I (1228) app_main: data : I (1238) app_main: d9 05 db I (1238) app_main: ESP_BLE_CONN_EVENT_PERIODIC_REPORT I (1248) app_main: sync_handle : 1 I (1248) app_main: tx_power : 0 I (1248) app_main: rssi : -31 I (1258) app_main: data_status : 1 I (1258) app_main: data_length : 247 I (1268) app_main: data : I (1268) app_main: d9 05 db 05 dd 05 df 05 e1 05 e3 05 e5 05 e7 05 I (1278) app_main: e9 05 eb 05 ed 05 ef 05 f1 05 f3 05 f5 05 f7 05 I (1278) app_main: f9 05 fb 05 fd 06 00 06 02 06 04 06 06 06 08 06 I (1288) app_main: 0a 06 0c 06 0e 06 10 06 12 06 14 06 16 06 18 06 I (1298) app_main: 1a 06 1c 06 1e 06 20 06 22 06 24 06 26 06 28 06 I (1298) app_main: 2a 06 2c 06 2e 06 30 06 32 06 34 06 36 06 38 06 I (1308) app_main: 3a 06 3c 06 3e 06 40 06 42 06 44 06 46 06 48 06 I (1318) app_main: 4a 06 4c 06 4e 06 50 06 52 06 54 06 56 06 58 06 I (1328) app_main: 5a 06 5c 06 5e 06 60 06 62 06 64 06 66 06 68 06 I (1328) app_main: 6a 06 6c 06 6e 06 70 06 72 06 74 06 76 06 78 04 I (1338) app_main: 84 04 86 04 88 04 8a 04 8c 04 8e 04 90 04 92 04 I (1348) app_main: 94 04 96 04 98 04 9a 04 9c 04 9e 04 a0 04 a2 04 I (1348) app_main: a4 04 a6 04 a8 04 aa 04 ac 04 ae 04 b0 04 b2 04 I (1358) app_main: b4 04 b6 04 b8 04 ba 04 bc 04 be 04 c0 04 c2 04 I (1368) app_main: c4 04 c6 04 c8 04 ca 04 cc 04 ce 04 d0 04 d2 04 I (1368) app_main: d4 04 d6 04 d8 04 da I (1378) app_main: ESP_BLE_CONN_EVENT_PERIODIC_REPORT I (1378) app_main: sync_handle : 1 I (1388) app_main: tx_power : 0 I (1388) app_main: rssi : -31 I (1398) app_main: data_status : 1 I (1398) app_main: data_length : 3 I (1398) app_main: data : I (1408) app_main: de 04 e0 I (1408) app_main: ESP_BLE_CONN_EVENT_PERIODIC_REPORT I (1418) app_main: sync_handle : 1 I (1418) app_main: tx_power : 0 I (1418) app_main: rssi : -31 I (1428) app_main: data_status : 1 I (1428) app_main: data_length : 247 I (1438) app_main: data : I (1438) app_main: de 04 e0 04 e2 04 e4 04 e6 04 e8 04 ea 04 ec 04 I (1448) app_main: ee 04 f0 04 f2 04 f4 04 f6 04 f8 04 fa 04 fc 04 I (1448) app_main: fe 05 01 05 03 05 05 05 07 05 09 05 0b 05 0d 05 I (1458) app_main: 0f 05 11 05 13 05 15 05 17 05 19 05 1b 05 1d 05 I (1468) app_main: 1f 05 21 05 23 05 25 05 27 05 29 05 2b 05 2d 05 I (1468) app_main: 2f 05 31 05 33 05 35 05 37 05 39 05 3b 05 3d 05 I (1478) app_main: 3f 05 41 05 43 05 45 05 47 05 49 05 4b 05 4d 05 I (1488) app_main: 4f 05 51 05 53 05 55 05 57 05 59 05 5b 05 5d 05 I (1498) app_main: 5f 05 61 05 63 05 65 05 67 05 69 05 6b 05 6d 05 I (1498) app_main: 6f 05 71 05 73 05 75 05 77 05 79 05 7b 05 7d 05 I (1508) app_main: 7f 05 81 05 83 05 85 05 87 05 89 05 8b 05 8d 05 I (1518) app_main: 8f 05 91 05 93 05 95 05 97 05 99 05 9b 05 9d 05 I (1518) app_main: 9f 05 a1 05 a3 05 a5 05 a7 05 a9 05 ab 05 ad 05 I (1528) app_main: af 05 b1 05 b3 05 b5 05 b7 05 b9 05 bb 05 bd 05 I (1538) app_main: bf 05 c1 05 c3 05 c5 05 c7 05 c9 05 cb 05 cd 05 I (1538) app_main: cf 05 d1 05 d3 05 d5 I (1548) app_main: ESP_BLE_CONN_EVENT_PERIODIC_REPORT I (1548) app_main: sync_handle : 1 I (1558) app_main: tx_power : 0 I (1558) app_main: rssi : -31 I (1568) app_main: data_status : 1 I (1568) app_main: data_length : 3 I (1568) app_main: data : I (1578) app_main: d9 05 db I (1578) app_main: ESP_BLE_CONN_EVENT_PERIODIC_REPORT I (1588) app_main: sync_handle : 1 I (1588) app_main: tx_power : 0 I (1588) app_main: rssi : -31 I (1598) app_main: data_status : 0 I (1598) app_main: data_length : 159 I (1608) app_main: data : I (1608) app_main: d9 05 db 05 dd 05 df 05 e1 05 e3 05 e5 05 e7 05 I (1618) app_main: e9 05 eb 05 ed 05 ef 05 f1 05 f3 05 f5 05 f7 05 I (1618) app_main: f9 05 fb 05 fd 06 00 06 02 06 04 06 06 06 08 06 I (1628) app_main: 0a 06 0c 06 0e 06 10 06 12 06 14 06 16 06 18 06 I (1638) app_main: 1a 06 1c 06 1e 06 20 06 22 06 24 06 26 06 28 06 I (1638) app_main: 2a 06 2c 06 2e 06 30 06 32 06 34 06 36 06 38 06 I (1648) app_main: 3a 06 3c 06 3e 06 40 06 42 06 44 06 46 06 48 06 I (1658) app_main: 4a 06 4c 06 4e 06 50 06 52 06 54 06 56 06 58 06 I (1668) app_main: 5a 06 5c 06 5e 06 60 06 62 06 64 06 66 06 68 06 I (1668) app_main: 6a 06 6c 06 6e 06 70 06 72 06 74 06 76 06 78 I (3878) app_main: ESP_BLE_CONN_EVENT_PERIODIC_REPORT I (3878) app_main: sync_handle : 1 I (3878) app_main: tx_power : 0 I (3878) app_main: rssi : -31 I (3878) app_main: data_status : 1 I (3888) app_main: data_length : 241 I (3888) app_main: data : I (3888) app_main: de 04 e0 04 e2 04 e4 04 e6 04 e8 04 ea 04 ec 04 I (3898) app_main: ee 04 f0 04 f2 04 f4 04 f6 04 f8 04 fa 04 fc 04 I (3908) app_main: fe 05 01 05 03 05 05 05 07 05 09 05 0b 05 0d 05 I (3918) app_main: 0f 05 11 05 13 05 15 05 17 05 19 05 1b 05 1d 05 I (3918) app_main: 1f 05 21 05 23 05 25 05 27 05 29 05 2b 05 2d 05 I (3928) app_main: 2f 05 31 05 33 05 35 05 37 05 39 05 3b 05 3d 05 I (3938) app_main: 3f 05 41 05 43 05 45 05 47 05 49 05 4b 05 4d 05 I (3938) app_main: 4f 05 51 05 53 05 55 05 57 05 59 05 5b 05 5d 05 I (3948) app_main: 5f 05 61 05 63 05 65 05 67 05 69 05 6b 05 6d 05 I (3958) app_main: 6f 05 71 05 73 05 75 05 77 05 79 05 7b 05 7d 05 I (3958) app_main: 7f 05 81 05 83 05 85 05 87 05 89 05 8b 05 8d 05 I (3968) app_main: 8f 05 91 05 93 05 95 05 97 05 99 05 9b 05 9d 05 I (3978) app_main: 9f 05 a1 05 a3 05 a5 05 a7 05 a9 05 ab 05 ad 05 I (3978) app_main: af 05 b1 05 b3 05 b5 05 b7 05 b9 05 bb 05 bd 05 I (3988) app_main: bf 05 c1 05 c3 05 c5 05 c7 05 c9 05 cb 05 cd 05 I (3998) app_main: cf I (3998) app_main: ESP_BLE_CONN_EVENT_PERIODIC_REPORT I (4008) app_main: sync_handle : 1 I (4008) app_main: tx_power : 0 I (4008) app_main: rssi : -32 I (4018) app_main: data_status : 1 I (4018) app_main: data_length : 247 I (4028) app_main: data : I (4028) app_main: de 04 e0 04 e2 04 e4 04 e6 04 e8 04 ea 04 ec 04 I (4038) app_main: ee 04 f0 04 f2 04 f4 04 f6 04 f8 04 fa 04 fc 04 I (4038) app_main: fe 05 01 05 03 05 05 05 07 05 09 05 0b 05 0d 05 I (4048) app_main: 0f 05 11 05 13 05 15 05 17 05 19 05 1b 05 1d 05 I (4058) app_main: 1f 05 21 05 23 05 25 05 27 05 29 05 2b 05 2d 05 I (4068) app_main: 2f 05 31 05 33 05 35 05 37 05 39 05 3b 05 3d 05 I (4068) app_main: 3f 05 41 05 43 05 45 05 47 05 49 05 4b 05 4d 05 I (4078) app_main: 4f 05 51 05 53 05 55 05 57 05 59 05 5b 05 5d 05 I (4088) app_main: 5f 05 61 05 63 05 65 05 67 05 69 05 6b 05 6d 05 I (4088) app_main: 6f 05 71 05 73 05 75 05 77 05 79 05 7b 05 7d 05 I (4098) app_main: 7f 05 81 05 83 05 85 05 87 05 89 05 8b 05 8d 05 I (4108) app_main: 8f 05 91 05 93 05 95 05 97 05 99 05 9b 05 9d 05 I (4108) app_main: 9f 05 a1 05 a3 05 a5 05 a7 05 a9 05 ab 05 ad 05 I (4118) app_main: af 05 b1 05 b3 05 b5 05 b7 05 b9 05 bb 05 bd 05 I (4128) app_main: bf 05 c1 05 c3 05 c5 05 c7 05 c9 05 cb 05 cd 05 I (4128) app_main: cf 05 d1 05 d3 05 d5 I (4138) app_main: ESP_BLE_CONN_EVENT_PERIODIC_REPORT I (4138) app_main: sync_handle : 1 I (4148) app_main: tx_power : 0 I (4148) app_main: rssi : -32 I (4158) app_main: data_status : 1 I (4158) app_main: data_length : 3 I (4158) app_main: data : I (4168) app_main: d9 05 db I (4168) app_main: ESP_BLE_CONN_EVENT_PERIODIC_REPORT I (4178) app_main: sync_handle : 1 I (4178) app_main: tx_power : 0 I (4178) app_main: rssi : -32 I (4188) app_main: data_status : 1 I (4188) app_main: data_length : 247 I (4198) app_main: data : I (4198) app_main: d9 05 db 05 dd 05 df 05 e1 05 e3 05 e5 05 e7 05 I (4208) app_main: e9 05 eb 05 ed 05 ef 05 f1 05 f3 05 f5 05 f7 05 I (4208) app_main: f9 05 fb 05 fd 06 00 06 02 06 04 06 06 06 08 06 I (4218) app_main: 0a 06 0c 06 0e 06 10 06 12 06 14 06 16 06 18 06 I (4228) app_main: 1a 06 1c 06 1e 06 20 06 22 06 24 06 26 06 28 06 I (4238) app_main: 2a 06 2c 06 2e 06 30 06 32 06 34 06 36 06 38 06 I (4238) app_main: 3a 06 3c 06 3e 06 40 06 42 06 44 06 46 06 48 06 I (4248) app_main: 4a 06 4c 06 4e 06 50 06 52 06 54 06 56 06 58 06 I (4258) app_main: 5a 06 5c 06 5e 06 60 06 62 06 64 06 66 06 68 06 I (4258) app_main: 6a 06 6c 06 6e 06 70 06 72 06 74 06 76 06 78 04 I (4268) app_main: 84 04 86 04 88 04 8a 04 8c 04 8e 04 90 04 92 04 I (4278) app_main: 94 04 96 04 98 04 9a 04 9c 04 9e 04 a0 04 a2 04 I (4278) app_main: a4 04 a6 04 a8 04 aa 04 ac 04 ae 04 b0 04 b2 04 I (4288) app_main: b4 04 b6 04 b8 04 ba 04 bc 04 be 04 c0 04 c2 04 I (4298) app_main: c4 04 c6 04 c8 04 ca 04 cc 04 ce 04 d0 04 d2 04 I (4298) app_main: d4 04 d6 04 d8 04 da I (4308) app_main: ESP_BLE_CONN_EVENT_PERIODIC_REPORT I (4308) app_main: sync_handle : 1 I (4318) app_main: tx_power : 0 I (4318) app_main: rssi : -32 I (4328) app_main: data_status : 1 I (4328) app_main: data_length : 3 I (4328) app_main: data : I (4338) app_main: de 04 e0 I (4338) app_main: ESP_BLE_CONN_EVENT_PERIODIC_REPORT I (4348) app_main: sync_handle : 1 I (4348) app_main: tx_power : 0 I (4358) app_main: rssi : -32 I (4358) app_main: data_status : 1 I (4358) app_main: data_length : 247 I (4368) app_main: data : I (4368) app_main: de 04 e0 04 e2 04 e4 04 e6 04 e8 04 ea 04 ec 04 I (4378) app_main: ee 04 f0 04 f2 04 f4 04 f6 04 f8 04 fa 04 fc 04 I (4378) app_main: fe 05 01 05 03 05 05 05 07 05 09 05 0b 05 0d 05 I (4388) app_main: 0f 05 11 05 13 05 15 05 17 05 19 05 1b 05 1d 05 I (4398) app_main: 1f 05 21 05 23 05 25 05 27 05 29 05 2b 05 2d 05 I (4408) app_main: 2f 05 31 05 33 05 35 05 37 05 39 05 3b 05 3d 05 I (4408) app_main: 3f 05 41 05 43 05 45 05 47 05 49 05 4b 05 4d 05 I (4418) app_main: 4f 05 51 05 53 05 55 05 57 05 59 05 5b 05 5d 05 I (4428) app_main: 5f 05 61 05 63 05 65 05 67 05 69 05 6b 05 6d 05 I (4428) app_main: 6f 05 71 05 73 05 75 05 77 05 79 05 7b 05 7d 05 I (4438) app_main: 7f 05 81 05 83 05 85 05 87 05 89 05 8b 05 8d 05 I (4448) app_main: 8f 05 91 05 93 05 95 05 97 05 99 05 9b 05 9d 05 I (4448) app_main: 9f 05 a1 05 a3 05 a5 05 a7 05 a9 05 ab 05 ad 05 I (4458) app_main: af 05 b1 05 b3 05 b5 05 b7 05 b9 05 bb 05 bd 05 I (4468) app_main: bf 05 c1 05 c3 05 c5 05 c7 05 c9 05 cb 05 cd 05 I (4468) app_main: cf 05 d1 05 d3 05 d5 I (4478) app_main: ESP_BLE_CONN_EVENT_PERIODIC_REPORT I (4488) app_main: sync_handle : 1 I (4488) app_main: tx_power : 0 I (4488) app_main: rssi : -32 I (4498) app_main: data_status : 1 I (4498) app_main: data_length : 3 I (4498) app_main: data : I (4508) app_main: d9 05 db I (4508) app_main: ESP_BLE_CONN_EVENT_PERIODIC_REPORT I (4518) app_main: sync_handle : 1 I (4518) app_main: tx_power : 0 I (4528) app_main: rssi : -32 I (4528) app_main: data_status : 1 I (4528) app_main: data_length : 247 I (4538) app_main: data : I (4538) app_main: d9 05 db 05 dd 05 df 05 e1 05 e3 05 e5 05 e7 05 I (4548) app_main: e9 05 eb 05 ed 05 ef 05 f1 05 f3 05 f5 05 f7 05 I (4548) app_main: f9 05 fb 05 fd 06 00 06 02 06 04 06 06 06 08 06 I (4558) app_main: 0a 06 0c 06 0e 06 10 06 12 06 14 06 16 06 18 06 I (4568) app_main: 1a 06 1c 06 1e 06 20 06 22 06 24 06 26 06 28 06 I (4578) app_main: 2a 06 2c 06 2e 06 30 06 32 06 34 06 36 06 38 06 I (4578) app_main: 3a 06 3c 06 3e 06 40 06 42 06 44 06 46 06 48 06 I (4588) app_main: 4a 06 4c 06 4e 06 50 06 52 06 54 06 56 06 58 06 I (4598) app_main: 5a 06 5c 06 5e 06 60 06 62 06 64 06 66 06 68 06 I (4598) app_main: 6a 06 6c 06 6e 06 70 06 72 06 74 06 76 06 78 04 I (4608) app_main: 84 04 86 04 88 04 8a 04 8c 04 8e 04 90 04 92 04 I (4618) app_main: 94 04 96 04 98 04 9a 04 9c 04 9e 04 a0 04 a2 04 I (4618) app_main: a4 04 a6 04 a8 04 aa 04 ac 04 ae 04 b0 04 b2 04 I (4628) app_main: b4 04 b6 04 b8 04 ba 04 bc 04 be 04 c0 04 c2 04 I (4638) app_main: c4 04 c6 04 c8 04 ca 04 cc 04 ce 04 d0 04 d2 04 I (4638) app_main: d4 04 d6 04 d8 04 da I (4648) app_main: ESP_BLE_CONN_EVENT_PERIODIC_REPORT I (4658) app_main: sync_handle : 1 I (4658) app_main: tx_power : 0 I (4658) app_main: rssi : -32 I (4668) app_main: data_status : 1 I (4668) app_main: data_length : 3 I (4668) app_main: data : I (4678) app_main: de 04 e0 I (4678) app_main: ESP_BLE_CONN_EVENT_PERIODIC_REPORT I (4688) app_main: sync_handle : 1 I (4688) app_main: tx_power : 0 I (4698) app_main: rssi : -32 I (4698) app_main: data_status : 1 I (4698) app_main: data_length : 247 I (4708) app_main: data : I (4708) app_main: de 04 e0 04 e2 04 e4 04 e6 04 e8 04 ea 04 ec 04 I (4718) app_main: ee 04 f0 04 f2 04 f4 04 f6 04 f8 04 fa 04 fc 04 I (4718) app_main: fe 05 01 05 03 05 05 05 07 05 09 05 0b 05 0d 05 I (4728) app_main: 0f 05 11 05 13 05 15 05 17 05 19 05 1b 05 1d 05 I (4738) app_main: 1f 05 21 05 23 05 25 05 27 05 29 05 2b 05 2d 05 I (4748) app_main: 2f 05 31 05 33 05 35 05 37 05 39 05 3b 05 3d 05 I (4748) app_main: 3f 05 41 05 43 05 45 05 47 05 49 05 4b 05 4d 05 I (4758) app_main: 4f 05 51 05 53 05 55 05 57 05 59 05 5b 05 5d 05 I (4768) app_main: 5f 05 61 05 63 05 65 05 67 05 69 05 6b 05 6d 05 I (4768) app_main: 6f 05 71 05 73 05 75 05 77 05 79 05 7b 05 7d 05 I (4778) app_main: 7f 05 81 05 83 05 85 05 87 05 89 05 8b 05 8d 05 I (4788) app_main: 8f 05 91 05 93 05 95 05 97 05 99 05 9b 05 9d 05 I (4788) app_main: 9f 05 a1 05 a3 05 a5 05 a7 05 a9 05 ab 05 ad 05 I (4798) app_main: af 05 b1 05 b3 05 b5 05 b7 05 b9 05 bb 05 bd 05 I (4808) app_main: bf 05 c1 05 c3 05 c5 05 c7 05 c9 05 cb 05 cd 05 I (4808) app_main: cf 05 d1 05 d3 05 d5 I (4818) app_main: ESP_BLE_CONN_EVENT_PERIODIC_REPORT I (4828) app_main: sync_handle : 1 I (4828) app_main: tx_power : 0 I (4828) app_main: rssi : -32 I (4838) app_main: data_status : 1 I (4838) app_main: data_length : 3 I (4838) app_main: data : I (4848) app_main: d9 05 db I (4848) app_main: ESP_BLE_CONN_EVENT_PERIODIC_REPORT I (4858) app_main: sync_handle : 1 I (4858) app_main: tx_power : 0 I (4868) app_main: rssi : -32 I (4868) app_main: data_status : 0 I (4868) app_main: data_length : 159 I (4878) app_main: data : I (4878) app_main: d9 05 db 05 dd 05 df 05 e1 05 e3 05 e5 05 e7 05 I (4888) app_main: e9 05 eb 05 ed 05 ef 05 f1 05 f3 05 f5 05 f7 05 I (4888) app_main: f9 05 fb 05 fd 06 00 06 02 06 04 06 06 06 08 06 I (4898) app_main: 0a 06 0c 06 0e 06 10 06 12 06 14 06 16 06 18 06 I (4908) app_main: 1a 06 1c 06 1e 06 20 06 22 06 24 06 26 06 28 06 I (4918) app_main: 2a 06 2c 06 2e 06 30 06 32 06 34 06 36 06 38 06 I (4918) app_main: 3a 06 3c 06 3e 06 40 06 42 06 44 06 46 06 48 06 I (4928) app_main: 4a 06 4c 06 4e 06 50 06 52 06 54 06 56 06 58 06 I (4938) app_main: 5a 06 5c 06 5e 06 60 06 62 06 64 06 66 06 68 06 I (4938) app_main: 6a 06 6c 06 6e 06 70 06 72 06 74 06 76 06 78 ``` ## Troubleshooting For any technical queries, please open an [issue](https://github.com/espressif/esp-iot-solution/issues) on GitHub. We will get back to you soon.

readme of ble_conn_mgr/ble_spp/spp_client example

| Supported Targets | ESP32 | ESP32-C3 | ESP32-C2 | ESP32-S3 | | ----------------- | ----- | -------- | -------- | -------- | # BLE SPP central example In Bluetooth classic (BR/EDR) systems, a Serial Port Profile (SPP) is an adopted profile defined by the Bluetooth Special Interest Group (SIG) used to emulate a serial port connection over a Bluetooth wireless connection. For BLE systems, an adopted SPP profile over BLE is not defined, thus emulation of a serial port must be implemented as a vendor-specific custom profile. This reference design consists of two Demos, the BLE SPP server and BLE SPP client that run on their respective endpoints. These devices connect and exchange data wirelessly with each other. This capability creates a virtual serial link over the air. Each byte input can be sent and received by both the server and client. The SPP server is implemented as the [spp_server](../spp_server) demo while the SPP client is implemented as the [spp_client](../spp_client) demo. Espressif designed the BLE SPP applications to use the UART transport layer but you could adapt this design to work with other serial protocols, such as SPI. This vendor-specific custom profile is implemented in [main.c](../spp_client/main/main.c) and [main.c](../spp_server/main/main.c). ## Using Examples ### Initialization Both the server and client will first initialize the UART and BLE. The server demo will set up the serial port service with standard GATT and GAP services in the attribute server. The client demo will scan the BLE broadcast over the air to find the SPP server. ### Functions Processing The spp server has two characteristic and one event processing functions: ```c esp_spp_chr_cb(const uint8_t *inbuf, uint16_t inlen, uint8_t **outbuf, uint16_t *outlen, void *priv_data); app_ble_conn_event_handler(void *handler_args, esp_event_base_t base, int32_t id, void *event_data); ``` The SPP client has one main event processing functions: ```c app_ble_conn_event_handler(void *handler_args, esp_event_base_t base, int32_t id, void *event_data); ``` These are some queues and tasks used by SPP application: Queues: * spp_uart_queue - Uart data messages received from the Uart Tasks: * `ble_client_uart_task` - process Uart ### Packet Structure After the Uart received data, the data will be posted to Uart task. Then, in the UART_DATA event, the raw data may be retrieved. The max length is 120 bytes every time. If you run the BLE SPP demo with two ESP32 chips, the MTU size will be exchanged after the BLE connection is established, so every packet can be send directly. If you only run the ble_spp_server demo, and it was connected by a phone, the MTU size may be less than 123 bytes. In such a case the data will be split into fragments and send in turn. In every packet, we add 4 bytes to indicate that this is a fragment packet. The first two bytes contain "##" if this is a fragment packet, the third byte is the total number of the packets, the fourth byte is the current number of this packet. The phone APP need to check the structure of the packet if it want to communicate with the ble_spp_server demo. ### Sending Data Wirelessly The client will be sending WriteNoRsp packets to the server. The server side sends data through notifications. When the Uart receives data, the Uart task places it in the buffer. ### Receiving Data Wirelessly The server will receive this data in the characteristic calback. ### GATT Server Attribute Table charactertistic|UUID|Permissions :-:|:-:|:-: SPP_DATA_RECV_CHAR|0xABF1|READ&WRITE_NR SPP_DATA_NOTIFY_CHAR|0xABF2|READ&NOTIFY SPP_COMMAND_CHAR|0xABF3|READ&WRITE_NR SPP_STATUS_CHAR|0xABF4|READ & NOTIFY This example creates GATT client and performs passive scan, it then connects to peripheral device if the device advertises connectability and the write characteristic. It performs three GATT operations against the specified peer: * Discover all services,characteristics and descriptors. * After the discovery is completed, take UART input from user and write characteristic. ## How to use example Before project configuration and build, be sure to set the correct chip target using: ```bash idf.py set-target <chip_name> ``` ### Hardware Required * A development board with ESP32/ESP32-C3/ESP32-C2/ESP32-S3 SoC * A USB cable for Power supply and programming See [Development Boards](https://www.espressif.com/en/products/devkits) for more information about it. ### Configure the Project Open the project configuration menu: ```bash idf.py menuconfig ``` ### Build and Flash Build the project and flash it to the board, then run monitor tool to view serial output: ``` idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects. ## Example Output This is the console output on successful connection: ``` I (322) BTDM_INIT: BT controller compile version [80abacd] I (322) phy_init: phy_version 950,11a46e9,Oct 21 2022,08:56:12 I (382) system_api: Base MAC address is not set I (382) system_api: read default base MAC address from EFUSE I (382) BTDM_INIT: Bluetooth MAC: 84:f7:03:08:21:1a I (382) blecm_nimble: BLE Host Task Started I (392) NimBLE: GAP procedure initiated: stop advertising. I (392) NimBLE: GAP procedure initiated: discovery; I (402) NimBLE: own_addr_type=0 filter_policy=0 passive=1 limited=0 filter_duplicates=1 I (412) NimBLE: duration=forever I (412) NimBLE: I (542) NimBLE: GAP procedure initiated: connect; I (542) NimBLE: peer_addr_type=0 peer_addr= I (542) NimBLE: 84:f7:03:09:09:ca I (542) NimBLE: scan_itvl=18 scan_window=17 itvl_min=25 itvl_max=26 latency=1 supervision_timeout=20 min_ce_len=3 max_ce_len=4 own_addr_type=0 I (562) NimBLE: I (702) NimBLE: GATT procedure initiated: discover all services I (702) app_main: ESP_BLE_CONN_EVENT_CONNECTED I (752) NimBLE: GATT procedure initiated: discover all characteristics; I (752) NimBLE: start_handle=1 end_handle=5 I (912) NimBLE: GATT procedure initiated: discover all characteristics; I (912) NimBLE: start_handle=6 end_handle=9 I (1102) NimBLE: GATT procedure initiated: discover all characteristics; I (1102) NimBLE: start_handle=10 end_handle=65535 I (1302) NimBLE: GATT procedure initiated: discover all descriptors; I (1302) NimBLE: chr_val_handle=8 end_handle=9 I (1402) NimBLE: GATT procedure initiated: discover all descriptors; I (1402) NimBLE: chr_val_handle=12 end_handle=65535 I (1592) blecm_nimble: Service discovery complete; rc=0, conn_handle=1 I (2852) NimBLE: GATT procedure initiated: write; I (2852) NimBLE: att_handle=12 len=1 I (2922) app_main: Write in uart task success! I (3312) NimBLE: GATT procedure initiated: write; I (3312) NimBLE: att_handle=12 len=1 I (3412) app_main: Write in uart task success! I (3792) NimBLE: GATT procedure initiated: write; I (3792) NimBLE: att_handle=12 len=1 I (3832) app_main: Write in uart task success! I (7672) blecm_nimble: received notification; conn_handle=1 attr_handle=12 attr_len=1 I (7672) app_main: ESP_BLE_CONN_EVENT_DATA_RECEIVE I (7672) app_main: 44017 I (7672) app_main: Z I (7682) NimBLE: GATT procedure initiated: read; I (7682) NimBLE: att_handle=12 I (7772) blecm_nimble: characteristic read; conn_handle=1 attr_handle=12 len=7 value= I (7772) app_main: Read data success! I (7772) app_main: SPP_CHR I (8122) blecm_nimble: received notification; conn_handle=1 attr_handle=12 attr_len=1 I (8122) app_main: ESP_BLE_CONN_EVENT_DATA_RECEIVE I (8132) app_main: 44017 I (8132) app_main: Z I (8132) NimBLE: GATT procedure initiated: read; I (8142) NimBLE: att_handle=12 I (8222) blecm_nimble: characteristic read; conn_handle=1 attr_handle=12 len=7 value= I (8222) app_main: Read data success! I (8222) app_main: SPP_CHR I (8582) blecm_nimble: received notification; conn_handle=1 attr_handle=12 attr_len=1 I (8582) app_main: ESP_BLE_CONN_EVENT_DATA_RECEIVE I (8582) app_main: 44017 I (8582) app_main: Z I (8592) NimBLE: GATT procedure initiated: read; I (8592) NimBLE: att_handle=12 I (8682) blecm_nimble: characteristic read; conn_handle=1 attr_handle=12 len=7 value= I (8682) app_main: Read data success! I (8682) app_main: SPP_CHR ```

readme of ble_conn_mgr/ble_spp/spp_server example

| Supported Targets | ESP32 | ESP32-C3 | ESP32-C2 | ESP32-S3 | | ----------------- | ----- | -------- | -------- | -------- | # BLE SPP peripheral example In Bluetooth classic (BR/EDR) systems, a Serial Port Profile (SPP) is an adopted profile defined by the Bluetooth Special Interest Group (SIG) used to emulate a serial port connection over a Bluetooth wireless connection. For BLE systems, an adopted SPP profile over BLE is not defined, thus emulation of a serial port must be implemented as a vendor-specific custom profile. This reference design consists of two Demos, the BLE SPP server and BLE SPP client that run on their respective endpoints. These devices connect and exchange data wirelessly with each other. This capability creates a virtual serial link over the air. Each byte input can be sent and received by both the server and client. The SPP server is implemented as the [spp_server](../spp_server) demo while the SPP client is implemented as the [spp_client](../spp_client) demo. Espressif designed the BLE SPP applications to use the UART transport layer but you could adapt this design to work with other serial protocols, such as SPI. This vendor-specific custom profile is implemented in [main.c](../spp_client/main/main.c) and [main.c](../spp_server/main/main.c). ## Using Examples ### Initialization Both the server and client will first initialize the UART and BLE. The server demo will set up the serial port service with standard GATT and GAP services in the attribute server. The client demo will scan the BLE broadcast over the air to find the SPP server. ### Functions Processing The spp server has two characteristic and one event processing functions: ```c esp_spp_chr_cb(const uint8_t *inbuf, uint16_t inlen, uint8_t **outbuf, uint16_t *outlen, void *priv_data); app_ble_conn_event_handler(void *handler_args, esp_event_base_t base, int32_t id, void *event_data); ``` The SPP client has one main event processing functions: ```c app_ble_conn_event_handler(void *handler_args, esp_event_base_t base, int32_t id, void *event_data); ``` These are some queues and tasks used by SPP application: Queues: * spp_uart_queue - Uart data messages received from the Uart Tasks: * `ble_server_uart_task` - process Uart ### Packet Structure After the Uart received data, the data will be posted to Uart task. Then, in the UART_DATA event, the raw data may be retrieved. The max length is 120 bytes every time. If you run the BLE SPP demo with two ESP32 chips, the MTU size will be exchanged for 200 bytes after the ble connection is established, so every packet can be send directly. If you only run the ble_spp_server demo, and it was connected by a phone, the MTU size may be less than 123 bytes. In such a case the data will be split into fragments and send in turn. In every packet, we add 4 bytes to indicate that this is a fragment packet. The first two bytes contain "##" if this is a fragment packet, the third byte is the total number of the packets, the fourth byte is the current number of this packet. The phone APP need to check the structure of the packet if it want to communicate with the ble_spp_server demo. ### Sending Data Wirelessly The client will be sending WriteNoRsp packets to the server. The server side sends data through notifications. When the Uart receives data, the Uart task places it in the buffer. ### Receiving Data Wirelessly The server will receive this data in the BLE_GATT_ACCESS_OP_WRITE_CHR event. ### GATT Server Attribute Table charactertistic|UUID|Permissions :-:|:-:|:-: SPP_DATA_RECV_CHAR|0xABF1|READ&WRITE_NR SPP_DATA_NOTIFY_CHAR|0xABF2|READ&NOTIFY SPP_COMMAND_CHAR|0xABF3|READ&WRITE_NR SPP_STATUS_CHAR|0xABF4|READ & NOTIFY This example creates GATT client and performs passive scan, it then connects to peripheral device if the device advertises connectability and the write characteristic. It performs three GATT operations against the specified peer: * Discover all services,characteristics and descriptors. * After the discovery is completed, take UART input from user and write characteristic. ## How to use example Before project configuration and build, be sure to set the correct chip target using: ```bash idf.py set-target <chip_name> ``` ### Hardware Required * A development board with ESP32/ESP32-C3/ESP32-C2/ESP32-S3 SoC * A USB cable for Power supply and programming See [Development Boards](https://www.espressif.com/en/products/devkits) for more information about it. ### Configure the Project Open the project configuration menu: ```bash idf.py menuconfig ``` ### Build and Flash Build the project and flash it to the board, then run monitor tool to view serial output: ``` idf.py -p PORT flash monitor ``` (To exit the serial monitor, type ``Ctrl-]``.) See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects. ## Example Output This is the console output on successful connection: ``` I (320) BTDM_INIT: BT controller compile version [80abacd] I (320) phy_init: phy_version 950,11a46e9,Oct 21 2022,08:56:12 I (370) system_api: Base MAC address is not set I (370) system_api: read default base MAC address from EFUSE I (370) BTDM_INIT: Bluetooth MAC: 84:f7:03:08:21:1a I (380) blecm_nimble: BLE Host Task Started I (380) blecm_nimble: getting characteristic(0x2a00) I (390) blecm_nimble: getting characteristic(0x2a01) I (390) blecm_nimble: getting characteristic(0x2a05) I (400) app_main: Callback for read I (410) NimBLE: GAP procedure initiated: stop advertising. I (410) NimBLE: GAP procedure initiated: advertise; I (420) NimBLE: disc_mode=2 I (420) NimBLE: adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=256 adv_itvl_max=256 I (430) NimBLE: I (4100) app_main: ESP_BLE_CONN_EVENT_CONNECTED I (7000) blecm_nimble: Write attempt for uuid = 0xabf1, attr_handle = 12, data_len = 1 I (7000) app_main: Callback for write I (7560) blecm_nimble: Write attempt for uuid = 0xabf1, attr_handle = 12, data_len = 1 I (7560) app_main: Callback for write I (7910) blecm_nimble: Write attempt for uuid = 0xabf1, attr_handle = 12, data_len = 1 I (7910) app_main: Callback for write I (8080) blecm_nimble: Write attempt for uuid = 0xabf1, attr_handle = 12, data_len = 1 I (8080) app_main: Callback for write I (10770) NimBLE: GATT procedure initiated: notify; I (10770) NimBLE: att_handle=12 I (10770) app_main: Notification sent successfully I (10840) blecm_nimble: Read attempted for characteristic UUID = 0xabf1, attr_handle = 12 I (10840) app_main: Callback for read I (11540) NimBLE: GATT procedure initiated: notify; I (11540) NimBLE: att_handle=12 I (11540) app_main: Notification sent successfully I (11620) blecm_nimble: Read attempted for characteristic UUID = 0xabf1, attr_handle = 12 I (11620) app_main: Callback for read ```

Links

Supports all targets

License: Apache-2.0

To add this component to your project, run:

idf.py add-dependency "espressif/ble_conn_mgr^0.1.0"

or download archive

Dependencies

  • espressif/cmake_utilities 0.*
  • ESP-IDF >=4.3
  • Examples:

    ble_conn_mgr/ble_periodic_adv

    more details

    ble_conn_mgr/ble_periodic_sync

    more details

    ble_conn_mgr/ble_spp/spp_client

    more details

    ble_conn_mgr/ble_spp/spp_server

    more details

    Stats

    • Downloaded in total
      Downloaded in total 29 times
    • Downloaded this version
      This version: 29 times

    Badge

    espressif/ble_conn_mgr version: 0.1.0 |