File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,22 +38,23 @@ NimBLE2905::NimBLE2905(NimBLECharacteristic* pChr)
3838} // NimBLE2905
3939
4040void NimBLE2905::initValue () {
41- const size_t count = m_vAggregatedDescriptors. size () ;
42- uint16_t aggregatedHandles[count] ;
41+ uint16_t aggregatedHandles[ NIMBLE_MAX_AGGREGATE_FORMAT_DESCRIPTORS ] ;
42+ size_t validCount = 0 ;
4343
44- for (size_t i = 0 ; i < count; ++i) {
45- auto * desc = m_vAggregatedDescriptors[i];
44+ for (auto * desc : m_vAggregatedDescriptors) {
4645 uint16_t handle = desc->getHandle ();
4746
4847 if (handle == 0 ) {
4948 NIMBLE_LOGE (LOG_TAG , " Failed to initialize value: presentation format descriptor handle is not initialized" );
50- return ;
49+ continue ;
5150 }
5251
53- aggregatedHandles[i ] = desc-> getHandle () ;
54- } // initValue
52+ aggregatedHandles[validCount++ ] = handle ;
53+ }
5554
56- setValue (reinterpret_cast <const uint8_t *>(aggregatedHandles), sizeof (aggregatedHandles));
55+ if (validCount > 0 ) {
56+ setValue (reinterpret_cast <const uint8_t *>(aggregatedHandles), validCount * sizeof (uint16_t ));
57+ }
5758
5859 // Presentation formats no longer needed, let's free some memory
5960 m_vAggregatedDescriptors.clear ();
You can’t perform that action at this time.
0 commit comments