diff --git a/platformio.ini b/platformio.ini index 60808a56d..a8940879e 100644 --- a/platformio.ini +++ b/platformio.ini @@ -248,7 +248,7 @@ lib_deps = [env:linux] platform = https://github.com/geeksville/platform-portduino.git -src_filter = ${env.src_filter} - - -build_flags = ${env.build_flags} -DRADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED +src_filter = ${env.src_filter} - - - +build_flags = ${env.build_flags} framework = arduino board = linux_x86_64 diff --git a/src/PowerFSM.cpp b/src/PowerFSM.cpp index 80580fd03..128947bcd 100644 --- a/src/PowerFSM.cpp +++ b/src/PowerFSM.cpp @@ -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) diff --git a/src/concurrency/BaseNotifiedWorkerThread.h b/src/concurrency/BaseNotifiedWorkerThread.h index 6d5db0ba5..03b82c4b0 100644 --- a/src/concurrency/BaseNotifiedWorkerThread.h +++ b/src/concurrency/BaseNotifiedWorkerThread.h @@ -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() diff --git a/src/concurrency/BaseThread.cpp b/src/concurrency/BaseThread.cpp index b7fea6a68..ab39a8c9f 100644 --- a/src/concurrency/BaseThread.cpp +++ b/src/concurrency/BaseThread.cpp @@ -1,5 +1,4 @@ #include "Thread.h" -#include "timing.h" #include namespace concurrency diff --git a/src/concurrency/FreeRtosThread.cpp b/src/concurrency/FreeRtosThread.cpp index 8d67eee13..1fe7108e3 100644 --- a/src/concurrency/FreeRtosThread.cpp +++ b/src/concurrency/FreeRtosThread.cpp @@ -2,7 +2,6 @@ #ifdef HAS_FREE_RTOS -#include "timing.h" #include #ifdef ARDUINO_ARCH_ESP32 diff --git a/src/concurrency/PeriodicScheduler.cpp b/src/concurrency/PeriodicScheduler.cpp index d2fa77f9c..5902ddd7a 100644 --- a/src/concurrency/PeriodicScheduler.cpp +++ b/src/concurrency/PeriodicScheduler.cpp @@ -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) { diff --git a/src/concurrency/PeriodicTask.h b/src/concurrency/PeriodicTask.h index 910c0dfde..74d4c8a34 100644 --- a/src/concurrency/PeriodicTask.h +++ b/src/concurrency/PeriodicTask.h @@ -1,7 +1,7 @@ #pragma once +#include #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; } diff --git a/src/concurrency/WorkerThread.cpp b/src/concurrency/WorkerThread.cpp index 8ea1e6a85..b2ec18d81 100644 --- a/src/concurrency/WorkerThread.cpp +++ b/src/concurrency/WorkerThread.cpp @@ -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 diff --git a/src/configuration.h b/src/configuration.h index 713aa9509..ff85fa06a 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -341,6 +341,10 @@ along with this program. If not, see . #define HW_VENDOR "nrf52unknown" // FIXME - unknown nrf52 board +#elif PORTDUINO + +#define HW_VENDOR "portduino" + #endif #ifdef USE_RF95 diff --git a/src/esp32/BluetoothSoftwareUpdate.cpp b/src/esp32/BluetoothSoftwareUpdate.cpp index 9bc7445a8..4fa518ccb 100644 --- a/src/esp32/BluetoothSoftwareUpdate.cpp +++ b/src/esp32/BluetoothSoftwareUpdate.cpp @@ -1,7 +1,6 @@ #include #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(); } diff --git a/src/freertosinc.h b/src/freertosinc.h index 798cf6410..c5dfddc8e 100644 --- a/src/freertosinc.h +++ b/src/freertosinc.h @@ -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 diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index 3902b655e..b3ab28d29 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -1,7 +1,6 @@ #include "GPS.h" #include "configuration.h" -#include "timing.h" #include #include @@ -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() diff --git a/src/gps/NEMAGPS.cpp b/src/gps/NEMAGPS.cpp index a1d848ad8..abd0ba003 100644 --- a/src/gps/NEMAGPS.cpp +++ b/src/gps/NEMAGPS.cpp @@ -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; diff --git a/src/main.cpp b/src/main.cpp index 49ade89f4..9a057c0b0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -38,7 +38,6 @@ #include "graphics/Screen.h" #include "main.h" #include "sleep.h" -#include "timing.h" #include #include // #include @@ -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 diff --git a/src/mesh/MeshService.cpp b/src/mesh/MeshService.cpp index f5d0ac173..70070b12b 100644 --- a/src/mesh/MeshService.cpp +++ b/src/mesh/MeshService.cpp @@ -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"); diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index e162c55ec..634bd9515 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -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) diff --git a/src/mesh/PacketHistory.cpp b/src/mesh/PacketHistory.cpp index b83fab3c6..3d1884ace 100644 --- a/src/mesh/PacketHistory.cpp +++ b/src/mesh/PacketHistory.cpp @@ -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]; diff --git a/src/mesh/PhoneAPI.cpp b/src/mesh/PhoneAPI.cpp index 2e8800c13..caadf8563 100644 --- a/src/mesh/PhoneAPI.cpp +++ b/src/mesh/PhoneAPI.cpp @@ -4,7 +4,6 @@ #include "NodeDB.h" #include "PowerFSM.h" #include "RadioInterface.h" -#include "timing.h" #include 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); diff --git a/src/mesh/RadioInterface.cpp b/src/mesh/RadioInterface.cpp index 45a9fed75..7629fdbe5 100644 --- a/src/mesh/RadioInterface.cpp +++ b/src/mesh/RadioInterface.cpp @@ -6,7 +6,6 @@ #include "assert.h" #include "configuration.h" #include "sleep.h" -#include "timing.h" #include #include #include @@ -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; diff --git a/src/mesh/ReliableRouter.cpp b/src/mesh/ReliableRouter.cpp index 174c184a0..acec6b7f9 100644 --- a/src/mesh/ReliableRouter.cpp +++ b/src/mesh/ReliableRouter.cpp @@ -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) { diff --git a/src/mesh/ReliableRouter.h b/src/mesh/ReliableRouter.h index 04974febb..f2e8774d8 100644 --- a/src/mesh/ReliableRouter.h +++ b/src/mesh/ReliableRouter.h @@ -2,7 +2,6 @@ #include "FloodingRouter.h" #include "../concurrency/PeriodicTask.h" -#include "../timing.h" #include /** @@ -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 diff --git a/src/mesh/TypedQueue.h b/src/mesh/TypedQueue.h index 90ed07f10..a2b82626f 100644 --- a/src/mesh/TypedQueue.h +++ b/src/mesh/TypedQueue.h @@ -53,7 +53,7 @@ template 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(); } diff --git a/src/mesh/mesh-pb-constants.cpp b/src/mesh/mesh-pb-constants.cpp index dc0d188ab..cc6beb73a 100644 --- a/src/mesh/mesh-pb-constants.cpp +++ b/src/mesh/mesh-pb-constants.cpp @@ -6,7 +6,7 @@ #include #include -#ifdef NO_ESP32 +#if 0 // FIXME NRF52 only #include "Adafruit_LittleFS.h" using namespace Adafruit_LittleFS_Namespace; // To get File type #endif diff --git a/src/sleep.cpp b/src/sleep.cpp index 3bce72669..a08707762 100644 --- a/src/sleep.cpp +++ b/src/sleep.cpp @@ -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; diff --git a/src/timing.cpp b/src/timing.cpp deleted file mode 100644 index f7cffaa65..000000000 --- a/src/timing.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "timing.h" -#include "freertosinc.h" - -namespace timing { - - uint32_t millis() { - return xTaskGetTickCount(); - } - -} // namespace timing diff --git a/src/timing.h b/src/timing.h deleted file mode 100644 index 7f741d45f..000000000 --- a/src/timing.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -#include - -namespace timing { - - uint32_t millis(); - -} // namespace timing \ No newline at end of file