WIP stubify to get app building without CONFIG_BLUEDROID (BLE disabled)

This commit is contained in:
geeksville
2020-07-21 11:16:14 -07:00
parent 1e86365167
commit 6aa28f55dd
9 changed files with 70 additions and 35 deletions

View File

@@ -1,6 +1,5 @@
#include "BluetoothSoftwareUpdate.h"
#include "BluetoothUtil.h"
#include "CallbackCharacteristic.h"
#include "RadioLibInterface.h"
#include "configuration.h"
#include "../concurrency/LockGuard.h"
@@ -11,7 +10,9 @@
#include <Update.h>
#include <esp_gatt_defs.h>
//using namespace meshtastic;
#ifdef CONFIG_BLUEDROID_ENABLED
#include "CallbackCharacteristic.h"
CRC32 crc;
uint32_t rebootAtMsec = 0; // If not zero we will reboot at this time (used to reboot shortly after the update completes)
@@ -176,4 +177,6 @@ void destroyUpdateService()
assert(resultC);
resultC = NULL;
}
}
#endif

View File

@@ -5,7 +5,11 @@
#include <BLEServer.h>
#include <BLEUtils.h>
#ifdef CONFIG_BLUEDROID_ENABLED
BLEService *createUpdateService(BLEServer *server, std::string hwVendor, std::string swVersion, std::string hwVersion);
void destroyUpdateService();
void bluetoothRebootCheck();
void bluetoothRebootCheck();
#endif

View File

@@ -6,6 +6,8 @@
#include <Update.h>
#include <esp_gatt_defs.h>
#ifdef CONFIG_BLUEDROID_ENABLED
SimpleAllocator btPool;
bool _BLEClientConnected = false;
@@ -321,3 +323,12 @@ void loopBLE()
{
bluetoothRebootCheck();
}
#else
/// Given a level between 0-100, update the BLE attribute
void updateBatteryLevel(uint8_t level) {}
void deinitBLE() {}
void loopBLE() {}
#endif

View File

@@ -8,8 +8,7 @@
#include <BLEUtils.h>
#include "SimpleAllocator.h"
// Now handled by BluetoothUtil.cpp
// BLEService *createDeviceInfomationService(BLEServer* server, uint8_t sig, uint16_t vid, uint16_t pid, uint16_t version);
#ifdef CONFIG_BLUEDROID_ENABLED
// Help routine to add a description to any BLECharacteristic and add it to the service
void addWithDesc(BLEService *service, BLECharacteristic *c, const char *description);
@@ -23,11 +22,9 @@ uint32_t getValue32(BLECharacteristic *c, uint32_t defaultValue);
using StartBluetoothPinScreenCallback = std::function<void(uint32_t pass_key)>;
using StopBluetoothPinScreenCallback = std::function<void(void)>;
void loopBLE();
BLEServer *initBLE(
StartBluetoothPinScreenCallback startBtPinScreen, StopBluetoothPinScreenCallback stopBtPinScreen,
std::string devName, std::string hwVendor, std::string swVersion, std::string hwVersion = "");
void deinitBLE();
/// Add a characteristic that we will delete when we restart
BLECharacteristic *addBLECharacteristic(BLECharacteristic *c);
@@ -35,8 +32,12 @@ BLECharacteristic *addBLECharacteristic(BLECharacteristic *c);
/// Add a characteristic that we will delete when we restart
BLEDescriptor *addBLEDescriptor(BLEDescriptor *c);
/// Given a level between 0-100, update the BLE attribute
void updateBatteryLevel(uint8_t level);
/// Any bluetooth objects you allocate _must_ come from this pool if you want to be able to call deinitBLE()
extern SimpleAllocator btPool;
#endif
/// Given a level between 0-100, update the BLE attribute
void updateBatteryLevel(uint8_t level);
void deinitBLE();
void loopBLE();

View File

@@ -1,11 +1,7 @@
#include "MeshBluetoothService.h"
#include "BluetoothUtil.h"
#include <Arduino.h>
#include <BLE2902.h>
#include <assert.h>
#include <esp_gatt_defs.h>
#include "CallbackCharacteristic.h"
#include <Arduino.h>
#include <assert.h>
#include "GPS.h"
#include "MeshService.h"
#include "NodeDB.h"
@@ -15,6 +11,14 @@
#include "mesh-pb-constants.h"
#include "mesh.pb.h"
#ifdef CONFIG_BLUEDROID_ENABLED
#include <BLE2902.h>
#include <esp_gatt_defs.h>
#include "CallbackCharacteristic.h"
#include "BluetoothUtil.h"
#include "MeshBluetoothService.h"
// This scratch buffer is used for various bluetooth reads/writes - but it is safe because only one bt operation can be in
// proccess at once
static uint8_t trBytes[_max(_max(_max(_max(ToRadio_size, RadioConfig_size), User_size), MyNodeInfo_size), FromRadio_size)];
@@ -141,3 +145,10 @@ void destroyMeshBluetoothService()
meshFromNumCharacteristic = NULL;
}
#else
void destroyMeshBluetoothService() {}
void stopMeshBluetoothService() {}
#endif

View File

@@ -4,12 +4,11 @@
#include <BLEServer.h>
#include <BLEService.h>
#ifdef CONFIG_BLUEDROID_ENABLED
BLEService *createMeshBluetoothService(BLEServer *server);
#endif
void destroyMeshBluetoothService();
/**
* Tell any bluetooth clients that the number of rx packets has changed
*/
void bluetoothNotifyFromNum(uint32_t newValue);
void stopMeshBluetoothService();

View File

@@ -17,9 +17,7 @@ void reinitBluetooth()
{
DEBUG_MSG("Starting bluetooth\n");
// FIXME - we are leaking like crazy
// AllocatorScope scope(btPool);
#ifdef CONFIG_BLUEDROID_ENABLED
// Note: these callbacks might be coming in from a different thread.
BLEServer *serve = initBLE(
[](uint32_t pin) {
@@ -32,6 +30,7 @@ void reinitBluetooth()
// Start advertising - this must be done _after_ creating all services
serve->getAdvertising()->start();
#endif
}
// Enable/disable bluetooth.