GAP based TOF Demo

Dependencies:   BLE_API X_NUCLEO_6180XA1 mbed

Fork of BLE_HeartRate_IDB0XA1 by ST

Committer:
hux
Date:
Sat Jan 07 15:38:15 2017 +0000
Revision:
26:fd06c8b57d16
Parent:
25:231d3f382583
Child:
27:32267cee7cb8
change of advertising service UUID in enrollment

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hux 23:677689000369 1 // service.h - declaring services and definitions
hux 23:677689000369 2 //
hux 26:fd06c8b57d16 3 // Synopsis
hux 26:fd06c8b57d16 4 //
hux 23:677689000369 5 // Example 1: A protocol might be declared as a class as follows
hux 23:677689000369 6 //
hux 23:677689000369 7 // Collection col; // collection used during setup
hux 23:677689000369 8 //
hux 23:677689000369 9 // Characteristic<ObjectId> id(col,0x2AC3,"rw","ID");
hux 23:677689000369 10 // Characteristic<ObjectName> name(col,0x2ABE,"rw","Name");
hux 23:677689000369 11 // Characteristic<Digital> presence(col,0x2A56,"r","Presence");
hux 23:677689000369 12 //
hux 23:677689000369 13 // Service presenceDetection(col,0xA001); // instantiate service
hux 23:677689000369 14 //
hux 23:677689000369 15 // onSetup(Blob &blue)
hux 23:677689000369 16 // {
hux 23:677689000369 17 // blue.service(presenceDetection); // use service
hux 23:677689000369 18 // }
hux 23:677689000369 19 //
hux 23:677689000369 20 // Example 2: service definition by means of a service definition class
hux 23:677689000369 21 //
hux 23:677689000369 22 // class PresenceDetector
hux 23:677689000369 23 // {
hux 23:677689000369 24 // public:
hux 23:677689000369 25 // Collection col; // collection used during setup
hux 23:677689000369 26 //
hux 23:677689000369 27 // Characteristic<ObjectId> id; // ID of presence detector
hux 23:677689000369 28 // Characteristic<ObjectName> name; // name of presence detector
hux 23:677689000369 29 // Characteristic<Digital> presence; // digital presence value
hux 23:677689000369 30 // Characteristic<DateTime> timestamp; // last detection change's time
hux 23:677689000369 31 // Characteristic<ObjectName> layout; // name of model railway layout
hux 23:677689000369 32 //
hux 23:677689000369 33 // Service presenceDetection; // the service
hux 23:677689000369 34 //
hux 23:677689000369 35 // public:
hux 23:677689000369 36 // PresenceDetector(Blob &blue, cost UUID uuid) :
hux 23:677689000369 37 // list; // init service list
hux 23:677689000369 38 // id(list,0x2AC3,"rw","ID"), // instantiate characteristic
hux 23:677689000369 39 // name(list,0x2ABE,"rw","Name"), // instantiate characteristic
hux 23:677689000369 40 // presence(list,0x2A56,"r","Presence"),// instantiate characteristic
hux 23:677689000369 41 // timestamp(list,0x2A08,"r","Timestamp"),// instantiate characteristic
hux 23:677689000369 42 // layout(list,0x2ABE,"rw","Layout"), // instantiate characteristic
hux 23:677689000369 43 // presenceDetection(list,uuid) // instantiate service
hux 23:677689000369 44 // {
hux 23:677689000369 45 // Blob blue;
hux 23:677689000369 46 // blue.service(presenceDetection); // use service
hux 23:677689000369 47 // }
hux 23:677689000369 48 // };
hux 23:677689000369 49 //
hux 23:677689000369 50 #ifndef _SERVICE_H_
hux 23:677689000369 51 #define _SERVICE_H_
hux 23:677689000369 52
hux 23:677689000369 53 #include "ble/BLE.h"
hux 23:677689000369 54 #include "ble/Gap.h"
hux 24:0f08f68579bd 55 #include "bricks/blob.h"
hux 23:677689000369 56 #include "bricks/collection.h"
hux 23:677689000369 57
hux 24:0f08f68579bd 58 class Service
hux 23:677689000369 59 {
hux 26:fd06c8b57d16 60 public: // public properties
hux 24:0f08f68579bd 61 Collection collection; // collection of characteristics
hux 26:fd06c8b57d16 62 uint16_t uuid; // UUID of service
hux 24:0f08f68579bd 63 const char *name; // name of service
hux 24:0f08f68579bd 64
hux 24:0f08f68579bd 65 public: // public methods
hux 26:fd06c8b57d16 66 Service(uint16_t _uuid, const char* _name = NULL) : collection()
hux 24:0f08f68579bd 67 {
hux 24:0f08f68579bd 68 uuid = _uuid;
hux 24:0f08f68579bd 69 name = _name;
hux 24:0f08f68579bd 70 }
hux 24:0f08f68579bd 71
hux 24:0f08f68579bd 72 void add(GattCharacteristic *pChr) // add a characteristic to collection
hux 23:677689000369 73 {
hux 24:0f08f68579bd 74 collection.add(pChr);
hux 24:0f08f68579bd 75 }
hux 23:677689000369 76 };
hux 23:677689000369 77
hux 23:677689000369 78 #endif // _SERVICE_H_