![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
A cute tiny piece of code implementing an IoT NAND device, demonstrating how to setup and advertise a cute GATT (NAND) service. The code has been tested on a Nordic nRF51822-DK.
Dependencies: BLE_API mbed nRF51822
Fork of BLE_HeartRate_IDB0XA1 by
Diff: bricks/descriptor.h
- Revision:
- 26:dce30a5341bb
- Parent:
- 23:2e73c391bb12
diff -r 339931243be4 -r dce30a5341bb bricks/descriptor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bricks/descriptor.h Sat May 19 14:10:17 2018 +0000 @@ -0,0 +1,50 @@ +// descriptor.h - a description list, containing a single descriptor +// +// Synopsis: +// +// Descriptor user(0x2901,"User"); +// Descriptor client(0x2902,"Client"); +// +// UserDescriptor status("Status"); // user descriptor 0x2901 +// ClientDescriptor client("Client"); // client descriptor 0x2902 +// +#ifndef _DESCRIPTOR_H_ +#define _DESCRIPTOR_H_ + +#include "ble/BLE.h" +#include "ble/Gap.h" + + class Descriptor : public GattAttribute + { + private: + typedef GattAttribute *GattAttributePtr; + + public: + GattAttributePtr plist[1]; + + Descriptor(UUID uuid, const char *name) : + GattAttribute(uuid,(uint8_t*)name,strlen(name),strlen(name)) + { + plist[0] = this; + } + }; + + class UserDescriptor : public Descriptor + { + public: + UserDescriptor(const char *name) : Descriptor(0x2901,name) + { + // empty + } + }; + + class ClientDescriptor : public Descriptor + { + public: + ClientDescriptor(const char *name) : Descriptor(0x2902,name) + { + // empty + } + }; + +#endif // _DESCRIPTOR_H_ \ No newline at end of file