Portduino WIP now compiles but does not link

This commit is contained in:
geeksville 2020-09-05 12:34:48 -07:00
parent 6a475d8288
commit fefd3d78f3
26 changed files with 41 additions and 67 deletions

View File

@ -248,7 +248,7 @@ lib_deps =
[env:linux]
platform = https://github.com/geeksville/platform-portduino.git
src_filter = ${env.src_filter} -<esp32/> -<nimble/>
build_flags = ${env.build_flags} -DRADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED
src_filter = ${env.src_filter} -<esp32/> -<nimble/> -<nrf52/>
build_flags = ${env.build_flags}
framework = arduino
board = linux_x86_64

View File

@ -8,7 +8,6 @@
#include "graphics/Screen.h"
#include "sleep.h"
#include "target_specific.h"
#include "timing.h"
static void sdsEnter()
{
@ -16,7 +15,7 @@ static void sdsEnter()
// Don't deepsleep if we have USB power or if the user as pressed a button recently
// !isUSBPowered <- doesn't work yet because the axp192 isn't letting the battery fully charge when we are awake - FIXME
if (timing::millis() - lastPressMs > radioConfig.preferences.mesh_sds_timeout_secs)
if (millis() - lastPressMs > radioConfig.preferences.mesh_sds_timeout_secs)
{
doDeepSleep(radioConfig.preferences.sds_secs);
}
@ -131,7 +130,7 @@ static void onEnter()
static uint32_t lastPingMs;
uint32_t now = timing::millis();
uint32_t now = millis();
if (now - lastPingMs > 30 * 1000) { // if more than a minute since our last press, ask other nodes to update their state
if (displayedNodeNum)

View File

@ -15,6 +15,13 @@ class BaseNotifiedWorkerThread : public WorkerThread
*/
virtual void notify(uint32_t v = 0, eNotifyAction action = eNoAction) = 0;
/**
* Notify from an ISR
*
* This must be inline or IRAM_ATTR on ESP32
*/
virtual void notifyFromISR(BaseType_t *highPriWoken, uint32_t v = 0, eNotifyAction action = eNoAction) { notify(v, action); }
protected:
/**
* The notification that was most recently used to wake the thread. Read from loop()

View File

@ -1,5 +1,4 @@
#include "Thread.h"
#include "timing.h"
#include <assert.h>
namespace concurrency

View File

@ -2,7 +2,6 @@
#ifdef HAS_FREE_RTOS
#include "timing.h"
#include <assert.h>
#ifdef ARDUINO_ARCH_ESP32

View File

@ -1,7 +1,6 @@
#include "PeriodicScheduler.h"
#include "PeriodicTask.h"
#include "LockGuard.h"
#include "../timing.h"
namespace concurrency {
@ -10,7 +9,7 @@ void PeriodicScheduler::loop()
{
LockGuard lg(&lock);
uint32_t now = timing::millis();
uint32_t now = millis();
for (auto t : tasks) {
if (t->period && (now - t->lastMsec) >= t->period) {

View File

@ -1,7 +1,7 @@
#pragma once
#include <Arduino.h>
#include "PeriodicScheduler.h"
#include "timing.h"
namespace concurrency {
@ -38,7 +38,7 @@ class PeriodicTask
*/
void setPeriod(uint32_t p)
{
lastMsec = timing::millis(); // reset starting from now
lastMsec = millis(); // reset starting from now
period = p;
}

View File

@ -1,5 +1,4 @@
#include "WorkerThread.h"
#include "timing.h"
namespace concurrency {
@ -17,8 +16,8 @@ void WorkerThread::doRun()
#ifdef DEBUG_STACK
static uint32_t lastPrint = 0;
if (timing::millis() - lastPrint > 10 * 1000L) {
lastPrint = timing::millis();
if (millis() - lastPrint > 10 * 1000L) {
lastPrint = millis();
meshtastic::printThreadInfo("net");
}
#endif

View File

@ -341,6 +341,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define HW_VENDOR "nrf52unknown" // FIXME - unknown nrf52 board
#elif PORTDUINO
#define HW_VENDOR "portduino"
#endif
#ifdef USE_RF95

View File

@ -1,7 +1,6 @@
#include <Arduino.h>
#include "../concurrency/LockGuard.h"
#include "../timing.h"
#include "BluetoothSoftwareUpdate.h"
#include "PowerFSM.h"
#include "RadioLibInterface.h"
@ -102,7 +101,7 @@ int update_crc32_callback(uint16_t conn_handle, uint16_t attr_handle, struct ble
} else {
if (Update.end()) {
DEBUG_MSG("OTA done, rebooting in 5 seconds!\n");
rebootAtMsec = timing::millis() + 5000;
rebootAtMsec = millis() + 5000;
} else {
DEBUG_MSG("Error Occurred. Error #: %d\n", Update.getError());
}
@ -128,7 +127,7 @@ int update_result_callback(uint16_t conn_handle, uint16_t attr_handle, struct bl
void bluetoothRebootCheck()
{
if (rebootAtMsec && timing::millis() > rebootAtMsec) {
if (rebootAtMsec && millis() > rebootAtMsec) {
DEBUG_MSG("Rebooting for update\n");
ESP.restart();
}

View File

@ -42,8 +42,6 @@ typedef uint32_t BaseType_t;
// Don't do anything on non free rtos platforms when done with the ISR
#define portYIELD_FROM_ISR(x)
enum eNotifyAction {
eNoAction
};
enum eNotifyAction { eNoAction, eSetValueWithoutOverwrite, eSetValueWithOverwrite };
#endif

View File

@ -1,7 +1,6 @@
#include "GPS.h"
#include "configuration.h"
#include "timing.h"
#include <assert.h>
#include <time.h>
@ -36,7 +35,7 @@ void readFromRTC()
struct timeval tv; /* btw settimeofday() is helpfull here too*/
if (!gettimeofday(&tv, NULL)) {
uint32_t now = timing::millis();
uint32_t now = millis();
DEBUG_MSG("Read RTC time as %ld (cur millis %u) valid=%d\n", tv.tv_sec, now, timeSetFromGPS);
timeStartMsec = now;
@ -79,7 +78,7 @@ void perhapsSetRTC(struct tm &t)
uint32_t getTime()
{
return ((timing::millis() - timeStartMsec) / 1000) + zeroOffsetSecs;
return ((millis() - timeStartMsec) / 1000) + zeroOffsetSecs;
}
uint32_t getValidTime()

View File

@ -1,6 +1,5 @@
#include "NEMAGPS.h"
#include "configuration.h"
#include "timing.h"
static int32_t toDegInt(RawDegrees d)
{
@ -19,7 +18,7 @@ void NEMAGPS::loop()
reader.encode(c);
}
uint32_t now = timing::millis();
uint32_t now = millis();
if ((now - lastUpdateMsec) > 20 * 1000) { // Ugly hack for now - limit update checks to once every 20 secs (but still consume
// serial chars at whatever rate)
lastUpdateMsec = now;

View File

@ -38,7 +38,6 @@
#include "graphics/Screen.h"
#include "main.h"
#include "sleep.h"
#include "timing.h"
#include <OneButton.h>
#include <Wire.h>
// #include <driver/rtc_io.h>
@ -392,15 +391,15 @@ void loop()
// Show boot screen for first 3 seconds, then switch to normal operation.
static bool showingBootScreen = true;
if (showingBootScreen && (timing::millis() > 3000)) {
if (showingBootScreen && (millis() > 3000)) {
screen.stopBootScreen();
showingBootScreen = false;
}
#ifdef DEBUG_STACK
static uint32_t lastPrint = 0;
if (timing::millis() - lastPrint > 10 * 1000L) {
lastPrint = timing::millis();
if (millis() - lastPrint > 10 * 1000L) {
lastPrint = millis();
meshtastic::printThreadInfo("main");
}
#endif

View File

@ -13,7 +13,6 @@
#include "main.h"
#include "mesh-pb-constants.h"
#include "power.h"
#include "timing.h"
/*
receivedPacketQueue - this is a queue of messages we've received from the mesh, which we are keeping to deliver to the phone.
@ -309,7 +308,7 @@ int MeshService::onGPSChanged(const meshtastic::GPSStatus *unused)
// We limit our GPS broadcasts to a max rate
static uint32_t lastGpsSend;
uint32_t now = timing::millis();
uint32_t now = millis();
if (lastGpsSend == 0 || now - lastGpsSend > radioConfig.preferences.position_broadcast_secs * 1000) {
lastGpsSend = now;
DEBUG_MSG("Sending position to mesh\n");

View File

@ -36,7 +36,7 @@ DeviceState versions used to be defined in the .proto file but really only this
// Portduino version
#include "PortduinoFS.h"
#define FS PortduinoFS
#define FSBegin() FS.begin(true)
#define FSBegin() true
#define FILE_O_WRITE "w"
#define FILE_O_READ "r"
#elif !defined(NO_ESP32)

View File

@ -1,7 +1,6 @@
#include "PacketHistory.h"
#include "configuration.h"
#include "mesh-pb-constants.h"
#include "../timing.h"
PacketHistory::PacketHistory()
{
@ -19,7 +18,7 @@ bool PacketHistory::wasSeenRecently(const MeshPacket *p, bool withUpdate)
return false; // Not a floodable message ID, so we don't care
}
uint32_t now = timing::millis();
uint32_t now = millis();
for (size_t i = 0; i < recentPackets.size();) {
PacketRecord &r = recentPackets[i];

View File

@ -4,7 +4,6 @@
#include "NodeDB.h"
#include "PowerFSM.h"
#include "RadioInterface.h"
#include "timing.h"
#include <assert.h>
PhoneAPI::PhoneAPI()
@ -21,7 +20,7 @@ void PhoneAPI::init()
void PhoneAPI::checkConnectionTimeout()
{
if (isConnected) {
bool newConnected = (timing::millis() - lastContactMsec < radioConfig.preferences.phone_timeout_secs * 1000L);
bool newConnected = (millis() - lastContactMsec < radioConfig.preferences.phone_timeout_secs * 1000L);
if (!newConnected) {
isConnected = false;
onConnectionChanged(isConnected);
@ -35,7 +34,7 @@ void PhoneAPI::checkConnectionTimeout()
void PhoneAPI::handleToRadio(const uint8_t *buf, size_t bufLength)
{
powerFSM.trigger(EVENT_CONTACT_FROM_PHONE); // As long as the phone keeps talking to us, don't let the radio go to sleep
lastContactMsec = timing::millis();
lastContactMsec = millis();
if (!isConnected) {
isConnected = true;
onConnectionChanged(isConnected);

View File

@ -6,7 +6,6 @@
#include "assert.h"
#include "configuration.h"
#include "sleep.h"
#include "timing.h"
#include <assert.h>
#include <pb_decode.h>
#include <pb_encode.h>
@ -163,7 +162,7 @@ size_t RadioInterface::beginSending(MeshPacket *p)
// DEBUG_MSG("sending queued packet on mesh (txGood=%d,rxGood=%d,rxBad=%d)\n", rf95.txGood(), rf95.rxGood(), rf95.rxBad());
assert(p->which_payload == MeshPacket_encrypted_tag); // It should have already been encoded by now
lastTxStart = timing::millis();
lastTxStart = millis();
PacketHeader *h = (PacketHeader *)radiobuf;

View File

@ -2,7 +2,6 @@
#include "MeshTypes.h"
#include "configuration.h"
#include "mesh-pb-constants.h"
#include "timing.h"
// ReliableRouter::ReliableRouter() {}
@ -163,7 +162,7 @@ PendingPacket *ReliableRouter::startRetransmission(MeshPacket *p)
*/
void ReliableRouter::doRetransmissions()
{
uint32_t now = timing::millis();
uint32_t now = millis();
// FIXME, we should use a better datastructure rather than walking through this map.
// for(auto el: pending) {

View File

@ -2,7 +2,6 @@
#include "FloodingRouter.h"
#include "../concurrency/PeriodicTask.h"
#include "../timing.h"
#include <unordered_map>
/**
@ -49,7 +48,7 @@ struct PendingPacket {
PendingPacket() {}
PendingPacket(MeshPacket *p);
void setNextTx() { nextTxMsec = timing::millis() + random(20 * 1000L, 22 * 1000L); }
void setNextTx() { nextTxMsec = millis() + random(20 * 1000L, 22 * 1000L); }
};
class GlobalPacketIdHashFunction

View File

@ -53,7 +53,7 @@ template <class T> class TypedQueue
public:
TypedQueue(int maxElements) {}
// int numFree() { return uxQueueSpacesAvailable(h); }
int numFree() { return 1; } // Always claim 1 free, because we can grow to any size
bool isEmpty() { return q.empty(); }

View File

@ -6,7 +6,7 @@
#include <pb_decode.h>
#include <pb_encode.h>
#ifdef NO_ESP32
#if 0 // FIXME NRF52 only
#include "Adafruit_LittleFS.h"
using namespace Adafruit_LittleFS_Namespace; // To get File type
#endif

View File

@ -7,7 +7,6 @@
#include "error.h"
#include "main.h"
#include "target_specific.h"
#include "timing.h"
#ifndef NO_ESP32
#include "esp32/pm.h"
@ -123,11 +122,11 @@ bool doPreflightSleep()
/// Tell devices we are going to sleep and wait for them to handle things
static void waitEnterSleep()
{
uint32_t now = timing::millis();
uint32_t now = millis();
while (!doPreflightSleep()) {
delay(100); // Kinda yucky - wait until radio says say we can shutdown (finished in process sends/receives)
if (timing::millis() - now > 30 * 1000) { // If we wait too long just report an error and go to sleep
if (millis() - now > 30 * 1000) { // If we wait too long just report an error and go to sleep
recordCriticalError(ErrSleepEnterWait);
assert(0); // FIXME - for now we just restart, need to fix bug #167
break;

View File

@ -1,10 +0,0 @@
#include "timing.h"
#include "freertosinc.h"
namespace timing {
uint32_t millis() {
return xTaskGetTickCount();
}
} // namespace timing

View File

@ -1,9 +0,0 @@
#pragma once
#include <cstdint>
namespace timing {
uint32_t millis();
} // namespace timing