The Bluefruit nRF52 BSP codebase is undergoing active development based on customer feedback and testing. As such, the class documentation here is incomplete, and you should consult the Github repo for the latest code and API developments: https://goo.gl/LdEx62

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:

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)
Note: The Softdevice and Bootloader fields are separated by a single comma, meaning the final output will resemble the following string: 'S132 2.0.1, 0.5.0'

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.

API

The following functions and constructors are defined in the BLEDis class:

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:

This guide was first published on Mar 11, 2020. It was last updated on Mar 29, 2024.

This page (BLEDis) was last updated on Mar 08, 2024.

Text editor powered by tinymce.