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_7 [2024/04/14 10:18] ktokarzen:iot-open:practical:hardware:sut:esp32:iot_7 [2024/05/02 11:11] (current) – [IOT7: BLE Beacon] ktokarz
Line 1: Line 1:
-====== IoT_7: BLE Beacon =====+====== IoT7: BLE Beacon =====
 This scenario presents how to create the Bluetooth Low Energy beacon device which periodically broadcasts a small amount of information, and the client device which can receive packets sent by the beacon. Beacons are usually used for sending useful information (eg. the web address of the owner, a link to the page with tourist information). In some cases, they simply send the identification number recognised by a dedicated mobile application allowing the users to localise themselves. This scenario presents how to create the Bluetooth Low Energy beacon device which periodically broadcasts a small amount of information, and the client device which can receive packets sent by the beacon. Beacons are usually used for sending useful information (eg. the web address of the owner, a link to the page with tourist information). In some cases, they simply send the identification number recognised by a dedicated mobile application allowing the users to localise themselves.
  
Line 20: Line 20:
 This scenario is intended to be implemented using two laboratory nodes. One node will work as the beacon device, while the second will receive the beacon's packets and display information on the LCD. This scenario is intended to be implemented using two laboratory nodes. One node will work as the beacon device, while the second will receive the beacon's packets and display information on the LCD.
 ==== Task to be implemented ==== ==== Task to be implemented ====
-**Task 1** Implement a program that operates as the BLE beacon which advertises itself with the link to the SUT website. This can be done with the Eddystone beacon format.+**Task 1** Implement a program that operates as the BLE beacon which advertises itself with the link to the website. This can be done with the Eddystone beacon format.
 **Task 2** Implement the receiver of advertising frames broadcasted by the beacon device capable of displaying information on the LCD screen. **Task 2** Implement the receiver of advertising frames broadcasted by the beacon device capable of displaying information on the LCD screen.
  
Line 32: Line 32:
 Let's begin with including Arduino and BLE libraries. Let's begin with including Arduino and BLE libraries.
 <code c> <code c>
-#include <Arduino.h>+#include "Arduino.h"
 #include "BLEDevice.h" #include "BLEDevice.h"
 #include "BLEAdvertising.h" #include "BLEAdvertising.h"
Line 71: Line 71:
 | 3             | 0x03        | Complete list of 16-bit service UUIDs  | 0xAAFE         | | 3             | 0x03        | Complete list of 16-bit service UUIDs  | 0xAAFE         |
 | 14            | 0x16        | Service data                           | Eddystone format               | | 14            | 0x16        | Service data                           | Eddystone format               |
-The Eddystone field starts with service UUID (0xAAFE), next specifies the content type (0x10 for URL), then the transmitting power in [dBm], and then the compressed URL. To compress URLs some default prefixes and suffixes were defined as non-ASCII characters. They are presented in the tables below.+The Eddystone field starts with service UUID (0xAAFE), next specifies the content type (0x10 for URL), then the transmitting power in [dBm], and then the compressed URL. 
 <note> <note>
 The UUID of Eddystone appears twice. Once as the element of the list of available services, the second time as the identifier of the service field. The UUID of Eddystone appears twice. Once as the element of the list of available services, the second time as the identifier of the service field.
 </note> </note>
 +To compress URLs some default prefixes and suffixes were defined as non-ASCII characters. They are presented in the tables below.
  
 ^ Decimal ^ Hex ^ Prefix ^ ^ Decimal ^ Hex ^ Prefix ^
Line 262: Line 263:
 }; // MyAdvertisedDeviceCallbacks }; // MyAdvertisedDeviceCallbacks
 </code> </code>
 +Additional filtering of remote devices can be done with their names. We can add in the "MyAdvertisedDeviceCallbacks()" function the comparison of the remote device name with the constant string. It should be done if the Eddystone service was found. 
 +<code c> 
 +String name; 
 +name = advertisedDevice.getName().c_str(); 
 +if (name.equals("SUT BLE device")) 
 +  { 
 +    // here the internal code of the MyAdvertisedDeviceCallbacks() 
 +  } 
 +</code>
  
 === Step 5 === === Step 5 ===
Line 272: Line 281:
  
 ==== Result validation ==== ==== Result validation ====
-You should be able to observe the content of the advertising frame in nRF Connect or a similar application. You should be able to navigate to the URL sent in the advertising.+After the implementation of steps 1-4, you should be able to see the name of the beacon device in the first line of LCD and the URL from the Eddystone field in the second line of LCD. Implementation of step 5 should result in a change of the device name.
  
 ==== Further work ==== ==== Further work ====
-You can try the example software for the beacon device which is available in the examples at the path: +You can try to implement the beacon device compatible with iBeacon. The description can be found on the website ((https://www.silabs.com/whitepapers/developing-beacons-with-bluetooth-low-energy-technology)).
-<code> +
-C:\..\.platformio\packages\framework-arduinoespressif32\libraries\BLE\examples\BLE_EddystoneURL_Beacon +
-</code> +
-It is more complex but enables automatic determination of packet length depending on the URL provided. +
-\\ +
-You can also try to implement the beacon device compatible with iBeacon. The description can be found on the website ((https://www.silabs.com/whitepapers/developing-beacons-with-bluetooth-low-energy-technology)).+
  
 ===== FAQ ===== ===== FAQ =====
en/iot-open/practical/hardware/sut/esp32/iot_7.1713089902.txt.gz · Last modified: 2024/04/14 10:18 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