@@ -527,13 +527,13 @@ bool BLEService::start() {
527527 // Nimble requires an array of services to be sent to the api
528528 // Since we are adding 1 at a time we create an array of 2 and set the type
529529 // of the second service to 0 to indicate the end of the array.
530- ble_gatt_svc_def *svc = new ble_gatt_svc_def[2 ];
530+ ble_gatt_svc_def *svc = new ble_gatt_svc_def[2 ]{} ;
531531 ble_gatt_chr_def *pChr_a = nullptr ;
532532 ble_gatt_dsc_def *pDsc_a = nullptr ;
533533
534534 svc[0 ].type = BLE_GATT_SVC_TYPE_PRIMARY;
535- svc[0 ].uuid = & m_uuid.getNative ()->u ;
536- svc[0 ].includes = NULL ;
535+ svc[0 ].uuid = ( const ble_uuid_t *) &( m_uuid.getNative ()->u ) ;
536+ svc[0 ].includes = nullptr ;
537537
538538 int removedCount = 0 ;
539539 BLECharacteristic *pCharacteristic;
@@ -558,12 +558,12 @@ bool BLEService::start() {
558558 log_d (" Adding %d characteristics for service %s" , numChrs, toString ().c_str ());
559559
560560 if (!numChrs) {
561- svc[0 ].characteristics = NULL ;
561+ svc[0 ].characteristics = nullptr ;
562562 } else {
563563 // Nimble requires the last characteristic to have it's uuid = 0 to indicate the end
564564 // of the characteristics for the service. We create 1 extra and set it to null
565565 // for this purpose.
566- pChr_a = new ble_gatt_chr_def[numChrs + 1 ];
566+ pChr_a = new ble_gatt_chr_def[numChrs + 1 ]{} ;
567567 uint8_t i = 0 ;
568568 pCharacteristic = m_characteristicMap.getFirst ();
569569 while (pCharacteristic != nullptr ) {
@@ -585,17 +585,18 @@ bool BLEService::start() {
585585 }
586586
587587 size_t numDscs = pCharacteristic->m_descriptorMap .getRegisteredDescriptorCount () - removedCount;
588+ log_d (" Adding %d descriptors for characteristic %s" , numDscs, pCharacteristic->getUUID ().toString ().c_str ());
588589
589590 if (!numDscs) {
590- pChr_a[i].descriptors = NULL ;
591+ pChr_a[i].descriptors = nullptr ;
591592 } else {
592593 // Must have last descriptor uuid = 0 so we have to create 1 extra
593- pDsc_a = new ble_gatt_dsc_def[numDscs + 1 ];
594+ pDsc_a = new ble_gatt_dsc_def[numDscs + 1 ]{} ;
594595 uint8_t d = 0 ;
595596 pDescriptor = pCharacteristic->m_descriptorMap .getFirst ();
596597 while (pDescriptor != nullptr ) {
597598 if (pDescriptor->m_removed <= 0 ) {
598- pDsc_a[d].uuid = & pDescriptor->m_bleUUID .getNative ()->u ;
599+ pDsc_a[d].uuid = ( const ble_uuid_t *) &( pDescriptor->m_bleUUID .getNative ()->u ) ;
599600 pDsc_a[d].att_flags = pDescriptor->m_permissions ;
600601 pDsc_a[d].min_key_size = 0 ;
601602 pDsc_a[d].access_cb = BLEDescriptor::handleGATTServerEvent;
@@ -605,11 +606,11 @@ bool BLEService::start() {
605606 pDescriptor = pCharacteristic->m_descriptorMap .getNext ();
606607 }
607608
608- pDsc_a[numDscs].uuid = NULL ;
609+ pDsc_a[numDscs].uuid = nullptr ;
609610 pChr_a[i].descriptors = pDsc_a;
610611 }
611612
612- pChr_a[i].uuid = & pCharacteristic->m_bleUUID .getNative ()->u ;
613+ pChr_a[i].uuid = ( const ble_uuid_t *) &( pCharacteristic->m_bleUUID .getNative ()->u ) ;
613614 pChr_a[i].access_cb = BLECharacteristic::handleGATTServerEvent;
614615 pChr_a[i].arg = pCharacteristic;
615616 pChr_a[i].flags = pCharacteristic->m_properties ;
@@ -621,7 +622,7 @@ bool BLEService::start() {
621622 pCharacteristic = m_characteristicMap.getNext ();
622623 }
623624
624- pChr_a[numChrs].uuid = NULL ;
625+ pChr_a[numChrs].uuid = nullptr ;
625626 svc[0 ].characteristics = pChr_a;
626627 }
627628
0 commit comments