mirror of
https://github.com/meshtastic/firmware.git
synced 2025-09-22 17:34:25 +00:00
Fix BLE
This commit is contained in:
parent
bfef356c9b
commit
2cb063a1cf
@ -22,7 +22,7 @@ class BluetoothPhoneAPI : public PhoneAPI
|
|||||||
/**
|
/**
|
||||||
* Subclasses can use this as a hook to provide custom notifications for their transport (i.e. bluetooth notifies)
|
* Subclasses can use this as a hook to provide custom notifications for their transport (i.e. bluetooth notifies)
|
||||||
*/
|
*/
|
||||||
virtual void onNowHasData(uint32_t fromRadioNum)
|
void onNowHasData(uint32_t fromRadioNum) override
|
||||||
{
|
{
|
||||||
PhoneAPI::onNowHasData(fromRadioNum);
|
PhoneAPI::onNowHasData(fromRadioNum);
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ class BluetoothPhoneAPI : public PhoneAPI
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Check the current underlying physical link to see if the client is currently connected
|
/// Check the current underlying physical link to see if the client is currently connected
|
||||||
virtual bool checkIsConnected() { return bleServer && bleServer->getConnectedCount() > 0; }
|
bool checkIsConnected() override { return bleServer && bleServer->getConnectedCount() > 0; }
|
||||||
};
|
};
|
||||||
|
|
||||||
static BluetoothPhoneAPI *bluetoothPhoneAPI;
|
static BluetoothPhoneAPI *bluetoothPhoneAPI;
|
||||||
@ -79,7 +79,7 @@ class NimbleBluetoothFromRadioCallback : public NimBLECharacteristicCallbacks
|
|||||||
|
|
||||||
class NimbleBluetoothServerCallback : public NimBLEServerCallbacks
|
class NimbleBluetoothServerCallback : public NimBLEServerCallbacks
|
||||||
{
|
{
|
||||||
virtual uint32_t onPassKeyRequest()
|
uint32_t onPassKeyDisplay() override
|
||||||
{
|
{
|
||||||
uint32_t passkey = config.bluetooth.fixed_pin;
|
uint32_t passkey = config.bluetooth.fixed_pin;
|
||||||
|
|
||||||
@ -148,6 +148,8 @@ class NimbleBluetoothServerCallback : public NimBLEServerCallbacks
|
|||||||
if (bluetoothPhoneAPI) {
|
if (bluetoothPhoneAPI) {
|
||||||
bluetoothPhoneAPI->close();
|
bluetoothPhoneAPI->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NimBLEDevice::startAdvertising();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -259,7 +261,7 @@ void NimbleBluetooth::setupService()
|
|||||||
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, 1);
|
(uint16_t)0x2a19, NIMBLE_PROPERTY::READ | NIMBLE_PROPERTY::NOTIFY, 1);
|
||||||
|
|
||||||
NimBLE2904 *batteryLevelDescriptor = (NimBLE2904 *)BatteryCharacteristic->createDescriptor((uint16_t)0x2904);
|
NimBLE2904 *batteryLevelDescriptor = BatteryCharacteristic->create2904();
|
||||||
batteryLevelDescriptor->setFormat(NimBLE2904::FORMAT_UINT8);
|
batteryLevelDescriptor->setFormat(NimBLE2904::FORMAT_UINT8);
|
||||||
batteryLevelDescriptor->setNamespace(1);
|
batteryLevelDescriptor->setNamespace(1);
|
||||||
batteryLevelDescriptor->setUnit(0x27ad);
|
batteryLevelDescriptor->setUnit(0x27ad);
|
||||||
@ -273,7 +275,7 @@ void NimbleBluetooth::startAdvertising()
|
|||||||
pAdvertising->reset();
|
pAdvertising->reset();
|
||||||
pAdvertising->addServiceUUID(MESH_SERVICE_UUID);
|
pAdvertising->addServiceUUID(MESH_SERVICE_UUID);
|
||||||
pAdvertising->addServiceUUID(NimBLEUUID((uint16_t)0x180f)); // 0x180F is the Battery Service
|
pAdvertising->addServiceUUID(NimBLEUUID((uint16_t)0x180f)); // 0x180F is the Battery Service
|
||||||
pAdvertising->start(0);
|
pAdvertising->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Given a level between 0-100, update the BLE attribute
|
/// Given a level between 0-100, update the BLE attribute
|
||||||
|
Loading…
Reference in New Issue
Block a user