diff --git a/arch/esp32/esp32.ini b/arch/esp32/esp32.ini index 5cc48e191..fb83ec2d4 100644 --- a/arch/esp32/esp32.ini +++ b/arch/esp32/esp32.ini @@ -35,7 +35,7 @@ lib_deps = https://github.com/meshtastic/esp32_https_server.git#23665b3adc080a311dcbb586ed5941b5f94d6ea2 h2zero/NimBLE-Arduino@^1.4.0 https://github.com/lewisxhe/XPowersLib.git#84b7373faea3118b6c37954d52f98b8a337148d6 - caveman99/ESP32 Codec2@^1.0.1 + https://github.com/meshtastic/ESP32_Codec2.git#633326c78ac251c059ab3a8c430fcdf25b41672f lib_ignore = segger_rtt diff --git a/arch/esp32/esp32c3.ini b/arch/esp32/esp32c3.ini index cca95f48a..5ebb789ad 100644 --- a/arch/esp32/esp32c3.ini +++ b/arch/esp32/esp32c3.ini @@ -34,8 +34,7 @@ lib_deps = https://github.com/meshtastic/esp32_https_server.git#23665b3adc080a311dcbb586ed5941b5f94d6ea2 h2zero/NimBLE-Arduino@^1.4.0 https://github.com/lewisxhe/XPowersLib.git#84b7373faea3118b6c37954d52f98b8a337148d6 - caveman99/ESP32 Codec2@^1.0.1 - + https://github.com/meshtastic/ESP32_Codec2.git#633326c78ac251c059ab3a8c430fcdf25b41672f lib_ignore = segger_rtt ESP32 BLE Arduino diff --git a/arch/esp32/esp32s2.ini b/arch/esp32/esp32s2.ini index b266d1792..6e75c08c9 100644 --- a/arch/esp32/esp32s2.ini +++ b/arch/esp32/esp32s2.ini @@ -35,7 +35,7 @@ lib_deps = ${environmental_base.lib_deps} https://github.com/meshtastic/esp32_https_server.git#23665b3adc080a311dcbb586ed5941b5f94d6ea2 https://github.com/lewisxhe/XPowersLib.git#84b7373faea3118b6c37954d52f98b8a337148d6 - caveman99/ESP32 Codec2@^1.0.1 + https://github.com/meshtastic/ESP32_Codec2.git#633326c78ac251c059ab3a8c430fcdf25b41672f lib_ignore = segger_rtt diff --git a/arch/esp32/esp32s3.ini b/arch/esp32/esp32s3.ini index 9a042b22b..bb0214f46 100644 --- a/arch/esp32/esp32s3.ini +++ b/arch/esp32/esp32s3.ini @@ -35,7 +35,7 @@ lib_deps = https://github.com/meshtastic/esp32_https_server.git#23665b3adc080a311dcbb586ed5941b5f94d6ea2 h2zero/NimBLE-Arduino@^1.4.0 https://github.com/lewisxhe/XPowersLib.git#84b7373faea3118b6c37954d52f98b8a337148d6 - caveman99/ESP32 Codec2@^1.0.1 + https://github.com/meshtastic/ESP32_Codec2.git#633326c78ac251c059ab3a8c430fcdf25b41672f lib_ignore = segger_rtt diff --git a/bin/generate_ci_matrix.py b/bin/generate_ci_matrix.py new file mode 100755 index 000000000..2501e83c1 --- /dev/null +++ b/bin/generate_ci_matrix.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python + +"""Generate the CI matrix""" + +import configparser +import json +import os +import sys + +rootdir = "variants/" + +options = sys.argv[1:] + +outlist = [] + +if len(options) < 1: + print(json.dumps(outlist)) + exit() + +for subdir, dirs, files in os.walk(rootdir): + for file in files: + if file == "platformio.ini": + config = configparser.ConfigParser() + config.read(subdir + "/" + file) + for c in config.sections(): + if c.startswith("env:"): + section = config[c].name[4:] + if "extends" in config[config[c].name]: + if config[config[c].name]["extends"] == options[0] + "_base": + if "board_level" in config[config[c].name]: + if ( + config[config[c].name]["board_level"] == "extra" + ) & ("extra" in options): + outlist.append(section) + else: + outlist.append(section) + +print(json.dumps(outlist)) diff --git a/protobufs b/protobufs index 5f00ad569..ee6f408bb 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 5f00ad5691ae7d8a03fd92437b81e9a424e3483f +Subproject commit ee6f408bb3c27b8ca820477cbb3a84ac6c8b0ffc diff --git a/src/ButtonThread.h b/src/ButtonThread.h index f35c53a46..b295f896a 100644 --- a/src/ButtonThread.h +++ b/src/ButtonThread.h @@ -123,14 +123,10 @@ class ButtonThread : public concurrency::OSThread static void userButtonPressedLong() { // LOG_DEBUG("Long press!\n"); - // If user button is held down for 5 seconds, shutdown the device. - if ((millis() - longPressTime > 5 * 1000) && (longPressTime > 0)) { -#ifdef HAS_PMU - if (pmu_found == true) { - setLed(false); - power->shutdown(); - } -#elif defined(ARCH_NRF52) || defined(ARCH_ESP32) + screen->adjustBrightness(); + // If user button is held down for 10 seconds, shutdown the device. + if ((millis() - longPressTime > 10000) && (longPressTime > 0)) { +#if defined(ARCH_NRF52) || defined(ARCH_ESP32) // Do actual shutdown when button released, otherwise the button release // may wake the board immediatedly. if ((!shutdown_on_long_stop) && (millis() > 30 * 1000)) { diff --git a/src/Power.cpp b/src/Power.cpp index b7e66ed6d..2acd2f6ab 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -277,12 +277,11 @@ void Power::shutdown() LOG_INFO("Shutting down\n"); #ifdef HAS_PMU - if (PMU) { + if (pmu_found == true) { PMU->setChargingLedMode(XPOWERS_CHG_LED_OFF); + PMU->shutdown(); } -#endif - -#if defined(ARCH_NRF52) || defined(ARCH_ESP32) +#elif defined(ARCH_NRF52) || defined(ARCH_ESP32) #ifdef PIN_LED1 ledOff(PIN_LED1); #endif diff --git a/src/mesh/CryptoEngine.cpp b/src/mesh/CryptoEngine.cpp index 9b5810650..1e44cb9b7 100644 --- a/src/mesh/CryptoEngine.cpp +++ b/src/mesh/CryptoEngine.cpp @@ -1,6 +1,8 @@ #include "CryptoEngine.h" #include "configuration.h" +concurrency::Lock *cryptLock; + void CryptoEngine::setKey(const CryptoKey &k) { LOG_DEBUG("Using AES%d key!\n", k.length * 8); diff --git a/src/mesh/CryptoEngine.h b/src/mesh/CryptoEngine.h index 1dda7ce31..2737dab2d 100644 --- a/src/mesh/CryptoEngine.h +++ b/src/mesh/CryptoEngine.h @@ -1,7 +1,10 @@ #pragma once +#include "concurrency/LockGuard.h" #include +extern concurrency::Lock *cryptLock; + struct CryptoKey { uint8_t bytes[32]; diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index c7a42cb09..02749feb8 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -689,11 +689,11 @@ void NodeDB::updateTelemetry(uint32_t nodeId, const meshtastic_Telemetry &t, RxS /** Update user info for this node based on received user data */ -void NodeDB::updateUser(uint32_t nodeId, const meshtastic_User &p) +bool NodeDB::updateUser(uint32_t nodeId, const meshtastic_User &p) { meshtastic_NodeInfo *info = getOrCreateNode(nodeId); if (!info) { - return; + return false; } LOG_DEBUG("old user %s/%s/%s\n", info->user.id, info->user.long_name, info->user.short_name); @@ -713,6 +713,8 @@ void NodeDB::updateUser(uint32_t nodeId, const meshtastic_User &p) // We just changed something important about the user, store our DB saveToDisk(SEGMENT_DEVICESTATE); } + + return changed; } /// given a subpacket sniffed from the network, update our DB state diff --git a/src/mesh/NodeDB.h b/src/mesh/NodeDB.h index 2822ffbf6..541b51f83 100644 --- a/src/mesh/NodeDB.h +++ b/src/mesh/NodeDB.h @@ -86,7 +86,7 @@ class NodeDB /** Update user info for this node based on received user data */ - void updateUser(uint32_t nodeId, const meshtastic_User &p); + bool updateUser(uint32_t nodeId, const meshtastic_User &p); /// @return our node number NodeNum getNodeNum() { return myNodeInfo.my_node_num; } diff --git a/src/mesh/Router.cpp b/src/mesh/Router.cpp index b3aee4e7d..e85d85450 100644 --- a/src/mesh/Router.cpp +++ b/src/mesh/Router.cpp @@ -55,6 +55,10 @@ Router::Router() : concurrency::OSThread("Router"), fromRadioQueue(MAX_RX_FROMRA LOG_DEBUG("Size of MeshPacket %d\n", sizeof(MeshPacket)); */ fromRadioQueue.setReader(this); + + // init Lockguard for crypt operations + assert(!cryptLock); + cryptLock = new concurrency::Lock(); } /** @@ -305,6 +309,8 @@ void Router::sniffReceived(const meshtastic_MeshPacket *p, const meshtastic_Rout bool perhapsDecode(meshtastic_MeshPacket *p) { + concurrency::LockGuard g(cryptLock); + if (config.device.role == meshtastic_Config_DeviceConfig_Role_REPEATER && config.device.rebroadcast_mode == meshtastic_Config_DeviceConfig_RebroadcastMode_ALL_SKIP_DECODING) return false; @@ -371,6 +377,8 @@ bool perhapsDecode(meshtastic_MeshPacket *p) */ meshtastic_Routing_Error perhapsEncode(meshtastic_MeshPacket *p) { + concurrency::LockGuard g(cryptLock); + // If the packet is not yet encrypted, do so now if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) { size_t numbytes = pb_encode_to_bytes(bytes, sizeof(bytes), &meshtastic_Data_msg, &p->decoded); diff --git a/src/mesh/generated/meshtastic/clientonly.pb.c b/src/mesh/generated/meshtastic/clientonly.pb.c new file mode 100644 index 000000000..ebc2ffabc --- /dev/null +++ b/src/mesh/generated/meshtastic/clientonly.pb.c @@ -0,0 +1,12 @@ +/* Automatically generated nanopb constant definitions */ +/* Generated by nanopb-0.4.7 */ + +#include "meshtastic/clientonly.pb.h" +#if PB_PROTO_HEADER_VERSION != 40 +#error Regenerate this file with the current version of nanopb generator. +#endif + +PB_BIND(meshtastic_DeviceProfile, meshtastic_DeviceProfile, 2) + + + diff --git a/src/mesh/generated/meshtastic/clientonly.pb.h b/src/mesh/generated/meshtastic/clientonly.pb.h new file mode 100644 index 000000000..0f70e09c6 --- /dev/null +++ b/src/mesh/generated/meshtastic/clientonly.pb.h @@ -0,0 +1,73 @@ +/* Automatically generated nanopb header */ +/* Generated by nanopb-0.4.7 */ + +#ifndef PB_MESHTASTIC_MESHTASTIC_CLIENTONLY_PB_H_INCLUDED +#define PB_MESHTASTIC_MESHTASTIC_CLIENTONLY_PB_H_INCLUDED +#include +#include "meshtastic/localonly.pb.h" + +#if PB_PROTO_HEADER_VERSION != 40 +#error Regenerate this file with the current version of nanopb generator. +#endif + +/* Struct definitions */ +/* This abstraction is used to contain any configuration for provisioning a node on any client. + It is useful for importing and exporting configurations. */ +typedef struct _meshtastic_DeviceProfile { + /* Long name for the node */ + bool has_long_name; + char long_name[40]; + /* Short name of the node */ + bool has_short_name; + char short_name[5]; + /* The url of the channels from our node */ + pb_callback_t channel_url; + /* The Config of the node */ + bool has_config; + meshtastic_LocalConfig config; + /* The ModuleConfig of the node */ + bool has_module_config; + meshtastic_LocalModuleConfig module_config; +} meshtastic_DeviceProfile; + + +#ifdef __cplusplus +extern "C" { +#endif + +/* Initializer values for message structs */ +#define meshtastic_DeviceProfile_init_default {false, "", false, "", {{NULL}, NULL}, false, meshtastic_LocalConfig_init_default, false, meshtastic_LocalModuleConfig_init_default} +#define meshtastic_DeviceProfile_init_zero {false, "", false, "", {{NULL}, NULL}, false, meshtastic_LocalConfig_init_zero, false, meshtastic_LocalModuleConfig_init_zero} + +/* Field tags (for use in manual encoding/decoding) */ +#define meshtastic_DeviceProfile_long_name_tag 1 +#define meshtastic_DeviceProfile_short_name_tag 2 +#define meshtastic_DeviceProfile_channel_url_tag 3 +#define meshtastic_DeviceProfile_config_tag 4 +#define meshtastic_DeviceProfile_module_config_tag 5 + +/* Struct field encoding specification for nanopb */ +#define meshtastic_DeviceProfile_FIELDLIST(X, a) \ +X(a, STATIC, OPTIONAL, STRING, long_name, 1) \ +X(a, STATIC, OPTIONAL, STRING, short_name, 2) \ +X(a, CALLBACK, OPTIONAL, STRING, channel_url, 3) \ +X(a, STATIC, OPTIONAL, MESSAGE, config, 4) \ +X(a, STATIC, OPTIONAL, MESSAGE, module_config, 5) +#define meshtastic_DeviceProfile_CALLBACK pb_default_field_callback +#define meshtastic_DeviceProfile_DEFAULT NULL +#define meshtastic_DeviceProfile_config_MSGTYPE meshtastic_LocalConfig +#define meshtastic_DeviceProfile_module_config_MSGTYPE meshtastic_LocalModuleConfig + +extern const pb_msgdesc_t meshtastic_DeviceProfile_msg; + +/* Defines for backwards compatibility with code written before nanopb-0.4.0 */ +#define meshtastic_DeviceProfile_fields &meshtastic_DeviceProfile_msg + +/* Maximum encoded size of messages (where known) */ +/* meshtastic_DeviceProfile_size depends on runtime parameters */ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif diff --git a/src/modules/NodeInfoModule.cpp b/src/modules/NodeInfoModule.cpp index cf8c17c3b..09819dab1 100644 --- a/src/modules/NodeInfoModule.cpp +++ b/src/modules/NodeInfoModule.cpp @@ -12,7 +12,7 @@ bool NodeInfoModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, mes { auto p = *pptr; - nodeDB.updateUser(getFrom(&mp), p); + bool hasChanged = nodeDB.updateUser(getFrom(&mp), p); bool wasBroadcast = mp.to == NODENUM_BROADCAST; @@ -23,6 +23,10 @@ bool NodeInfoModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, mes screen->print(lcd.c_str()); } + // if user has changed while packet was not for us, inform phone + if (hasChanged && !wasBroadcast && mp.to != nodeDB.getNodeNum()) + service.sendToPhone(packetPool.allocCopy(mp)); + // LOG_DEBUG("did handleReceived\n"); return false; // Let others look at this message also if they want } diff --git a/src/platform/esp32/main-esp32.cpp b/src/platform/esp32/main-esp32.cpp index 645132f38..2068025c2 100644 --- a/src/platform/esp32/main-esp32.cpp +++ b/src/platform/esp32/main-esp32.cpp @@ -162,7 +162,7 @@ void esp32Loop() // radio.radioIf.canSleep(); } -void cpuDeepSleep(uint64_t msecToWake) +void cpuDeepSleep(uint32_t msecToWake) { /* Some ESP32 IOs have internal pullups or pulldowns, which are enabled by default. diff --git a/src/platform/nrf52/main-nrf52.cpp b/src/platform/nrf52/main-nrf52.cpp index 1cbe05631..36ddefeb4 100644 --- a/src/platform/nrf52/main-nrf52.cpp +++ b/src/platform/nrf52/main-nrf52.cpp @@ -155,7 +155,7 @@ void nrf52Setup() nRFCrypto.end(); } -void cpuDeepSleep(uint64_t msecToWake) +void cpuDeepSleep(uint32_t msecToWake) { // FIXME, configure RTC or button press to wake us // FIXME, power down SPI, I2C, RAMs diff --git a/src/platform/portduino/PortduinoGlue.cpp b/src/platform/portduino/PortduinoGlue.cpp index fee6e05f9..4e957cb1e 100644 --- a/src/platform/portduino/PortduinoGlue.cpp +++ b/src/platform/portduino/PortduinoGlue.cpp @@ -16,7 +16,7 @@ void setBluetoothEnable(bool on) // not needed } -void cpuDeepSleep(uint64_t msecs) +void cpuDeepSleep(uint32_t msecs) { notImplemented("cpuDeepSleep"); } diff --git a/src/platform/rp2040/main-rp2040.cpp b/src/platform/rp2040/main-rp2040.cpp index 1de8c5b68..af200f961 100644 --- a/src/platform/rp2040/main-rp2040.cpp +++ b/src/platform/rp2040/main-rp2040.cpp @@ -7,7 +7,7 @@ void setBluetoothEnable(bool on) // not needed } -void cpuDeepSleep(uint64_t msecs) +void cpuDeepSleep(uint32_t msecs) { // not needed } diff --git a/src/platform/stm32wl/main-stm32wl.cpp b/src/platform/stm32wl/main-stm32wl.cpp index 147408441..8ebcb029e 100644 --- a/src/platform/stm32wl/main-stm32wl.cpp +++ b/src/platform/stm32wl/main-stm32wl.cpp @@ -15,7 +15,7 @@ void getMacAddr(uint8_t *dmac) dmac[i] = i; } -void cpuDeepSleep(uint64_t msecToWake) {} +void cpuDeepSleep(uint32_t msecToWake) {} /* pacify libc_nano */ extern "C" { diff --git a/src/sleep.cpp b/src/sleep.cpp index e3f042a27..9468b7d09 100644 --- a/src/sleep.cpp +++ b/src/sleep.cpp @@ -19,6 +19,10 @@ esp_sleep_source_t wakeCause; // the reason we booted this time #endif +#ifndef INCLUDE_vTaskSuspend +#define INCLUDE_vTaskSuspend 0 +#endif + #ifdef HAS_PMU #include "XPowersLibInterface.hpp" extern XPowersLibInterface *PMU; @@ -201,9 +205,13 @@ void doGPSpowersave(bool on) #endif } -void doDeepSleep(uint64_t msecToWake) +void doDeepSleep(uint32_t msecToWake) { - LOG_INFO("Entering deep sleep for %lu seconds\n", msecToWake / 1000); + if (INCLUDE_vTaskSuspend && (msecToWake == portMAX_DELAY)) { + LOG_INFO("Entering deep sleep forever\n"); + } else { + LOG_INFO("Entering deep sleep for %u seconds\n", msecToWake / 1000); + } // not using wifi yet, but once we are this is needed to shutoff the radio hw // esp_wifi_stop(); diff --git a/src/sleep.h b/src/sleep.h index af59a8dad..a4b8f37b5 100644 --- a/src/sleep.h +++ b/src/sleep.h @@ -4,7 +4,7 @@ #include "Observer.h" #include "configuration.h" -void doDeepSleep(uint64_t msecToWake), cpuDeepSleep(uint64_t msecToWake); +void doDeepSleep(uint32_t msecToWake), cpuDeepSleep(uint32_t msecToWake); #ifdef ARCH_ESP32 #include "esp_sleep.h" diff --git a/variants/MakePython_nRF52840_eink/platformio.ini b/variants/MakePython_nRF52840_eink/platformio.ini index 825566146..9ed5a8594 100644 --- a/variants/MakePython_nRF52840_eink/platformio.ini +++ b/variants/MakePython_nRF52840_eink/platformio.ini @@ -7,7 +7,7 @@ build_flags = ${nrf52840_base.build_flags} -Ivariants/MakePython_nRF52840_eink - build_src_filter = ${nrf52_base.build_src_filter} +<../variants/MakePython_nRF52840_eink> lib_deps = ${nrf52840_base.lib_deps} - caveman99/ESP32 Codec2@^1.0.1 + https://github.com/meshtastic/ESP32_Codec2.git#633326c78ac251c059ab3a8c430fcdf25b41672f zinggjm/GxEPD2@^1.4.9 debug_tool = jlink upload_port = /dev/ttyACM4 diff --git a/variants/MakePython_nRF52840_oled/platformio.ini b/variants/MakePython_nRF52840_oled/platformio.ini index 35011fb09..9332bd786 100644 --- a/variants/MakePython_nRF52840_oled/platformio.ini +++ b/variants/MakePython_nRF52840_oled/platformio.ini @@ -6,5 +6,5 @@ build_flags = ${nrf52840_base.build_flags} -Ivariants/MakePython_nRF52840_oled - build_src_filter = ${nrf52_base.build_src_filter} +<../variants/MakePython_nRF52840_oled> lib_deps = ${nrf52840_base.lib_deps} - caveman99/ESP32 Codec2@^1.0.1 + https://github.com/meshtastic/ESP32_Codec2.git#633326c78ac251c059ab3a8c430fcdf25b41672f debug_tool = jlink diff --git a/variants/my_esp32s3_diy_eink/platformio.ini b/variants/my_esp32s3_diy_eink/platformio.ini index 01376f256..8405f784e 100644 --- a/variants/my_esp32s3_diy_eink/platformio.ini +++ b/variants/my_esp32s3_diy_eink/platformio.ini @@ -12,7 +12,6 @@ platform_packages = tool-esptoolpy@^1.40500.0 lib_deps = ${esp32_base.lib_deps} - caveman99/ESP32 Codec2@^1.0.1 zinggjm/GxEPD2@^1.5.1 adafruit/Adafruit NeoPixel@^1.10.7 build_unflags = -DARDUINO_USB_MODE=1 diff --git a/variants/my_esp32s3_diy_oled/platformio.ini b/variants/my_esp32s3_diy_oled/platformio.ini index 189e87fba..1430dfd96 100644 --- a/variants/my_esp32s3_diy_oled/platformio.ini +++ b/variants/my_esp32s3_diy_oled/platformio.ini @@ -12,7 +12,6 @@ platform_packages = tool-esptoolpy@^1.40500.0 lib_deps = ${esp32_base.lib_deps} - caveman99/ESP32 Codec2@^1.0.1 adafruit/Adafruit NeoPixel@^1.10.7 build_unflags = -DARDUINO_USB_MODE=1 build_flags = diff --git a/variants/tlora_t3s3_v1/platformio.ini b/variants/tlora_t3s3_v1/platformio.ini index 568e8af42..bef57c3b4 100644 --- a/variants/tlora_t3s3_v1/platformio.ini +++ b/variants/tlora_t3s3_v1/platformio.ini @@ -2,9 +2,6 @@ extends = esp32s3_base board = tlora-t3s3-v1 upload_protocol = esp-builtin -lib_deps = - ${esp32_base.lib_deps} - caveman99/ESP32 Codec2@^1.0.1 build_flags = ${esp32_base.build_flags} -D TLORA_T3S3_V1 -I variants/tlora_t3s3_v1 \ No newline at end of file diff --git a/variants/tlora_v2_1_18/platformio.ini b/variants/tlora_v2_1_18/platformio.ini index c61b8a28c..01741ca13 100644 --- a/variants/tlora_v2_1_18/platformio.ini +++ b/variants/tlora_v2_1_18/platformio.ini @@ -1,9 +1,6 @@ [env:tlora-v2-1-1.8] extends = esp32_base board = ttgo-lora32-v21 -lib_deps = - ${esp32_base.lib_deps} - caveman99/ESP32 Codec2@^1.0.1 build_flags = ${esp32_base.build_flags} -D TLORA_V2_1_18 -I variants/tlora_v2_1_18 \ No newline at end of file diff --git a/version.properties b/version.properties index 909888740..02e47fdf2 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ [VERSION] major = 2 minor = 1 -build = 8 +build = 9