mirror of
https://github.com/meshtastic/firmware.git
synced 2026-01-04 17:11:01 +00:00
NimBLE speedup (#8281)
* Remove status polling code in NimBLE * Goober --------- Co-authored-by: Jonathan Bennett <jbennett@incomsystems.biz>
This commit is contained in:
committed by
Jonathan Bennett
parent
91d928d4c5
commit
f99747180e
@@ -120,14 +120,19 @@ class NimbleBluetoothFromRadioCallback : public NimBLECharacteristicCallbacks
|
||||
virtual void onRead(NimBLECharacteristic *pCharacteristic)
|
||||
#endif
|
||||
{
|
||||
int tries = 0;
|
||||
bluetoothPhoneAPI->phoneWants = true;
|
||||
while (!bluetoothPhoneAPI->hasChecked && tries < 100) {
|
||||
bluetoothPhoneAPI->setIntervalFromNow(0);
|
||||
delay(20);
|
||||
tries++;
|
||||
}
|
||||
std::lock_guard<std::mutex> guard(bluetoothPhoneAPI->nimble_mutex);
|
||||
|
||||
// If we don't have fresh data, trigger a refresh
|
||||
if (!bluetoothPhoneAPI->hasChecked || bluetoothPhoneAPI->numBytes == 0) {
|
||||
bluetoothPhoneAPI->phoneWants = true;
|
||||
bluetoothPhoneAPI->setIntervalFromNow(0);
|
||||
|
||||
// Get fresh data immediately
|
||||
bluetoothPhoneAPI->numBytes = bluetoothPhoneAPI->getFromRadio(bluetoothPhoneAPI->fromRadioBytes);
|
||||
bluetoothPhoneAPI->hasChecked = true;
|
||||
}
|
||||
|
||||
// Set the characteristic value with whatever data we have
|
||||
pCharacteristic->setValue(bluetoothPhoneAPI->fromRadioBytes, bluetoothPhoneAPI->numBytes);
|
||||
|
||||
if (bluetoothPhoneAPI->numBytes != 0) // if we did send something, queue it up right away to reload
|
||||
|
||||
Reference in New Issue
Block a user