Update NRF52 build to work again

This commit is contained in:
geeksville
2020-07-09 19:57:55 -07:00
parent 62c9bad183
commit ed589727d6
13 changed files with 82 additions and 24 deletions

8
src/BluetoothCommon.h Normal file
View File

@@ -0,0 +1,8 @@
#pragma once
/**
* Common lib functions for all platforms that have bluetooth
*/
/// Given a level between 0-100, update the BLE attribute
void updateBatteryLevel(uint8_t level);

View File

@@ -1,7 +1,13 @@
#include "Thread.h"
#include "timing.h"
#include <assert.h>
namespace concurrency {
#ifdef ARDUINO_ARCH_ESP32
#include "esp_task_wdt.h"
#endif
namespace concurrency
{
void Thread::start(const char *name, size_t stackSize, uint32_t priority)
{
@@ -14,4 +20,27 @@ void Thread::callRun(void *_this)
((Thread *)_this)->doRun();
}
void Thread::serviceWatchdog()
{
#ifdef ARDUINO_ARCH_ESP32
esp_task_wdt_reset();
#endif
}
void Thread::startWatchdog()
{
#ifdef ARDUINO_ARCH_ESP32
auto r = esp_task_wdt_add(taskHandle);
assert(r == ESP_OK);
#endif
}
void Thread::stopWatchdog()
{
#ifdef ARDUINO_ARCH_ESP32
auto r = esp_task_wdt_delete(taskHandle);
assert(r == ESP_OK);
#endif
}
} // namespace concurrency

View File

@@ -1,7 +1,6 @@
#pragma once
#include "freertosinc.h"
#include "esp_task_wdt.h"
namespace concurrency {
@@ -36,17 +35,9 @@ class Thread
*
* this only applies after startWatchdog() has been called. If you need to sleep for a long time call stopWatchdog()
*/
void serviceWatchdog() { esp_task_wdt_reset(); }
void startWatchdog()
{
auto r = esp_task_wdt_add(taskHandle);
assert(r == ESP_OK);
}
void stopWatchdog()
{
auto r = esp_task_wdt_delete(taskHandle);
assert(r == ESP_OK);
}
void serviceWatchdog();
void startWatchdog();
void stopWatchdog();
private:
static void callRun(void *_this);

View File

@@ -62,6 +62,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// Standard definitions for NRF52 targets
//
// Nop definition for these attributes - not used on NRF52
#define EXT_RAM_ATTR
#define IRAM_ATTR
#define NO_ESP32 // Don't use ESP32 libs (mainly bluetooth)
// We bind to the GPS using variant.h instead for this platform (Serial1)

View File

@@ -35,8 +35,5 @@ 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;

View File

@@ -33,7 +33,7 @@
#include "power.h"
// #include "rom/rtc.h"
#include "DSRRouter.h"
#include "debug.h"
// #include "debug.h"
#include "graphics/Screen.h"
#include "main.h"
#include "sleep.h"

View File

@@ -5,14 +5,14 @@
#include "GPS.h"
//#include "MeshBluetoothService.h"
#include "../concurrency/Periodic.h"
#include "BluetoothCommon.h" // needed for updateBatteryLevel, FIXME, eventually when we pull mesh out into a lib we shouldn't be whacking bluetooth from here
#include "MeshService.h"
#include "NodeDB.h"
#include "../concurrency/Periodic.h"
#include "PowerFSM.h"
#include "main.h"
#include "mesh-pb-constants.h"
#include "power.h"
#include "BluetoothUtil.h" // needed for updateBatteryLevel, FIXME, eventually when we pull mesh out into a lib we shouldn't be whacking bluetooth from here
#include "timing.h"
/*
@@ -283,8 +283,6 @@ void MeshService::sendOurPosition(NodeNum dest, bool wantReplies)
sendToMesh(p);
}
int MeshService::onGPSChanged(void *unused)
{
// DEBUG_MSG("got gps notify\n");

View File

@@ -1,6 +1,7 @@
#include "NRF52Bluetooth.h"
#include "configuration.h"
#include "main.h"
#include "BluetoothCommon.h"
#include <bluefruit.h>
/* HRM Service Definitions
@@ -192,6 +193,11 @@ void NRF52Bluetooth::setup()
}
}
/// Given a level between 0-100, update the BLE attribute
void updateBatteryLevel(uint8_t level) {
// FIXME - implement
}
/*
void loop()
{