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:stm32:iot_6 [2024/05/03 18:02] – [Steps] ktokarzen:iot-open:practical:hardware:sut:stm32:iot_6 [2024/05/04 08:10] (current) ktokarz
Line 48: Line 48:
 While none of the standard UUIDs fits your device you need to define your own UUID. It must be 128-bit long and can be randomly generated with the tool available on the website https://www.uuidgenerator.net/((https://www.uuidgenerator.net/)). While none of the standard UUIDs fits your device you need to define your own UUID. It must be 128-bit long and can be randomly generated with the tool available on the website https://www.uuidgenerator.net/((https://www.uuidgenerator.net/)).
 The service UUID and characteristic UUID must differ. Although they can be completely different in many implementations the UUIDs of characteristics grouped under one service differ on one digit. The service UUID and characteristic UUID must differ. Although they can be completely different in many implementations the UUIDs of characteristics grouped under one service differ on one digit.
-<code>+<code c>
 #define SERVICE_UUID        "6e9b7b26-ca96-4774-b056-8ec5b759fd86" #define SERVICE_UUID        "6e9b7b26-ca96-4774-b056-8ec5b759fd86"
 #define CHARACTERISTIC_UUID "6e9b7b27-ca96-4774-b056-8ec5b759fd86" #define CHARACTERISTIC_UUID "6e9b7b27-ca96-4774-b056-8ec5b759fd86"
Line 63: Line 63:
 The function creates and initialises the BLE device instance named "SUT STM BLE". It creates a service with the characteristic, sets the characteristic's initial value and finally starts advertising. The function creates and initialises the BLE device instance named "SUT STM BLE". It creates a service with the characteristic, sets the characteristic's initial value and finally starts advertising.
  
-<code>+<code c>
 void setup() { void setup() {
      
Line 90: Line 90:
 </note> </note>
  
-In the loop function, we need to call a function waiting for the connection of the client. +In the loop function, we need to call a function waiting for the connection of the client (central device)
-<code>+<code c>
 void loop() { void loop() {
-  // listen for BLE peripherals to connect:+  // listen for BLE central device to connect:
   BLE.central();   BLE.central();
 } }
Line 105: Line 105:
 While we have analysed the client's behaviour we can start implementation. Let's begin with the libraries needed. While we have analysed the client's behaviour we can start implementation. Let's begin with the libraries needed.
 Add the libraries to the platformio.ini.  Add the libraries to the platformio.ini. 
-<code>+<code c>
 lib_deps =  lib_deps = 
   stm32duino/STM32duinoBLE @ 1.2.6   stm32duino/STM32duinoBLE @ 1.2.6
Line 111: Line 111:
 </code>  </code> 
 And import libraries into the cpp file. And import libraries into the cpp file.
-<code>+<code c>
 #include "Arduino.h" #include "Arduino.h"
 #include "STM32duinoBLE.h" #include "STM32duinoBLE.h"
Line 117: Line 117:
 </code> </code>
 Next, we define the UUIDs for remote service and a characteristic. Notice they must match the ones defined in the server. Next, we define the UUIDs for remote service and a characteristic. Notice they must match the ones defined in the server.
-<code>+<code c>
 // The remote service we wish to connect to. // The remote service we wish to connect to.
 #define REMOTE_SERVICE_UUID "6e9b7b26-ca96-4774-b056-8ec5b759fd86" #define REMOTE_SERVICE_UUID "6e9b7b26-ca96-4774-b056-8ec5b759fd86"
Line 127: Line 127:
 </note> </note>
 Some global class objects and variables will be needed for our software. Some global class objects and variables will be needed for our software.
-<code>+<code c>
 // Variables // Variables
 HCISharedMemTransportClass HCISharedMemTransport; HCISharedMemTransportClass HCISharedMemTransport;
Line 143: Line 143:
 In the setup() function we initialise LCD and Bluetooth and start scanning for the device having the service UUID we want to connect. In the setup() function we initialise LCD and Bluetooth and start scanning for the device having the service UUID we want to connect.
  
-<code>+<code c>
 void setup() { void setup() {
   // initialise LCD   // initialise LCD
Line 174: Line 174:
  
   if (peripheral) {   if (peripheral) {
-    if (peripheral.localName() = "SUT STM BLE") {+    if (peripheral.localName() == "SUT STM BLE") {
  
       // display remote name         // display remote name  
Line 220: Line 220:
   - Disconnects from the remote server.   - Disconnects from the remote server.
  
-<code>+<code c>
 void display_characteristic(BLEDevice peripheral) { void display_characteristic(BLEDevice peripheral) {
      
en/iot-open/practical/hardware/sut/stm32/iot_6.1714759337.txt.gz · Last modified: 2024/05/03 18:02 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