From 74714bf0c58d8dc898281835b52be9844d7301a2 Mon Sep 17 00:00:00 2001 From: neil Date: Sat, 24 Feb 2024 14:28:58 -0800 Subject: [PATCH 01/13] station-g2 --- .vscode/extensions.json | 9 +++--- boards/station-g2.json | 41 +++++++++++++++++++++++ src/platform/esp32/architecture.h | 4 ++- variants/station-g2/pins_arduino.h | 29 +++++++++++++++++ variants/station-g2/platformio.ini | 15 +++++++++ variants/station-g2/variant.h | 52 ++++++++++++++++++++++++++++++ 6 files changed, 145 insertions(+), 5 deletions(-) create mode 100755 boards/station-g2.json create mode 100755 variants/station-g2/pins_arduino.h create mode 100755 variants/station-g2/platformio.ini create mode 100755 variants/station-g2/variant.h diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 783791f0b..080e70d08 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -2,8 +2,9 @@ // See http://go.microsoft.com/fwlink/?LinkId=827846 // for the documentation about the extensions.json format "recommendations": [ - "ms-vscode.cpptools", - "platformio.platformio-ide", - "trunk.io" + "platformio.platformio-ide" ], -} \ No newline at end of file + "unwantedRecommendations": [ + "ms-vscode.cpptools-extension-pack" + ] +} diff --git a/boards/station-g2.json b/boards/station-g2.json new file mode 100755 index 000000000..871f067aa --- /dev/null +++ b/boards/station-g2.json @@ -0,0 +1,41 @@ +{ + "build": { + "arduino": { + "ldscript": "esp32s3_out.ld", + "memory_type": "qio_opi" + }, + "core": "esp32", + "extra_flags": [ + "-DBOARD_HAS_PSRAM", + "-DARDUINO_USB_CDC_ON_BOOT=1", + "-DARDUINO_USB_MODE=0", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=0" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "hwids": [["0x303A", "0x1001"]], + "mcu": "esp32s3", + "variant": "station-g2" + }, + "connectivity": ["wifi", "bluetooth", "lora"], + "debug": { + "default_tool": "esp-builtin", + "onboard_tools": ["esp-builtin"], + "openocd_target": "esp32s3.cfg" + }, + "frameworks": ["arduino", "espidf"], + "name": "BQ Station G2", + "upload": { + "flash_size": "16MB", + "maximum_ram_size": 327680, + "maximum_size": 16777216, + "use_1200bps_touch": true, + "wait_for_upload_port": true, + "require_upload_port": true, + "speed": 921600 + }, + "url": "https://wiki.uniteng.com/en/meshtastic/station-g2", + "vendor": "BQ Consulting" +} diff --git a/src/platform/esp32/architecture.h b/src/platform/esp32/architecture.h index 7fab475f3..703bcefc9 100644 --- a/src/platform/esp32/architecture.h +++ b/src/platform/esp32/architecture.h @@ -133,6 +133,8 @@ #define HW_VENDOR meshtastic_HardwareModel_HELTEC_HT62 #elif defined(CHATTER_2) #define HW_VENDOR meshtastic_HardwareModel_CHATTER_2 +#elif defined(STATION_G2) +#define HW_VENDOR meshtastic_HardwareModel_STATION_G2 #endif // ----------------------------------------------------------------------------- @@ -155,4 +157,4 @@ #define LORA_CS 18 #endif -#define SERIAL0_RX_GPIO 3 // Always GPIO3 on ESP32 // FIXME: may be different on ESP32-S3, etc. +#define SERIAL0_RX_GPIO 3 // Always GPIO3 on ESP32 // FIXME: may be different on ESP32-S3, etc. \ No newline at end of file diff --git a/variants/station-g2/pins_arduino.h b/variants/station-g2/pins_arduino.h new file mode 100755 index 000000000..98cbd46d3 --- /dev/null +++ b/variants/station-g2/pins_arduino.h @@ -0,0 +1,29 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include + +#define USB_VID 0x303a +#define USB_PID 0x1001 + +#define EXTERNAL_NUM_INTERRUPTS 46 +#define NUM_DIGITAL_PINS 48 +#define NUM_ANALOG_INPUTS 20 + +#define analogInputToDigitalPin(p) (((p) < 20) ? (analogChannelToDigitalPin(p)) : -1) +#define digitalPinToInterrupt(p) (((p) <= 48) ? (p) : -1) +#define digitalPinHasPWM(p) (p < 46) + +// GPIO48 Reference: https://github.com/espressif/arduino-esp32/pull/8600 + +// The default Wire will be mapped to Screen and Sensors +static const uint8_t SDA = 5; +static const uint8_t SCL = 6; + +// Default SPI will be mapped to Radio +static const uint8_t MISO = 14; +static const uint8_t SCK = 12; +static const uint8_t MOSI = 13; +static const uint8_t SS = 11; + +#endif /* Pins_Arduino_h */ \ No newline at end of file diff --git a/variants/station-g2/platformio.ini b/variants/station-g2/platformio.ini new file mode 100755 index 000000000..b39136684 --- /dev/null +++ b/variants/station-g2/platformio.ini @@ -0,0 +1,15 @@ +[env:station-g2] +extends = esp32s3_base +board = station-g2 +board_build.mcu = esp32s3 +upload_protocol = esptool +;upload_port = /dev/ttyACM0 +upload_speed = 921600 +lib_deps = + ${esp32s3_base.lib_deps} +build_unflags = -DARDUINO_USB_MODE=1 +build_flags = + ${esp32s3_base.build_flags} -D STATION_G2 -I variants/station-g2 + -DBOARD_HAS_PSRAM + -DSTATION_G2 + -DARDUINO_USB_MODE=0 \ No newline at end of file diff --git a/variants/station-g2/variant.h b/variants/station-g2/variant.h new file mode 100755 index 000000000..6a24cd016 --- /dev/null +++ b/variants/station-g2/variant.h @@ -0,0 +1,52 @@ +/* +Board Information: https://wiki.uniteng.com/en/meshtastic/station-g2 +*/ + +// Station G2 may not have GPS installed, but it has a GROVE GPS Socket for Optional GPS Module +#define GPS_RX_PIN 7 +#define GPS_TX_PIN 15 + +// Station G2 has 1.3 inch OLED Screen +#define USE_SH1107_128_64 + +#define I2C_SDA 5 // I2C pins for this board +#define I2C_SCL 6 + +#define BUTTON_PIN 38 // This is the Program Button +#define BUTTON_NEED_PULLUP + +#define USE_SX1262 + +#define LORA_MISO 14 +#define LORA_SCK 12 +#define LORA_MOSI 13 +#define LORA_CS 11 + +#define LORA_RESET 21 +#define LORA_DIO1 48 + +#ifdef USE_SX1262 +#define SX126X_CS LORA_CS // FIXME - we really should define LORA_CS instead +#define SX126X_DIO1 LORA_DIO1 +#define SX126X_BUSY 47 +#define SX126X_RESET LORA_RESET + +// DIO2 controlls an antenna switch and the TCXO voltage is controlled by DIO3 +#define SX126X_DIO2_AS_RF_SWITCH +#define SX126X_DIO3_TCXO_VOLTAGE 1.8 + +#define SX126X_MAX_POWER \ + 19 // Ensure the PA does not exceed the saturation output power. More + // Info:https://wiki.uniteng.com/en/meshtastic/station-g2#summary-for-lora-power-amplifier-conduction-test +#endif + +#define BATTERY_PIN 4 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage +#define ADC_CHANNEL ADC1_GPIO4_CHANNEL +#define ADC_MULTIPLIER 4 +#define BATTERY_SENSE_SAMPLES 15 // Set the number of samples, It has an effect of increasing sensitivity. +#define BAT_FULLVOLT 8400 +#define BAT_EMPTYVOLT 5000 +#define BAT_CHARGINGVOLT 8400 +#define BAT_NOBATVOLT 4460 +#define CELL_TYPE_LION // same curve for liion/lipo +#define NUM_CELLS 2 \ No newline at end of file From 1fe230a0653556c849e21ec6630e6ee24df51db4 Mon Sep 17 00:00:00 2001 From: Neil Hao Date: Sun, 25 Feb 2024 08:18:30 +0800 Subject: [PATCH 02/13] Undo VS automatic modifications to this file --- .vscode/extensions.json | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 080e70d08..4fc84fa78 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -2,9 +2,8 @@ // See http://go.microsoft.com/fwlink/?LinkId=827846 // for the documentation about the extensions.json format "recommendations": [ - "platformio.platformio-ide" + "ms-vscode.cpptools", + "platformio.platformio-ide", + "trunk.io" ], - "unwantedRecommendations": [ - "ms-vscode.cpptools-extension-pack" - ] } From 8c7ee1a7bb6f375b817638c884851713aa3e8ff9 Mon Sep 17 00:00:00 2001 From: Neil Hao Date: Sun, 25 Feb 2024 18:32:46 +0800 Subject: [PATCH 03/13] Corrected the Trunk Problem --- variants/station-g2/variant.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/variants/station-g2/variant.h b/variants/station-g2/variant.h index 6a24cd016..b1d6914bb 100755 --- a/variants/station-g2/variant.h +++ b/variants/station-g2/variant.h @@ -35,9 +35,8 @@ Board Information: https://wiki.uniteng.com/en/meshtastic/station-g2 #define SX126X_DIO2_AS_RF_SWITCH #define SX126X_DIO3_TCXO_VOLTAGE 1.8 -#define SX126X_MAX_POWER \ - 19 // Ensure the PA does not exceed the saturation output power. More - // Info:https://wiki.uniteng.com/en/meshtastic/station-g2#summary-for-lora-power-amplifier-conduction-test +// Ensure the PA does not exceed the saturation output power. More Info:https://wiki.uniteng.com/en/meshtastic/station-g2#summary-for-lora-power-amplifier-conduction-test +#define SX126X_MAX_POWER 19 #endif #define BATTERY_PIN 4 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage @@ -49,4 +48,4 @@ Board Information: https://wiki.uniteng.com/en/meshtastic/station-g2 #define BAT_CHARGINGVOLT 8400 #define BAT_NOBATVOLT 4460 #define CELL_TYPE_LION // same curve for liion/lipo -#define NUM_CELLS 2 \ No newline at end of file +#define NUM_CELLS 2 From 8726cb830ed6e5c3286d5979545f6bd5a3ac4b05 Mon Sep 17 00:00:00 2001 From: Neil Hao Date: Sun, 25 Feb 2024 18:44:43 +0800 Subject: [PATCH 04/13] Trunk don't like long line:) --- variants/station-g2/variant.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/variants/station-g2/variant.h b/variants/station-g2/variant.h index b1d6914bb..f781ceb24 100755 --- a/variants/station-g2/variant.h +++ b/variants/station-g2/variant.h @@ -35,7 +35,8 @@ Board Information: https://wiki.uniteng.com/en/meshtastic/station-g2 #define SX126X_DIO2_AS_RF_SWITCH #define SX126X_DIO3_TCXO_VOLTAGE 1.8 -// Ensure the PA does not exceed the saturation output power. More Info:https://wiki.uniteng.com/en/meshtastic/station-g2#summary-for-lora-power-amplifier-conduction-test +// Ensure the PA does not exceed the saturation output power. More +// Info:https://wiki.uniteng.com/en/meshtastic/station-g2#summary-for-lora-power-amplifier-conduction-test #define SX126X_MAX_POWER 19 #endif From 6932f073100092211f8a1d8a4d29efab1a2777ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sun, 25 Feb 2024 12:11:11 +0100 Subject: [PATCH 05/13] Add Station G2 to the build matrix --- .github/workflows/main_matrix.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml index 5c1cf4c21..1e3e07106 100644 --- a/.github/workflows/main_matrix.yml +++ b/.github/workflows/main_matrix.yml @@ -32,7 +32,7 @@ jobs: - board: meshtastic-diy-v1 - board: rak4631 - board: t-echo - - board: station-g1 + - board: station-g2 - board: m5stack-coreink - board: tbeam-s3-core - board: tlora-t3s3-v1 @@ -99,6 +99,7 @@ jobs: - board: t-watch-s3 - board: t-deck - board: picomputer-s3 + - board: station-g2 uses: ./.github/workflows/build_esp32_s3.yml with: board: ${{ matrix.board }} From b98ddbddf413084ce3258cafb482d90767398853 Mon Sep 17 00:00:00 2001 From: rcarteraz Date: Sat, 24 Feb 2024 08:19:31 -0700 Subject: [PATCH 06/13] update node db lite log message --- src/mesh/NodeDB.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index add1b1296..506adda5c 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -903,8 +903,8 @@ meshtastic_NodeInfoLite *NodeDB::getOrCreateMeshNode(NodeNum n) if (!lite) { if ((*numMeshNodes >= MAX_NUM_NODES) || (memGet.getFreeHeap() < meshtastic_NodeInfoLite_size * 3)) { if (screen) - screen->print("warning: node_db_lite full! erasing oldest entry\n"); - LOG_INFO("warning: node_db_lite full! erasing oldest entry\n"); + screen->print("Warn: node database full!\nErasing oldest entry\n"); + LOG_INFO("Warn: node database full!\nErasing oldest entry\n"); // look for oldest node and erase it uint32_t oldest = UINT32_MAX; int oldestIndex = -1; From 02192e1163d1145974b4004db72dd86b4f9f30df Mon Sep 17 00:00:00 2001 From: GUVWAF <78759985+GUVWAF@users.noreply.github.com> Date: Sun, 25 Feb 2024 14:29:34 +0100 Subject: [PATCH 07/13] More StoreForward updates (#3274) * More StoreForward updates * Disable heartbeat again if not in config --------- Co-authored-by: Ben Meadors --- src/modules/esp32/StoreForwardModule.cpp | 78 ++++++++++++++---------- src/modules/esp32/StoreForwardModule.h | 2 +- 2 files changed, 47 insertions(+), 33 deletions(-) diff --git a/src/modules/esp32/StoreForwardModule.cpp b/src/modules/esp32/StoreForwardModule.cpp index cb1552521..70d13afca 100644 --- a/src/modules/esp32/StoreForwardModule.cpp +++ b/src/modules/esp32/StoreForwardModule.cpp @@ -45,7 +45,8 @@ int32_t StoreForwardModule::runOnce() this->busy = false; } } - } else if ((millis() - lastHeartbeat > (heartbeatInterval * 1000)) && airTime->isTxAllowedChannelUtil(true)) { + } else if (this->heartbeat && (millis() - lastHeartbeat > (heartbeatInterval * 1000)) && + airTime->isTxAllowedChannelUtil(true)) { lastHeartbeat = millis(); LOG_INFO("*** Sending heartbeat\n"); meshtastic_StoreAndForward sf = meshtastic_StoreAndForward_init_zero; @@ -141,25 +142,31 @@ uint32_t StoreForwardModule::historyQueueCreate(uint32_t msAgo, uint32_t to, uin LOG_DEBUG("SF historyQueueCreate - millis %d\n", millis()); LOG_DEBUG("SF historyQueueCreate - math %d\n", (millis() - msAgo)); */ - if (this->packetHistory[i].time && (this->packetHistory[i].time < (millis() - msAgo))) { - /* Copy the messages that were received by the router in the last msAgo - to the packetHistoryTXQueue structure. - Client not interested in packets from itself and only in broadcast packets or packets towards it. */ - if (this->packetHistory[i].from != to && - (this->packetHistory[i].to == NODENUM_BROADCAST || this->packetHistory[i].to == to)) { - this->packetHistoryTXQueue[this->packetHistoryTXQueue_size].time = this->packetHistory[i].time; - this->packetHistoryTXQueue[this->packetHistoryTXQueue_size].to = this->packetHistory[i].to; - this->packetHistoryTXQueue[this->packetHistoryTXQueue_size].from = this->packetHistory[i].from; - this->packetHistoryTXQueue[this->packetHistoryTXQueue_size].channel = this->packetHistory[i].channel; - this->packetHistoryTXQueue[this->packetHistoryTXQueue_size].payload_size = this->packetHistory[i].payload_size; - memcpy(this->packetHistoryTXQueue[this->packetHistoryTXQueue_size].payload, this->packetHistory[i].payload, - meshtastic_Constants_DATA_PAYLOAD_LEN); - this->packetHistoryTXQueue_size++; - *last_request_index = i + 1; // Set to one higher such that we don't send the same message again + if (this->packetHistoryTXQueue_size < this->historyReturnMax) { + if (this->packetHistory[i].time && (this->packetHistory[i].time < (millis() - msAgo))) { + /* Copy the messages that were received by the router in the last msAgo + to the packetHistoryTXQueue structure. + Client not interested in packets from itself and only in broadcast packets or packets towards it. */ + if (this->packetHistory[i].from != to && + (this->packetHistory[i].to == NODENUM_BROADCAST || this->packetHistory[i].to == to)) { + this->packetHistoryTXQueue[this->packetHistoryTXQueue_size].time = this->packetHistory[i].time; + this->packetHistoryTXQueue[this->packetHistoryTXQueue_size].to = this->packetHistory[i].to; + this->packetHistoryTXQueue[this->packetHistoryTXQueue_size].from = this->packetHistory[i].from; + this->packetHistoryTXQueue[this->packetHistoryTXQueue_size].channel = this->packetHistory[i].channel; + this->packetHistoryTXQueue[this->packetHistoryTXQueue_size].payload_size = + this->packetHistory[i].payload_size; + memcpy(this->packetHistoryTXQueue[this->packetHistoryTXQueue_size].payload, this->packetHistory[i].payload, + meshtastic_Constants_DATA_PAYLOAD_LEN); + this->packetHistoryTXQueue_size++; + *last_request_index = i + 1; // Set to one higher such that we don't send the same message again - LOG_DEBUG("*** PacketHistoryStruct time=%d, msg=%s\n", this->packetHistory[i].time, - this->packetHistory[i].payload); + LOG_DEBUG("*** PacketHistoryStruct time=%d, msg=%s\n", this->packetHistory[i].time, + this->packetHistory[i].payload); + } } + } else { + LOG_WARN("*** S&F - Maximum history return reached.\n"); + return this->packetHistoryTXQueue_size; } } return this->packetHistoryTXQueue_size; @@ -174,20 +181,24 @@ void StoreForwardModule::historyAdd(const meshtastic_MeshPacket &mp) { const auto &p = mp.decoded; - if (this->packetHistoryCurrent < this->records) { - this->packetHistory[this->packetHistoryCurrent].time = millis(); - this->packetHistory[this->packetHistoryCurrent].to = mp.to; - this->packetHistory[this->packetHistoryCurrent].channel = mp.channel; - this->packetHistory[this->packetHistoryCurrent].from = mp.from; - this->packetHistory[this->packetHistoryCurrent].payload_size = p.payload.size; - memcpy(this->packetHistory[this->packetHistoryCurrent].payload, p.payload.bytes, meshtastic_Constants_DATA_PAYLOAD_LEN); - - this->packetHistoryCurrent++; - this->packetHistoryMax++; - } else { - // TODO: Overwrite the oldest message in the history buffer when it is full. - LOG_WARN("*** S&F - PSRAM Full. Packet is not added to the history.\n"); + if (this->packetHistoryCurrent == this->records) { + LOG_WARN("*** S&F - PSRAM Full. Starting overwrite now.\n"); + this->packetHistoryCurrent = 0; + this->packetHistoryMax = 0; + for (auto &i : lastRequest) { + i.second = 0; // Clear the last request index for each client device + } } + + this->packetHistory[this->packetHistoryCurrent].time = millis(); + this->packetHistory[this->packetHistoryCurrent].to = mp.to; + this->packetHistory[this->packetHistoryCurrent].channel = mp.channel; + this->packetHistory[this->packetHistoryCurrent].from = mp.from; + this->packetHistory[this->packetHistoryCurrent].payload_size = p.payload.size; + memcpy(this->packetHistory[this->packetHistoryCurrent].payload, p.payload.bytes, meshtastic_Constants_DATA_PAYLOAD_LEN); + + this->packetHistoryCurrent++; + this->packetHistoryMax++; } meshtastic_MeshPacket *StoreForwardModule::allocReply() @@ -313,7 +324,8 @@ ProcessMessage StoreForwardModule::handleReceived(const meshtastic_MeshPacket &m if ((mp.decoded.portnum == meshtastic_PortNum_TEXT_MESSAGE_APP) && is_server) { auto &p = mp.decoded; - if ((p.payload.bytes[0] == 'S') && (p.payload.bytes[1] == 'F') && (p.payload.bytes[2] == 0x00)) { + if (mp.to == nodeDB.getNodeNum() && (p.payload.bytes[0] == 'S') && (p.payload.bytes[1] == 'F') && + (p.payload.bytes[2] == 0x00)) { LOG_DEBUG("*** Legacy Request to send\n"); // Send the last 60 minutes of messages. @@ -543,6 +555,8 @@ StoreForwardModule::StoreForwardModule() // send heartbeat advertising? if (moduleConfig.store_forward.heartbeat) this->heartbeat = moduleConfig.store_forward.heartbeat; + else + this->heartbeat = false; // Popupate PSRAM with our data structures. this->populatePSRAM(); diff --git a/src/modules/esp32/StoreForwardModule.h b/src/modules/esp32/StoreForwardModule.h index cfa9945d5..0d2fb9fce 100644 --- a/src/modules/esp32/StoreForwardModule.h +++ b/src/modules/esp32/StoreForwardModule.h @@ -44,7 +44,7 @@ class StoreForwardModule : private concurrency::OSThread, public ProtobufModule< StoreForwardModule(); unsigned long lastHeartbeat = 0; - uint32_t heartbeatInterval = default_broadcast_interval_secs; + uint32_t heartbeatInterval = 900; /** Update our local reference of when we last saw that node. From 824991c17804d2418405af85b6c734618b213b8c Mon Sep 17 00:00:00 2001 From: GUVWAF <78759985+GUVWAF@users.noreply.github.com> Date: Sun, 25 Feb 2024 14:43:44 +0100 Subject: [PATCH 08/13] Ignore MQTT by default if region has a duty cycle limit (#3277) Co-authored-by: Ben Meadors --- src/modules/AdminModule.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index 94df601d8..abd7c2e54 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -332,6 +332,9 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c) if (isRegionUnset && config.lora.region > meshtastic_Config_LoRaConfig_RegionCode_UNSET) { config.lora.tx_enabled = true; initRegion(); + if (myRegion->dutyCycle < 100) { + config.lora.ignore_mqtt = true; // Ignore MQTT by default if region has a duty cycle limit + } if (strcmp(moduleConfig.mqtt.root, default_mqtt_root) == 0) { sprintf(moduleConfig.mqtt.root, "%s/%s", default_mqtt_root, myRegion->name); changes = SEGMENT_CONFIG | SEGMENT_MODULECONFIG; From 0f27992c5a95c73e7a71876d2bd049d46ff2a1d7 Mon Sep 17 00:00:00 2001 From: GUVWAF <78759985+GUVWAF@users.noreply.github.com> Date: Sun, 25 Feb 2024 14:44:08 +0100 Subject: [PATCH 09/13] Ignore JSON enabled setting on nRF52 platforms (#3286) Not supported, see #2804 Co-authored-by: Ben Meadors --- src/mqtt/MQTT.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/mqtt/MQTT.cpp b/src/mqtt/MQTT.cpp index 8c241a302..898607eca 100644 --- a/src/mqtt/MQTT.cpp +++ b/src/mqtt/MQTT.cpp @@ -351,11 +351,13 @@ void MQTT::sendSubscriptions() std::string topic = cryptTopic + channels.getGlobalId(i) + "/#"; LOG_INFO("Subscribing to %s\n", topic.c_str()); pubSub.subscribe(topic.c_str(), 1); // FIXME, is QOS 1 right? +#ifndef ARCH_NRF52 // JSON is not supported on nRF52, see issue #2804 if (moduleConfig.mqtt.json_enabled == true) { std::string topicDecoded = jsonTopic + channels.getGlobalId(i) + "/#"; LOG_INFO("Subscribing to %s\n", topicDecoded.c_str()); pubSub.subscribe(topicDecoded.c_str(), 1); // FIXME, is QOS 1 right? } +#endif // ARCH_NRF52 } } #endif @@ -450,6 +452,7 @@ void MQTT::publishQueuedMessages() publish(topic.c_str(), bytes, numBytes, false); +#ifndef ARCH_NRF52 // JSON is not supported on nRF52, see issue #2804 if (moduleConfig.mqtt.json_enabled) { // handle json topic auto jsonString = this->meshPacketToJson(env->packet); @@ -460,6 +463,7 @@ void MQTT::publishQueuedMessages() publish(topicJson.c_str(), jsonString.c_str(), false); } } +#endif // ARCH_NRF52 mqttPool.release(env); } } @@ -504,6 +508,7 @@ void MQTT::onSend(const meshtastic_MeshPacket &mp, const meshtastic_MeshPacket & publish(topic.c_str(), bytes, numBytes, false); +#ifndef ARCH_NRF52 // JSON is not supported on nRF52, see issue #2804 if (moduleConfig.mqtt.json_enabled) { // handle json topic auto jsonString = this->meshPacketToJson((meshtastic_MeshPacket *)&mp_decoded); @@ -514,7 +519,7 @@ void MQTT::onSend(const meshtastic_MeshPacket &mp, const meshtastic_MeshPacket & publish(topicJson.c_str(), jsonString.c_str(), false); } } - +#endif // ARCH_NRF52 } else { LOG_INFO("MQTT not connected, queueing packet\n"); if (mqttQueue.numFree() == 0) { From d434117ffdded1e1dbb118264c546fafab097375 Mon Sep 17 00:00:00 2001 From: Thomas Herrmann Date: Sun, 25 Feb 2024 20:03:54 +0100 Subject: [PATCH 10/13] add UI frame for PaxCounter module (#3285) * add UI frame to display PaxCounter module data * only acquire screen when paxcounter is active, i.e. enabled and wifi and ble are both off * sync font #define with other occurrences in code * protect screen specific code with #if HAS_SCREEN * limit upload_speed to 115200 for TLORA_V2_1_16 * fix failing trunk checks; sorry * Revert "limit upload_speed to 115200 for TLORA_V2_1_16" This reverts commit 4eb549c5e886508a4d39a7bfe689bc1976cbaa4b. --------- Co-authored-by: Ben Meadors --- src/modules/esp32/PaxcounterModule.cpp | 45 +++++++++++++++++++++++++- src/modules/esp32/PaxcounterModule.h | 5 +++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/modules/esp32/PaxcounterModule.cpp b/src/modules/esp32/PaxcounterModule.cpp index f3df7ffdf..b3506891d 100644 --- a/src/modules/esp32/PaxcounterModule.cpp +++ b/src/modules/esp32/PaxcounterModule.cpp @@ -57,7 +57,7 @@ meshtastic_MeshPacket *PaxcounterModule::allocReply() int32_t PaxcounterModule::runOnce() { - if (moduleConfig.paxcounter.enabled && !config.bluetooth.enabled && !config.network.wifi_enabled) { + if (isActive()) { if (firstTime) { firstTime = false; LOG_DEBUG( @@ -87,4 +87,47 @@ int32_t PaxcounterModule::runOnce() } } +#if HAS_SCREEN + +// TODO / FIXME: This code is copied from src/graphics/Screen.cpp +// It appears (in slightly variants) also in other modules like +// src/modules/Telemetry/PowerTelemetry.cpp, src/modules/Telemetry/EnvironmentTelemetry.cpp +// and src/modules/CannedMessageModule.cpp +// It probably should go to a common header file for consistency +#if (defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS) || defined(ST7789_CS)) && \ + !defined(DISPLAY_FORCE_SMALL_FONTS) +// The screen is bigger so use bigger fonts +#define FONT_SMALL ArialMT_Plain_16 // Height: 19 +#define FONT_MEDIUM ArialMT_Plain_24 // Height: 28 +#define FONT_LARGE ArialMT_Plain_24 // Height: 28 +#else +#ifdef OLED_RU +#define FONT_SMALL ArialMT_Plain_10_RU +#else +#ifdef OLED_UA +#define FONT_SMALL ArialMT_Plain_10_UA +#else +#define FONT_SMALL ArialMT_Plain_10 // Height: 13 +#endif +#endif +#define FONT_MEDIUM ArialMT_Plain_16 // Height: 19 +#define FONT_LARGE ArialMT_Plain_24 // Height: 28 +#endif + +void PaxcounterModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) +{ + char buffer[50]; + display->setTextAlignment(TEXT_ALIGN_LEFT); + display->setFont(FONT_SMALL); + display->drawString(x + 0, y + 0, "PAX"); + + libpax_counter_count(&count_from_libpax); + + display->setTextAlignment(TEXT_ALIGN_CENTER); + display->setFont(FONT_SMALL); + display->drawStringf(display->getWidth() / 2 + x, 0 + y + 12, buffer, "WiFi: %d\nBLE: %d\nuptime: %ds", + count_from_libpax.wifi_count, count_from_libpax.ble_count, millis() / 1000); +} +#endif // HAS_SCREEN + #endif \ No newline at end of file diff --git a/src/modules/esp32/PaxcounterModule.h b/src/modules/esp32/PaxcounterModule.h index 0aa9be68d..e72f87450 100644 --- a/src/modules/esp32/PaxcounterModule.h +++ b/src/modules/esp32/PaxcounterModule.h @@ -23,6 +23,11 @@ class PaxcounterModule : private concurrency::OSThread, public ProtobufModule Date: Sun, 25 Feb 2024 21:27:32 -0600 Subject: [PATCH 11/13] Fix wrong-side-of-globe when precision set to 32 --- src/modules/PositionModule.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/modules/PositionModule.cpp b/src/modules/PositionModule.cpp index 5f20dbafb..d8d52667c 100644 --- a/src/modules/PositionModule.cpp +++ b/src/modules/PositionModule.cpp @@ -118,13 +118,16 @@ meshtastic_MeshPacket *PositionModule::allocReply() // lat/lon are unconditionally included - IF AVAILABLE! LOG_DEBUG("Sending location with precision %i\n", precision); - p.latitude_i = localPosition.latitude_i & (INT32_MAX << (32 - precision)); - p.longitude_i = localPosition.longitude_i & (INT32_MAX << (32 - precision)); + if (precision < 32 && precision > 0) { + p.latitude_i = localPosition.latitude_i & (INT32_MAX << (32 - precision)); + p.longitude_i = localPosition.longitude_i & (INT32_MAX << (32 - precision)); - // We want the imprecise position to be the middle of the possible location, not - if (precision < 31 && precision > 1) { + // We want the imprecise position to be the middle of the possible location, not p.latitude_i += (1 << (31 - precision)); p.longitude_i += (1 << (31 - precision)); + } else { + p.latitude_i = localPosition.latitude_i; + p.longitude_i = localPosition.longitude_i; } p.precision_bits = precision; p.time = localPosition.time; From 146b5b557adc5653287d7cf02792aa4e59aab56f Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Mon, 26 Feb 2024 00:22:05 -0600 Subject: [PATCH 12/13] UINT32_MAX is not the same as INT32_MAX --- src/modules/PositionModule.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/PositionModule.cpp b/src/modules/PositionModule.cpp index d8d52667c..92e8f8a4d 100644 --- a/src/modules/PositionModule.cpp +++ b/src/modules/PositionModule.cpp @@ -119,8 +119,8 @@ meshtastic_MeshPacket *PositionModule::allocReply() // lat/lon are unconditionally included - IF AVAILABLE! LOG_DEBUG("Sending location with precision %i\n", precision); if (precision < 32 && precision > 0) { - p.latitude_i = localPosition.latitude_i & (INT32_MAX << (32 - precision)); - p.longitude_i = localPosition.longitude_i & (INT32_MAX << (32 - precision)); + p.latitude_i = localPosition.latitude_i & (UINT32_MAX << (32 - precision)); + p.longitude_i = localPosition.longitude_i & (UINT32_MAX << (32 - precision)); // We want the imprecise position to be the middle of the possible location, not p.latitude_i += (1 << (31 - precision)); From d556d59308faa5404f987eac0c6e1544cf55a3dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Mon, 26 Feb 2024 09:42:12 +0100 Subject: [PATCH 13/13] fix compilation for Cyrillic fonts --- src/modules/esp32/PaxcounterModule.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/modules/esp32/PaxcounterModule.cpp b/src/modules/esp32/PaxcounterModule.cpp index b3506891d..89bf8f072 100644 --- a/src/modules/esp32/PaxcounterModule.cpp +++ b/src/modules/esp32/PaxcounterModule.cpp @@ -89,6 +89,14 @@ int32_t PaxcounterModule::runOnce() #if HAS_SCREEN +#ifdef OLED_RU +#include "graphics/fonts/OLEDDisplayFontsRU.h" +#endif + +#ifdef OLED_UA +#include "graphics/fonts/OLEDDisplayFontsUA.h" +#endif + // TODO / FIXME: This code is copied from src/graphics/Screen.cpp // It appears (in slightly variants) also in other modules like // src/modules/Telemetry/PowerTelemetry.cpp, src/modules/Telemetry/EnvironmentTelemetry.cpp