This helper class acts as a wrapper for the Bluetooth Device Information Service (0x180A). This official GATT service allows you to publish basic information about your device in a generic manner.
The Bluefruit BLEDis helper class exposes the following characteristics:
- Model Number String (0x2A24), exposed via .setModel(const char*)
- Serial Number String (0x2A25), private
- Firmware Revision String (0x2A26), private
- Hardware Revision String (0x2A27), exposed via .setHardwareRev(const char*)
- Software Revision String (0x2A28), exposed via .setSoftwareRev(const char*)
- Manufacturer Name String (0x2A29), exposed via .setManufacturer(const char*)
The Serial Number String is private and is populated with a unique device ID that nRF52832 SoCs are programmed with during manufacturing.
The Firmware Revision String is also private and is populated with the following fields (to help us track issues and offer better feedback in the support forums):
- Softdevice Name (Sxxx)
- Softdevice Version (x.x.x)
- Bootloader Version (x.x.x)
The remaining characteristics are all public and can be set to an value (up to 20 chars in length) using the appropriate helper function, but they have the following default values (for the nRF52832):
- Model Number String: Bluefruit Feather 52
- Hardware Revision String: NULL
- Software Revision String: The nRF52 BSP version number
- Manufacturer Name String: Adafruit Industries
Setting a public value to NULL will prevent the characteristic from being present in the DIS service.
BLEDis(void); void setModel(const char* model); void setHardwareRev(const char* hw_rev); void setSoftwareRev(const char* sw_rev); void setManufacturer(const char* manufacturer); err_t begin(void);
The individual characteristic values are set via the .set*() functions above, and when all values have been set you call the .begin() function to add the service to the device's internal GATT registry.
Example
The following bare bones examples show how to setup the device information service with user-configurable strings for values:
#include <bluefruit.h> BLEDis bledis; void setup() { Serial.begin(115200); Serial.println("Bluefruit52 DIS Example"); Bluefruit.begin(); Bluefruit.setName("Bluefruit52"); // Configure and Start Device Information Service bledis.setManufacturer("Adafruit Industries"); bledis.setModel("Bluefruit Feather52"); bledis.begin(); // Set up Advertising Packet setupAdv(); // Start Advertising Bluefruit.Advertising.start(); } void setupAdv(void) { Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE); Bluefruit.Advertising.addTxPower(); // There isn't enough room in the advertising packet for the // name so we'll place it on the secondary Scan Response packet Bluefruit.ScanResponse.addName(); } void loop() { }
Output
If you examine the device using the Bluefruit LE Connect app on iOS, Android or OS X you should see something resembling the following output:
Text editor powered by tinymce.