]> granicus.if.org Git - esp-idf/blob - examples/bluetooth/nimble/blehr/README.md
Add NimBLE bleprph,blecent,blehr example tests
[esp-idf] / examples / bluetooth / nimble / blehr / README.md
1 # BLE Heart Rate Measurement example
2
3 (See the README.md file in the upper level 'examples' directory for more information about examples.)
4
5 This example creates GATT server demonstrating standard Heart Rate measurement service. It simulates Hear rate measurement and notifies to client when the notifications are enabled.
6
7 It uses ESP32's Bluetooth controller and NimBLE stack based BLE host
8
9 This example aims at understanding notification subscriptions and sending notifications.
10
11 To test this demo, any BLE scanner app can be used.
12
13 A Python based utility `blehr_test.py` is also provided (which will run as a BLE GATT Client) and can be used to test this example.   
14
15 Note :
16
17 * Make sure to run `python -m pip install --user -r $IDF_PATH/requirements.txt -r $IDF_PATH/tools/ble/requirements.txt` to install the dependency packages needed.
18 * Currently this Python utility is only supported on Linux (BLE communication is via BLuez + DBus).
19
20
21 ## How to use example
22
23 ### Configure the project
24
25 ```
26 make menuconfig
27 ```
28
29 * Set serial port under Serial Flasher Options.
30
31 ### Build and Flash
32
33 Build the project and flash it to the board, then run monitor tool to view serial output:
34
35 ```
36 make -j4 flash monitor
37 ```
38
39 (To exit the serial monitor, type ``Ctrl-]``.)
40
41 See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects.
42
43 ## Example Output
44
45 This console output can be observed when blehr is connected to client and client enables notifications:
46
47 ```
48 I (91) BTDM_INIT: BT controller compile version [fe7ced0]
49 I (91) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
50 I (181) phy: phy_version: 4100, 6fa5e27, Jan 25 2019, 17:02:06, 0, 0
51 I (421) NimBLE_BLE_HeartRate: BLE Host Task Started
52 GAP procedure initiated: stop advertising.
53 Device Address: xx:xx:xx:xx:xx:xx
54 GAP procedure initiated: advertise; disc_mode=2 adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=0 adv_itvl_max=0
55 connection established; status=0
56 subscribe event; cur_notify=1
57  value handle; val_handle=3
58 I (21611) BLE_GAP_SUBSCRIBE_EVENT: conn_handle from subscribe=0
59 GATT procedure initiated: notify; att_handle=3
60 GATT procedure initiated: notify; att_handle=3
61 GATT procedure initiated: notify; att_handle=3
62 GATT procedure initiated: notify; att_handle=3
63 GATT procedure initiated: notify; att_handle=3
64 GATT procedure initiated: notify; att_handle=3
65 GATT procedure initiated: notify; att_handle=3
66
67 ```
68
69 ## Running Python Utility
70
71 ```
72 python blehr_test.py
73 ```
74
75 ## Python Utility Output
76
77 This is this output seen on the python side on successful connection:
78
79 ```
80 discovering adapter...
81 bluetooth adapter discovered
82 powering on adapter...
83 bluetooth adapter powered on
84
85 Started Discovery
86
87 Connecting to device...
88
89 Connected to device
90
91 Services
92
93 [dbus.String(u'00001801-0000-1000-8000-00805f9b34fb', variant_level=1), dbus.String(u'0000180d-0000-1000-8000-00805f9b34fb', variant_level=1), dbus.String(u'0000180a-0000-1000-8000-00805f9b34fb', variant_level=1)]
94
95 Subscribe to notifications: On
96 dbus.Array([dbus.Byte(6), dbus.Byte(90)], signature=dbus.Signature('y'), variant_level=1)
97 dbus.Array([dbus.Byte(6), dbus.Byte(91)], signature=dbus.Signature('y'), variant_level=1)
98 dbus.Array([dbus.Byte(6), dbus.Byte(92)], signature=dbus.Signature('y'), variant_level=1)
99 dbus.Array([dbus.Byte(6), dbus.Byte(93)], signature=dbus.Signature('y'), variant_level=1)
100 dbus.Array([dbus.Byte(6), dbus.Byte(94)], signature=dbus.Signature('y'), variant_level=1)
101 dbus.Array([dbus.Byte(6), dbus.Byte(95)], signature=dbus.Signature('y'), variant_level=1)
102 dbus.Array([dbus.Byte(6), dbus.Byte(96)], signature=dbus.Signature('y'), variant_level=1)
103 dbus.Array([dbus.Byte(6), dbus.Byte(97)], signature=dbus.Signature('y'), variant_level=1)
104 dbus.Array([dbus.Byte(6), dbus.Byte(98)], signature=dbus.Signature('y'), variant_level=1)
105 dbus.Array([dbus.Byte(6), dbus.Byte(99)], signature=dbus.Signature('y'), variant_level=1)
106
107 Subscribe to notifications: Off
108 Success: blehr example test passed
109
110 exiting from test...
111 disconnecting device...
112 device disconnected
113 powering off adapter...
114 bluetooth adapter powered off
115 ```