mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
* BIG refactor: 'board' and 'radio' objects now defined in 'target.h/.cpp'
* mesh::RTCClock class moved to MeshCore.h
This commit is contained in:
parent
0a5a115875
commit
bfb4b1c496
48 changed files with 726 additions and 407 deletions
28
src/Mesh.h
28
src/Mesh.h
|
|
@ -4,34 +4,6 @@
|
|||
|
||||
namespace mesh {
|
||||
|
||||
/**
|
||||
* An abstraction of the device's Realtime Clock.
|
||||
*/
|
||||
class RTCClock {
|
||||
uint32_t last_unique;
|
||||
protected:
|
||||
RTCClock() { last_unique = 0; }
|
||||
|
||||
public:
|
||||
/**
|
||||
* \returns the current time. in UNIX epoch seconds.
|
||||
*/
|
||||
virtual uint32_t getCurrentTime() = 0;
|
||||
|
||||
/**
|
||||
* \param time current time in UNIX epoch seconds.
|
||||
*/
|
||||
virtual void setCurrentTime(uint32_t time) = 0;
|
||||
|
||||
uint32_t getCurrentTimeUnique() {
|
||||
uint32_t t = getCurrentTime();
|
||||
if (t <= last_unique) {
|
||||
return ++last_unique;
|
||||
}
|
||||
return last_unique = t;
|
||||
}
|
||||
};
|
||||
|
||||
class GroupChannel {
|
||||
public:
|
||||
uint8_t hash[PATH_HASH_SIZE];
|
||||
|
|
|
|||
|
|
@ -45,4 +45,32 @@ public:
|
|||
virtual bool startOTAUpdate() { return false; } // not supported
|
||||
};
|
||||
|
||||
/**
|
||||
* An abstraction of the device's Realtime Clock.
|
||||
*/
|
||||
class RTCClock {
|
||||
uint32_t last_unique;
|
||||
protected:
|
||||
RTCClock() { last_unique = 0; }
|
||||
|
||||
public:
|
||||
/**
|
||||
* \returns the current time. in UNIX epoch seconds.
|
||||
*/
|
||||
virtual uint32_t getCurrentTime() = 0;
|
||||
|
||||
/**
|
||||
* \param time current time in UNIX epoch seconds.
|
||||
*/
|
||||
virtual void setCurrentTime(uint32_t time) = 0;
|
||||
|
||||
uint32_t getCurrentTimeUnique() {
|
||||
uint32_t t = getCurrentTime();
|
||||
if (t <= last_unique) {
|
||||
return ++last_unique;
|
||||
}
|
||||
return last_unique = t;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include <rom/rtc.h>
|
||||
#include <sys/time.h>
|
||||
#include <Wire.h>
|
||||
|
||||
class ESP32Board : public mesh::MainBoard {
|
||||
protected:
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
static BLEDfu bledfu;
|
||||
|
||||
void faketecBoard::begin() {
|
||||
void FaketecBoard::begin() {
|
||||
// for future use, sub-classes SHOULD call this from their begin()
|
||||
startup_reason = BD_STARTUP_NORMAL;
|
||||
btn_prev_state = HIGH;
|
||||
|
|
@ -39,7 +39,7 @@ static void disconnect_callback(uint16_t conn_handle, uint8_t reason) {
|
|||
MESH_DEBUG_PRINTLN("BLE client disconnected");
|
||||
}
|
||||
|
||||
bool faketecBoard::startOTAUpdate() {
|
||||
bool FaketecBoard::startOTAUpdate() {
|
||||
// Config the peripheral connection with maximum bandwidth
|
||||
// more SRAM required by SoftDevice
|
||||
// Note: All config***() function must be called before begin()
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
#define PIN_VBAT_READ 17
|
||||
#define ADC_MULTIPLIER (1.815f) // dependent on voltage divider resistors. TODO: more accurate battery tracking
|
||||
|
||||
class faketecBoard : public mesh::MainBoard {
|
||||
class FaketecBoard : public mesh::MainBoard {
|
||||
protected:
|
||||
uint8_t startup_reason;
|
||||
uint8_t btn_prev_state;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue