Skip to content

Commit f12c9e0

Browse files
committed
Reduce log spam while scanning.
Scanning now only invokes callback when scan response received if active scanning.
1 parent 0a035d4 commit f12c9e0

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/NimBLEScan.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ NimBLEScan::NimBLEScan() {
9696
NimBLEAddress advertisedAddress(event->disc.addr);
9797

9898
// Print advertisement data
99-
print_adv_fields(&fields);
99+
// print_adv_fields(&fields);
100100

101101
// If we are not scanning, nothing to do with the extra results.
102102
if (pScan->m_stopped) {
@@ -128,20 +128,27 @@ NimBLEScan::NimBLEScan() {
128128
NIMBLE_LOGI(LOG_TAG, "UPDATING PREVIOUSLY FOUND DEVICE: %s", advertisedAddress.toString().c_str());
129129
}
130130
advertisedDevice->setRSSI(event->disc.rssi);
131+
// NIMBLE_LOGI(LOG_TAG, "advertisement type: %d, %s",advType, NimBLEUtils::advTypeToString(event->disc.event_type));
131132
advertisedDevice->setAdvType(event->disc.event_type);
132133
advertisedDevice->parseAdvertisement(&fields);
133134
advertisedDevice->setScan(pScan);
134135
advertisedDevice->setAdvertisementResult(event->disc.data, event->disc.length_data);
135136

136137
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+
}
138145
//m_pAdvertisedDeviceCallbacks->onResult(*advertisedDevice);
139146
}
140147

141148
return 0;
142149
}
143150
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",
145152
event->disc_complete.reason);
146153

147154
pScan->m_stopped = true;

0 commit comments

Comments
 (0)