@@ -69,22 +69,23 @@ BLEService* BLEServer::createService(const char* uuid) {
69
69
* of a new service. Every service must have a unique UUID.
70
70
* @param [in] uuid The UUID of the new service.
71
71
* @param [in] numHandles The maximum number of handles associated with this service.
72
+ * @param [in] inst_id With multiple services with the same UUID we need to provide inst_id value different for each service.
72
73
* @return A reference to the new service object.
73
74
*/
74
- BLEService* BLEServer::createService (BLEUUID uuid, uint32_t numHandles) {
75
+ BLEService* BLEServer::createService (BLEUUID uuid, uint32_t numHandles, uint8_t inst_id ) {
75
76
ESP_LOGD (LOG_TAG, " >> createService - %s" , uuid.toString ().c_str ());
76
77
m_semaphoreCreateEvt.take (" createService" );
77
78
78
- BLEService* pService = new BLEService (uuid, numHandles);
79
79
// Check that a service with the supplied UUID does not already exist.
80
80
if (m_serviceMap.getByUUID (uuid) != nullptr ) {
81
81
ESP_LOGW (LOG_TAG, " << Attempt to create a new service with uuid %s but a service with that UUID already exists." ,
82
82
uuid.toString ().c_str ());
83
83
// m_semaphoreCreateEvt.give();
84
84
// return nullptr;
85
- pService->m_id = 1 ;
86
85
}
87
86
87
+ BLEService* pService = new BLEService (uuid, numHandles);
88
+ pService->m_id = inst_id;
88
89
m_serviceMap.setByUUID (uuid, pService); // Save a reference to this service being on this server.
89
90
pService->executeCreate (this ); // Perform the API calls to actually create the service.
90
91
0 commit comments