mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-18 02:52:05 +00:00
Merge branch 'master' into 2264-feature-check-for-low-heap-before-adding-to-nodedb-was-reboot-loop-heap-too-low
This commit is contained in:
commit
4b89f7dfcb
1
.github/workflows/main_matrix.yml
vendored
1
.github/workflows/main_matrix.yml
vendored
@ -42,6 +42,7 @@ jobs:
|
||||
uses: ./.github/actions/setup-base
|
||||
|
||||
- name: Trunk Check
|
||||
if: ${{ github.event_name != 'workflow_dispatch' }}
|
||||
uses: trunk-io/trunk-action@v1
|
||||
|
||||
- name: Check ${{ matrix.board }}
|
||||
|
@ -1,5 +1 @@
|
||||
cd protobufs && ..\nanopb-0.4.7\generator-bin\protoc.exe --nanopb_out=-v:..\src\mesh\generated -I=..\protobufs ..\protobufs\meshtastic\*.proto
|
||||
|
||||
@REM cd ../src/mesh/generated/meshtastic
|
||||
@REM sed -i 's/#include "meshtastic/#include "./g' *
|
||||
@REM sed -i 's/meshtastic_//g' *
|
||||
cd protobufs && ..\nanopb-0.4.7\generator-bin\protoc.exe --experimental_allow_proto3_optional --nanopb_out=-v:..\src\mesh\generated -I=..\protobufs ..\protobufs\meshtastic\*.proto
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 641d7c3a460de9cc580bc2b8a0812e8b9d417b05
|
||||
Subproject commit 5f00ad5691ae7d8a03fd92437b81e9a424e3483f
|
@ -93,18 +93,23 @@ static void lsIdle()
|
||||
powerFSM.trigger(EVENT_SERIAL_CONNECTED);
|
||||
break;
|
||||
|
||||
case ESP_SLEEP_WAKEUP_GPIO:
|
||||
// GPIO of BUTTON_PIN (if available) triggered the wakeup
|
||||
powerFSM.trigger(EVENT_PRESS);
|
||||
break;
|
||||
|
||||
default:
|
||||
// We woke for some other reason (device interrupt)
|
||||
// We woke for some other reason (button press, device interrupt)
|
||||
// uint64_t status = esp_sleep_get_ext1_wakeup_status();
|
||||
LOG_INFO("wakeCause2 %d\n", wakeCause2);
|
||||
// Let the NB state handle the IRQ (and that state will handle stuff like IRQs etc)
|
||||
|
||||
#ifdef BUTTON_PIN
|
||||
bool pressed = !digitalRead(BUTTON_PIN);
|
||||
#else
|
||||
bool pressed = false;
|
||||
#endif
|
||||
if (pressed) { // If we woke because of press, instead generate a PRESS event.
|
||||
powerFSM.trigger(EVENT_PRESS);
|
||||
} else {
|
||||
// Otherwise let the NB state handle the IRQ (and that state will handle stuff like IRQs etc)
|
||||
// we lie and say "wake timer" because the interrupt will be handled by the regular IRQ code
|
||||
powerFSM.trigger(EVENT_WAKE_TIMER);
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
@ -31,11 +31,9 @@ typedef enum _meshtastic_Channel_Role {
|
||||
|
||||
/* Struct definitions */
|
||||
typedef PB_BYTES_ARRAY_T(32) meshtastic_ChannelSettings_psk_t;
|
||||
/* Full settings (center freq, spread factor, pre-shared secret key etc...)
|
||||
needed to configure a radio for speaking on a particular channel This
|
||||
information can be encoded as a QRcode/url so that other users can configure
|
||||
/* This information can be encoded as a QRcode/url so that other users can configure
|
||||
their radio to join the same channel.
|
||||
A note about how channel names are shown to users: channelname-Xy
|
||||
A note about how channel names are shown to users: channelname-X
|
||||
poundsymbol is a prefix used to indicate this is a channel name (idea from @professr).
|
||||
Where X is a letter from A-Z (base 26) representing a hash of the PSK for this
|
||||
channel - so that if the user changes anything about the channel (which does
|
||||
@ -45,8 +43,6 @@ typedef PB_BYTES_ARRAY_T(32) meshtastic_ChannelSettings_psk_t;
|
||||
The PSK is hashed into this letter by "0x41 + [xor all bytes of the psk ] modulo 26"
|
||||
This also allows the option of someday if people have the PSK off (zero), the
|
||||
users COULD type in a channel name and be able to talk.
|
||||
Y is a lower case letter from a-z that represents the channel 'speed' settings
|
||||
(for some future definition of speed)
|
||||
FIXME: Add description of multi-channel support and how primary vs secondary channels are used.
|
||||
FIXME: explain how apps use channels for security.
|
||||
explain how remote settings and remote gpio are managed as an example */
|
||||
@ -60,7 +56,7 @@ typedef struct _meshtastic_ChannelSettings {
|
||||
because they are listed in this source code.
|
||||
Those bytes are mapped using the following scheme:
|
||||
`0` = No crypto
|
||||
`1` = The special "default" channel key: {0xd4, 0xf1, 0xbb, 0x3a, 0x20, 0x29, 0x07, 0x59, 0xf0, 0xbc, 0xff, 0xab, 0xcf, 0x4e, 0x69, 0xbf}
|
||||
`1` = The special "default" channel key: {0xd4, 0xf1, 0xbb, 0x3a, 0x20, 0x29, 0x07, 0x59, 0xf0, 0xbc, 0xff, 0xab, 0xcf, 0x4e, 0x69, 0x01}
|
||||
`2` through 10 = The default channel key, except with 1 through 9 added to the last byte.
|
||||
Shown to user as simple1 through 10 */
|
||||
meshtastic_ChannelSettings_psk_t psk;
|
||||
|
@ -188,7 +188,7 @@ extern const pb_msgdesc_t meshtastic_OEMStore_msg;
|
||||
/* Maximum encoded size of messages (where known) */
|
||||
#define meshtastic_ChannelFile_size 638
|
||||
#define meshtastic_DeviceState_size 22040
|
||||
#define meshtastic_OEMStore_size 3024
|
||||
#define meshtastic_OEMStore_size 3041
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
@ -157,7 +157,7 @@ extern const pb_msgdesc_t meshtastic_LocalModuleConfig_msg;
|
||||
|
||||
/* Maximum encoded size of messages (where known) */
|
||||
#define meshtastic_LocalConfig_size 456
|
||||
#define meshtastic_LocalModuleConfig_size 422
|
||||
#define meshtastic_LocalModuleConfig_size 439
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
@ -98,6 +98,9 @@ typedef struct _meshtastic_ModuleConfig_MQTTConfig {
|
||||
bool json_enabled;
|
||||
/* If true, we attempt to establish a secure connection using TLS */
|
||||
bool tls_enabled;
|
||||
/* The root topic to use for MQTT messages. Default is "msh".
|
||||
This is useful if you want to use a single MQTT server for multiple meshtastic networks and separate them via ACLs */
|
||||
char root[16];
|
||||
} meshtastic_ModuleConfig_MQTTConfig;
|
||||
|
||||
/* RemoteHardwareModule Config */
|
||||
@ -325,7 +328,7 @@ extern "C" {
|
||||
|
||||
/* Initializer values for message structs */
|
||||
#define meshtastic_ModuleConfig_init_default {0, {meshtastic_ModuleConfig_MQTTConfig_init_default}}
|
||||
#define meshtastic_ModuleConfig_MQTTConfig_init_default {0, "", "", "", 0, 0, 0}
|
||||
#define meshtastic_ModuleConfig_MQTTConfig_init_default {0, "", "", "", 0, 0, 0, ""}
|
||||
#define meshtastic_ModuleConfig_RemoteHardwareConfig_init_default {0}
|
||||
#define meshtastic_ModuleConfig_AudioConfig_init_default {0, 0, _meshtastic_ModuleConfig_AudioConfig_Audio_Baud_MIN, 0, 0, 0, 0}
|
||||
#define meshtastic_ModuleConfig_SerialConfig_init_default {0, 0, 0, 0, _meshtastic_ModuleConfig_SerialConfig_Serial_Baud_MIN, 0, _meshtastic_ModuleConfig_SerialConfig_Serial_Mode_MIN}
|
||||
@ -335,7 +338,7 @@ extern "C" {
|
||||
#define meshtastic_ModuleConfig_TelemetryConfig_init_default {0, 0, 0, 0, 0, 0, 0}
|
||||
#define meshtastic_ModuleConfig_CannedMessageConfig_init_default {0, 0, 0, 0, _meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_MIN, _meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_MIN, _meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_MIN, 0, 0, "", 0}
|
||||
#define meshtastic_ModuleConfig_init_zero {0, {meshtastic_ModuleConfig_MQTTConfig_init_zero}}
|
||||
#define meshtastic_ModuleConfig_MQTTConfig_init_zero {0, "", "", "", 0, 0, 0}
|
||||
#define meshtastic_ModuleConfig_MQTTConfig_init_zero {0, "", "", "", 0, 0, 0, ""}
|
||||
#define meshtastic_ModuleConfig_RemoteHardwareConfig_init_zero {0}
|
||||
#define meshtastic_ModuleConfig_AudioConfig_init_zero {0, 0, _meshtastic_ModuleConfig_AudioConfig_Audio_Baud_MIN, 0, 0, 0, 0}
|
||||
#define meshtastic_ModuleConfig_SerialConfig_init_zero {0, 0, 0, 0, _meshtastic_ModuleConfig_SerialConfig_Serial_Baud_MIN, 0, _meshtastic_ModuleConfig_SerialConfig_Serial_Mode_MIN}
|
||||
@ -353,6 +356,7 @@ extern "C" {
|
||||
#define meshtastic_ModuleConfig_MQTTConfig_encryption_enabled_tag 5
|
||||
#define meshtastic_ModuleConfig_MQTTConfig_json_enabled_tag 6
|
||||
#define meshtastic_ModuleConfig_MQTTConfig_tls_enabled_tag 7
|
||||
#define meshtastic_ModuleConfig_MQTTConfig_root_tag 8
|
||||
#define meshtastic_ModuleConfig_RemoteHardwareConfig_enabled_tag 1
|
||||
#define meshtastic_ModuleConfig_AudioConfig_codec2_enabled_tag 1
|
||||
#define meshtastic_ModuleConfig_AudioConfig_ptt_pin_tag 2
|
||||
@ -448,7 +452,8 @@ X(a, STATIC, SINGULAR, STRING, username, 3) \
|
||||
X(a, STATIC, SINGULAR, STRING, password, 4) \
|
||||
X(a, STATIC, SINGULAR, BOOL, encryption_enabled, 5) \
|
||||
X(a, STATIC, SINGULAR, BOOL, json_enabled, 6) \
|
||||
X(a, STATIC, SINGULAR, BOOL, tls_enabled, 7)
|
||||
X(a, STATIC, SINGULAR, BOOL, tls_enabled, 7) \
|
||||
X(a, STATIC, SINGULAR, STRING, root, 8)
|
||||
#define meshtastic_ModuleConfig_MQTTConfig_CALLBACK NULL
|
||||
#define meshtastic_ModuleConfig_MQTTConfig_DEFAULT NULL
|
||||
|
||||
@ -566,13 +571,13 @@ extern const pb_msgdesc_t meshtastic_ModuleConfig_CannedMessageConfig_msg;
|
||||
#define meshtastic_ModuleConfig_AudioConfig_size 19
|
||||
#define meshtastic_ModuleConfig_CannedMessageConfig_size 49
|
||||
#define meshtastic_ModuleConfig_ExternalNotificationConfig_size 40
|
||||
#define meshtastic_ModuleConfig_MQTTConfig_size 203
|
||||
#define meshtastic_ModuleConfig_MQTTConfig_size 220
|
||||
#define meshtastic_ModuleConfig_RangeTestConfig_size 10
|
||||
#define meshtastic_ModuleConfig_RemoteHardwareConfig_size 2
|
||||
#define meshtastic_ModuleConfig_SerialConfig_size 26
|
||||
#define meshtastic_ModuleConfig_StoreForwardConfig_size 22
|
||||
#define meshtastic_ModuleConfig_TelemetryConfig_size 26
|
||||
#define meshtastic_ModuleConfig_size 206
|
||||
#define meshtastic_ModuleConfig_size 223
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
@ -19,9 +19,9 @@ const int reconnectMax = 5;
|
||||
|
||||
MQTT *mqtt;
|
||||
|
||||
std::string statusTopic = "msh/2/stat/";
|
||||
std::string cryptTopic = "msh/2/c/"; // msh/2/c/CHANNELID/NODEID
|
||||
std::string jsonTopic = "msh/2/json/"; // msh/2/json/CHANNELID/NODEID
|
||||
std::string statusTopic = "/2/stat/";
|
||||
std::string cryptTopic = "/2/c/"; // msh/2/c/CHANNELID/NODEID
|
||||
std::string jsonTopic = "/2/json/"; // msh/2/json/CHANNELID/NODEID
|
||||
|
||||
static MemoryDynamic<meshtastic_ServiceEnvelope> staticMqttPool;
|
||||
|
||||
@ -164,6 +164,16 @@ MQTT::MQTT() : concurrency::OSThread("mqtt"), pubSub(mqttClient), mqttQueue(MAX_
|
||||
assert(!mqtt);
|
||||
mqtt = this;
|
||||
|
||||
if (moduleConfig.mqtt.root) {
|
||||
statusTopic = moduleConfig.mqtt.root + statusTopic;
|
||||
cryptTopic = moduleConfig.mqtt.root + cryptTopic;
|
||||
jsonTopic = moduleConfig.mqtt.root + jsonTopic;
|
||||
} else {
|
||||
statusTopic = "msh" + statusTopic;
|
||||
cryptTopic = "msh" + cryptTopic;
|
||||
jsonTopic = "msh" + jsonTopic;
|
||||
}
|
||||
|
||||
pubSub.setCallback(mqttCallback);
|
||||
|
||||
// preflightSleepObserver.observe(&preflightSleep);
|
||||
@ -192,6 +202,26 @@ void MQTT::reconnect()
|
||||
mqttPassword = moduleConfig.mqtt.password;
|
||||
}
|
||||
|
||||
#if HAS_WIFI && !defined(ARCH_PORTDUINO)
|
||||
if (moduleConfig.mqtt.tls_enabled) {
|
||||
// change default for encrypted to 8883
|
||||
try {
|
||||
serverPort = 8883;
|
||||
wifiSecureClient.setInsecure();
|
||||
|
||||
pubSub.setClient(wifiSecureClient);
|
||||
LOG_INFO("Using TLS-encrypted session\n");
|
||||
} catch (const std::exception &e) {
|
||||
LOG_ERROR("MQTT ERROR: %s\n", e.what());
|
||||
}
|
||||
} else {
|
||||
LOG_INFO("Using non-TLS-encrypted session\n");
|
||||
pubSub.setClient(mqttClient);
|
||||
}
|
||||
#else
|
||||
pubSub.setClient(mqttClient);
|
||||
#endif
|
||||
|
||||
String server = String(serverAddr);
|
||||
int delimIndex = server.indexOf(':');
|
||||
if (delimIndex > 0) {
|
||||
|
@ -8,6 +8,9 @@
|
||||
#include <PubSubClient.h>
|
||||
#if HAS_WIFI
|
||||
#include <WiFiClient.h>
|
||||
#if !defined(ARCH_PORTDUINO)
|
||||
#include <WiFiClientSecure.h>
|
||||
#endif
|
||||
#endif
|
||||
#if HAS_ETHERNET
|
||||
#include <EthernetClient.h>
|
||||
@ -23,9 +26,11 @@ class MQTT : private concurrency::OSThread
|
||||
{
|
||||
// supposedly the current version is busted:
|
||||
// http://www.iotsharing.com/2017/08/how-to-use-esp32-mqtts-with-mqtts-mosquitto-broker-tls-ssl.html
|
||||
// WiFiClientSecure wifiClient;
|
||||
#if HAS_WIFI
|
||||
WiFiClient mqttClient;
|
||||
#if !defined(ARCH_PORTDUINO)
|
||||
WiFiClientSecure wifiSecureClient;
|
||||
#endif
|
||||
#endif
|
||||
#if HAS_ETHERNET
|
||||
EthernetClient mqttClient;
|
||||
|
@ -1,4 +1,4 @@
|
||||
[VERSION]
|
||||
major = 2
|
||||
minor = 1
|
||||
build = 7
|
||||
build = 8
|
||||
|
Loading…
Reference in New Issue
Block a user