Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BLE_API X_NUCLEO_6180XA1 X_NUCLEO_IDB0XA1 mbed
Fork of BLE_HeartRate_IDB0XA1 by
enroll.h
00001 // enroll.h - enroll a service 00002 // 00003 // Synopsis: 00004 // 00005 // void enroll(Blob &o, GattService &gservice); 00006 // void enroll(Blob &o, uint16_t bcid = 0xFFFF); 00007 // 00008 // void enroll(Blob &o, Service &service, uint16_t bcid = 0xFFFF); 00009 // 00010 // Arguments: 00011 // 00012 // o: Blob object (to avoid name clashes) 00013 // gservice: The GattService to be enrolled 00014 // service: The Service to be enrolled 00015 // bcid: Broadcast ID (optional); if not provided the default value 00016 // 0xFFFF will be used 00017 // 00018 // Description 00019 // 00020 // There are three ways to call enrollment. 00021 // 00022 // In the first case the service has been setup via a GattService class. 00023 // The service is enrolled by registering the service @ GAP. On advertising 00024 // the provided broadcast ID is used (otherwise default ID 0xFFFF). 00025 // 00026 // The second case is based on a Service class object which has been setup 00027 // by having added a set of characteristics to the internal collection. Upon 00028 // enrollment a GattService instance will be created internally and enroll- 00029 // ment of this GattService will be performed according to the first case. 00030 // 00031 // The third way is to enroll only the service id. This calling syntax is 00032 // used, if a Gatt servive is pre-enrolled without enrolling the service ID. 00033 // 00034 // Example 1: enrollment of GattService 00035 // 00036 // enroll(o,gservice); 00037 // enroll(o,0xFFFF); 00038 // 00039 // See also: SERVICE 00040 // 00041 #ifndef _ENROLL_H_ 00042 #define _ENROLL_H_ 00043 00044 #include "bricks/blob.h" 00045 #include "bricks/service.h" 00046 00047 00048 inline void enroll(Blob &o, uint16_t bcid = 0xFFFF) 00049 { 00050 static uint16_t list[1]; 00051 00052 // Custom UUID, FFFF is reserved for development 00053 // Used for UUID's broadcast in advertising packet 00054 00055 list[0] = bcid; // set broadcast ID 00056 00057 // o.pble->gap().accumulateAdvertisingPayload( 00058 o.gap().accumulateAdvertisingPayload( 00059 GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, 00060 (uint8_t *)list, sizeof(list)); 00061 } 00062 00063 00064 inline void enroll(Blob &o, GattService &gservice, uint16_t bcid = 0xFFFF) 00065 { 00066 // o.pble->addService(gservice); // add service to GATT attributes 00067 o.addService(gservice); // add service to GATT attributes 00068 enroll(o,bcid); // enroll GattService (without BCID) 00069 } 00070 00071 00072 inline void enroll(Blob &o, Service &service, uint16_t bcid = 0) 00073 { 00074 Collection &collection = service.collection; 00075 GattService gservice(service.uuid, collection.plist, collection.count); 00076 00077 if (bcid == 0) 00078 bcid = service.uuid; 00079 00080 enroll(o,gservice,bcid); // enroll GattService (with BCID) 00081 } 00082 00083 #endif // _ENROLL_H_
Generated on Sat Jul 16 2022 07:45:39 by
1.7.2
