Datasheet
maximum value it will hold (up to 20 bytes).
.begin() will cause this characteristic to be added to the last BLEService that had it's .begin() method called.
Order of Operations (Important!)
One very important thing to take into consideration when working with BLEService and BLECharacteristic, is that any
BLECharacteristic will automatically be added to the last BLEService that had it's `.begin()` function called. As such, you
must call yourService.begin() before adding any characteristics!
See the example at the bottom of this page for a concrete example of how this works in practice.
API
BLECharacteristic has the following overall class structure:
This documentation may be slightly out of date as bugs are fixed, and the API develops. You should always
consult the Github repo for the definitive latest code release and class definitions!
/*--------- Callback Signatures ----------*/
typedef void (*read_authorize_cb_t) (BLECharacteristic& chr, ble_gatts_evt_read_t * request);
typedef void (*write_authorize_cb_t) (BLECharacteristic& chr, ble_gatts_evt_write_t* request);
typedef void (*write_cb_t) (BLECharacteristic& chr, uint8_t* data, uint16_t len, uint16_t offset);
typedef void (*write_cccd_cb_t) (BLECharacteristic& chr, uint16_t value);
BLEUuid uuid;
// Constructors
BLECharacteristic(void);
BLECharacteristic(BLEUuid bleuuid);
// Destructor
virtual ~BLECharacteristic();
BLEService& parentService(void);
void setTempMemory(void);
/*------------- Configure -------------*/
void setUuid(BLEUuid bleuuid);
void setProperties(uint8_t prop);
void setPermission(BleSecurityMode read_perm, BleSecurityMode write_perm);
void setMaxLen(uint16_t max_len);
void setFixedLen(uint16_t fixed_len);
/*------------- Descriptors -------------*/
void setUserDescriptor(const char* descriptor); // aka user descriptor
void setReportRefDescriptor(uint8_t id, uint8_t type); // TODO refactor to use addDescriptor()
void setPresentationFormatDescriptor(uint8_t type, int8_t exponent, uint16_t unit, uint8_t name_space = 1, uint16_t descritpor = 0);
/*------------- Callbacks -------------*/
void setWriteCallback (write_cb_t fp);
void setCccdWriteCallback (write_cccd_cb_t fp);
void setReadAuthorizeCallback(read_authorize_cb_t fp);
void setWriteAuthorizeCallbak(write_authorize_cb_t fp);
virtual err_t begin(void);
© Adafruit Industries https://learn.adafruit.com/bluefruit-nrf52-feather-learning-guide Page 108 of 175