BLE NAND for ST Boards

Dependencies:   BLE_API X_NUCLEO_IDB0XA1 mbed

Fork of N06_NAND by Hugo Pristauz

Committer:
hux
Date:
Sun Jan 08 23:15:53 2017 +0000
Revision:
23:2e73c391bb12
A cute tiny piece of code implementing an Iot NAND device, demonstrating how to setup and advertise a cute GATT (NAND) service.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hux 23:2e73c391bb12 1 // descriptor.h - a description list, containing a single descriptor
hux 23:2e73c391bb12 2 //
hux 23:2e73c391bb12 3 // Synopsis:
hux 23:2e73c391bb12 4 //
hux 23:2e73c391bb12 5 // Descriptor user(0x2901,"User");
hux 23:2e73c391bb12 6 // Descriptor client(0x2902,"Client");
hux 23:2e73c391bb12 7 //
hux 23:2e73c391bb12 8 // UserDescriptor status("Status"); // user descriptor 0x2901
hux 23:2e73c391bb12 9 // ClientDescriptor client("Client"); // client descriptor 0x2902
hux 23:2e73c391bb12 10 //
hux 23:2e73c391bb12 11 #ifndef _DESCRIPTOR_H_
hux 23:2e73c391bb12 12 #define _DESCRIPTOR_H_
hux 23:2e73c391bb12 13
hux 23:2e73c391bb12 14 #include "ble/BLE.h"
hux 23:2e73c391bb12 15 #include "ble/Gap.h"
hux 23:2e73c391bb12 16
hux 23:2e73c391bb12 17 class Descriptor : public GattAttribute
hux 23:2e73c391bb12 18 {
hux 23:2e73c391bb12 19 private:
hux 23:2e73c391bb12 20 typedef GattAttribute *GattAttributePtr;
hux 23:2e73c391bb12 21
hux 23:2e73c391bb12 22 public:
hux 23:2e73c391bb12 23 GattAttributePtr plist[1];
hux 23:2e73c391bb12 24
hux 23:2e73c391bb12 25 Descriptor(UUID uuid, const char *name) :
hux 23:2e73c391bb12 26 GattAttribute(uuid,(uint8_t*)name,strlen(name),strlen(name))
hux 23:2e73c391bb12 27 {
hux 23:2e73c391bb12 28 plist[0] = this;
hux 23:2e73c391bb12 29 }
hux 23:2e73c391bb12 30 };
hux 23:2e73c391bb12 31
hux 23:2e73c391bb12 32 class UserDescriptor : public Descriptor
hux 23:2e73c391bb12 33 {
hux 23:2e73c391bb12 34 public:
hux 23:2e73c391bb12 35 UserDescriptor(const char *name) : Descriptor(0x2901,name)
hux 23:2e73c391bb12 36 {
hux 23:2e73c391bb12 37 // empty
hux 23:2e73c391bb12 38 }
hux 23:2e73c391bb12 39 };
hux 23:2e73c391bb12 40
hux 23:2e73c391bb12 41 class ClientDescriptor : public Descriptor
hux 23:2e73c391bb12 42 {
hux 23:2e73c391bb12 43 public:
hux 23:2e73c391bb12 44 ClientDescriptor(const char *name) : Descriptor(0x2902,name)
hux 23:2e73c391bb12 45 {
hux 23:2e73c391bb12 46 // empty
hux 23:2e73c391bb12 47 }
hux 23:2e73c391bb12 48 };
hux 23:2e73c391bb12 49
hux 23:2e73c391bb12 50 #endif // _DESCRIPTOR_H_