don't recreate callback at each scan to avoid memory consumption

#173
This commit is contained in:
1technophile committed 2018-02-17 08:28:19 +01:00
1 parent f9ddb05c65
commit f9f04494fa
1 file changed
+5 -4
+5 -4
View File
@@ -103,7 +103,7 @@ Thanks to wolass https://github.com/wolass for suggesting me HM 10 and dinosd ht
mac_adress.toCharArray(mac,mac_adress.length()+1);
boolean result = process_miflora_data(-22,service_data,mac);
}
}
}
}
};
@@ -117,7 +117,8 @@ Thanks to wolass https://github.com/wolass for suggesting me HM 10 and dinosd ht
1, /* Priority of the task */
NULL, /* Task handle. */
taskCore); /* Core where the task should run */
trc(F("ZgatewayBT ESP32 setup done "));
trc(F("ZgatewayBT ESP32 setup done "));
BLEDevice::init("");
}
void coreTask( void * pvParameters ){
@@ -128,9 +129,9 @@ Thanks to wolass https://github.com/wolass for suggesting me HM 10 and dinosd ht
while(true){
trc(taskMessage);
delay(TimeBtw_Read);
BLEDevice::init("");
BLEScan* pBLEScan = BLEDevice::getScan(); //create new scan
pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
MyAdvertisedDeviceCallbacks myCallbacks;
pBLEScan->setAdvertisedDeviceCallbacks(&myCallbacks);
pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster
BLEScanResults foundDevices = pBLEScan->start(Scan_duration);
}