mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-24 01:16:55 +00:00
tryfix crash (#2964)
* tryfix crash * only use this when wifi is not enabled. (poking around) --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
This commit is contained in:
parent
4c69d06ac0
commit
1b6c11c5f1
@ -320,7 +320,9 @@ meshtastic_NodeInfoLite *MeshService::refreshLocalMeshNode()
|
|||||||
|
|
||||||
position.time = getValidTime(RTCQualityFromNet);
|
position.time = getValidTime(RTCQualityFromNet);
|
||||||
|
|
||||||
updateBatteryLevel(powerStatus->getBatteryChargePercent());
|
if (powerStatus->getHasBattery() == 1) {
|
||||||
|
updateBatteryLevel(powerStatus->getBatteryChargePercent());
|
||||||
|
}
|
||||||
|
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
@ -186,7 +186,7 @@ void NimbleBluetooth::setupService()
|
|||||||
// Setup the battery service
|
// Setup the battery service
|
||||||
NimBLEService *batteryService = bleServer->createService(NimBLEUUID((uint16_t)0x180f)); // 0x180F is the Battery Service
|
NimBLEService *batteryService = bleServer->createService(NimBLEUUID((uint16_t)0x180f)); // 0x180F is the Battery Service
|
||||||
BatteryCharacteristic = batteryService->createCharacteristic( // 0x2A19 is the Battery Level characteristic)
|
BatteryCharacteristic = batteryService->createCharacteristic( // 0x2A19 is the Battery Level characteristic)
|
||||||
(uint16_t)0x2a19, NIMBLE_PROPERTY::READ | NIMBLE_PROPERTY::NOTIFY);
|
(uint16_t)0x2a19, NIMBLE_PROPERTY::READ | NIMBLE_PROPERTY::NOTIFY, 1);
|
||||||
|
|
||||||
NimBLE2904 *batteryLevelDescriptor = (NimBLE2904 *)BatteryCharacteristic->createDescriptor((uint16_t)0x2904);
|
NimBLE2904 *batteryLevelDescriptor = (NimBLE2904 *)BatteryCharacteristic->createDescriptor((uint16_t)0x2904);
|
||||||
batteryLevelDescriptor->setFormat(NimBLE2904::FORMAT_UINT8);
|
batteryLevelDescriptor->setFormat(NimBLE2904::FORMAT_UINT8);
|
||||||
@ -208,8 +208,10 @@ void NimbleBluetooth::startAdvertising()
|
|||||||
/// Given a level between 0-100, update the BLE attribute
|
/// Given a level between 0-100, update the BLE attribute
|
||||||
void updateBatteryLevel(uint8_t level)
|
void updateBatteryLevel(uint8_t level)
|
||||||
{
|
{
|
||||||
BatteryCharacteristic->setValue(&level, 1);
|
if ((config.bluetooth.enabled == true) && bleServer && nimbleBluetooth->isConnected()) {
|
||||||
BatteryCharacteristic->notify();
|
BatteryCharacteristic->setValue(&level, 1);
|
||||||
|
BatteryCharacteristic->notify();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NimbleBluetooth::clearBonds()
|
void NimbleBluetooth::clearBonds()
|
||||||
|
Loading…
Reference in New Issue
Block a user