@@ -96,7 +96,7 @@ NimBLEScan::NimBLEScan() {
96
96
NimBLEAddress advertisedAddress (event->disc .addr );
97
97
98
98
// Print advertisement data
99
- print_adv_fields (&fields);
99
+ // print_adv_fields(&fields);
100
100
101
101
// If we are not scanning, nothing to do with the extra results.
102
102
if (pScan->m_stopped ) {
@@ -128,20 +128,27 @@ NimBLEScan::NimBLEScan() {
128
128
NIMBLE_LOGI (LOG_TAG, " UPDATING PREVIOUSLY FOUND DEVICE: %s" , advertisedAddress.toString ().c_str ());
129
129
}
130
130
advertisedDevice->setRSSI (event->disc .rssi );
131
+ // NIMBLE_LOGI(LOG_TAG, "advertisement type: %d, %s",advType, NimBLEUtils::advTypeToString(event->disc.event_type));
131
132
advertisedDevice->setAdvType (event->disc .event_type );
132
133
advertisedDevice->parseAdvertisement (&fields);
133
134
advertisedDevice->setScan (pScan);
134
135
advertisedDevice->setAdvertisementResult (event->disc .data , event->disc .length_data );
135
136
136
137
if (pScan->m_pAdvertisedDeviceCallbacks ) {
137
- pScan->m_pAdvertisedDeviceCallbacks ->onResult (advertisedDevice);
138
+ // If not active scanning report the result to the listener.
139
+ if (pScan->m_scan_params .passive ) {
140
+ pScan->m_pAdvertisedDeviceCallbacks ->onResult (advertisedDevice);
141
+ // Otherwise wait for the scan response so we can report all of the data at once.
142
+ } else if (event->disc .event_type == BLE_HCI_ADV_RPT_EVTYPE_SCAN_RSP) {
143
+ pScan->m_pAdvertisedDeviceCallbacks ->onResult (advertisedDevice);
144
+ }
138
145
// m_pAdvertisedDeviceCallbacks->onResult(*advertisedDevice);
139
146
}
140
147
141
148
return 0 ;
142
149
}
143
150
case BLE_GAP_EVENT_DISC_COMPLETE: {
144
- NIMBLE_LOGI (LOG_TAG, " discovery complete; reason=%d\n " ,
151
+ NIMBLE_LOGD (LOG_TAG, " discovery complete; reason=%d" ,
145
152
event->disc_complete .reason );
146
153
147
154
pScan->m_stopped = true ;
0 commit comments