Programming IoT Devices
Understanding Bluetooth
Leopoldo Armesto
Senior Lecturer
Universitat Politècnica de València
1
Outline
Material
Worked Instructions
RPCs
Exercises
Light Dimm using RPCs in ThingsBoard
Remotely Controlled RGB using RPCs in ThingsBoard
Remotely Controlled Melody using RPCs in ThingsBoard
Remotely Controlled LEDs using RPCs in ThingsBoard
2
Bluetooth 2.1+EDR & 3.0 HS
Bluetooth 2.1+EDR:
Upto 3Mbps (2.1 Mpbs in practice).
Pairing required
Used by many low-speed microcontrollers to implement a low-cost wireless solution, i.e.: Arduino Uno+HC-05.
Bluetooth 3.0+HS:
Upto 24 Mpbs.
Combined transmission of bluetooth and WiFi. Bluetooth is actually used to stablish the connection, while
transmission is over WiFi (802.11).
Ideal for transmitting data and audio.
3
Bluetooth 4.0
Bluetooth High-Speed is indeed Bluetooth 3.0+HS.
Bluetooth Classic is indeed Bluetooth 2.1+EDR.
Bluetooth Low-Energy:
Device state
Low bandwidth (0.27Mpbs) Y Low consumption
4
Battery Life
Classic Bluetooth has a medium power consumption, compared to Bluetooth BLE. It is connection oriented, link is
mantained, even if there’s no data flowing.
Bluetooth BLE has similar performance to ZigBee (in terms of power consumption).
Bluetooth is a device to device connection, while ZigBee can include multiple wireless nodes in the same network.
ZigBee is a good choice for monitoring networks, i.e.: home automation.
WiFi has much high bandwidth at the cost of higher power consumption.
5
Device Modes
6
Bluetooth BR/EDR (Bluetooth 2.1)
Dual Mode
Single Mode (BLE)
BR/EDR Dual-mode stack Single-mode
Bluetooth LE Connections
7
Link Layer
BLE Generic Access Profile (GAP)
Defines the general topology, i.e.: how two BLE devices can communicate.
GAP modes: Connectable, Discoverable, Bondable.
GAP procedures: Name discovery, device discovery, service discovery, etc.
Roles:
Broadcasting:
Broadcaster: Public advertising data.
Observer: List to data (no required connection).
Connecting:
Peripheral: After connection peripherals no longer broadcast data to other central.
Central: Innitiates the connection.
8
BLE Generic Attribute Profile (GATT)
Defines how data is transmitted once they are connected.
Roles:
Client: Sends request to the GATT server. Can read/write attributes (data) on the server. For instance, our mobile
pone acts as a client when reading data from a IoT device.
Server: Stores attributes. Our IoT device acts as a server, being responsible of storing data (i.e.: temperature).
GATT protocol:
Attributes: List of services and characteristics
Service: Collection of characteristics.
Characteristics: Data
9
GATT Operations:
• Read
• Write
• Notify
• Indicate
UUIDs
Universal Unique Identifier (16bit or 128 bit)
16-bit UUIDs are efficent in time and energy. Regulated by Bluetooth SIG for common services and
characteristics
Heart reate service: 0x180D
Heart Rate Measurement characteristic: 0x2A37
128-bit UUIDs custom devices:
4A98xxxx-1CC4-E7C1-C757-F1267DD021E8
UUID generator tool:
10
https://www.uuidgenerator.net/
Some interesting Services
11
Name UUID Characteristics
Automation I/O 0x1815 Digital, Analog, Aggregate
Battery 0x180F Battery Level
Heart Rate 0x180D Heart Rate Measurement, Body Sensor Location, Heart Rate Control Point
Health Thermometer 0x1809 Temperature Measurement, Temperature Type, Intermediate Temperature, Measurement Interval
Pulse Oximeter 0x1822 PLX Spot-check Measurement, PLX ContinuousMeasurement, PLX Features, Record Access Control Point
Environmental Sensing 0x181A
Wind Direction, Speed, Dew Point, Elevation, Gust Factor, Heat Index, Humidity, Irradiance, Pollen Concentration,
Rainfall, Pressure, Temperature, True Wind Direction, True Wind Speed, UV Index, Wind Chill, Barometric Pressure
Trend, Magnetic Declination,Magnetic Flux Density 2D/3D
Location and Navigation 0x1819 LN Feature, Location and Speed, Position Quality, LN Control Point, Navigation
Blood Pressure 0x1810 Blood Pressure Measurement, Intermediate Cuff Pressure, Blood Pressure Feature
Programming IoT Devices
Understanding Bluetooth
Leopoldo Armesto
Senior Lecturer
Universitat Politècnica de València
12

Undestanding Bluetooth

  • 1.
    Programming IoT Devices UnderstandingBluetooth Leopoldo Armesto Senior Lecturer Universitat Politècnica de València 1
  • 2.
    Outline Material Worked Instructions RPCs Exercises Light Dimmusing RPCs in ThingsBoard Remotely Controlled RGB using RPCs in ThingsBoard Remotely Controlled Melody using RPCs in ThingsBoard Remotely Controlled LEDs using RPCs in ThingsBoard 2
  • 3.
    Bluetooth 2.1+EDR &3.0 HS Bluetooth 2.1+EDR: Upto 3Mbps (2.1 Mpbs in practice). Pairing required Used by many low-speed microcontrollers to implement a low-cost wireless solution, i.e.: Arduino Uno+HC-05. Bluetooth 3.0+HS: Upto 24 Mpbs. Combined transmission of bluetooth and WiFi. Bluetooth is actually used to stablish the connection, while transmission is over WiFi (802.11). Ideal for transmitting data and audio. 3
  • 4.
    Bluetooth 4.0 Bluetooth High-Speedis indeed Bluetooth 3.0+HS. Bluetooth Classic is indeed Bluetooth 2.1+EDR. Bluetooth Low-Energy: Device state Low bandwidth (0.27Mpbs) Y Low consumption 4
  • 5.
    Battery Life Classic Bluetoothhas a medium power consumption, compared to Bluetooth BLE. It is connection oriented, link is mantained, even if there’s no data flowing. Bluetooth BLE has similar performance to ZigBee (in terms of power consumption). Bluetooth is a device to device connection, while ZigBee can include multiple wireless nodes in the same network. ZigBee is a good choice for monitoring networks, i.e.: home automation. WiFi has much high bandwidth at the cost of higher power consumption. 5
  • 6.
    Device Modes 6 Bluetooth BR/EDR(Bluetooth 2.1) Dual Mode Single Mode (BLE) BR/EDR Dual-mode stack Single-mode
  • 7.
  • 8.
    BLE Generic AccessProfile (GAP) Defines the general topology, i.e.: how two BLE devices can communicate. GAP modes: Connectable, Discoverable, Bondable. GAP procedures: Name discovery, device discovery, service discovery, etc. Roles: Broadcasting: Broadcaster: Public advertising data. Observer: List to data (no required connection). Connecting: Peripheral: After connection peripherals no longer broadcast data to other central. Central: Innitiates the connection. 8
  • 9.
    BLE Generic AttributeProfile (GATT) Defines how data is transmitted once they are connected. Roles: Client: Sends request to the GATT server. Can read/write attributes (data) on the server. For instance, our mobile pone acts as a client when reading data from a IoT device. Server: Stores attributes. Our IoT device acts as a server, being responsible of storing data (i.e.: temperature). GATT protocol: Attributes: List of services and characteristics Service: Collection of characteristics. Characteristics: Data 9 GATT Operations: • Read • Write • Notify • Indicate
  • 10.
    UUIDs Universal Unique Identifier(16bit or 128 bit) 16-bit UUIDs are efficent in time and energy. Regulated by Bluetooth SIG for common services and characteristics Heart reate service: 0x180D Heart Rate Measurement characteristic: 0x2A37 128-bit UUIDs custom devices: 4A98xxxx-1CC4-E7C1-C757-F1267DD021E8 UUID generator tool: 10 https://www.uuidgenerator.net/
  • 11.
    Some interesting Services 11 NameUUID Characteristics Automation I/O 0x1815 Digital, Analog, Aggregate Battery 0x180F Battery Level Heart Rate 0x180D Heart Rate Measurement, Body Sensor Location, Heart Rate Control Point Health Thermometer 0x1809 Temperature Measurement, Temperature Type, Intermediate Temperature, Measurement Interval Pulse Oximeter 0x1822 PLX Spot-check Measurement, PLX ContinuousMeasurement, PLX Features, Record Access Control Point Environmental Sensing 0x181A Wind Direction, Speed, Dew Point, Elevation, Gust Factor, Heat Index, Humidity, Irradiance, Pollen Concentration, Rainfall, Pressure, Temperature, True Wind Direction, True Wind Speed, UV Index, Wind Chill, Barometric Pressure Trend, Magnetic Declination,Magnetic Flux Density 2D/3D Location and Navigation 0x1819 LN Feature, Location and Speed, Position Quality, LN Control Point, Navigation Blood Pressure 0x1810 Blood Pressure Measurement, Intermediate Cuff Pressure, Blood Pressure Feature
  • 12.
    Programming IoT Devices UnderstandingBluetooth Leopoldo Armesto Senior Lecturer Universitat Politècnica de València 12