This commit is contained in:
Ben Meadors 2023-02-02 14:05:58 -06:00
parent 3c6bbff4f9
commit e8e04d23d7
9 changed files with 387 additions and 75 deletions

View File

@ -2,7 +2,7 @@
; https://docs.platformio.org/page/projectconf.html
[platformio]
;default_envs = tbeam
default_envs = tbeam
;default_envs = pico
;default_envs = tbeam-s3-core
;default_envs = tbeam0.7

@ -1 +1 @@
Subproject commit b9953ff48b81a06e062e35ff3c2ea6de862ee144
Subproject commit 4ef7e46a8b83d4d2147f027c7aaa7d1b481f8688

View File

@ -9,6 +9,7 @@
#include "meshtastic/device_metadata.pb.h"
#include "meshtastic/mesh.pb.h"
#include "meshtastic/module_config.pb.h"
#include "meshtastic/connection_status.pb.h"
#if PB_PROTO_HEADER_VERSION != 40
#error Regenerate this file with the current version of nanopb generator.
@ -91,6 +92,10 @@ typedef struct _meshtastic_AdminMessage {
bool get_ringtone_request;
/* Get the Ringtone in the response to this message. */
char get_ringtone_response[231];
/* Request the node to send it's connection status */
bool get_device_connection_status_request;
/* Device connection status response */
meshtastic_DeviceConnectionStatus get_device_connection_status_response;
/* Set the owner for this node */
meshtastic_User set_owner;
/* Set channels (using the new API).
@ -166,6 +171,8 @@ extern "C" {
#define meshtastic_AdminMessage_get_device_metadata_response_tag 13
#define meshtastic_AdminMessage_get_ringtone_request_tag 14
#define meshtastic_AdminMessage_get_ringtone_response_tag 15
#define meshtastic_AdminMessage_get_device_connection_status_request_tag 16
#define meshtastic_AdminMessage_get_device_connection_status_response_tag 17
#define meshtastic_AdminMessage_set_owner_tag 32
#define meshtastic_AdminMessage_set_channel_tag 33
#define meshtastic_AdminMessage_set_config_tag 34
@ -197,6 +204,8 @@ X(a, STATIC, ONEOF, BOOL, (payload_variant,get_device_metadata_request,
X(a, STATIC, ONEOF, MESSAGE, (payload_variant,get_device_metadata_response,get_device_metadata_response), 13) \
X(a, STATIC, ONEOF, BOOL, (payload_variant,get_ringtone_request,get_ringtone_request), 14) \
X(a, STATIC, ONEOF, STRING, (payload_variant,get_ringtone_response,get_ringtone_response), 15) \
X(a, STATIC, ONEOF, BOOL, (payload_variant,get_device_connection_status_request,get_device_connection_status_request), 16) \
X(a, STATIC, ONEOF, MESSAGE, (payload_variant,get_device_connection_status_response,get_device_connection_status_response), 17) \
X(a, STATIC, ONEOF, MESSAGE, (payload_variant,set_owner,set_owner), 32) \
X(a, STATIC, ONEOF, MESSAGE, (payload_variant,set_channel,set_channel), 33) \
X(a, STATIC, ONEOF, MESSAGE, (payload_variant,set_config,set_config), 34) \
@ -218,6 +227,7 @@ X(a, STATIC, ONEOF, INT32, (payload_variant,nodedb_reset,nodedb_reset),
#define meshtastic_AdminMessage_payload_variant_get_config_response_MSGTYPE meshtastic_Config
#define meshtastic_AdminMessage_payload_variant_get_module_config_response_MSGTYPE meshtastic_ModuleConfig
#define meshtastic_AdminMessage_payload_variant_get_device_metadata_response_MSGTYPE meshtastic_DeviceMetadata
#define meshtastic_AdminMessage_payload_variant_get_device_connection_status_response_MSGTYPE meshtastic_DeviceConnectionStatus
#define meshtastic_AdminMessage_payload_variant_set_owner_MSGTYPE meshtastic_User
#define meshtastic_AdminMessage_payload_variant_set_channel_MSGTYPE meshtastic_Channel
#define meshtastic_AdminMessage_payload_variant_set_config_MSGTYPE meshtastic_Config

View File

@ -0,0 +1,27 @@
/* Automatically generated nanopb constant definitions */
/* Generated by nanopb-0.4.7 */
#include "meshtastic/connection_status.pb.h"
#if PB_PROTO_HEADER_VERSION != 40
#error Regenerate this file with the current version of nanopb generator.
#endif
PB_BIND(meshtastic_DeviceConnectionStatus, meshtastic_DeviceConnectionStatus, AUTO)
PB_BIND(meshtastic_WifiConnectionStatus, meshtastic_WifiConnectionStatus, AUTO)
PB_BIND(meshtastic_EthernetConnectionStatus, meshtastic_EthernetConnectionStatus, AUTO)
PB_BIND(meshtastic_NetworkConnectionStatus, meshtastic_NetworkConnectionStatus, AUTO)
PB_BIND(meshtastic_BluetoothConnectionStatus, meshtastic_BluetoothConnectionStatus, AUTO)
PB_BIND(meshtastic_SerialConnectionStatus, meshtastic_SerialConnectionStatus, AUTO)

View File

@ -0,0 +1,189 @@
/* Automatically generated nanopb header */
/* Generated by nanopb-0.4.7 */
#ifndef PB_MESHTASTIC_MESHTASTIC_CONNECTION_STATUS_PB_H_INCLUDED
#define PB_MESHTASTIC_MESHTASTIC_CONNECTION_STATUS_PB_H_INCLUDED
#include <pb.h>
#if PB_PROTO_HEADER_VERSION != 40
#error Regenerate this file with the current version of nanopb generator.
#endif
/* Struct definitions */
/* Ethernet or WiFi connection status */
typedef struct _meshtastic_NetworkConnectionStatus {
/* IP address of device */
uint32_t ip_address;
/* Whether the device has an active connection or not */
bool is_connected;
/* Whether the device has an active connection to an MQTT broker or not */
bool is_mqtt_connected;
/* Whether the device is actively remote syslogging or not */
bool is_syslog_connected;
} meshtastic_NetworkConnectionStatus;
/* Ethernet connection status */
typedef struct _meshtastic_EthernetConnectionStatus {
/* Connection status */
bool has_status;
meshtastic_NetworkConnectionStatus status;
} meshtastic_EthernetConnectionStatus;
/* WiFi connection status */
typedef struct _meshtastic_WifiConnectionStatus {
/* Connection status */
bool has_status;
meshtastic_EthernetConnectionStatus status;
/* WiFi access point ssid */
char ssid[33];
/* Rssi of wireless connection */
int32_t rssi;
} meshtastic_WifiConnectionStatus;
/* Bluetooth connection status */
typedef struct _meshtastic_BluetoothConnectionStatus {
/* The pairing pin for bluetooth */
uint32_t pin;
/* Rssi of bluetooth connection */
int32_t rssi;
/* Whether the device has an active connection or not */
bool is_connected;
} meshtastic_BluetoothConnectionStatus;
/* Serial connection status */
typedef struct _meshtastic_SerialConnectionStatus {
/* The serial baud rate */
uint32_t baud;
/* Whether the device has an active connection or not */
bool is_connected;
} meshtastic_SerialConnectionStatus;
typedef struct _meshtastic_DeviceConnectionStatus {
/* WiFi Status */
bool has_wifi;
meshtastic_WifiConnectionStatus wifi;
/* WiFi Status */
bool has_ethernet;
meshtastic_EthernetConnectionStatus ethernet;
/* Bluetooth Status */
bool has_bluetooth;
meshtastic_BluetoothConnectionStatus bluetooth;
/* Serial Status */
bool has_serial;
meshtastic_SerialConnectionStatus serial;
} meshtastic_DeviceConnectionStatus;
#ifdef __cplusplus
extern "C" {
#endif
/* Initializer values for message structs */
#define meshtastic_DeviceConnectionStatus_init_default {false, meshtastic_WifiConnectionStatus_init_default, false, meshtastic_EthernetConnectionStatus_init_default, false, meshtastic_BluetoothConnectionStatus_init_default, false, meshtastic_SerialConnectionStatus_init_default}
#define meshtastic_WifiConnectionStatus_init_default {false, meshtastic_EthernetConnectionStatus_init_default, "", 0}
#define meshtastic_EthernetConnectionStatus_init_default {false, meshtastic_NetworkConnectionStatus_init_default}
#define meshtastic_NetworkConnectionStatus_init_default {0, 0, 0, 0}
#define meshtastic_BluetoothConnectionStatus_init_default {0, 0, 0}
#define meshtastic_SerialConnectionStatus_init_default {0, 0}
#define meshtastic_DeviceConnectionStatus_init_zero {false, meshtastic_WifiConnectionStatus_init_zero, false, meshtastic_EthernetConnectionStatus_init_zero, false, meshtastic_BluetoothConnectionStatus_init_zero, false, meshtastic_SerialConnectionStatus_init_zero}
#define meshtastic_WifiConnectionStatus_init_zero {false, meshtastic_EthernetConnectionStatus_init_zero, "", 0}
#define meshtastic_EthernetConnectionStatus_init_zero {false, meshtastic_NetworkConnectionStatus_init_zero}
#define meshtastic_NetworkConnectionStatus_init_zero {0, 0, 0, 0}
#define meshtastic_BluetoothConnectionStatus_init_zero {0, 0, 0}
#define meshtastic_SerialConnectionStatus_init_zero {0, 0}
/* Field tags (for use in manual encoding/decoding) */
#define meshtastic_NetworkConnectionStatus_ip_address_tag 1
#define meshtastic_NetworkConnectionStatus_is_connected_tag 2
#define meshtastic_NetworkConnectionStatus_is_mqtt_connected_tag 3
#define meshtastic_NetworkConnectionStatus_is_syslog_connected_tag 4
#define meshtastic_EthernetConnectionStatus_status_tag 1
#define meshtastic_WifiConnectionStatus_status_tag 1
#define meshtastic_WifiConnectionStatus_ssid_tag 2
#define meshtastic_WifiConnectionStatus_rssi_tag 3
#define meshtastic_BluetoothConnectionStatus_pin_tag 1
#define meshtastic_BluetoothConnectionStatus_rssi_tag 2
#define meshtastic_BluetoothConnectionStatus_is_connected_tag 3
#define meshtastic_SerialConnectionStatus_baud_tag 1
#define meshtastic_SerialConnectionStatus_is_connected_tag 2
#define meshtastic_DeviceConnectionStatus_wifi_tag 1
#define meshtastic_DeviceConnectionStatus_ethernet_tag 2
#define meshtastic_DeviceConnectionStatus_bluetooth_tag 3
#define meshtastic_DeviceConnectionStatus_serial_tag 4
/* Struct field encoding specification for nanopb */
#define meshtastic_DeviceConnectionStatus_FIELDLIST(X, a) \
X(a, STATIC, OPTIONAL, MESSAGE, wifi, 1) \
X(a, STATIC, OPTIONAL, MESSAGE, ethernet, 2) \
X(a, STATIC, OPTIONAL, MESSAGE, bluetooth, 3) \
X(a, STATIC, OPTIONAL, MESSAGE, serial, 4)
#define meshtastic_DeviceConnectionStatus_CALLBACK NULL
#define meshtastic_DeviceConnectionStatus_DEFAULT NULL
#define meshtastic_DeviceConnectionStatus_wifi_MSGTYPE meshtastic_WifiConnectionStatus
#define meshtastic_DeviceConnectionStatus_ethernet_MSGTYPE meshtastic_EthernetConnectionStatus
#define meshtastic_DeviceConnectionStatus_bluetooth_MSGTYPE meshtastic_BluetoothConnectionStatus
#define meshtastic_DeviceConnectionStatus_serial_MSGTYPE meshtastic_SerialConnectionStatus
#define meshtastic_WifiConnectionStatus_FIELDLIST(X, a) \
X(a, STATIC, OPTIONAL, MESSAGE, status, 1) \
X(a, STATIC, SINGULAR, STRING, ssid, 2) \
X(a, STATIC, SINGULAR, INT32, rssi, 3)
#define meshtastic_WifiConnectionStatus_CALLBACK NULL
#define meshtastic_WifiConnectionStatus_DEFAULT NULL
#define meshtastic_WifiConnectionStatus_status_MSGTYPE meshtastic_EthernetConnectionStatus
#define meshtastic_EthernetConnectionStatus_FIELDLIST(X, a) \
X(a, STATIC, OPTIONAL, MESSAGE, status, 1)
#define meshtastic_EthernetConnectionStatus_CALLBACK NULL
#define meshtastic_EthernetConnectionStatus_DEFAULT NULL
#define meshtastic_EthernetConnectionStatus_status_MSGTYPE meshtastic_NetworkConnectionStatus
#define meshtastic_NetworkConnectionStatus_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, FIXED32, ip_address, 1) \
X(a, STATIC, SINGULAR, BOOL, is_connected, 2) \
X(a, STATIC, SINGULAR, BOOL, is_mqtt_connected, 3) \
X(a, STATIC, SINGULAR, BOOL, is_syslog_connected, 4)
#define meshtastic_NetworkConnectionStatus_CALLBACK NULL
#define meshtastic_NetworkConnectionStatus_DEFAULT NULL
#define meshtastic_BluetoothConnectionStatus_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, UINT32, pin, 1) \
X(a, STATIC, SINGULAR, INT32, rssi, 2) \
X(a, STATIC, SINGULAR, BOOL, is_connected, 3)
#define meshtastic_BluetoothConnectionStatus_CALLBACK NULL
#define meshtastic_BluetoothConnectionStatus_DEFAULT NULL
#define meshtastic_SerialConnectionStatus_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, UINT32, baud, 1) \
X(a, STATIC, SINGULAR, BOOL, is_connected, 2)
#define meshtastic_SerialConnectionStatus_CALLBACK NULL
#define meshtastic_SerialConnectionStatus_DEFAULT NULL
extern const pb_msgdesc_t meshtastic_DeviceConnectionStatus_msg;
extern const pb_msgdesc_t meshtastic_WifiConnectionStatus_msg;
extern const pb_msgdesc_t meshtastic_EthernetConnectionStatus_msg;
extern const pb_msgdesc_t meshtastic_NetworkConnectionStatus_msg;
extern const pb_msgdesc_t meshtastic_BluetoothConnectionStatus_msg;
extern const pb_msgdesc_t meshtastic_SerialConnectionStatus_msg;
/* Defines for backwards compatibility with code written before nanopb-0.4.0 */
#define meshtastic_DeviceConnectionStatus_fields &meshtastic_DeviceConnectionStatus_msg
#define meshtastic_WifiConnectionStatus_fields &meshtastic_WifiConnectionStatus_msg
#define meshtastic_EthernetConnectionStatus_fields &meshtastic_EthernetConnectionStatus_msg
#define meshtastic_NetworkConnectionStatus_fields &meshtastic_NetworkConnectionStatus_msg
#define meshtastic_BluetoothConnectionStatus_fields &meshtastic_BluetoothConnectionStatus_msg
#define meshtastic_SerialConnectionStatus_fields &meshtastic_SerialConnectionStatus_msg
/* Maximum encoded size of messages (where known) */
#define meshtastic_BluetoothConnectionStatus_size 19
#define meshtastic_DeviceConnectionStatus_size 108
#define meshtastic_EthernetConnectionStatus_size 13
#define meshtastic_NetworkConnectionStatus_size 11
#define meshtastic_SerialConnectionStatus_size 8
#define meshtastic_WifiConnectionStatus_size 60
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif

View File

@ -5,6 +5,7 @@
#define PB_MESHTASTIC_MESHTASTIC_DEVICE_METADATA_PB_H_INCLUDED
#include <pb.h>
#include "meshtastic/config.pb.h"
#include "meshtastic/mesh.pb.h"
#if PB_PROTO_HEADER_VERSION != 40
#error Regenerate this file with the current version of nanopb generator.
@ -29,6 +30,8 @@ typedef struct _meshtastic_DeviceMetadata {
meshtastic_Config_DeviceConfig_Role role;
/* Indicates the device's current enabled position flags */
uint32_t position_flags;
/* Device hardware model */
meshtastic_HardwareModel hw_model;
} meshtastic_DeviceMetadata;
@ -37,8 +40,8 @@ extern "C" {
#endif
/* Initializer values for message structs */
#define meshtastic_DeviceMetadata_init_default {"", 0, 0, 0, 0, 0, _meshtastic_Config_DeviceConfig_Role_MIN, 0}
#define meshtastic_DeviceMetadata_init_zero {"", 0, 0, 0, 0, 0, _meshtastic_Config_DeviceConfig_Role_MIN, 0}
#define meshtastic_DeviceMetadata_init_default {"", 0, 0, 0, 0, 0, _meshtastic_Config_DeviceConfig_Role_MIN, 0, _meshtastic_HardwareModel_MIN}
#define meshtastic_DeviceMetadata_init_zero {"", 0, 0, 0, 0, 0, _meshtastic_Config_DeviceConfig_Role_MIN, 0, _meshtastic_HardwareModel_MIN}
/* Field tags (for use in manual encoding/decoding) */
#define meshtastic_DeviceMetadata_firmware_version_tag 1
@ -49,6 +52,7 @@ extern "C" {
#define meshtastic_DeviceMetadata_hasEthernet_tag 6
#define meshtastic_DeviceMetadata_role_tag 7
#define meshtastic_DeviceMetadata_position_flags_tag 8
#define meshtastic_DeviceMetadata_hw_model_tag 9
/* Struct field encoding specification for nanopb */
#define meshtastic_DeviceMetadata_FIELDLIST(X, a) \
@ -59,7 +63,8 @@ X(a, STATIC, SINGULAR, BOOL, hasWifi, 4) \
X(a, STATIC, SINGULAR, BOOL, hasBluetooth, 5) \
X(a, STATIC, SINGULAR, BOOL, hasEthernet, 6) \
X(a, STATIC, SINGULAR, UENUM, role, 7) \
X(a, STATIC, SINGULAR, UINT32, position_flags, 8)
X(a, STATIC, SINGULAR, UINT32, position_flags, 8) \
X(a, STATIC, SINGULAR, UENUM, hw_model, 9)
#define meshtastic_DeviceMetadata_CALLBACK NULL
#define meshtastic_DeviceMetadata_DEFAULT NULL
@ -69,7 +74,7 @@ extern const pb_msgdesc_t meshtastic_DeviceMetadata_msg;
#define meshtastic_DeviceMetadata_fields &meshtastic_DeviceMetadata_msg
/* Maximum encoded size of messages (where known) */
#define meshtastic_DeviceMetadata_size 41
#define meshtastic_DeviceMetadata_size 44
#ifdef __cplusplus
} /* extern "C" */

View File

@ -5,6 +5,7 @@
#define PB_MESHTASTIC_MESHTASTIC_DEVICEONLY_PB_H_INCLUDED
#include <pb.h>
#include "meshtastic/channel.pb.h"
#include "meshtastic/localonly.pb.h"
#include "meshtastic/mesh.pb.h"
#if PB_PROTO_HEADER_VERSION != 40
@ -85,6 +86,12 @@ typedef struct _meshtastic_OEMStore {
char oem_text[40];
/* The default device encryption key, 16 or 32 byte */
meshtastic_OEMStore_oem_aes_key_t oem_aes_key;
/* A Preset LocalConfig to apply during factory reset */
bool has_oem_local_config;
meshtastic_LocalConfig oem_local_config;
/* A Preset LocalModuleConfig to apply during factory reset */
bool has_oem_local_module_config;
meshtastic_LocalModuleConfig oem_local_module_config;
} meshtastic_OEMStore;
@ -105,10 +112,10 @@ extern "C" {
/* Initializer values for message structs */
#define meshtastic_DeviceState_init_default {false, meshtastic_MyNodeInfo_init_default, false, meshtastic_User_init_default, 0, {meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default, meshtastic_NodeInfo_init_default}, 0, {meshtastic_MeshPacket_init_default}, false, meshtastic_MeshPacket_init_default, 0, 0, 0}
#define meshtastic_ChannelFile_init_default {0, {meshtastic_Channel_init_default, meshtastic_Channel_init_default, meshtastic_Channel_init_default, meshtastic_Channel_init_default, meshtastic_Channel_init_default, meshtastic_Channel_init_default, meshtastic_Channel_init_default, meshtastic_Channel_init_default}, 0}
#define meshtastic_OEMStore_init_default {0, 0, {0, {0}}, _meshtastic_ScreenFonts_MIN, "", {0, {0}}}
#define meshtastic_OEMStore_init_default {0, 0, {0, {0}}, _meshtastic_ScreenFonts_MIN, "", {0, {0}}, false, meshtastic_LocalConfig_init_default, false, meshtastic_LocalModuleConfig_init_default}
#define meshtastic_DeviceState_init_zero {false, meshtastic_MyNodeInfo_init_zero, false, meshtastic_User_init_zero, 0, {meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero, meshtastic_NodeInfo_init_zero}, 0, {meshtastic_MeshPacket_init_zero}, false, meshtastic_MeshPacket_init_zero, 0, 0, 0}
#define meshtastic_ChannelFile_init_zero {0, {meshtastic_Channel_init_zero, meshtastic_Channel_init_zero, meshtastic_Channel_init_zero, meshtastic_Channel_init_zero, meshtastic_Channel_init_zero, meshtastic_Channel_init_zero, meshtastic_Channel_init_zero, meshtastic_Channel_init_zero}, 0}
#define meshtastic_OEMStore_init_zero {0, 0, {0, {0}}, _meshtastic_ScreenFonts_MIN, "", {0, {0}}}
#define meshtastic_OEMStore_init_zero {0, 0, {0, {0}}, _meshtastic_ScreenFonts_MIN, "", {0, {0}}, false, meshtastic_LocalConfig_init_zero, false, meshtastic_LocalModuleConfig_init_zero}
/* Field tags (for use in manual encoding/decoding) */
#define meshtastic_DeviceState_my_node_tag 2
@ -127,6 +134,8 @@ extern "C" {
#define meshtastic_OEMStore_oem_font_tag 4
#define meshtastic_OEMStore_oem_text_tag 5
#define meshtastic_OEMStore_oem_aes_key_tag 6
#define meshtastic_OEMStore_oem_local_config_tag 7
#define meshtastic_OEMStore_oem_local_module_config_tag 8
/* Struct field encoding specification for nanopb */
#define meshtastic_DeviceState_FIELDLIST(X, a) \
@ -159,9 +168,13 @@ X(a, STATIC, SINGULAR, UINT32, oem_icon_height, 2) \
X(a, STATIC, SINGULAR, BYTES, oem_icon_bits, 3) \
X(a, STATIC, SINGULAR, UENUM, oem_font, 4) \
X(a, STATIC, SINGULAR, STRING, oem_text, 5) \
X(a, STATIC, SINGULAR, BYTES, oem_aes_key, 6)
X(a, STATIC, SINGULAR, BYTES, oem_aes_key, 6) \
X(a, STATIC, OPTIONAL, MESSAGE, oem_local_config, 7) \
X(a, STATIC, OPTIONAL, MESSAGE, oem_local_module_config, 8)
#define meshtastic_OEMStore_CALLBACK NULL
#define meshtastic_OEMStore_DEFAULT NULL
#define meshtastic_OEMStore_oem_local_config_MSGTYPE meshtastic_LocalConfig
#define meshtastic_OEMStore_oem_local_module_config_MSGTYPE meshtastic_LocalModuleConfig
extern const pb_msgdesc_t meshtastic_DeviceState_msg;
extern const pb_msgdesc_t meshtastic_ChannelFile_msg;
@ -175,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 21800
#define meshtastic_OEMStore_size 2140
#define meshtastic_OEMStore_size 2992
#ifdef __cplusplus
} /* extern "C" */

View File

@ -26,7 +26,8 @@ static const char *secretReserved = "sekrit";
/// If buf is the reserved secret word, replace the buffer with currentVal
static void writeSecret(char *buf, size_t bufsz, const char *currentVal)
{
if (strcmp(buf, secretReserved) == 0) {
if (strcmp(buf, secretReserved) == 0)
{
strncpy(buf, currentVal, bufsz);
}
}
@ -44,7 +45,8 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
bool handled = false;
assert(r);
switch (r->which_payload_variant) {
switch (r->which_payload_variant)
{
/**
* Getters
@ -64,7 +66,8 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
handleGetModuleConfig(mp, r->get_module_config_request);
break;
case meshtastic_AdminMessage_get_channel_request_tag: {
case meshtastic_AdminMessage_get_channel_request_tag:
{
uint32_t i = r->get_channel_request - 1;
LOG_INFO("Client is getting channel %u\n", i);
if (i >= MAX_NUM_CHANNELS)
@ -103,17 +106,22 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
/**
* Other
*/
case meshtastic_AdminMessage_reboot_seconds_tag: {
case meshtastic_AdminMessage_reboot_seconds_tag:
{
reboot(r->reboot_seconds);
break;
}
case meshtastic_AdminMessage_reboot_ota_seconds_tag: {
case meshtastic_AdminMessage_reboot_ota_seconds_tag:
{
int32_t s = r->reboot_ota_seconds;
#ifdef ARCH_ESP32
if (BleOta::getOtaAppVersion().isEmpty()) {
if (BleOta::getOtaAppVersion().isEmpty())
{
LOG_INFO("No OTA firmware available, scheduling regular reboot in %d seconds\n", s);
screen->startRebootScreen();
} else {
}
else
{
screen->startFirmwareUpdateScreen();
BleOta::switchToOtaApp();
LOG_INFO("Rebooting to OTA in %d seconds\n", s);
@ -125,35 +133,41 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
rebootAtMsec = (s < 0) ? 0 : (millis() + s * 1000);
break;
}
case meshtastic_AdminMessage_shutdown_seconds_tag: {
case meshtastic_AdminMessage_shutdown_seconds_tag:
{
int32_t s = r->shutdown_seconds;
LOG_INFO("Shutdown in %d seconds\n", s);
shutdownAtMsec = (s < 0) ? 0 : (millis() + s * 1000);
break;
}
case meshtastic_AdminMessage_get_device_metadata_request_tag: {
case meshtastic_AdminMessage_get_device_metadata_request_tag:
{
LOG_INFO("Client is getting device metadata\n");
handleGetDeviceMetadata(mp);
break;
}
case meshtastic_AdminMessage_factory_reset_tag: {
case meshtastic_AdminMessage_factory_reset_tag:
{
LOG_INFO("Initiating factory reset\n");
nodeDB.factoryReset();
reboot(DEFAULT_REBOOT_SECONDS);
break;
}
case meshtastic_AdminMessage_nodedb_reset_tag: {
case meshtastic_AdminMessage_nodedb_reset_tag:
{
LOG_INFO("Initiating node-db reset\n");
nodeDB.resetNodes();
reboot(DEFAULT_REBOOT_SECONDS);
break;
}
case meshtastic_AdminMessage_begin_edit_settings_tag: {
case meshtastic_AdminMessage_begin_edit_settings_tag:
{
LOG_INFO("Beginning transaction for editing settings\n");
hasOpenEditTransaction = true;
break;
}
case meshtastic_AdminMessage_commit_edit_settings_tag: {
case meshtastic_AdminMessage_commit_edit_settings_tag:
{
LOG_INFO("Committing transaction for edited settings\n");
hasOpenEditTransaction = false;
saveChanges(SEGMENT_CONFIG | SEGMENT_MODULECONFIG | SEGMENT_DEVICESTATE | SEGMENT_CHANNELS);
@ -170,11 +184,16 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
meshtastic_AdminMessage res = meshtastic_AdminMessage_init_default;
AdminMessageHandleResult handleResult = MeshModule::handleAdminMessageForAllPlugins(mp, r, &res);
if (handleResult == AdminMessageHandleResult::HANDLED_WITH_RESPONSE) {
if (handleResult == AdminMessageHandleResult::HANDLED_WITH_RESPONSE)
{
myReply = allocDataProtobuf(res);
} else if (mp.decoded.want_response) {
}
else if (mp.decoded.want_response)
{
LOG_DEBUG("We did not responded to a request that wanted a respond. req.variant=%d\n", r->which_payload_variant);
} else if (handleResult != AdminMessageHandleResult::HANDLED) {
}
else if (handleResult != AdminMessageHandleResult::HANDLED)
{
// Probably a message sent by us or sent to our local node. FIXME, we should avoid scanning these messages
LOG_INFO("Ignoring nonrelevant admin %d\n", r->which_payload_variant);
}
@ -182,7 +201,8 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
}
// If asked for a response and it is not yet set, generate an 'ACK' response
if (mp.decoded.want_response && !myReply) {
if (mp.decoded.want_response && !myReply)
{
myReply = allocErrorResponse(meshtastic_Routing_Error_NONE, &mp);
}
@ -198,26 +218,31 @@ void AdminModule::handleSetOwner(const meshtastic_User &o)
int changed = 0;
bool licensed_changed = false;
if (*o.long_name) {
if (*o.long_name)
{
changed |= strcmp(owner.long_name, o.long_name);
strncpy(owner.long_name, o.long_name, sizeof(owner.long_name));
}
if (*o.short_name) {
if (*o.short_name)
{
changed |= strcmp(owner.short_name, o.short_name);
strncpy(owner.short_name, o.short_name, sizeof(owner.short_name));
}
if (*o.id) {
if (*o.id)
{
changed |= strcmp(owner.id, o.id);
strncpy(owner.id, o.id, sizeof(owner.id));
}
if (owner.is_licensed != o.is_licensed) {
if (owner.is_licensed != o.is_licensed)
{
changed = 1;
licensed_changed = true;
owner.is_licensed = o.is_licensed;
config.lora.override_duty_cycle = owner.is_licensed; // override duty cycle for licensed operators
}
if (changed) { // If nothing really changed, don't broadcast on the network or write to flash
if (changed)
{ // If nothing really changed, don't broadcast on the network or write to flash
service.reloadOwner(!hasOpenEditTransaction);
licensed_changed ? saveChanges(SEGMENT_CONFIG | SEGMENT_DEVICESTATE) : saveChanges(SEGMENT_DEVICESTATE);
}
@ -228,7 +253,8 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c)
auto existingRole = config.device.role;
bool isRegionUnset = (config.lora.region == meshtastic_Config_LoRaConfig_RegionCode_UNSET);
switch (c.which_payload_variant) {
switch (c.which_payload_variant)
{
case meshtastic_Config_device_tag:
LOG_INFO("Setting config: Device\n");
config.has_device = true;
@ -263,7 +289,8 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c)
LOG_INFO("Setting config: LoRa\n");
config.has_lora = true;
config.lora = c.payload_variant.lora;
if (isRegionUnset && config.lora.region > meshtastic_Config_LoRaConfig_RegionCode_UNSET) {
if (isRegionUnset && config.lora.region > meshtastic_Config_LoRaConfig_RegionCode_UNSET)
{
config.lora.tx_enabled = true;
}
break;
@ -279,7 +306,8 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c)
void AdminModule::handleSetModuleConfig(const meshtastic_ModuleConfig &c)
{
switch (c.which_payload_variant) {
switch (c.which_payload_variant)
{
case meshtastic_ModuleConfig_mqtt_tag:
LOG_INFO("Setting module config: MQTT\n");
moduleConfig.has_mqtt = true;
@ -343,7 +371,8 @@ void AdminModule::handleSetChannel(const meshtastic_Channel &cc)
void AdminModule::handleGetOwner(const meshtastic_MeshPacket &req)
{
if (req.decoded.want_response) {
if (req.decoded.want_response)
{
// We create the reply here
meshtastic_AdminMessage res = meshtastic_AdminMessage_init_default;
res.get_owner_response = owner;
@ -357,8 +386,10 @@ void AdminModule::handleGetConfig(const meshtastic_MeshPacket &req, const uint32
{
meshtastic_AdminMessage res = meshtastic_AdminMessage_init_default;
if (req.decoded.want_response) {
switch (configType) {
if (req.decoded.want_response)
{
switch (configType)
{
case meshtastic_AdminMessage_ConfigType_DEVICE_CONFIG:
LOG_INFO("Getting config: Device\n");
res.get_config_response.which_payload_variant = meshtastic_Config_device_tag;
@ -413,8 +444,10 @@ void AdminModule::handleGetModuleConfig(const meshtastic_MeshPacket &req, const
{
meshtastic_AdminMessage res = meshtastic_AdminMessage_init_default;
if (req.decoded.want_response) {
switch (configType) {
if (req.decoded.want_response)
{
switch (configType)
{
case meshtastic_AdminMessage_ModuleConfigType_MQTT_CONFIG:
LOG_INFO("Getting module config: MQTT\n");
res.get_module_config_response.which_payload_variant = meshtastic_ModuleConfig_mqtt_tag;
@ -487,15 +520,43 @@ void AdminModule::handleGetDeviceMetadata(const meshtastic_MeshPacket &req)
deviceMetadata.hasEthernet = HAS_ETHERNET;
deviceMetadata.role = config.device.role;
deviceMetadata.position_flags = config.position.position_flags;
deviceMetadata.hw_model = HW_VENDOR;
r.get_device_metadata_response = deviceMetadata;
r.which_payload_variant = meshtastic_AdminMessage_get_device_metadata_response_tag;
myReply = allocDataProtobuf(r);
}
void AdminModule::handleGetDeviceConnectionStatus(const meshtastic_MeshPacket &req)
{
meshtastic_AdminMessage r = meshtastic_AdminMessage_init_default;
meshtastic_DeviceConnectionStatus connectionStatus;
connectionStatus.has_wifi = HAS_WIFI;
#if HAS_WIFI
connectionStatus.wifi.status.status.is_connected = WiFi.status() != WL_CONNECTED;
strncpy(connectionStatus.wifi.ssid, config.network.wifi_ssid, 33);
connectionStatus.wifi.status.status.is_syslog_connected = false; // FIXME wire this up
#endif
connectionStatus.has_bluetooth = HAS_BLUETOOTH;
#if HAS_BLUETOOTH
#endif
connectionStatus.has_ethernet = HAS_ETHERNET;
connectionStatus.has_serial = true; // No serial-less devices
r.get_device_connection_status_response = connectionStatus;
r.which_payload_variant = meshtastic_AdminMessage_get_device_connection_status_response_tag;
myReply = allocDataProtobuf(r);
}
void AdminModule::handleGetChannel(const meshtastic_MeshPacket &req, uint32_t channelIndex)
{
if (req.decoded.want_response) {
if (req.decoded.want_response)
{
// We create the reply here
meshtastic_AdminMessage r = meshtastic_AdminMessage_init_default;
r.get_channel_response = channels.getByIndex(channelIndex);
@ -513,13 +574,17 @@ void AdminModule::reboot(int32_t seconds)
void AdminModule::saveChanges(int saveWhat, bool shouldReboot)
{
if (!hasOpenEditTransaction) {
if (!hasOpenEditTransaction)
{
LOG_INFO("Saving changes to disk\n");
service.reloadConfig(saveWhat); // Calls saveToDisk among other things
} else {
}
else
{
LOG_INFO("Delaying save of changes to disk until the open transaction is committed\n");
}
if (shouldReboot) {
if (shouldReboot)
{
reboot(DEFAULT_REBOOT_SECONDS);
}
}

View File

@ -1,46 +1,49 @@
#pragma once
#include "ProtobufModule.h"
#ifdef ARCH_ESP32
#include "mesh/http/WiFiAPClient.h"
#endif
/**
* Admin module for admin messages
*/
class AdminModule : public ProtobufModule<meshtastic_AdminMessage>
{
public:
/** Constructor
* name is for debugging output
*/
AdminModule();
public:
/** Constructor
* name is for debugging output
*/
AdminModule();
protected:
/** Called to handle a particular incoming message
protected:
/** Called to handle a particular incoming message
@return true if you've guaranteed you've handled this message and no other handlers should be considered for it
*/
virtual bool handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_AdminMessage *p) override;
@return true if you've guaranteed you've handled this message and no other handlers should be considered for it
*/
virtual bool handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_AdminMessage *p) override;
private:
bool hasOpenEditTransaction = false;
private:
bool hasOpenEditTransaction = false;
void saveChanges(int saveWhat, bool shouldReboot = true);
/**
* Getters
*/
void handleGetOwner(const meshtastic_MeshPacket &req);
void handleGetConfig(const meshtastic_MeshPacket &req, uint32_t configType);
void handleGetModuleConfig(const meshtastic_MeshPacket &req, uint32_t configType);
void handleGetChannel(const meshtastic_MeshPacket &req, uint32_t channelIndex);
void handleGetDeviceMetadata(const meshtastic_MeshPacket &req);
/**
* Setters
*/
void handleSetOwner(const meshtastic_User &o);
void handleSetChannel(const meshtastic_Channel &cc);
void handleSetConfig(const meshtastic_Config &c);
void handleSetModuleConfig(const meshtastic_ModuleConfig &c);
void handleSetChannel();
void reboot(int32_t seconds);
void saveChanges(int saveWhat, bool shouldReboot = true);
/**
* Getters
*/
void handleGetOwner(const meshtastic_MeshPacket &req);
void handleGetConfig(const meshtastic_MeshPacket &req, uint32_t configType);
void handleGetModuleConfig(const meshtastic_MeshPacket &req, uint32_t configType);
void handleGetChannel(const meshtastic_MeshPacket &req, uint32_t channelIndex);
void handleGetDeviceMetadata(const meshtastic_MeshPacket &req);
void handleGetDeviceConnectionStatus(const meshtastic_MeshPacket &req);
/**
* Setters
*/
void handleSetOwner(const meshtastic_User &o);
void handleSetChannel(const meshtastic_Channel &cc);
void handleSetConfig(const meshtastic_Config &c);
void handleSetModuleConfig(const meshtastic_ModuleConfig &c);
void handleSetChannel();
void reboot(int32_t seconds);
};
extern AdminModule *adminModule;