Datasheet
BLECharacteristic
This base class is used when defining custom BLE GATT characteristics, and is used throughput the Adafruit Bluefruit
nRF52 API and helper classes.
Unless you are implementing a custom GATT service and characteristic, you normally won't use this base class directly,
and would instantiate and call a higher level helper service or characteristic included in the Bluefruit nRF52 API.
Basic Usage
There are two main steps to using the BLECharacteristic class.
First, you need to declare and instantiate your BLECharacteristic class with a 16-bit or 128-bit UUID:
Then you need to set the relevant properties for the characteristic, with the following values at minimum:
.setProperties can be set to one or more of the following macros, which correspond to a single bit in the eight bit
'properties' field for the characteristic definition:
CHR_PROPS_BROADCAST = bit(0),
CHR_PROPS_READ = bit(1),
CHR_PROPS_WRITE_WO_RESP = bit(2),
CHR_PROPS_WRITE = bit(3),
CHR_PROPS_NOTIFY = bit(4),
CHR_PROPS_INDICATE = bit(5)
.setPermission sets the security level for the characteristic, where the first value sets the read permissions, and
the second value sets the write permissions, where both fields can have one of the following values:
SECMODE_NO_ACCESS = 0x00,
SECMODE_OPEN = 0x11,
SECMODE_ENC_NO_MITM = 0x21,
SECMODE_ENC_WITH_MITM = 0x31,
SECMODE_SIGNED_NO_MITM = 0x12,
SECMODE_SIGNED_WITH_MITM = 0x22
.setFixedLen() indicates how many bytes this characteristic has. For characteristics that use 'notify' or 'indicate'
this value can be from 1..20, other characteristic types can be set from 1..512 and values >20 bytes will be sent
across multiple 20 byte packets. If the characteristic has a variable len, you set the .setMaxLen() value to the
The Bluefruit nRF52 Feather codebase is in an early BETA stage and 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
BLECharacteristic myChar = BLECharacteristic(0xABCD);
myChar.setProperties(CHR_PROPS_READ);
myChar.setPermission(SECMODE_OPEN, SECMODE_NO_ACCESS);
myChar.setFixedLen(1); // Alternatively .setMaxLen(uint16_t len)
myChar.begin();
© Adafruit Industries https://learn.adafruit.com/bluefruit-nrf52-feather-learning-guide Page 107 of 175