A library for easier setup and prototyping of IoT devices (pucks), by collecting everything that is common for all pucks in one place.
Dependencies: BLE_API nRF51822
Dependents: ir-puck display-puck ir-puck2 BLE_ScoringDevice ... more
Puck Class Reference
A library for easier setup and prototyping of IoT devices (pucks), by collecting everything that is common for all pucks in one place. More...
#include <Puck.h>
Public Member Functions | |
void | init (uint16_t minor) |
Call after finishing configuring puck (adding services, characteristics, callbacks). | |
bool | drive () |
Pass control to the bluetooth stack, executing pending callbacks afterwards. | |
int | countFreeMemory () |
Approximates malloc-able heap space. | |
void | onDataWritten (GattAttribute::Handle_t handle, const uint8_t *data, const uint8_t length) |
For internal use only. | |
void | addCharacteristic (const UUID serviceUuid, const UUID characteristicUuid, int bytes, int properties=0xA) |
Extends the given gatt service with the given gatt characteristic. | |
void | onCharacteristicWrite (const UUID *uuid, CharacteristicWriteCallback callback) |
Register callback to be triggered on characteristic write. | |
void | updateCharacteristicValue (const UUID uuid, uint8_t *value, int length) |
Update the value of the given gatt characteristic. | |
uint8_t * | getCharacteristicValue (const UUID uuid) |
Returns current value of provided gatt characteristic. | |
Static Public Member Functions | |
static Puck & | getPuck () |
Returns singleton instance of puck object. |
Detailed Description
A library for easier setup and prototyping of IoT devices (pucks), by collecting everything that is common for all pucks in one place.
Definition at line 46 of file Puck.h.
Member Function Documentation
void addCharacteristic | ( | const UUID | serviceUuid, |
const UUID | characteristicUuid, | ||
int | bytes, | ||
int | properties = 0xA |
||
) |
Extends the given gatt service with the given gatt characteristic.
If the service doesn't exist, it is created.
- Parameters:
-
serviceUuid UUID of the gatt service to be extended. characteristicUuid UUID to use for this characteristic. bytes Length in bytes of this characteristic's value. properties 8-bit bit field containing the characteristic's properties. See ble_gatt_char_properties_t.
- Returns:
- Void.
int countFreeMemory | ( | ) |
bool drive | ( | ) |
uint8_t * getCharacteristicValue | ( | const UUID | uuid ) |
Puck & getPuck | ( | ) | [static] |
void init | ( | uint16_t | minor ) |
void onCharacteristicWrite | ( | const UUID * | uuid, |
CharacteristicWriteCallback | callback | ||
) |
Register callback to be triggered on characteristic write.
uuid UUID of the gatt characteristic to bind callback to.
callback CharacteristicWriteCallback to be executed on characteristic write.It's signature should be void (*CharacteristicWriteCallback)(const uint8_t* value, uint8_t length); "value" is the value that was written, and "length" is the length of the value that was written.
- Returns:
- Void.
void onDataWritten | ( | GattAttribute::Handle_t | handle, |
const uint8_t * | data, | ||
const uint8_t | length | ||
) |
void updateCharacteristicValue | ( | const UUID | uuid, |
uint8_t * | value, | ||
int | length | ||
) |
Generated on Tue Jul 12 2022 21:59:45 by
