Merge branch 'master' into transactional-config-edits

This commit is contained in:
Ben Meadors 2022-11-21 12:10:49 -06:00 committed by GitHub
commit fb4f9bdc40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 105 additions and 118 deletions

View File

@ -31,7 +31,7 @@ lib_deps =
${arduino_base.lib_deps} ${arduino_base.lib_deps}
${networking_base.lib_deps} ${networking_base.lib_deps}
${environmental_base.lib_deps} ${environmental_base.lib_deps}
https://github.com/meshtastic/esp32_https_server.git#657509856ce97e9dddeffb89a559f544faefd5cd https://github.com/meshtastic/esp32_https_server.git#23665b3adc080a311dcbb586ed5941b5f94d6ea2
h2zero/NimBLE-Arduino@^1.4.0 h2zero/NimBLE-Arduino@^1.4.0
https://github.com/lewisxhe/XPowersLib.git#84b7373faea3118b6c37954d52f98b8a337148d6 https://github.com/lewisxhe/XPowersLib.git#84b7373faea3118b6c37954d52f98b8a337148d6

View File

@ -31,7 +31,7 @@ lib_deps =
${arduino_base.lib_deps} ${arduino_base.lib_deps}
${networking_base.lib_deps} ${networking_base.lib_deps}
${environmental_base.lib_deps} ${environmental_base.lib_deps}
https://github.com/meshtastic/esp32_https_server.git#657509856ce97e9dddeffb89a559f544faefd5cd https://github.com/meshtastic/esp32_https_server.git#23665b3adc080a311dcbb586ed5941b5f94d6ea2
h2zero/NimBLE-Arduino@^1.4.0 h2zero/NimBLE-Arduino@^1.4.0
https://github.com/lewisxhe/XPowersLib.git#84b7373faea3118b6c37954d52f98b8a337148d6 https://github.com/lewisxhe/XPowersLib.git#84b7373faea3118b6c37954d52f98b8a337148d6

View File

@ -1,5 +1,7 @@
; The Portduino based sim environment on top of any host OS, all hardware will be simulated ; The Portduino based sim environment on top of any host OS, all hardware will be simulated
[portduino_base] [portduino_base]
platform = https://github.com/meshtastic/platform-native.git#develop
framework = arduino
build_src_filter = build_src_filter =
${env.build_src_filter} ${env.build_src_filter}
-<platform/esp32/> -<platform/esp32/>
@ -16,5 +18,6 @@ lib_deps =
${env.lib_deps} ${env.lib_deps}
${networking_base.lib_deps} ${networking_base.lib_deps}
rweather/Crypto@^0.4.0 rweather/Crypto@^0.4.0
https://github.com/meshtastic/RadioLib.git#5582ac30578ff3f53f20630a00b2a8a4b8f92c74 ; jgromes/RadioLib@5.4.1
https://github.com/jgromes/RadioLib.git#63208f1e89d4dac6eedaafbe234bf90f1fd5402b ; 5.4.1 with some fixes, remove when 5.4.2 is released
build_flags = ${arduino_base.build_flags} -Isrc/platform/portduino build_flags = ${arduino_base.build_flags} -Isrc/platform/portduino

View File

@ -37,12 +37,24 @@ extra_scripts = bin/platformio-custom.py
; note: TINYGPS_OPTION_NO_CUSTOM_FIELDS is VERY important. We don't use custom fields and somewhere in that pile ; note: TINYGPS_OPTION_NO_CUSTOM_FIELDS is VERY important. We don't use custom fields and somewhere in that pile
; of code is a heap corruption bug! ; of code is a heap corruption bug!
; FIXME: fix lib/BluetoothOTA dependency back on src/ so we can remove -Isrc ; FIXME: fix lib/BluetoothOTA dependency back on src/ so we can remove -Isrc
; The Radiolib stuff will speed up building considerably. Exclud all the stuff we dont need.
build_flags = -Wno-missing-field-initializers build_flags = -Wno-missing-field-initializers
-Wno-format -Wno-format
-Isrc -Isrc/mesh -Isrc/gps -Isrc/buzz -Wl,-Map,.pio/build/output.map -Isrc -Isrc/mesh -Isrc/gps -Isrc/buzz -Wl,-Map,.pio/build/output.map
-DUSE_THREAD_NAMES -DUSE_THREAD_NAMES
-DTINYGPS_OPTION_NO_CUSTOM_FIELDS ; -DTINYGPS_OPTION_NO_CUSTOM_FIELDS // this should work now...
-DPB_ENABLE_MALLOC=1 -DPB_ENABLE_MALLOC=1
-DRADIOLIB_EXCLUDE_CC1101
-DRADIOLIB_EXCLUDE_NRF24
-DRADIOLIB_EXCLUDE_RF69
-DRADIOLIB_EXCLUDE_SX1231
-DRADIOLIB_EXCLUDE_SI443X
-DRADIOLIB_EXCLUDE_RFM2X
-DRADIOLIB_EXCLUDE_AFSK
-DRADIOLIB_EXCLUDE_HELLSCHREIBER
-DRADIOLIB_EXCLUDE_MORSE
-DRADIOLIB_EXCLUDE_RTTY
-DRADIOLIB_EXCLUDE_SSTV
monitor_speed = 115200 monitor_speed = 115200

View File

@ -25,22 +25,6 @@ class GPSStatus : public Status
public: public:
GPSStatus() { statusType = STATUS_TYPE_GPS; } GPSStatus() { statusType = STATUS_TYPE_GPS; }
// // proposed for deprecation
// GPSStatus(bool hasLock, bool isConnected, int32_t latitude, int32_t longitude, int32_t altitude, uint32_t dop,
// uint32_t heading, uint32_t numSatellites)
// : Status()
// {
// this->hasLock = hasLock;
// this->isConnected = isConnected;
// this->p.latitude_i = latitude;
// this->p.longitude_i = longitude;
// this->p.altitude = altitude;
// this->p.PDOP = dop;
// this->p.ground_track = heading;
// this->p.sats_in_view = numSatellites;
// }
// preferred method // preferred method
GPSStatus(bool hasLock, bool isConnected, const Position &pos) : Status() GPSStatus(bool hasLock, bool isConnected, const Position &pos) : Status()
{ {

View File

@ -109,7 +109,7 @@ bool NMEAGPS::lookForLocation()
#ifndef TINYGPS_OPTION_NO_CUSTOM_FIELDS #ifndef TINYGPS_OPTION_NO_CUSTOM_FIELDS
fixType = atoi(gsafixtype.value()); // will set to zero if no data fixType = atoi(gsafixtype.value()); // will set to zero if no data
DEBUG_MSG("FIX QUAL=%d, TYPE=%d\n", fixQual, fixType); // DEBUG_MSG("FIX QUAL=%d, TYPE=%d\n", fixQual, fixType);
#endif #endif
// check if GPS has an acceptable lock // check if GPS has an acceptable lock
@ -168,7 +168,7 @@ bool NMEAGPS::lookForLocation()
#ifndef TINYGPS_OPTION_NO_CUSTOM_FIELDS #ifndef TINYGPS_OPTION_NO_CUSTOM_FIELDS
p.HDOP = reader.hdop.value(); p.HDOP = reader.hdop.value();
p.PDOP = TinyGPSPlus::parseDecimal(gsapdop.value()); p.PDOP = TinyGPSPlus::parseDecimal(gsapdop.value());
DEBUG_MSG("PDOP=%d, HDOP=%d\n", dop, reader.hdop.value()); // DEBUG_MSG("PDOP=%d, HDOP=%d\n", p.PDOP, p.HDOP);
#else #else
// FIXME! naive PDOP emulation (assumes VDOP==HDOP) // FIXME! naive PDOP emulation (assumes VDOP==HDOP)
// correct formula is PDOP = SQRT(HDOP^2 + VDOP^2) // correct formula is PDOP = SQRT(HDOP^2 + VDOP^2)

View File

@ -8,6 +8,6 @@ template class SX126xInterface<SX1262>;
template class SX126xInterface<SX1268>; template class SX126xInterface<SX1268>;
template class SX126xInterface<LLCC68>; template class SX126xInterface<LLCC68>;
#if !defined(ARCH_PORTDUINO) #if defined(RADIOLIB_GODMODE)
template class SX128xInterface<SX1280>; template class SX128xInterface<SX1280>;
#endif #endif

View File

@ -204,6 +204,7 @@ void NodeDB::installDefaultModuleConfig()
{ {
DEBUG_MSG("Installing default ModuleConfig\n"); DEBUG_MSG("Installing default ModuleConfig\n");
memset(&moduleConfig, 0, sizeof(ModuleConfig)); memset(&moduleConfig, 0, sizeof(ModuleConfig));
moduleConfig.version = DEVICESTATE_CUR_VER; moduleConfig.version = DEVICESTATE_CUR_VER;
moduleConfig.has_mqtt = true; moduleConfig.has_mqtt = true;
moduleConfig.has_range_test = true; moduleConfig.has_range_test = true;
@ -213,6 +214,10 @@ void NodeDB::installDefaultModuleConfig()
moduleConfig.has_external_notification = true; moduleConfig.has_external_notification = true;
moduleConfig.has_canned_message = true; moduleConfig.has_canned_message = true;
strncpy(moduleConfig.mqtt.address, default_mqtt_address, sizeof(default_mqtt_address));
strncpy(moduleConfig.mqtt.username, default_mqtt_username, sizeof(default_mqtt_username));
strncpy(moduleConfig.mqtt.password, default_mqtt_password, sizeof(default_mqtt_password));
initModuleConfigIntervals(); initModuleConfigIntervals();
} }
@ -741,9 +746,9 @@ void recordCriticalError(CriticalErrorCode code, uint32_t address, const char *f
String lcd = String("Critical error ") + code + "!\n"; String lcd = String("Critical error ") + code + "!\n";
screen->print(lcd.c_str()); screen->print(lcd.c_str());
if (filename) if (filename)
DEBUG_MSG("NOTE! Recording critical error %d at %s:%lx\n", code, filename, address); DEBUG_MSG("NOTE! Recording critical error %d at %s:%lu\n", code, filename, address);
else else
DEBUG_MSG("NOTE! Recording critical error %d, address=%lx\n", code, address); DEBUG_MSG("NOTE! Recording critical error %d, address=0x%lx\n", code, address);
// Record error to DB // Record error to DB
myNodeInfo.error_code = code; myNodeInfo.error_code = code;

View File

@ -194,6 +194,10 @@ extern NodeDB nodeDB;
#define default_min_wake_secs 10 #define default_min_wake_secs 10
#define default_screen_on_secs 60 * 10 #define default_screen_on_secs 60 * 10
#define default_mqtt_address "mqtt.meshtastic.org"
#define default_mqtt_username "meshdev"
#define default_mqtt_password "large4cats"
inline uint32_t getConfiguredOrDefaultMs(uint32_t configuredInterval) inline uint32_t getConfiguredOrDefaultMs(uint32_t configuredInterval)
{ {
if (configuredInterval > 0) return configuredInterval * 1000; if (configuredInterval > 0) return configuredInterval * 1000;

View File

@ -129,6 +129,7 @@ bool RF95Interface::reconfigure()
if (power > MAX_POWER) // This chip has lower power limits than some if (power > MAX_POWER) // This chip has lower power limits than some
power = MAX_POWER; power = MAX_POWER;
err = lora->setOutputPower(power); err = lora->setOutputPower(power);
if (err != RADIOLIB_ERR_NONE) if (err != RADIOLIB_ERR_NONE)
RECORD_CRITICALERROR(CriticalErrorCode_INVALID_RADIO_SETTING); RECORD_CRITICALERROR(CriticalErrorCode_INVALID_RADIO_SETTING);

View File

@ -11,17 +11,6 @@
// FIXME, we default to 4MHz SPI, SPI mode 0, check if the datasheet says it can really do that // FIXME, we default to 4MHz SPI, SPI mode 0, check if the datasheet says it can really do that
static SPISettings spiSettings(4000000, MSBFIRST, SPI_MODE0); static SPISettings spiSettings(4000000, MSBFIRST, SPI_MODE0);
#ifdef ARCH_PORTDUINO
void LockingModule::SPItransfer(uint8_t cmd, uint8_t reg, uint8_t *dataOut, uint8_t *dataIn, uint8_t numBytes)
{
concurrency::LockGuard g(spiLock);
Module::SPItransfer(cmd, reg, dataOut, dataIn, numBytes);
}
#else
void LockingModule::SPIbeginTransaction() void LockingModule::SPIbeginTransaction()
{ {
spiLock->lock(); spiLock->lock();
@ -36,8 +25,6 @@ void LockingModule::SPIendTransaction()
Module::SPIendTransaction(); Module::SPIendTransaction();
} }
#endif
RadioLibInterface::RadioLibInterface(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE busy, RadioLibInterface::RadioLibInterface(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE busy,
SPIClass &spi, PhysicalLayer *_iface) SPIClass &spi, PhysicalLayer *_iface)
: NotifiedWorkerThread("RadioIf"), module(cs, irq, rst, busy, spi, spiSettings), iface(_iface) : NotifiedWorkerThread("RadioIf"), module(cs, irq, rst, busy, spi, spiSettings), iface(_iface)

View File

@ -41,12 +41,8 @@ class LockingModule : public Module
{ {
} }
#ifdef ARCH_PORTDUINO
void SPItransfer(uint8_t cmd, uint8_t reg, uint8_t *dataOut, uint8_t *dataIn, uint8_t numBytes) override;
#else
void SPIbeginTransaction() override; void SPIbeginTransaction() override;
void SPIendTransaction() override; void SPIendTransaction() override;
#endif
}; };
class RadioLibInterface : public RadioInterface, protected concurrency::NotifiedWorkerThread class RadioLibInterface : public RadioInterface, protected concurrency::NotifiedWorkerThread

View File

@ -144,8 +144,9 @@ bool SX126xInterface<T>::reconfigure()
if (err != RADIOLIB_ERR_NONE) if (err != RADIOLIB_ERR_NONE)
RECORD_CRITICALERROR(CriticalErrorCode_INVALID_RADIO_SETTING); RECORD_CRITICALERROR(CriticalErrorCode_INVALID_RADIO_SETTING);
if (power > 22) // This chip has lower power limits than some if (power > SX126X_MAX_POWER) // This chip has lower power limits than some
power = 22; power = SX126X_MAX_POWER;
err = lora.setOutputPower(power); err = lora.setOutputPower(power);
assert(err == RADIOLIB_ERR_NONE); assert(err == RADIOLIB_ERR_NONE);

View File

@ -2,7 +2,7 @@
#include "SX1280Interface.h" #include "SX1280Interface.h"
#include "error.h" #include "error.h"
#if !defined(ARCH_PORTDUINO) #if defined(RADIOLIB_GODMODE)
SX1280Interface::SX1280Interface(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE busy, SX1280Interface::SX1280Interface(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE busy,
SPIClass &spi) SPIClass &spi)

View File

@ -6,7 +6,7 @@
* Our adapter for SX1280 radios * Our adapter for SX1280 radios
*/ */
#if !defined(ARCH_PORTDUINO) #if defined(RADIOLIB_GODMODE)
class SX1280Interface : public SX128xInterface<SX1280> class SX1280Interface : public SX128xInterface<SX1280>
{ {

View File

@ -2,7 +2,7 @@
#include "SX128xInterface.h" #include "SX128xInterface.h"
#include "error.h" #include "error.h"
#if !defined(ARCH_PORTDUINO) #if defined(RADIOLIB_GODMODE)
// Particular boards might define a different max power based on what their hardware can do // Particular boards might define a different max power based on what their hardware can do
#ifndef SX128X_MAX_POWER #ifndef SX128X_MAX_POWER
@ -105,8 +105,9 @@ bool SX128xInterface<T>::reconfigure()
if (err != RADIOLIB_ERR_NONE) if (err != RADIOLIB_ERR_NONE)
RECORD_CRITICALERROR(CriticalErrorCode_INVALID_RADIO_SETTING); RECORD_CRITICALERROR(CriticalErrorCode_INVALID_RADIO_SETTING);
if (power > 22) // This chip has lower power limits than some if (power > SX128X_MAX_POWER) // This chip has lower power limits than some
power = 22; power = SX128X_MAX_POWER;
err = lora.setOutputPower(power); err = lora.setOutputPower(power);
assert(err == RADIOLIB_ERR_NONE); assert(err == RADIOLIB_ERR_NONE);
@ -218,7 +219,11 @@ bool SX128xInterface<T>::isChannelActive()
template<typename T> template<typename T>
bool SX128xInterface<T>::isActivelyReceiving() bool SX128xInterface<T>::isActivelyReceiving()
{ {
return isChannelActive(); // return isChannelActive();
uint16_t irq = lora.getIrqStatus();
bool hasPreamble = (irq & RADIOLIB_SX128X_IRQ_HEADER_VALID);
return hasPreamble;
} }
template<typename T> template<typename T>

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#if !defined(ARCH_PORTDUINO) #if defined(RADIOLIB_GODMODE)
#include "RadioLibInterface.h" #include "RadioLibInterface.h"

View File

@ -35,32 +35,34 @@ char ourHost[16];
bool APStartupComplete = 0; bool APStartupComplete = 0;
unsigned long lastrun_ntp = 0;
static bool needReconnect = true; // If we create our reconnector, run it once at the beginning static bool needReconnect = true; // If we create our reconnector, run it once at the beginning
static Periodic *wifiReconnect;
static int32_t reconnectWiFi() static int32_t reconnectWiFi()
{ {
const char *wifiName = config.network.wifi_ssid; const char *wifiName = config.network.wifi_ssid;
const char *wifiPsw = config.network.wifi_psk; const char *wifiPsw = config.network.wifi_psk;
if (config.network.wifi_enabled && needReconnect && !WiFi.isConnected()) { if (config.network.wifi_enabled && needReconnect) {
if (!*wifiPsw) // Treat empty password as no password if (!*wifiPsw) // Treat empty password as no password
wifiPsw = NULL; wifiPsw = NULL;
if (*wifiName) { needReconnect = false;
needReconnect = false;
// Make sure we clear old connection credentials // Make sure we clear old connection credentials
WiFi.disconnect(false, true); WiFi.disconnect(false, true);
DEBUG_MSG("... Reconnecting to WiFi access point\n"); DEBUG_MSG("... Reconnecting to WiFi access point\n");
WiFi.mode(WIFI_MODE_STA); WiFi.mode(WIFI_MODE_STA);
WiFi.begin(wifiName, wifiPsw); WiFi.begin(wifiName, wifiPsw);
}
} }
#ifndef DISABLE_NTP #ifndef DISABLE_NTP
if (WiFi.isConnected()) { if (WiFi.isConnected() && ((millis() - lastrun_ntp) > 43200000)) { // every 12 hours
DEBUG_MSG("Updating NTP time\n"); DEBUG_MSG("Updating NTP time\n");
if (timeClient.update()) { if (timeClient.update()) {
DEBUG_MSG("NTP Request Success - Setting RTCQualityNTP if needed\n"); DEBUG_MSG("NTP Request Success - Setting RTCQualityNTP if needed\n");
@ -70,6 +72,7 @@ static int32_t reconnectWiFi()
tv.tv_usec = 0; tv.tv_usec = 0;
perhapsSetRTC(RTCQualityNTP, &tv); perhapsSetRTC(RTCQualityNTP, &tv);
lastrun_ntp = millis();
} else { } else {
DEBUG_MSG("NTP Update failed\n"); DEBUG_MSG("NTP Update failed\n");
@ -77,11 +80,13 @@ static int32_t reconnectWiFi()
} }
#endif #endif
return 43200 * 1000; // every 12 hours if (config.network.wifi_enabled && !WiFi.isConnected()) {
return 1000; // check once per second
} else {
return 300000; // every 5 minutes
}
} }
static Periodic *wifiReconnect;
bool isWifiAvailable() bool isWifiAvailable()
{ {
@ -95,20 +100,10 @@ bool isWifiAvailable()
// Disable WiFi // Disable WiFi
void deinitWifi() void deinitWifi()
{ {
/*
Note from Jm (jm@casler.org - Sept 16, 2020):
A bug in the ESP32 SDK was introduced in Oct 2019 that keeps the WiFi radio from
turning back on after it's shut off. See:
https://github.com/espressif/arduino-esp32/issues/3522
Until then, WiFi should only be allowed when there's no power
saving on the 2.4g transceiver.
*/
DEBUG_MSG("WiFi deinit\n"); DEBUG_MSG("WiFi deinit\n");
if (isWifiAvailable()) { if (isWifiAvailable()) {
WiFi.disconnect(true);
WiFi.mode(WIFI_MODE_NULL); WiFi.mode(WIFI_MODE_NULL);
DEBUG_MSG("WiFi Turned Off\n"); DEBUG_MSG("WiFi Turned Off\n");
// WiFi.printDiag(Serial); // WiFi.printDiag(Serial);
@ -169,7 +164,7 @@ bool initWifi()
WiFi.mode(WIFI_MODE_STA); WiFi.mode(WIFI_MODE_STA);
WiFi.setHostname(ourHost); WiFi.setHostname(ourHost);
WiFi.onEvent(WiFiEvent); WiFi.onEvent(WiFiEvent);
WiFi.setAutoReconnect(true); WiFi.setAutoReconnect(false);
WiFi.setSleep(false); WiFi.setSleep(false);
if (config.network.eth_mode == Config_NetworkConfig_EthMode_STATIC && config.network.ipv4_config.ip != 0) { if (config.network.eth_mode == Config_NetworkConfig_EthMode_STATIC && config.network.ipv4_config.ip != 0) {
WiFi.config(config.network.ipv4_config.ip, WiFi.config(config.network.ipv4_config.ip,
@ -231,7 +226,9 @@ static void WiFiEvent(WiFiEvent_t event)
break; break;
case SYSTEM_EVENT_STA_DISCONNECTED: case SYSTEM_EVENT_STA_DISCONNECTED:
DEBUG_MSG("Disconnected from WiFi access point\n"); DEBUG_MSG("Disconnected from WiFi access point\n");
WiFi.disconnect(false, true);
needReconnect = true; needReconnect = true;
wifiReconnect->setIntervalFromNow(1000);
break; break;
case SYSTEM_EVENT_STA_AUTHMODE_CHANGE: case SYSTEM_EVENT_STA_AUTHMODE_CHANGE:
DEBUG_MSG("Authentication mode of access point has changed\n"); DEBUG_MSG("Authentication mode of access point has changed\n");
@ -243,7 +240,9 @@ static void WiFiEvent(WiFiEvent_t event)
break; break;
case SYSTEM_EVENT_STA_LOST_IP: case SYSTEM_EVENT_STA_LOST_IP:
DEBUG_MSG("Lost IP address and IP address is reset to 0\n"); DEBUG_MSG("Lost IP address and IP address is reset to 0\n");
WiFi.disconnect(false, true);
needReconnect = true; needReconnect = true;
wifiReconnect->setIntervalFromNow(1000);
break; break;
case SYSTEM_EVENT_STA_WPS_ER_SUCCESS: case SYSTEM_EVENT_STA_WPS_ER_SUCCESS:
DEBUG_MSG("WiFi Protected Setup (WPS): succeeded in enrollee mode\n"); DEBUG_MSG("WiFi Protected Setup (WPS): succeeded in enrollee mode\n");
@ -259,7 +258,6 @@ static void WiFiEvent(WiFiEvent_t event)
break; break;
case SYSTEM_EVENT_AP_START: case SYSTEM_EVENT_AP_START:
DEBUG_MSG("WiFi access point started\n"); DEBUG_MSG("WiFi access point started\n");
onNetworkConnected();
break; break;
case SYSTEM_EVENT_AP_STOP: case SYSTEM_EVENT_AP_STOP:
DEBUG_MSG("WiFi access point stopped\n"); DEBUG_MSG("WiFi access point stopped\n");

View File

@ -176,7 +176,7 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event)
DEBUG_MSG("Canned message event Matrix key pressed\n"); DEBUG_MSG("Canned message event Matrix key pressed\n");
// this will send the text immediately on matrix press // this will send the text immediately on matrix press
this->runState = CANNED_MESSAGE_RUN_STATE_ACTION_SELECT; this->runState = CANNED_MESSAGE_RUN_STATE_ACTION_SELECT;
this->payload = event->kbchar; this->payload = MATRIXKEY;
this->currentMessageIndex = event->kbchar -1; this->currentMessageIndex = event->kbchar -1;
this->lastTouchMillis = millis(); this->lastTouchMillis = millis();
validEvent = true; validEvent = true;
@ -246,7 +246,12 @@ int32_t CannedMessageModule::runOnce()
} }
} else { } else {
if ((this->messagesCount > this->currentMessageIndex) && (strlen(this->messages[this->currentMessageIndex]) > 0)) { if ((this->messagesCount > this->currentMessageIndex) && (strlen(this->messages[this->currentMessageIndex]) > 0)) {
sendText(NODENUM_BROADCAST, this->messages[this->currentMessageIndex], true); if(strcmp (this->messages[this->currentMessageIndex], "~") == 0) {
powerFSM.trigger(EVENT_PRESS);
return INT32_MAX;
} else {
sendText(NODENUM_BROADCAST, this->messages[this->currentMessageIndex], true);
}
this->runState = CANNED_MESSAGE_RUN_STATE_SENDING_ACTIVE; this->runState = CANNED_MESSAGE_RUN_STATE_SENDING_ACTIVE;
} else { } else {
DEBUG_MSG("Reset message is empty.\n"); DEBUG_MSG("Reset message is empty.\n");

View File

@ -118,24 +118,16 @@ bool MQTT::connected()
void MQTT::reconnect() void MQTT::reconnect()
{ {
if (wantsLink()) { if (wantsLink()) {
const char *serverAddr = "mqtt.meshtastic.org"; // default hostname // Defaults
int serverPort = 1883; // default server port int serverPort = 1883;
const char *mqttUsername = "meshdev"; const char *serverAddr = default_mqtt_address;
const char *mqttPassword = "large4cats"; const char *mqttUsername = default_mqtt_username;
const char *mqttPassword = default_mqtt_password;
if (*moduleConfig.mqtt.address) { if (*moduleConfig.mqtt.address) {
serverAddr = moduleConfig.mqtt.address; // Override the default serverAddr = moduleConfig.mqtt.address;
mqttUsername = mqttUsername = moduleConfig.mqtt.username;
moduleConfig.mqtt.username; // do not use the hardcoded credentials for a custom mqtt server
mqttPassword = moduleConfig.mqtt.password; mqttPassword = moduleConfig.mqtt.password;
} else {
// we are using the default server. Use the hardcoded credentials by default, but allow overriding
if (*moduleConfig.mqtt.username && moduleConfig.mqtt.username[0] != '\0') {
mqttUsername = moduleConfig.mqtt.username;
}
if (*moduleConfig.mqtt.password && moduleConfig.mqtt.password[0] != '\0') {
mqttPassword = moduleConfig.mqtt.password;
}
} }
String server = String(serverAddr); String server = String(serverAddr);
@ -148,8 +140,7 @@ void MQTT::reconnect()
} }
pubSub.setServer(serverAddr, serverPort); pubSub.setServer(serverAddr, serverPort);
DEBUG_MSG("Connecting to MQTT server %s, port: %d, username: %s, password: %s\n", serverAddr, serverPort, mqttUsername, DEBUG_MSG("Connecting to MQTT server %s, port: %d, username: %s, password: %s\n", serverAddr, serverPort, mqttUsername, mqttPassword);
mqttPassword);
auto myStatus = (statusTopic + owner.id); auto myStatus = (statusTopic + owner.id);
bool connected = pubSub.connect(owner.id, mqttUsername, mqttPassword, myStatus.c_str(), 1, true, "offline"); bool connected = pubSub.connect(owner.id, mqttUsername, mqttPassword, myStatus.c_str(), 1, true, "offline");
if (connected) { if (connected) {
@ -176,9 +167,11 @@ void MQTT::sendSubscriptions()
String topic = cryptTopic + channels.getGlobalId(i) + "/#"; String topic = cryptTopic + channels.getGlobalId(i) + "/#";
DEBUG_MSG("Subscribing to %s\n", topic.c_str()); DEBUG_MSG("Subscribing to %s\n", topic.c_str());
pubSub.subscribe(topic.c_str(), 1); // FIXME, is QOS 1 right? pubSub.subscribe(topic.c_str(), 1); // FIXME, is QOS 1 right?
String topicDecoded = jsonTopic + channels.getGlobalId(i) + "/#"; if (moduleConfig.mqtt.json_enabled == true) {
DEBUG_MSG("Subscribing to %s\n", topicDecoded.c_str()); String topicDecoded = jsonTopic + channels.getGlobalId(i) + "/#";
pubSub.subscribe(topicDecoded.c_str(), 1); // FIXME, is QOS 1 right? DEBUG_MSG("Subscribing to %s\n", topicDecoded.c_str());
pubSub.subscribe(topicDecoded.c_str(), 1); // FIXME, is QOS 1 right?
}
} }
} }
} }

View File

@ -1,16 +1,22 @@
[env:native] [env:native]
platform = https://github.com/meshtastic/platform-native.git extends = portduino_base
build_flags = ${portduino_base.build_flags} -O0 -I variants/portduino build_flags = ${portduino_base.build_flags} -O0 -I variants/portduino
framework = arduino
board = cross_platform board = cross_platform
lib_deps = ${portduino_base.lib_deps} lib_deps = ${portduino_base.lib_deps}
build_src_filter = ${portduino_base.build_src_filter} build_src_filter = ${portduino_base.build_src_filter}
; The Portduino based sim environment on top of a linux OS and touching linux hardware devices ; The Portduino based sim environment on top of a linux OS and touching linux hardware devices
[env:linux] [env:linux]
platform = https://github.com/meshtastic/platform-native.git extends = portduino_base
build_flags = ${portduino_base.build_flags} -O0 -lgpiod -I variants/portduino build_flags = ${portduino_base.build_flags} -O0 -lgpiod -I variants/portduino
framework = arduino
board = linux_hardware board = linux_hardware
lib_deps = ${portduino_base.lib_deps} lib_deps = ${portduino_base.lib_deps}
build_src_filter = ${portduino_base.build_src_filter} build_src_filter = ${portduino_base.build_src_filter}
; The Portduino based sim environment on top of a linux OS and touching linux hardware devices
[env:linux-arm]
extends = portduino_base
build_flags = ${portduino_base.build_flags} -O0 -lgpiod -I variants/portduino
board = linux_arm
lib_deps = ${portduino_base.lib_deps}
build_src_filter = ${portduino_base.build_src_filter}

View File

@ -23,16 +23,3 @@
// HOPE RFM90 does not have a TCXO therefore not SX126X_E22 // HOPE RFM90 does not have a TCXO therefore not SX126X_E22
#endif #endif
// Temporary shim for radio lib macros until we upgrade to upstream for portduino
#define RADIOLIB_PREAMBLE_DETECTED PREAMBLE_DETECTED
#define RADIOLIB_ERR_NONE ERR_NONE
#define RADIOLIB_ERR_WRONG_MODEM ERR_WRONG_MODEM
#define RADIOLIB_SX126X_IRQ_HEADER_VALID SX126X_IRQ_HEADER_VALID
#define RADIOLIB_SX126X_LORA_CRC_ON SX126X_LORA_CRC_ON
#define RADIOLIB_SX127X_REG_TCXO SX127X_REG_TCXO
#define RADIOLIB_SX127X_REG_MODEM_STAT SX127X_REG_MODEM_STAT
#define RADIOLIB_SX127X_SYNC_WORD SX127X_SYNC_WORD
#define RADIOLIB_SX127X_MASK_IRQ_FLAG_VALID_HEADER SX127X_MASK_IRQ_FLAG_VALID_HEADER

View File

@ -6,7 +6,7 @@
#define RESET_OLED 16 // If defined, this pin will be used to reset the display controller #define RESET_OLED 16 // If defined, this pin will be used to reset the display controller
// #define VEXT_ENABLE 21 // active low, powers the oled display and the lora antenna boost #define VEXT_ENABLE 21 // active low, powers the oled display and the lora antenna boost
#define LED_PIN 2 // If defined we will blink this LED #define LED_PIN 2 // If defined we will blink this LED
#define BUTTON_PIN 0 // If defined, this will be used for user button presses #define BUTTON_PIN 0 // If defined, this will be used for user button presses
#define BUTTON_NEED_PULLUP #define BUTTON_NEED_PULLUP

View File

@ -5,4 +5,4 @@ lib_deps =
${esp32_base.lib_deps} ${esp32_base.lib_deps}
caveman99/ESP32 Codec2@^1.0.1 caveman99/ESP32 Codec2@^1.0.1
build_flags = build_flags =
${esp32_base.build_flags} -D TLORA_V2_1_18 -I variants/tlora_v2_1_18 ${esp32_base.build_flags} -D TLORA_V2_1_18 -I variants/tlora_v2_1_18 -D RADIOLIB_GODMODE