Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:iot-open:practical:hardware:sut:esp32:iot_9 [2024/05/01 14:32] – [FAQ] ktokarzen:iot-open:practical:hardware:sut:esp32:iot_9 [2024/05/04 09:20] (current) ktokarz
Line 1: Line 1:
-====== IoT_9: BLE Communication with notify/indicate =====+====== IoT9: BLE Communication with notify/indicate =====
 This scenario presents how to extend the Bluetooth Low Energy server and client devices with a notification/indication mechanism for sending data automatically. If enabled, notifications or indications are sent at any time while the data in the server is updated. A difference between them is that a notification is an unacknowledged message while an indication is an acknowledged message. While one of them is enabled by the client, the server decides on the time of the message sent. This scenario presents how to extend the Bluetooth Low Energy server and client devices with a notification/indication mechanism for sending data automatically. If enabled, notifications or indications are sent at any time while the data in the server is updated. A difference between them is that a notification is an unacknowledged message while an indication is an acknowledged message. While one of them is enabled by the client, the server decides on the time of the message sent.
  
 ===== Prerequisites ===== ===== Prerequisites =====
-It is necessary to understand the principles of the Bluetooth Low Energy protocol with concepts of services, characteristics and descriptors. Notification and indication methods of data transmission should be known. We will use in this scenario the knowledge of the services and characteristics so making the IoT_8 exercise is recommended.+It is necessary to understand the principles of the Bluetooth Low Energy protocol with concepts of services, characteristics and descriptors. Notification and indication methods of data transmission should be known. We will use in this scenario the knowledge of the services and characteristics so making the [[en:iot-open:practical:hardware:sut:esp32:IoT_8]] exercise is recommended.
 ===== Suggested Readings and Knowledge Resources ===== ===== Suggested Readings and Knowledge Resources =====
   * [[en:iot-open:introductiontoembeddedprogramming2:cppfundamentals]]   * [[en:iot-open:introductiontoembeddedprogramming2:cppfundamentals]]
Line 11: Line 11:
  
 ===== Hands-on Lab Scenario ===== ===== Hands-on Lab Scenario =====
-This scenario is intended to be implemented using two BLE laboratory nodes. One of them is a server, while the second is a client. Here we will present the extension of the scenario implemented in IoT_8.+This scenario is intended to be implemented using two BLE laboratory nodes. One of them is a server, while the second is a client. Here we will present the extension of the scenario implemented in [[en:iot-open:practical:hardware:sut:esp32:IoT_8]].
 ==== Task to be implemented ==== ==== Task to be implemented ====
 **Task 1.** Implement a program that operates as the BLE server which advertises itself and allows us to connect to. After a successful connection, it handles the notify descriptor modification and sends the data automatically if notifications are enabled. **Task 1.** Implement a program that operates as the BLE server which advertises itself and allows us to connect to. After a successful connection, it handles the notify descriptor modification and sends the data automatically if notifications are enabled.
Line 18: Line 18:
  
 ==== Start ==== ==== Start ====
-You can use the simple client and server programs from IoT_8 as the starting point.+You can use the simple client and server programs from [[en:iot-open:practical:hardware:sut:esp32:IoT_8]] as the starting point.
  
 ==== Steps ==== ==== Steps ====
-We will pass through the lab in a few steps. We will add the second characteristic to the example from lab IoT_8. We will configure this characteristic as notify/indicate capable. It allows us to establish a connection and, if successfully connected, enable the indication or notification feature. With this feature enabled peripheral device initiates data transmission. It can be used for the periodic measurement reading or updating information on value change.+We will pass through the lab in a few steps. We will add the second characteristic to the example from lab [[en:iot-open:practical:hardware:sut:esp32:IoT_8]]. We will configure this characteristic as notify/indicate capable. It allows us to establish a connection and, if successfully connected, enable the indication or notification feature. With this feature enabled, the peripheral device initiates data transmission. It can be used for periodic measurement reading or updating information on value change.
  
 === Step 1 === === Step 1 ===
-We start with the program written during the laboratory IoT_8 by including the BLE2902.h library which handles the Client Characteristic Configuration Descriptor (CCCD). The descriptor of this type is used to enable or disable the notification and indication feature.+We start with the program written during the laboratory [[en:iot-open:practical:hardware:sut:esp32:IoT_8]] by including the BLE2902.h library which handles the Client Characteristic Configuration Descriptor (CCCD). The descriptor of this type is used to enable or disable the notification and indication feature.
 ^ Descriptor UUID  ^ Bits 1 and 0  ^ CCCD value  ^ Function                  ^ ^ Descriptor UUID  ^ Bits 1 and 0  ^ CCCD value  ^ Function                  ^
 | 0x2902           | 00            | 0           | notify/indicate disabled  | | 0x2902           | 00            | 0           | notify/indicate disabled  |
Line 89: Line 89:
  
 === Step 4 === === Step 4 ===
-We have to extend the client software from scenario IoT_8 with some elements. Let's start with adding another remote characteristic which is responsible for receiving notifications.+We have to extend the client software from scenario [[en:iot-open:practical:hardware:sut:esp32:IoT_8]] with some elements. Let's start with adding another remote characteristic which is responsible for receiving notifications.
 <code c> <code c>
 #define REMOTE_NOTIFY_CHARACTERISTIC_UUID "6e9b7b28-ca96-4774-b056-8ec5b759fd86" #define REMOTE_NOTIFY_CHARACTERISTIC_UUID "6e9b7b28-ca96-4774-b056-8ec5b759fd86"
Line 126: Line 126:
 ==== Result validation ==== ==== Result validation ====
 You should be able to establish a connection and read the non-notification characteristic data. After enabling the notification we will observe periodic incrementation of the value sent with notify data packets.  You should be able to establish a connection and read the non-notification characteristic data. After enabling the notification we will observe periodic incrementation of the value sent with notify data packets. 
 +<note>
 +You can observe that sometimes devices do not connect. This can happen because if you upload the new version of the program to one of the devices the second one remains in a connected state. In such a situation you need to restart both devices.
 +</note>
  
 ===== FAQ ===== ===== FAQ =====
en/iot-open/practical/hardware/sut/esp32/iot_9.1714573975.txt.gz · Last modified: 2024/05/01 14:32 by ktokarz
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0