Skip to content

Commit

Permalink
Merge pull request #9 from meshtastic/dev-wifi
Browse files Browse the repository at this point in the history
from dev-wifi to my fork
  • Loading branch information
mc-hamster authored Sep 23, 2020
2 parents 10b24c0 + 52a3927 commit 2d8eb8e
Show file tree
Hide file tree
Showing 46 changed files with 520 additions and 209 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ jobs:
run: |
pip install -U adafruit-nrfutil
- name: Build
run: platformio run -e tbeam -e heltec -e lora-relay-v1
run: platformio run -e tbeam -e heltec -e lora-relay-v1 -e linux
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
"optional": "cpp",
"string_view": "cpp",
"cassert": "cpp",
"iterator": "cpp"
"iterator": "cpp",
"shared_mutex": "cpp"
},
"cSpell.words": [
"Blox",
Expand Down
2 changes: 1 addition & 1 deletion bin/build-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e

source bin/version.sh

COUNTRIES="US EU433 EU865 CN JP"
COUNTRIES="US EU433 EU865 CN JP ANZ KR"
#COUNTRIES=US
#COUNTRIES=CN

Expand Down
2 changes: 1 addition & 1 deletion bin/version.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@


export VERSION=1.0.0
export VERSION=1.1.0
60 changes: 38 additions & 22 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
; https://docs.platformio.org/page/projectconf.html

[platformio]
default_envs = tbeam # or if you'd like to change the default to something like lora-relay-v1 put that here
default_envs = tbeam # lora-relay-v1 # nrf52840dk-geeksville # linux # or if you'd like to change the default to something like lora-relay-v1 put that here

[common]
; common is not currently used
Expand All @@ -23,15 +23,9 @@ default_envs = tbeam # or if you'd like to change the default to something like

[env]

framework = arduino

; customize the partition table
; http://docs.platformio.org/en/latest/platforms/espressif32.html#partition-tables
board_build.partitions = partition-table.csv

; note: we add src to our include search path so that lmic_project_config can override
; FIXME: fix lib/BluetoothOTA dependency back on src/ so we can remove -Isrc
build_flags = -Wno-missing-field-initializers -Isrc -Isrc/mesh -Isrc/gps -Ilib/nanopb/include -Os -Wl,-Map,.pio/build/output.map
build_flags = -Wno-missing-field-initializers -Isrc -Isrc/mesh -Isrc/gps -Ilib/nanopb/include -Wl,-Map,.pio/build/output.map
-DHW_VERSION_${sysenv.COUNTRY}
-DAPP_VERSION=${sysenv.APP_VERSION}
-DHW_VERSION=${sysenv.HW_VERSION}
Expand Down Expand Up @@ -60,25 +54,38 @@ debug_tool = jlink

lib_deps =
https://github.com/meshtastic/esp8266-oled-ssd1306.git ; ESP8266_SSD1306
SPI
1260 ; OneButton library for non-blocking button debounce
1202 ; CRC32, explicitly needed because dependency is missing in the ble ota update lib
Wire ; explicitly needed here because the AXP202 library forgets to add it
https://github.com/meshtastic/arduino-fsm.git
https://github.com/meshtastic/SparkFun_Ublox_Arduino_Library.git
https://github.com/meshtastic/RadioLib.git#7989a269be590a5d4914ac04069b58f4930c45c1
https://github.com/meshtastic/RadioLib.git#ac7feac00f5e0bd95a3ac5d5852b4cc7344cf95c
https://github.com/meshtastic/TinyGPSPlus.git
https://github.com/meshtastic/AXP202X_Library.git#8404abb6d4b486748636bc6ad72d2a47baaf5460
Wire ; explicitly needed here because the AXP202 library forgets to add it
SPI

; Common settings for conventional (non Portduino) Ardino targets
[arduino_base]

framework = arduino

lib_deps =
${env.lib_deps}

build_flags = ${env.build_flags} -Os

src_filter = ${env.src_filter} -<portduino/>

; Common settings for ESP targes, mixin with extends = esp32_base
[esp32_base]
extends = arduino_base
platform = espressif32
src_filter =
${env.src_filter} -<nrf52/>
${arduino_base.src_filter} -<nrf52/>
upload_speed = 921600
debug_init_break = tbreak setup
build_flags =
${env.build_flags} -Wall -Wextra -Isrc/esp32 -mfix-esp32-psram-cache-issue -lnimble -std=c++11
${arduino_base.build_flags} -Wall -Wextra -Isrc/esp32 -Isrc/esp32-mfix-esp32-psram-cache-issue -lnimble -std=c++11
-DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
-DAXP_DEBUG_PORT=Serial
# Hmm - this doesn't work yet
Expand All @@ -87,6 +94,10 @@ lib_ignore = segger_rtt
platform_packages =
framework-arduinoespressif32@https://github.com/meshtastic/arduino-esp32.git#2814f110aa618429bdd9a0a2d6a93c55f29f87a6

; customize the partition table
; http://docs.platformio.org/en/latest/platforms/espressif32.html#partition-tables
board_build.partitions = partition-table.csv

; not needed included in ttgo-t-beam board file
; also to use PSRAM https://docs.platformio.org/en/latest/platforms/espressif32.html#external-ram-psram
; -DBOARD_HAS_PSRAM
Expand All @@ -99,7 +110,7 @@ platform_packages =
extends = esp32_base
board = ttgo-t-beam
lib_deps =
${env.lib_deps}
${arduino_base.lib_deps}
build_flags =
${esp32_base.build_flags} -D TBEAM_V10

Expand Down Expand Up @@ -142,20 +153,21 @@ build_flags =
platform = https://github.com/HelTecAutomation/platform-asrmicro650x.git ; we use top-of-tree because stable version has too many bugs - asrmicro650x
board = cubecell_board_plus
; FIXME, bug in cubecell arduino - they are supposed to set ARDUINO
build_flags = ${env.build_flags} -DARDUINO=100 -Isrc/cubecell
build_flags = ${arduino_base.build_flags} -DARDUINO=100 -Isrc/cubecell
src_filter =
${env.src_filter} -<esp32/> -<nrf52/>
${arduino_base.src_filter} -<esp32/> -<nrf52/>

; Common settings for NRF52 based targets
[nrf52_base]
; Instead of the standard nordicnrf52 platform, we use our fork which has our added variant files
; platform = nordicnrf52
platform = https://github.com/meshtastic/platform-nordicnrf52.git#1a2639a6b0f79b5df66bea3e3089f0d5285fdc63
extends = arduino_base
debug_tool = jlink
build_type = debug ; I'm debugging with ICE a lot now
; note: liboberon provides the AES256 implementation for NRF52 (though not using the hardware acceleration of the NRF52840 - FIXME)
build_flags =
${env.build_flags} -Wno-unused-variable
${arduino_base.build_flags} -Wno-unused-variable
-Isrc/nrf52
-Isdk-nrfxlib/crypto/nrf_oberon/include -Lsdk-nrfxlib/crypto/nrf_oberon/lib/cortex-m4/hard-float/ -lliboberon_3.0.3
;-DCFG_DEBUG=3
Expand Down Expand Up @@ -212,7 +224,7 @@ monitor_speed = 115200
extends = nrf52_base
board = ppr
lib_deps =
${env.lib_deps}
${arduino_base.lib_deps}
UC1701

; The https://github.com/BigCorvus/SX1262-LoRa-BLE-Relay board by @BigCorvus
Expand All @@ -233,11 +245,15 @@ build_flags = ${nrf52_base.build_flags} -Ivariants/lora_relay_v1
-DSPI_FREQUENCY=27000000
src_filter = ${nrf52_base.src_filter} +<../variants/lora_relay_v1>
lib_deps =
${env.lib_deps}
${arduino_base.lib_deps}
SparkFun BQ27441 LiPo Fuel Gauge Arduino Library
TFT_eSPI
# Adafruit ST7735 and ST7789 Library




; The Portduino based sim environment on top of linux
[env:linux]
platform = https://github.com/geeksville/platform-portduino.git
src_filter = ${env.src_filter} -<esp32/> -<nimble/> -<nrf52/>
build_flags = ${arduino_base.build_flags} -O0
framework = arduino
board = linux_x86_64
5 changes: 2 additions & 3 deletions src/PowerFSM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@
#include "graphics/Screen.h"
#include "sleep.h"
#include "target_specific.h"
#include "timing.h"

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);
}
Expand Down Expand Up @@ -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)
Expand Down
44 changes: 44 additions & 0 deletions src/concurrency/BaseNotifiedWorkerThread.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#pragma once

#include "WorkerThread.h"

namespace concurrency {

/**
* @brief A worker thread that waits on a freertos notification
*/
class BaseNotifiedWorkerThread : public WorkerThread
{
public:
/**
* Notify this thread so it can run
*/
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()
*/
uint32_t notification = 0;

/**
* What notification bits should be cleared just after we read and return them in notification?
*
* Defaults to clear all of them.
*/
uint32_t clearOnRead = UINT32_MAX;

/**
* A method that should block execution - either waiting ona queue/mutex or a "task notification"
*/
virtual void block() = 0;
};

} // namespace concurrency
12 changes: 12 additions & 0 deletions src/concurrency/BaseThread.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include "Thread.h"
#include <assert.h>

namespace concurrency
{

void BaseThread::callRun(void *_this)
{
((BaseThread *)_this)->doRun();
}

} // namespace concurrency
47 changes: 47 additions & 0 deletions src/concurrency/BaseThread.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#pragma once

#include <cstdlib>
#include <stdint.h>

#include "freertosinc.h"

namespace concurrency
{

/**
* @brief Base threading
*/
class BaseThread
{
protected:
/**
* set this to true to ask thread to cleanly exit asap
*/
volatile bool wantExit = false;

public:
virtual void start(const char *name, size_t stackSize = 1024, uint32_t priority = tskIDLE_PRIORITY) = 0;

virtual ~BaseThread() {}

// uint32_t getStackHighwaterMark() { return uxTaskGetStackHighWaterMark(taskHandle); }

protected:
/**
* The method that will be called when start is called.
*/
virtual void doRun() = 0;

/**
* All thread run methods must periodically call serviceWatchdog, or the system will declare them hung and panic.
*
* this only applies after startWatchdog() has been called. If you need to sleep for a long time call stopWatchdog()
*/
virtual void serviceWatchdog() {}
virtual void startWatchdog() {}
virtual void stopWatchdog() {}

static void callRun(void *_this);
};

} // namespace concurrency
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
#include "NotifiedWorkerThread.h"

#ifdef HAS_FREE_RTOS

namespace concurrency {

/**
* Notify this thread so it can run
*/
void NotifiedWorkerThread::notify(uint32_t v, eNotifyAction action)
void FreeRtosNotifiedWorkerThread::notify(uint32_t v, eNotifyAction action)
{
xTaskNotify(taskHandle, v, action);
}

void NotifiedWorkerThread::block()
void FreeRtosNotifiedWorkerThread::block()
{
xTaskNotifyWait(0, // don't clear notification on entry
clearOnRead, &notification, portMAX_DELAY); // Wait forever
}

} // namespace concurrency

#endif
40 changes: 40 additions & 0 deletions src/concurrency/FreeRtosNotifiedWorkerThread.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#pragma once

#include "BaseNotifiedWorkerThread.h"

#ifdef HAS_FREE_RTOS

namespace concurrency {

/**
* @brief A worker thread that waits on a freertos notification
*/
class FreeRtosNotifiedWorkerThread : public BaseNotifiedWorkerThread
{
public:
/**
* Notify this thread so it can run
*/
void notify(uint32_t v = 0, eNotifyAction action = eNoAction);

/**
* Notify from an ISR
*
* This must be inline or IRAM_ATTR on ESP32
*/
inline void notifyFromISR(BaseType_t *highPriWoken, uint32_t v = 0, eNotifyAction action = eNoAction)
{
xTaskNotifyFromISR(taskHandle, v, action, highPriWoken);
}

protected:

/**
* A method that should block execution - either waiting ona queue/mutex or a "task notification"
*/
virtual void block();
};

} // namespace concurrency

#endif
Loading

0 comments on commit 2d8eb8e

Please sign in to comment.