![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
A blue button is always a nice toy ...
Dependencies: BLE_API X_NUCLEO_IDB0XA1 mbed
Fork of BLE_HeartRate_IDB0XA1 by
bricks/service.h@23:677689000369, 2017-01-06 (annotated)
- Committer:
- hux
- Date:
- Fri Jan 06 15:28:18 2017 +0000
- Revision:
- 23:677689000369
- Child:
- 24:0f08f68579bd
Already nice & easy level. Still bugs!
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hux | 23:677689000369 | 1 | // service.h - declaring services and definitions |
hux | 23:677689000369 | 2 | // |
hux | 23:677689000369 | 3 | // Example 1: A protocol might be declared as a class as follows |
hux | 23:677689000369 | 4 | // |
hux | 23:677689000369 | 5 | // Collection col; // collection used during setup |
hux | 23:677689000369 | 6 | // |
hux | 23:677689000369 | 7 | // Characteristic<ObjectId> id(col,0x2AC3,"rw","ID"); |
hux | 23:677689000369 | 8 | // Characteristic<ObjectName> name(col,0x2ABE,"rw","Name"); |
hux | 23:677689000369 | 9 | // Characteristic<Digital> presence(col,0x2A56,"r","Presence"); |
hux | 23:677689000369 | 10 | // |
hux | 23:677689000369 | 11 | // Service presenceDetection(col,0xA001); // instantiate service |
hux | 23:677689000369 | 12 | // |
hux | 23:677689000369 | 13 | // onSetup(Blob &blue) |
hux | 23:677689000369 | 14 | // { |
hux | 23:677689000369 | 15 | // blue.service(presenceDetection); // use service |
hux | 23:677689000369 | 16 | // } |
hux | 23:677689000369 | 17 | // |
hux | 23:677689000369 | 18 | // Example 2: service definition by means of a service definition class |
hux | 23:677689000369 | 19 | // |
hux | 23:677689000369 | 20 | // class PresenceDetector |
hux | 23:677689000369 | 21 | // { |
hux | 23:677689000369 | 22 | // public: |
hux | 23:677689000369 | 23 | // Collection col; // collection used during setup |
hux | 23:677689000369 | 24 | // |
hux | 23:677689000369 | 25 | // Characteristic<ObjectId> id; // ID of presence detector |
hux | 23:677689000369 | 26 | // Characteristic<ObjectName> name; // name of presence detector |
hux | 23:677689000369 | 27 | // Characteristic<Digital> presence; // digital presence value |
hux | 23:677689000369 | 28 | // Characteristic<DateTime> timestamp; // last detection change's time |
hux | 23:677689000369 | 29 | // Characteristic<ObjectName> layout; // name of model railway layout |
hux | 23:677689000369 | 30 | // |
hux | 23:677689000369 | 31 | // Service presenceDetection; // the service |
hux | 23:677689000369 | 32 | // |
hux | 23:677689000369 | 33 | // public: |
hux | 23:677689000369 | 34 | // PresenceDetector(Blob &blue, cost UUID uuid) : |
hux | 23:677689000369 | 35 | // list; // init service list |
hux | 23:677689000369 | 36 | // id(list,0x2AC3,"rw","ID"), // instantiate characteristic |
hux | 23:677689000369 | 37 | // name(list,0x2ABE,"rw","Name"), // instantiate characteristic |
hux | 23:677689000369 | 38 | // presence(list,0x2A56,"r","Presence"),// instantiate characteristic |
hux | 23:677689000369 | 39 | // timestamp(list,0x2A08,"r","Timestamp"),// instantiate characteristic |
hux | 23:677689000369 | 40 | // layout(list,0x2ABE,"rw","Layout"), // instantiate characteristic |
hux | 23:677689000369 | 41 | // presenceDetection(list,uuid) // instantiate service |
hux | 23:677689000369 | 42 | // { |
hux | 23:677689000369 | 43 | // Blob blue; |
hux | 23:677689000369 | 44 | // blue.service(presenceDetection); // use service |
hux | 23:677689000369 | 45 | // } |
hux | 23:677689000369 | 46 | // }; |
hux | 23:677689000369 | 47 | // |
hux | 23:677689000369 | 48 | #ifndef _SERVICE_H_ |
hux | 23:677689000369 | 49 | #define _SERVICE_H_ |
hux | 23:677689000369 | 50 | |
hux | 23:677689000369 | 51 | #include "ble/BLE.h" |
hux | 23:677689000369 | 52 | #include "ble/Gap.h" |
hux | 23:677689000369 | 53 | #include "bricks/collection.h" |
hux | 23:677689000369 | 54 | |
hux | 23:677689000369 | 55 | class Service : public GattService |
hux | 23:677689000369 | 56 | { |
hux | 23:677689000369 | 57 | public: |
hux | 23:677689000369 | 58 | Service(Collection &list, UUID uuid) : |
hux | 23:677689000369 | 59 | GattService(uuid, list.plist, list.count) |
hux | 23:677689000369 | 60 | { |
hux | 23:677689000369 | 61 | // empty |
hux | 23:677689000369 | 62 | } |
hux | 23:677689000369 | 63 | }; |
hux | 23:677689000369 | 64 | |
hux | 23:677689000369 | 65 | #endif // _SERVICE_H_ |