espressif/ble_services

0.1.0

uploaded 2 months ago
BLE standard GATT services support

readme

## BLE Services Component

[![Component Registry](https://components.espressif.com/components/espressif/ble_services/badge.svg)](https://components.espressif.com/components/espressif/ble_services)

- [User Guide](https://docs.espressif.com/projects/espressif-esp-iot-solution/en/latest/bluetooth/ble_services.html)

The ``ble_services`` component provides a simplified API interface for accessing commonly used standard and custom BLE services functionality on a GATT server.

### Adding the component to your project

Please use the component manager command `idf.py add-dependency` to add `ble_services` as a dependency to your project. The component will be downloaded automatically during the CMake step.

```
idf.py add-dependency "espressif/ble_services=*"
```

### Examples

To create a project from the example template, please use the component manager command `idf.py create-project-from-example`.

* BLE Device Information Service
```
idf.py create-project-from-example "espressif/ble_services=*:ble_dis"
```

The example will be downloaded to the current folder. You can navigate into it for building and flashing.

> You can use this command to download other examples. Or you can download examples from esp-iot-solution repository:
1. [ble_ans](https://github.com/espressif/esp-iot-solution/tree/master/examples/bluetooth/ble_services/ble_ans)
2. [ble_bas](https://github.com/espressif/esp-iot-solution/tree/master/examples/bluetooth/ble_services/ble_bas)
3. [ble_dis](https://github.com/espressif/esp-iot-solution/tree/master/examples/bluetooth/ble_services/ble_dis)
4. [ble_hrs](https://github.com/espressif/esp-iot-solution/tree/master/examples/bluetooth/ble_services/ble_hrs)
5. [ble_hts](https://github.com/espressif/esp-iot-solution/tree/master/examples/bluetooth/ble_services/ble_hts)
5. [ble_tps](https://github.com/espressif/esp-iot-solution/tree/master/examples/bluetooth/ble_services/ble_tps)

### 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 services 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_services.html).

Features:
- ANS: Support Alert Notification Service
- BAS: Support Battery Service
- DIS: Support Device Information Service
- HRS: Support Heart Rate Service
- HTS: Support Health Thermometer Service
- TPS: Support TX Power Service

readme of ble_services/ble_ans example

                                        
                                        | Supported Targets | ESP32 | ESP32-C3 | ESP32-C2 | ESP32-S3 | ESP32-H2 |
| ----------------- | ----- | -------- | -------- | -------- | -------- |

# BLE Alert Notification Service Example 

(See the README.md file in the upper level 'examples' directory for more information about examples.)

This example creates a GATT server and starts advertising, waiting to be connected by a GATT client.

At the same time, it also creates an interactive shell that can be controlled/interacted with over a serial interface to emulate the behavior of ANS.

The alert notification service exposes alert information in a device. This information includes the following:

* Type of alert occurring in a device
* Additional text information such as caller ID or sender ID
* Count of new alerts
* Count of unread alert items

It uses Bluetooth controller based on BLE connection management.

This example aims at understanding alert notification service and BLE connection management APIs.

To test this demo, any BLE scanner app can be used.

## Using Examples

### Functions Processing

Use the commands as follows can check the alert notification services functions.

* ans

  * `-t (Mandatory)`: Get or Set function
  * `-c (Mandatory)`: Category ID
  * `-o (Mandatory)`: Enable or Disable optional

* New Alert

  * Read the Value of Supported New Alert Category
```
ans -t 1 -c 1 -o 0
```

  * Enable the specific category for New Alert to Notify when New Alert Count Changes
```
ans -t 2 -c 1 -o 0
```

  * Disable the specific category for New Alert to Notify when New Alert Count Changes
```
ans -t 2 -c 1 -o 1
```

* Unread Alert

  * Read the Value of Supported Unread Alert Category
```
ans -t 3 -c 1 -o 0
```

  * Enable the specific category for Unread Alert to Notify when Unread Alert Status Changes
```
ans -t 4 -c 1 -o 0
```

  * Disable the specific category for Unread Alert to Notify when Unread Alert Status Changes
```
ans -t 4 -c 1 -o 1
```

## 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
```

In the `Example Configuration` menu:

* Select advertisement name of device from `Example Configuration --> Advertisement name`, default is `BLE_ANS`.

### 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](https://idf.espressif.com/) for full steps to configure and use ESP-IDF to build projects.

## Example Output

There is this console output when bleprph is connected and characteristic is read:

```
I (367) BTDM_INIT: BT controller compile version [80abacd]
I (367) phy_init: phy_version 950,11a46e9,Oct 21 2022,08:56:12
I (417) system_api: Base MAC address is not set
I (417) system_api: read default base MAC address from EFUSE
I (417) BTDM_INIT: Bluetooth MAC: 84:f7:03:08:21:1a

I (437) blecm_nimble: BLE Host Task Started
I (437) blecm_nimble: No characteristic(0x2a00) found
I (437) blecm_nimble: No characteristic(0x2a01) found
I (457) blecm_nimble: No characteristic(0x2a05) found
I (457) NimBLE: GAP procedure initiated: stop advertising.

I (467) NimBLE: GAP procedure initiated: advertise; 
I (467) NimBLE: disc_mode=2
I (467) NimBLE:  adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=256 adv_itvl_max=256
I (477) NimBLE: 

esp32c3> help
help 
  Print the list of registered commands

ans  [-t <01~04>] [-c <00~07>] [-o <00~01>]
  Alert Notification Service
  -t, --type=<01~04>  01 Get supported new alert category
                      02 Set supported new alert category
                      03 Get supported unread alert status category
                      04 Set supported unread alert status category
  -c, --category=<00~07>  Category ID
  -o, --option=<00~01>  1: Enable, 0: Disable

esp32c3> I (6447) app_main: ESP_BLE_CONN_EVENT_CONNECTED
esp32c3> 
esp32c3> ans -t 1 -c 3 -o 0
I (15227) app_ans: Category 3 of Supported New Alert Category is Disabled
esp32c3> I (29907) blecm_nimble: Write attempt for uuid = 0x2a44, attr_handle = 26, data_len = 2
I (30007) blecm_nimble: Write attempt for uuid = 0x2a44, attr_handle = 26, data_len = 2
I (30007) NimBLE: GATT procedure initiated: notify; 
I (30017) NimBLE: att_handle=15

esp32c3> 
esp32c3> ans -t 1 -c 3 -o 0
I (33817) app_ans: Category 3 of Supported New Alert Category is Enabled
esp32c3> ans -t 2 -c 3 -o 0
I (50387) NimBLE: GATT procedure initiated: notify; 
I (50387) NimBLE: att_handle=15

I (50387) app_ans: Notify New Alert of Supported Category ID 3
esp32c3> ans -t 2 -c 3 -o 1
I (58047) NimBLE: GATT procedure initiated: notify; 
I (58047) NimBLE: att_handle=15

I (58047) app_ans: Notify New Alert of Supported Category ID 3
esp32c3> ans -t 3 -c 3 -o 0
I (97907) app_ans: Category 3 of Supported Unread Alert Status Category is Disabled
esp32c3> I (101637) blecm_nimble: Write attempt for uuid = 0x2a44, attr_handle = 26, data_len = 2
I (101737) blecm_nimble: Write attempt for uuid = 0x2a44, attr_handle = 26, data_len = 2
I (101737) NimBLE: GATT procedure initiated: notify; 
I (101747) NimBLE: att_handle=22

esp32c3> 
esp32c3> ans -t 3 -c 3 -o 0
I (105757) app_ans: Category 3 of Supported Unread Alert Status Category is Enabled
esp32c3> ans -t 4 -c 3 -o 0
I (125137) NimBLE: GATT procedure initiated: notify; 
I (125137) NimBLE: att_handle=22

I (125137) app_ans: Notify Unread Alert Status of Supported Category ID 3
esp32c3> ans -t 4 -c 3 -o 1
I (127517) NimBLE: GATT procedure initiated: notify; 
I (127517) NimBLE: att_handle=22

I (127517) app_ans: Notify Unread Alert Status of Supported Category ID 3
esp32c3>
```

## 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_services/ble_bas example

                                        
                                        | Supported Targets | ESP32 | ESP32-C3 | ESP32-C2 | ESP32-S3 | ESP32-H2 |
| ----------------- | ----- | -------- | -------- | -------- | -------- |

# BLE Battery Service Example

(See the README.md file in the upper level 'examples' directory for more information about examples.)

This example creates a GATT server and starts advertising, waiting to be connected by a GATT client.

At the same time, it also creates an interactive shell that can be controlled/interacted with over a serial interface to emulate the behavior of BAS.

The battery service exposes the Battery Level and other information for a battery in the context of the battery’s electrical connection to a device.

It uses Bluetooth controller based on BLE connection management.

This example aims at understanding battery service and BLE connection management APIs.

To test this demo, any BLE scanner app can be used.

## Using Examples

### Functions Processing

Use the commands as follows can check the battery services functions.

* bas

  * `-t (Mandatory)`: Get or Set function
  * `-c (Mandatory)`: Characteristic ID

* functions

| Supported Functions | Commands | Description |
| ----------------- | ----- | -------- |
| Battery Level | bas -t 1 -c 1 | Read the value |
| Battery Level | bas -t 0 -c 1 | Update the value and notify to the client if the Notifiy Properties is enabled |
| Battery Level Status | bas -t 1 -c 2 | Read the value |
| Battery Level Status | bas -t 0 -c 2 | Update/Notify the value and indicate to the client if the Indicate Properties is enabled |
| Estimated Service Date | bas -t 1 -c 3 | Read the value |
| Estimated Service Date | bas -t 0 -c 3 | Update/Notify the value and indicate to the client if the Indicate Properties is enabled |
| Battery Critical Status | bas -t 1 -c 4 | Read the value |
| Battery Critical Status | bas -t 0 -c 4 | Update/Indicate the value to the client |
| Battery Energy Status | bas -t 1 -c 5 | Read the value |
| Battery Energy Status | bas -t 0 -c 5 | Update/Notify the value and indicate to the client if the Indicate Properties is enabled |
| Battery Time Status | bas -t 1 -c 6 | Read the value |
| Battery Time Status | bas -t 0 -c 6 | Update/Notify the value and indicate to the client if the Indicate Properties is enabled |
| Battery Health Status | bas -t 1 -c 7 | Read the value |
| Battery Health Status | bas -t 0 -c 7 | Update/Notify the value and indicate to the client if the Indicate Properties is enabled |
| Battery Health Information | bas -t 1 -c 8 | Read the value |
| Battery Health Information | bas -t 0 -c 8 | Update/Indicate the value to the client |
| Battery Information | bas -t 1 -c 9 | Read the value |
| Battery Information | bas -t 0 -c 9 | Update/Indicate the value to the client |

## 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
```

In the `Example Configuration` menu:

* Select advertisement name of device from `Example Configuration --> Advertisement name`, default is `BLE_BAS`.

In the `BLE Standard Services` menu:

* Select the optional functions of device from `GATT Battery service`, default is disable.

### 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](https://idf.espressif.com/) for full steps to configure and use ESP-IDF to build projects.

## Example Output

There is this console output when bleprph is connected and characteristic is read:

```
This is an example of profile component.
Type 'help' to get the list of commands.
Use UP/DOWN arrows to navigate through command history.
Press TAB when typing command name to auto-complete.
Press Enter or Ctrl+C will terminate the console environment.
I (346) BTDM_INIT: BT controller compile version [80abacd]
I (366) phy_init: phy_version 950,11a46e9,Oct 21 2022,08:56:12
I (416) system_api: Base MAC address is not set
I (426) system_api: read default base MAC address from EFUSE
I (426) BTDM_INIT: Bluetooth MAC: 84:f7:03:08:21:1a

I (436) blecm_nimble: BLE Host Task Started
I (436) blecm_nimble: getting characteristic(0x2a00)
I (446) blecm_nimble: getting characteristic(0x2a01)
I (456) blecm_nimble: getting characteristic(0x2a05)
I (456) NimBLE: GAP procedure initiated: stop advertising.

I (456) NimBLE: GAP procedure initiated: advertise; 
I (466) NimBLE: disc_mode=2
I (466) NimBLE:  adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=256 adv_itvl_max=256
I (486) NimBLE: 

esp32c3> I (234206) app_main: ESP_BLE_CONN_EVENT_CONNECTED
I (234646) blecm_nimble: mtu update event; conn_handle=1 cid=4 mtu=256
I (238236) blecm_nimble: Read attempted for characteristic UUID = 0x2a19, attr_handle = 12
esp32c3> 
esp32c3> help
help 
  Print the list of registered commands

bas  [-t <00~01>] [-c <01~09>]
  Battery Service
  -t, --type=<00~01>  00 Set, 01 Get
  -c, --characteristic=<01~09>  01 Battery Level
                                02 Battery Level Status
                                03 Estimated Service Date
                                04 Battery Critical Status
                                05 Battery Energy Status
                                06 Battery Time Status
                                07 Battery Health Status
                                08 Battery Health Information
                                09 Battery Information


esp32c3> bas -t 0 -c 1
I (256746) NimBLE: GATT procedure initiated: notify; 
I (256746) NimBLE: att_handle=12

esp32c3> bas -t 0 -c 1
I (260536) NimBLE: GATT procedure initiated: notify; 
I (260536) NimBLE: att_handle=12

esp32c3> bas -t 0 -c 1
I (264576) NimBLE: GATT procedure initiated: notify; 
I (264576) NimBLE: att_handle=12

esp32c3> bas -t 0 -c 1
I (267086) NimBLE: GATT procedure initiated: notify; 
I (267086) NimBLE: att_handle=12

esp32c3> I (271386) blecm_nimble: Read attempted for characteristic UUID = 0x2a19, attr_handle = 12
I (272196) blecm_nimble: Read attempted for characteristic UUID = 0x2a19, attr_handle = 12
I (272496) blecm_nimble: Read attempted for characteristic UUID = 0x2a19, attr_handle = 12

```

## 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_services/ble_dis example

                                        
                                        | Supported Targets | ESP32 | ESP32-C3 | ESP32-C2 | ESP32-S3 | ESP32-H2 |
| ----------------- | ----- | -------- | -------- | -------- | -------- |

# BLE Device Information Service Example

(See the README.md file in the upper level 'examples' directory for more information about examples.)

This example creates a GATT server and starts advertising, waiting to be connected by a GATT client.

The device information service exposes manufacturer and/or vendor information about a device.

It uses Bluetooth controller based on BLE connection management.

This example aims at understanding device information service and BLE connection management APIs.

To test this demo, any BLE scanner 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/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 `BLE_DIS`.

In the `BLE Standard Services` menu:

* Select the optional functions of device from `GATT Device Information service`, default is disable.

### 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](https://idf.espressif.com/) for full steps to configure and use ESP-IDF to build projects.

## Example Output

There is this console output when bleprph is connected and characteristic is read:

```
I (150) BTDM_INIT: BT controller compile version [80abacd]
I (150) coexist: coexist rom version 9387209
I (160) phy_init: phy_version 950,11a46e9,Oct 21 2022,08:56:12
I (200) BTDM_INIT: Bluetooth MAC: 84:f7:03:08:21:1a

I (200) blecm_nimble: BLE Host Task Started
I (200) blecm_nimble: getting characteristic(0x2a00)
I (210) blecm_nimble: getting characteristic(0x2a01)
I (210) blecm_nimble: getting characteristic(0x2a05)
I (220) NimBLE: GAP procedure initiated: stop advertising.

I (220) NimBLE: GAP procedure initiated: advertise; 
I (230) NimBLE: disc_mode=2
I (230) NimBLE:  adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=256 adv_itvl_max=256
I (240) NimBLE: 

I (27280) app_main: ESP_BLE_CONN_EVENT_CONNECTED
I (27280) app_main: Model name ESP
I (27280) app_main: Serial Number 84:f7:03:08:21:1a
I (27290) app_main: Firmware revision v4.3.5-dirty
I (27290) app_main: Hardware revision v4.3.5-dirty
I (27300) app_main: Software revision v4.3.5-dirty
I (27300) app_main: Manufacturer name Manufacturer
I (27310) app_main: System ID System
I (27310) app_main: PnP ID Vendor ID Source 0x1, Vendor ID 0x00, Product ID 0x00, Product Version 0x01
I (27880) blecm_nimble: mtu update event; conn_handle=1 cid=4 mtu=256
I (30970) blecm_nimble: Read attempted for characteristic UUID = 0x2a23, attr_handle = 12
I (32140) blecm_nimble: Read attempted for characteristic UUID = 0x2a24, attr_handle = 15
I (33820) blecm_nimble: Read attempted for characteristic UUID = 0x2a25, attr_handle = 18
I (37870) blecm_nimble: Read attempted for characteristic UUID = 0x2a26, attr_handle = 21
I (38890) blecm_nimble: Read attempted for characteristic UUID = 0x2a27, attr_handle = 24
I (42790) blecm_nimble: Read attempted for characteristic UUID = 0x2a28, attr_handle = 27
I (44560) blecm_nimble: Read attempted for characteristic UUID = 0x2a29, attr_handle = 30
I (47470) blecm_nimble: Read attempted for characteristic UUID = 0x2a50, attr_handle = 33
```

## 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_services/ble_hrs example

                                        
                                        | Supported Targets | ESP32 | ESP32-C3 | ESP32-C2 | ESP32-S3 | ESP32-H2 |
| ----------------- | ----- | -------- | -------- | -------- | -------- |

# BLE Heart Rate Service Example

(See the README.md file in the upper level 'examples' directory for more information about examples.)

This example creates a GATT server and starts advertising, waiting to be connected by a GATT client.

The heart rate service exposes heart rate and other data related to a heart rate sensor intended for fitness applications.

It uses Bluetooth controller based on BLE connection management.

This example aims at understanding heart rate service and BLE connection management APIs.

To test this demo, any BLE scanner 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/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 `BLE_HTS`.
* Select thermometer role which instantiate one device information service of device from `Example Configuration --> Thermometer Role`, default is disable.

In the `BLE Standard Services` menu:

* Select the optional functions of device from `GATT Heart Rate service`, default is disable.

### 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](https://idf.espressif.com/) for full steps to configure and use ESP-IDF to build projects.

## Example Output

There is this console output when bleprph is connected and characteristic is read:

```
I (316) BTDM_INIT: BT controller compile version [80abacd]
I (316) phy_init: phy_version 950,11a46e9,Oct 21 2022,08:56:12
I (376) system_api: Base MAC address is not set
I (376) system_api: read default base MAC address from EFUSE
I (376) BTDM_INIT: Bluetooth MAC: 84:f7:03:08:21:1a

I (386) 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) NimBLE: GAP procedure initiated: stop advertising.

I (406) NimBLE: GAP procedure initiated: advertise; 
I (416) NimBLE: disc_mode=2
I (416) NimBLE:  adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=256 adv_itvl_max=256
I (426) NimBLE: 

I (5066) app_main: ESP_BLE_CONN_EVENT_CONNECTED
I (15066) app_main: Heart Rate Value 17
I (15066) app_main: Skin Contact should be detected on Sensor Contact Feature Supported
I (15066) NimBLE: GATT procedure initiated: notify; 
I (15066) NimBLE: att_handle=12

I (25066) app_main: Heart Rate Value 28
I (25066) app_main: Sensor Contact Feature is Supported
I (25066) app_main: Skin Contact is Detected
I (25066) app_main: The Energy Expended feature is supported and accumulated 29520kJ
I (25076) NimBLE: GATT procedure initiated: notify; 
I (25076) NimBLE: att_handle=12

I (35066) app_main: Heart Rate Value 50373
I (35066) app_main: Sensor Contact Feature is Supported
I (35066) app_main: Skin Contact is Detected
I (35066) app_main: The multiple time between two R-Wave detections
I (35076) app_main: cb fa 3e ec 12 3b 2c 5d c9 6d 00 00 00 00 
I (35076) NimBLE: GATT procedure initiated: notify; 
I (35086) NimBLE: att_handle=12

I (45066) app_main: Heart Rate Value 179
I (45066) app_main: Sensor Contact Feature isn't Supported
I (45066) app_main: Skin Contact isn't Detected
I (45066) app_main: The multiple time between two R-Wave detections
I (45076) app_main: cd 14 00 00 00 00 00 00 00 00 00 00 00 00 
I (45076) NimBLE: GATT procedure initiated: notify; 
I (45086) NimBLE: att_handle=12

I (55066) app_main: Heart Rate Value 9821
I (55066) app_main: Sensor Contact Feature is Supported
I (55066) app_main: Skin Contact isn't Detected
I (55066) app_main: The Energy Expended feature is supported and accumulated 31366kJ
I (55076) NimBLE: GATT procedure initiated: notify; 
I (55076) NimBLE: att_handle=12

I (58946) blecm_nimble: Read attempted for characteristic UUID = 0x2a38, attr_handle = 16
I (63526) blecm_nimble: Read attempted for characteristic UUID = 0x2a38, attr_handle = 16
I (65066) app_main: Heart Rate Value 84
I (65066) app_main: Sensor Contact Feature is Supported
I (65066) app_main: Skin Contact is Detected
I (65066) app_main: The Energy Expended feature is supported and accumulated 51049kJ
I (65076) NimBLE: GATT procedure initiated: notify; 
I (65076) NimBLE: att_handle=12
```

## 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_services/ble_hts example

                                        
                                        | Supported Targets | ESP32 | ESP32-C3 | ESP32-C2 | ESP32-S3 | ESP32-H2 |
| ----------------- | ----- | -------- | -------- | -------- | -------- |

# BLE Health Thermometer Service Example

(See the README.md file in the upper level 'examples' directory for more information about examples.)

This example creates a GATT server and starts advertising, waiting to be connected by a GATT client.

The health thermometer service exposes temperature and other data related to a thermometer used for healthcare applications.

It uses Bluetooth controller based on BLE connection management.

This example aims at understanding health thermometer service and BLE connection management APIs.

To test this demo, any BLE scanner 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/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 `BLE_HTS`.
* Select thermometer role which instantiate one device information service of device from `Example Configuration --> Thermometer Role`, default is disable.

In the `BLE Standard Services` menu:

* Select the optional functions of device from `GATT Health Thermometer service`, default is disable.

### 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](https://idf.espressif.com/) for full steps to configure and use ESP-IDF to build projects.

## Example Output

There is this console output when bleprph is connected and characteristic is read:

```
I (319) BTDM_INIT: BT controller compile version [80abacd]
I (319) phy_init: phy_version 950,11a46e9,Oct 21 2022,08:56:12
I (379) system_api: Base MAC address is not set
I (379) system_api: read default base MAC address from EFUSE
I (379) BTDM_INIT: Bluetooth MAC: 84:f7:03:08:21:1a

I (389) blecm_nimble: BLE Host Task Started
I (389) blecm_nimble: getting characteristic(0x2a00)
I (399) blecm_nimble: getting characteristic(0x2a01)
I (399) blecm_nimble: getting characteristic(0x2a05)
I (409) NimBLE: GAP procedure initiated: stop advertising.

I (419) NimBLE: GAP procedure initiated: advertise; 
I (419) NimBLE: disc_mode=2
I (419) NimBLE:  adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=256 adv_itvl_max=256
I (429) NimBLE: 

I (2239) app_main: ESP_BLE_CONN_EVENT_CONNECTED
I (2239) NimBLE: GATT procedure initiated: indicate; 
I (2239) NimBLE: att_handle=23

I (25559) blecm_nimble: Read attempted for characteristic UUID = 0x2a1d, attr_handle = 16
I (48799) blecm_nimble: Read attempted for characteristic UUID = 0x2a21, attr_handle = 23
I (68949) blecm_nimble: Write attempt for uuid = 0x2a21, attr_handle = 23, data_len = 2
I (68949) app_main: Measurement Temperature 39041°C
I (68949) NimBLE: GATT procedure initiated: indicate; 
I (68959) NimBLE: att_handle=12

I (69039) app_main: 1970年1月1日  0:1:8
I (69039) app_main: Intermediate Temperature 34252°F
I (69039) NimBLE: GATT procedure initiated: notify; 
I (69049) NimBLE: att_handle=19

I (73039) blecm_nimble: Read attempted for characteristic UUID = 0x2a21, attr_handle = 23
I (79049) app_main: Measurement Temperature 14901°F
I (79049) app_main: Temperature Type 6
I (79049) NimBLE: GATT procedure initiated: indicate; 
I (79059) NimBLE: att_handle=12

I (79149) app_main: Intermediate Temperature 37898°F
I (79149) app_main: Temperature Type 0
I (79149) NimBLE: GATT procedure initiated: notify; 
I (79159) NimBLE: att_handle=19

I (89049) app_main: 1970年1月1日  0:1:28
I (89049) app_main: Measurement Temperature 1674°F
I (89049) NimBLE: GATT procedure initiated: indicate; 
I (89059) NimBLE: att_handle=12

I (89159) app_main: 1970年1月1日  0:1:28
I (89159) app_main: Intermediate Temperature 42280°C
I (89159) NimBLE: GATT procedure initiated: notify; 
I (89169) NimBLE: att_handle=19

I (99049) app_main: Measurement Temperature 6344°F
I (99049) NimBLE: GATT procedure initiated: indicate; 
I (99049) NimBLE: att_handle=12

I (99139) app_main: 1970年1月1日  0:1:38
I (99139) app_main: Intermediate Temperature 2420°C
I (99139) app_main: Temperature Type 3
I (99139) NimBLE: GATT procedure initiated: notify; 
I (99149) NimBLE: att_handle=19

I (109049) app_main: 1970年1月1日  0:1:48
I (109049) app_main: Measurement Temperature 53149°C
I (109049) app_main: Temperature Type 9
I (109059) NimBLE: GATT procedure initiated: indicate; 
I (109059) NimBLE: att_handle=12

I (109149) app_main: 1970年1月1日  0:1:48
I (109149) app_main: Intermediate Temperature 32984°C
I (109149) NimBLE: GATT procedure initiated: notify; 
I (109149) NimBLE: att_handle=19

I (110379) blecm_nimble: Read attempted for characteristic UUID = 0x2a1d, attr_handle = 16
I (119049) app_main: 1970年1月1日  0:1:58
I (119049) app_main: Measurement Temperature 19839°F
I (119049) app_main: Temperature Type 1
I (119059) NimBLE: GATT procedure initiated: indicate; 
I (119059) NimBLE: att_handle=12

I (119159) app_main: 1970年1月1日  0:1:58
I (119159) app_main: Intermediate Temperature 63994°C
I (119159) NimBLE: GATT procedure initiated: notify; 
I (119159) NimBLE: att_handle=19
```

## 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_services/ble_tps example

                                        
                                        | Supported Targets | ESP32 | ESP32-C3 | ESP32-C2 | ESP32-S3 | ESP32-H2 |
| ----------------- | ----- | -------- | -------- | -------- | -------- |

# BLE TX Power Service Example

(See the README.md file in the upper level 'examples' directory for more information about examples.)

This example creates a GATT server and starts advertising, waiting to be connected by a GATT client.

The Tx power service expose the current transmit power level of a device when in a connection.

It uses Bluetooth controller based on BLE connection management.

This example aims at understanding TX power service and BLE connection management APIs.

To test this demo, any BLE scanner 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/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 `BLE_TPS`.

### 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](https://idf.espressif.com/) for full steps to configure and use ESP-IDF to build projects.

## Example Output

There is this console output when bleprph is connected and characteristic is read:

```
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 (366) BTDM_INIT: Bluetooth MAC: 84:f7:03:08:21:1a

I (376) blecm_nimble: BLE Host Task Started
I (376) blecm_nimble: getting characteristic(0x2a00)
I (386) blecm_nimble: getting characteristic(0x2a01)
I (396) blecm_nimble: getting characteristic(0x2a05)
I (396) NimBLE: GAP procedure initiated: stop advertising.

I (406) NimBLE: GAP procedure initiated: advertise; 
I (406) NimBLE: disc_mode=2
I (416) NimBLE:  adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=256 adv_itvl_max=256
I (426) NimBLE: 

I (54526) app_main: ESP_BLE_CONN_EVENT_CONNECTED
I (54526) app_main: TX Power Level 3dBm
I (54976) blecm_nimble: mtu update event; conn_handle=1 cid=4 mtu=256
I (58366) blecm_nimble: Read attempted for characteristic UUID = 0x2a07, attr_handle = 12
I (61006) blecm_nimble: Read attempted for characteristic UUID = 0x2a07, attr_handle = 12
I (61756) blecm_nimble: Read attempted for characteristic UUID = 0x2a07, attr_handle = 12 
```

## 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.

                                    

Links

Supports all targets

License: Apache-2.0

To add this component to your project, run:

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

or download archive

Examples:

ble_services/ble_ans

more details

To create a project from this example, run:

idf.py create-project-from-example "espressif/ble_services^0.1.0:ble_services/ble_ans"

or download archive

ble_services/ble_bas

more details

To create a project from this example, run:

idf.py create-project-from-example "espressif/ble_services^0.1.0:ble_services/ble_bas"

or download archive

ble_services/ble_dis

more details

To create a project from this example, run:

idf.py create-project-from-example "espressif/ble_services^0.1.0:ble_services/ble_dis"

or download archive

ble_services/ble_hrs

more details

To create a project from this example, run:

idf.py create-project-from-example "espressif/ble_services^0.1.0:ble_services/ble_hrs"

or download archive

ble_services/ble_hts

more details

To create a project from this example, run:

idf.py create-project-from-example "espressif/ble_services^0.1.0:ble_services/ble_hts"

or download archive

ble_services/ble_tps

more details

To create a project from this example, run:

idf.py create-project-from-example "espressif/ble_services^0.1.0:ble_services/ble_tps"

or download archive

Stats

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

Badge

espressif/ble_services version: 0.1.0
|