mirror of https://github.com/ARMmbed/mbed-os.git
add default services first
parent
0066ba9b0d
commit
20d6cd9cc5
|
@ -185,6 +185,8 @@ public:
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void add_default_services();
|
||||||
|
|
||||||
static uint16_t compute_attributes_count(GattService& service);
|
static uint16_t compute_attributes_count(GattService& service);
|
||||||
|
|
||||||
void insert_service_attribute(
|
void insert_service_attribute(
|
||||||
|
@ -280,6 +282,8 @@ private:
|
||||||
|
|
||||||
uint16_t currentHandle;
|
uint16_t currentHandle;
|
||||||
|
|
||||||
|
bool default_services_added;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GattServer();
|
GattServer();
|
||||||
|
|
||||||
|
|
|
@ -71,12 +71,21 @@ void GattServer::initialize()
|
||||||
#if BLE_FEATURE_SECURITY
|
#if BLE_FEATURE_SECURITY
|
||||||
AttsAuthorRegister(atts_auth_cb);
|
AttsAuthorRegister(atts_auth_cb);
|
||||||
#endif
|
#endif
|
||||||
add_generic_access_service();
|
add_default_services();
|
||||||
add_generic_attribute_service();
|
}
|
||||||
|
|
||||||
|
void GattServer::add_default_services()
|
||||||
|
{
|
||||||
|
if (!default_services_added) {
|
||||||
|
default_services_added = true;
|
||||||
|
add_generic_access_service();
|
||||||
|
add_generic_attribute_service();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ble_error_t GattServer::addService_(GattService &service)
|
ble_error_t GattServer::addService_(GattService &service)
|
||||||
{
|
{
|
||||||
|
add_default_services();
|
||||||
// create and fill the service structure
|
// create and fill the service structure
|
||||||
internal_service_t *att_service = new internal_service_t;
|
internal_service_t *att_service = new internal_service_t;
|
||||||
att_service->attGroup.pNext = NULL;
|
att_service->attGroup.pNext = NULL;
|
||||||
|
@ -1344,7 +1353,8 @@ GattServer::GattServer() :
|
||||||
generic_attribute_service(),
|
generic_attribute_service(),
|
||||||
registered_service(NULL),
|
registered_service(NULL),
|
||||||
allocated_blocks(NULL),
|
allocated_blocks(NULL),
|
||||||
currentHandle(0)
|
currentHandle(0),
|
||||||
|
default_services_added(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue