mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-23 19:20:41 +00:00
Connection status admin message
This commit is contained in:
@@ -93,7 +93,6 @@ class NimbleBluetoothServerCallback : public NimBLEServerCallbacks
|
||||
passkeyShowing = false;
|
||||
screen->stopBluetoothPinScreen();
|
||||
}
|
||||
// bluetoothPhoneAPI->setInitialState();
|
||||
}
|
||||
|
||||
virtual void onDisconnect(NimBLEServer *pServer, ble_gap_conn_desc *desc) { LOG_INFO("BLE disconnect\n"); }
|
||||
@@ -117,6 +116,21 @@ bool NimbleBluetooth::isActive()
|
||||
return bleServer;
|
||||
}
|
||||
|
||||
bool NimbleBluetooth::isConnected()
|
||||
{
|
||||
return bleServer->getConnectedCount() > 0;
|
||||
}
|
||||
|
||||
int NimbleBluetooth::getRssi()
|
||||
{
|
||||
if (bleServer && isConnected()) {
|
||||
auto service = bleServer->getServiceByUUID(MESH_SERVICE_UUID);
|
||||
uint16_t handle = service->getHandle();
|
||||
return NimBLEDevice::getClientByID(handle)->getRssi();
|
||||
}
|
||||
return 0; // FIXME figure out where to source this
|
||||
}
|
||||
|
||||
void NimbleBluetooth::setup()
|
||||
{
|
||||
// Uncomment for testing
|
||||
@@ -135,7 +149,6 @@ void NimbleBluetooth::setup()
|
||||
|
||||
NimbleBluetoothServerCallback *serverCallbacks = new NimbleBluetoothServerCallback();
|
||||
bleServer->setCallbacks(serverCallbacks, true);
|
||||
|
||||
setupService();
|
||||
startAdvertising();
|
||||
}
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
#pragma once
|
||||
#include "BluetoothCommon.h"
|
||||
|
||||
class NimbleBluetooth
|
||||
class NimbleBluetooth : BluetoothApi
|
||||
{
|
||||
public:
|
||||
void setup();
|
||||
void shutdown();
|
||||
void clearBonds();
|
||||
bool isActive();
|
||||
bool isConnected();
|
||||
int getRssi();
|
||||
|
||||
private:
|
||||
void setupService();
|
||||
|
||||
Reference in New Issue
Block a user