@@ -527,13 +527,13 @@ bool BLEService::start() {
527
527
// Nimble requires an array of services to be sent to the api
528
528
// Since we are adding 1 at a time we create an array of 2 and set the type
529
529
// 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 ]{} ;
531
531
ble_gatt_chr_def *pChr_a = nullptr ;
532
532
ble_gatt_dsc_def *pDsc_a = nullptr ;
533
533
534
534
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 ;
537
537
538
538
int removedCount = 0 ;
539
539
BLECharacteristic *pCharacteristic;
@@ -558,12 +558,12 @@ bool BLEService::start() {
558
558
log_d (" Adding %d characteristics for service %s" , numChrs, toString ().c_str ());
559
559
560
560
if (!numChrs) {
561
- svc[0 ].characteristics = NULL ;
561
+ svc[0 ].characteristics = nullptr ;
562
562
} else {
563
563
// Nimble requires the last characteristic to have it's uuid = 0 to indicate the end
564
564
// of the characteristics for the service. We create 1 extra and set it to null
565
565
// for this purpose.
566
- pChr_a = new ble_gatt_chr_def[numChrs + 1 ];
566
+ pChr_a = new ble_gatt_chr_def[numChrs + 1 ]{} ;
567
567
uint8_t i = 0 ;
568
568
pCharacteristic = m_characteristicMap.getFirst ();
569
569
while (pCharacteristic != nullptr ) {
@@ -585,17 +585,18 @@ bool BLEService::start() {
585
585
}
586
586
587
587
size_t numDscs = pCharacteristic->m_descriptorMap .getRegisteredDescriptorCount () - removedCount;
588
+ log_d (" Adding %d descriptors for characteristic %s" , numDscs, pCharacteristic->getUUID ().toString ().c_str ());
588
589
589
590
if (!numDscs) {
590
- pChr_a[i].descriptors = NULL ;
591
+ pChr_a[i].descriptors = nullptr ;
591
592
} else {
592
593
// 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 ]{} ;
594
595
uint8_t d = 0 ;
595
596
pDescriptor = pCharacteristic->m_descriptorMap .getFirst ();
596
597
while (pDescriptor != nullptr ) {
597
598
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 ) ;
599
600
pDsc_a[d].att_flags = pDescriptor->m_permissions ;
600
601
pDsc_a[d].min_key_size = 0 ;
601
602
pDsc_a[d].access_cb = BLEDescriptor::handleGATTServerEvent;
@@ -605,11 +606,11 @@ bool BLEService::start() {
605
606
pDescriptor = pCharacteristic->m_descriptorMap .getNext ();
606
607
}
607
608
608
- pDsc_a[numDscs].uuid = NULL ;
609
+ pDsc_a[numDscs].uuid = nullptr ;
609
610
pChr_a[i].descriptors = pDsc_a;
610
611
}
611
612
612
- pChr_a[i].uuid = & pCharacteristic->m_bleUUID .getNative ()->u ;
613
+ pChr_a[i].uuid = ( const ble_uuid_t *) &( pCharacteristic->m_bleUUID .getNative ()->u ) ;
613
614
pChr_a[i].access_cb = BLECharacteristic::handleGATTServerEvent;
614
615
pChr_a[i].arg = pCharacteristic;
615
616
pChr_a[i].flags = pCharacteristic->m_properties ;
@@ -621,7 +622,7 @@ bool BLEService::start() {
621
622
pCharacteristic = m_characteristicMap.getNext ();
622
623
}
623
624
624
- pChr_a[numChrs].uuid = NULL ;
625
+ pChr_a[numChrs].uuid = nullptr ;
625
626
svc[0 ].characteristics = pChr_a;
626
627
}
627
628
0 commit comments