mirror of
https://github.com/meshtastic/firmware.git
synced 2025-10-02 21:47:15 +00:00
Split config structure in two
This commit is contained in:
parent
399e053ebd
commit
f84286d138
2
proto
2
proto
@ -1 +1 @@
|
|||||||
Subproject commit 79d24080ff83b0a54bc1619f07f41f17ffedfb99
|
Subproject commit 521620ba14862d541f85e1eee7445eccb6a6b92a
|
@ -36,6 +36,7 @@ EXT_RAM_ATTR DeviceState devicestate;
|
|||||||
MyNodeInfo &myNodeInfo = devicestate.my_node;
|
MyNodeInfo &myNodeInfo = devicestate.my_node;
|
||||||
RadioConfig radioConfig;
|
RadioConfig radioConfig;
|
||||||
Config config;
|
Config config;
|
||||||
|
ModuleConfig moduleConfig;
|
||||||
ChannelFile channelFile;
|
ChannelFile channelFile;
|
||||||
|
|
||||||
/** The current change # for radio settings. Starts at 0 on boot and any time the radio settings
|
/** The current change # for radio settings. Starts at 0 on boot and any time the radio settings
|
||||||
@ -96,7 +97,7 @@ bool NodeDB::resetRadioConfig()
|
|||||||
nvs_flash_erase();
|
nvs_flash_erase();
|
||||||
#endif
|
#endif
|
||||||
#ifdef NRF52_SERIES
|
#ifdef NRF52_SERIES
|
||||||
// first, remove the "/prefs" (this removes most prefs)
|
// first, remove the "/prefs" (this removes most prefs)
|
||||||
FSCom.rmdir_r("/prefs");
|
FSCom.rmdir_r("/prefs");
|
||||||
// second, install default state (this will deal with the duplicate mac address issue)
|
// second, install default state (this will deal with the duplicate mac address issue)
|
||||||
installDefaultDeviceState();
|
installDefaultDeviceState();
|
||||||
@ -148,6 +149,11 @@ void NodeDB::installDefaultConfig()
|
|||||||
memset(&config, 0, sizeof(config));
|
memset(&config, 0, sizeof(config));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NodeDB::installDefaultModuleConfig()
|
||||||
|
{
|
||||||
|
memset(&moduleConfig, 0, sizeof(moduleConfig));
|
||||||
|
}
|
||||||
|
|
||||||
void NodeDB::installDefaultRadioConfig()
|
void NodeDB::installDefaultRadioConfig()
|
||||||
{
|
{
|
||||||
memset(&radioConfig, 0, sizeof(radioConfig));
|
memset(&radioConfig, 0, sizeof(radioConfig));
|
||||||
@ -155,9 +161,7 @@ void NodeDB::installDefaultRadioConfig()
|
|||||||
resetRadioConfig();
|
resetRadioConfig();
|
||||||
|
|
||||||
// for backward compat, default position flags are BAT+ALT+MSL (0x23 = 35)
|
// for backward compat, default position flags are BAT+ALT+MSL (0x23 = 35)
|
||||||
radioConfig.preferences.position_flags = (PositionFlags_POS_BATTERY |
|
radioConfig.preferences.position_flags = (PositionFlags_POS_BATTERY | PositionFlags_POS_ALTITUDE | PositionFlags_POS_ALT_MSL);
|
||||||
PositionFlags_POS_ALTITUDE | PositionFlags_POS_ALT_MSL);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeDB::installDefaultChannels()
|
void NodeDB::installDefaultChannels()
|
||||||
@ -247,8 +251,8 @@ void NodeDB::init()
|
|||||||
DEBUG_MSG("Number of Device Reboots: %d\n", myNodeInfo.reboot_count);
|
DEBUG_MSG("Number of Device Reboots: %d\n", myNodeInfo.reboot_count);
|
||||||
|
|
||||||
/* The ESP32 has a wifi radio. This will need to be modified at some point so
|
/* The ESP32 has a wifi radio. This will need to be modified at some point so
|
||||||
* the test isn't so simplistic.
|
* the test isn't so simplistic.
|
||||||
*/
|
*/
|
||||||
myNodeInfo.has_wifi = true;
|
myNodeInfo.has_wifi = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -287,6 +291,7 @@ void NodeDB::pickNewNodeNum()
|
|||||||
static const char *preffile = "/prefs/db.proto";
|
static const char *preffile = "/prefs/db.proto";
|
||||||
static const char *radiofile = "/prefs/radio.proto";
|
static const char *radiofile = "/prefs/radio.proto";
|
||||||
static const char *configfile = "/prefs/config.proto";
|
static const char *configfile = "/prefs/config.proto";
|
||||||
|
static const char *moduleConfigfile = "/prefs/module_config.proto";
|
||||||
static const char *channelfile = "/prefs/channels.proto";
|
static const char *channelfile = "/prefs/channels.proto";
|
||||||
|
|
||||||
/** Load a protobuf from a file, return true for success */
|
/** Load a protobuf from a file, return true for success */
|
||||||
@ -343,6 +348,10 @@ void NodeDB::loadFromDisk()
|
|||||||
installDefaultConfig(); // Our in RAM copy might now be corrupt
|
installDefaultConfig(); // Our in RAM copy might now be corrupt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!loadProto(moduleConfigfile, ModuleConfig_size, sizeof(ModuleConfig), ModuleConfig_fields, &moduleConfig)) {
|
||||||
|
installDefaultModuleConfig(); // Our in RAM copy might now be corrupt
|
||||||
|
}
|
||||||
|
|
||||||
if (!loadProto(channelfile, ChannelFile_size, sizeof(ChannelFile), ChannelFile_fields, &channelFile)) {
|
if (!loadProto(channelfile, ChannelFile_size, sizeof(ChannelFile), ChannelFile_fields, &channelFile)) {
|
||||||
installDefaultChannels(); // Our in RAM copy might now be corrupt
|
installDefaultChannels(); // Our in RAM copy might now be corrupt
|
||||||
}
|
}
|
||||||
@ -402,6 +411,7 @@ void NodeDB::saveToDisk()
|
|||||||
saveProto(preffile, DeviceState_size, sizeof(devicestate), DeviceState_fields, &devicestate);
|
saveProto(preffile, DeviceState_size, sizeof(devicestate), DeviceState_fields, &devicestate);
|
||||||
saveProto(radiofile, RadioConfig_size, sizeof(RadioConfig), RadioConfig_fields, &radioConfig);
|
saveProto(radiofile, RadioConfig_size, sizeof(RadioConfig), RadioConfig_fields, &radioConfig);
|
||||||
saveProto(configfile, Config_size, sizeof(Config), Config_fields, &config);
|
saveProto(configfile, Config_size, sizeof(Config), Config_fields, &config);
|
||||||
|
saveProto(moduleConfigfile, Module_Config_size, sizeof(ModuleConfig), ModuleConfig_fields, &moduleConfig);
|
||||||
saveChannelsToDisk();
|
saveChannelsToDisk();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -456,12 +466,11 @@ void NodeDB::updatePosition(uint32_t nodeId, const Position &p, RxSource src)
|
|||||||
|
|
||||||
if (src == RX_SRC_LOCAL) {
|
if (src == RX_SRC_LOCAL) {
|
||||||
// Local packet, fully authoritative
|
// Local packet, fully authoritative
|
||||||
DEBUG_MSG("updatePosition LOCAL pos@%x, time=%u, latI=%d, lonI=%d, alt=%d\n",
|
DEBUG_MSG("updatePosition LOCAL pos@%x, time=%u, latI=%d, lonI=%d, alt=%d\n", p.pos_timestamp, p.time, p.latitude_i,
|
||||||
p.pos_timestamp, p.time, p.latitude_i, p.longitude_i, p.altitude);
|
p.longitude_i, p.altitude);
|
||||||
info->position = p;
|
info->position = p;
|
||||||
|
|
||||||
} else if ((p.time > 0) && !p.latitude_i && !p.longitude_i && !p.pos_timestamp &&
|
} else if ((p.time > 0) && !p.latitude_i && !p.longitude_i && !p.pos_timestamp && !p.location_source) {
|
||||||
!p.location_source) {
|
|
||||||
// FIXME SPECIAL TIME SETTING PACKET FROM EUD TO RADIO
|
// FIXME SPECIAL TIME SETTING PACKET FROM EUD TO RADIO
|
||||||
// (stop-gap fix for issue #900)
|
// (stop-gap fix for issue #900)
|
||||||
DEBUG_MSG("updatePosition SPECIAL time setting time=%u\n", p.time);
|
DEBUG_MSG("updatePosition SPECIAL time setting time=%u\n", p.time);
|
||||||
@ -473,8 +482,7 @@ void NodeDB::updatePosition(uint32_t nodeId, const Position &p, RxSource src)
|
|||||||
// recorded based on the packet rxTime
|
// recorded based on the packet rxTime
|
||||||
//
|
//
|
||||||
// FIXME perhaps handle RX_SRC_USER separately?
|
// FIXME perhaps handle RX_SRC_USER separately?
|
||||||
DEBUG_MSG("updatePosition REMOTE node=0x%x time=%u, latI=%d, lonI=%d\n",
|
DEBUG_MSG("updatePosition REMOTE node=0x%x time=%u, latI=%d, lonI=%d\n", nodeId, p.time, p.latitude_i, p.longitude_i);
|
||||||
nodeId, p.time, p.latitude_i, p.longitude_i);
|
|
||||||
|
|
||||||
// First, back up fields that we want to protect from overwrite
|
// First, back up fields that we want to protect from overwrite
|
||||||
uint32_t tmp_time = info->position.time;
|
uint32_t tmp_time = info->position.time;
|
||||||
@ -483,7 +491,7 @@ void NodeDB::updatePosition(uint32_t nodeId, const Position &p, RxSource src)
|
|||||||
info->position = p;
|
info->position = p;
|
||||||
|
|
||||||
// Last, restore any fields that may have been overwritten
|
// Last, restore any fields that may have been overwritten
|
||||||
if (! info->position.time)
|
if (!info->position.time)
|
||||||
info->position.time = tmp_time;
|
info->position.time = tmp_time;
|
||||||
}
|
}
|
||||||
info->has_position = true;
|
info->has_position = true;
|
||||||
@ -491,7 +499,6 @@ void NodeDB::updatePosition(uint32_t nodeId, const Position &p, RxSource src)
|
|||||||
notifyObservers(true); // Force an update whether or not our node counts have changed
|
notifyObservers(true); // Force an update whether or not our node counts have changed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Update telemetry info for this node based on received metrics
|
/** Update telemetry info for this node based on received metrics
|
||||||
* We only care about device telemetry here
|
* We only care about device telemetry here
|
||||||
*/
|
*/
|
||||||
@ -603,7 +610,7 @@ void recordCriticalError(CriticalErrorCode code, uint32_t address, const char *f
|
|||||||
// Print error to screen and serial port
|
// Print error to screen and serial port
|
||||||
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:%lx\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=%lx\n", code, address);
|
||||||
|
@ -13,6 +13,7 @@ extern ChannelFile channelFile;
|
|||||||
extern MyNodeInfo &myNodeInfo;
|
extern MyNodeInfo &myNodeInfo;
|
||||||
extern RadioConfig radioConfig;
|
extern RadioConfig radioConfig;
|
||||||
extern Config config;
|
extern Config config;
|
||||||
|
extern ModuleConfig moduleConfig;
|
||||||
extern User &owner;
|
extern User &owner;
|
||||||
|
|
||||||
/// Given a node, return how many seconds in the past (vs now) that we last heard from it
|
/// Given a node, return how many seconds in the past (vs now) that we last heard from it
|
||||||
@ -64,7 +65,7 @@ class NodeDB
|
|||||||
|
|
||||||
/** Update telemetry info for this node based on received metrics
|
/** Update telemetry info for this node based on received metrics
|
||||||
*/
|
*/
|
||||||
void updateTelemetry(uint32_t nodeId, const Telemetry &t, RxSource src = RX_SRC_RADIO);
|
void updateTelemetry(uint32_t nodeId, const Telemetry &t, RxSource src = RX_SRC_RADIO);
|
||||||
|
|
||||||
/** Update user info for this node based on received user data
|
/** Update user info for this node based on received user data
|
||||||
*/
|
*/
|
||||||
@ -123,7 +124,8 @@ class NodeDB
|
|||||||
void loadFromDisk();
|
void loadFromDisk();
|
||||||
|
|
||||||
/// Reinit device state from scratch (not loading from disk)
|
/// Reinit device state from scratch (not loading from disk)
|
||||||
void installDefaultDeviceState(), installDefaultRadioConfig(), installDefaultChannels(), installDefaultConfig();
|
void installDefaultDeviceState(), installDefaultRadioConfig(), installDefaultChannels(), installDefaultConfig(),
|
||||||
|
installDefaultModuleConfig();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -164,9 +166,11 @@ extern NodeDB nodeDB;
|
|||||||
|
|
||||||
#define default_broadcast_interval_secs IF_ROUTER(12 * 60 * 60, 15 * 60)
|
#define default_broadcast_interval_secs IF_ROUTER(12 * 60 * 60, 15 * 60)
|
||||||
|
|
||||||
inline uint32_t getIntervalOrDefaultMs(uint32_t interval) {
|
inline uint32_t getIntervalOrDefaultMs(uint32_t interval)
|
||||||
if (interval > 0) return interval * 1000;
|
{
|
||||||
return default_broadcast_interval_secs * 1000;
|
if (interval > 0)
|
||||||
|
return interval * 1000;
|
||||||
|
return default_broadcast_interval_secs * 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PREF_GET(name, defaultVal) \
|
#define PREF_GET(name, defaultVal) \
|
||||||
@ -174,7 +178,6 @@ inline uint32_t getIntervalOrDefaultMs(uint32_t interval) {
|
|||||||
|
|
||||||
PREF_GET(position_broadcast_secs, IF_ROUTER(12 * 60 * 60, 15 * 60))
|
PREF_GET(position_broadcast_secs, IF_ROUTER(12 * 60 * 60, 15 * 60))
|
||||||
|
|
||||||
|
|
||||||
// Each time we wake into the DARK state allow 1 minute to send and receive BLE packets to the phone
|
// Each time we wake into the DARK state allow 1 minute to send and receive BLE packets to the phone
|
||||||
PREF_GET(wait_bluetooth_secs, IF_ROUTER(1, 60))
|
PREF_GET(wait_bluetooth_secs, IF_ROUTER(1, 60))
|
||||||
|
|
||||||
@ -195,4 +198,6 @@ PREF_GET(min_wake_secs, 10)
|
|||||||
extern uint32_t radioGeneration;
|
extern uint32_t radioGeneration;
|
||||||
|
|
||||||
// Config doesn't have a nanopb generated full size constant
|
// Config doesn't have a nanopb generated full size constant
|
||||||
#define Config_size (Config_DeviceConfig_size + Config_DisplayConfig_size + Config_GpsConfig_size + Config_LoRaConfig_size + Config_ModuleConfig_CannedMessageConfig_size + Config_ModuleConfig_ExternalNotificationConfig_size + Config_ModuleConfig_MQTTConfig_size + Config_ModuleConfig_RangeTestConfig_size + Config_ModuleConfig_SerialConfig_size + Config_ModuleConfig_StoreForwardConfig_size + Config_ModuleConfig_TelemetryConfig_size + Config_ModuleConfig_size + Config_PowerConfig_size)
|
#define Config_size (Config_DeviceConfig_size + Config_DisplayConfig_size + Config_GpsConfig_size + Config_LoRaConfig_size + Config_PowerConfig_size)
|
||||||
|
|
||||||
|
#define Module_Config_size (Config_ModuleConfig_CannedMessageConfig_size + Config_ModuleConfig_ExternalNotificationConfig_size + Config_ModuleConfig_MQTTConfig_size + Config_ModuleConfig_RangeTestConfig_size + Config_ModuleConfig_SerialConfig_size + Config_ModuleConfig_StoreForwardConfig_size + Config_ModuleConfig_TelemetryConfig_size + Config_ModuleConfig_size)
|
@ -7,6 +7,7 @@
|
|||||||
#include "channel.pb.h"
|
#include "channel.pb.h"
|
||||||
#include "config.pb.h"
|
#include "config.pb.h"
|
||||||
#include "mesh.pb.h"
|
#include "mesh.pb.h"
|
||||||
|
#include "module_config.pb.h"
|
||||||
#include "radioconfig.pb.h"
|
#include "radioconfig.pb.h"
|
||||||
|
|
||||||
#if PB_PROTO_HEADER_VERSION != 40
|
#if PB_PROTO_HEADER_VERSION != 40
|
||||||
@ -15,24 +16,24 @@
|
|||||||
|
|
||||||
/* Enum definitions */
|
/* Enum definitions */
|
||||||
typedef enum _AdminMessage_ConfigType {
|
typedef enum _AdminMessage_ConfigType {
|
||||||
AdminMessage_ConfigType_ALL = 0,
|
AdminMessage_ConfigType_DEVICE_CONFIG = 0,
|
||||||
AdminMessage_ConfigType_CORE_ONLY = 1,
|
AdminMessage_ConfigType_GPS_CONFIG = 1,
|
||||||
AdminMessage_ConfigType_MODULE_ONLY = 2,
|
AdminMessage_ConfigType_POWER_CONFIG = 2,
|
||||||
AdminMessage_ConfigType_DEVICE_CONFIG = 3,
|
AdminMessage_ConfigType_WIFI_CONFIG = 3,
|
||||||
AdminMessage_ConfigType_GPS_CONFIG = 4,
|
AdminMessage_ConfigType_DISPLAY_CONFIG = 4,
|
||||||
AdminMessage_ConfigType_POWER_CONFIG = 5,
|
AdminMessage_ConfigType_LORA_CONFIG = 5
|
||||||
AdminMessage_ConfigType_WIFI_CONFIG = 6,
|
|
||||||
AdminMessage_ConfigType_DISPLAY_CONFIG = 7,
|
|
||||||
AdminMessage_ConfigType_LORA_CONFIG = 8,
|
|
||||||
AdminMessage_ConfigType_MODULE_MQTT_CONFIG = 9,
|
|
||||||
AdminMessage_ConfigType_MODULE_SERIAL_CONFIG = 10,
|
|
||||||
AdminMessage_ConfigType_MODULE_EXTNOTIF_CONFIG = 11,
|
|
||||||
AdminMessage_ConfigType_MODULE_STOREFORWARD_CONFIG = 12,
|
|
||||||
AdminMessage_ConfigType_MODULE_RANGETEST_CONFIG = 13,
|
|
||||||
AdminMessage_ConfigType_MODULE_TELEMETRY_CONFIG = 14,
|
|
||||||
AdminMessage_ConfigType_MODULE_CANNEDMSG_CONFIG = 15
|
|
||||||
} AdminMessage_ConfigType;
|
} AdminMessage_ConfigType;
|
||||||
|
|
||||||
|
typedef enum _AdminMessage_ModuleConfigType {
|
||||||
|
AdminMessage_ModuleConfigType_MQTT_CONFIG = 0,
|
||||||
|
AdminMessage_ModuleConfigType_SERIAL_CONFIG = 1,
|
||||||
|
AdminMessage_ModuleConfigType_EXTNOTIF_CONFIG = 2,
|
||||||
|
AdminMessage_ModuleConfigType_STOREFORWARD_CONFIG = 3,
|
||||||
|
AdminMessage_ModuleConfigType_RANGETEST_CONFIG = 4,
|
||||||
|
AdminMessage_ModuleConfigType_TELEMETRY_CONFIG = 5,
|
||||||
|
AdminMessage_ModuleConfigType_CANNEDMSG_CONFIG = 6
|
||||||
|
} AdminMessage_ModuleConfigType;
|
||||||
|
|
||||||
/* Struct definitions */
|
/* Struct definitions */
|
||||||
/* This message is handled by the Admin module and is responsible for all settings/channel read/write operations.
|
/* This message is handled by the Admin module and is responsible for all settings/channel read/write operations.
|
||||||
This message is used to do settings operations to both remote AND local nodes.
|
This message is used to do settings operations to both remote AND local nodes.
|
||||||
@ -54,6 +55,10 @@ typedef struct _AdminMessage {
|
|||||||
Config get_config_response;
|
Config get_config_response;
|
||||||
Config set_config;
|
Config set_config;
|
||||||
bool confirm_set_config;
|
bool confirm_set_config;
|
||||||
|
AdminMessage_ModuleConfigType get_module_config_request;
|
||||||
|
ModuleConfig get_module_config_response;
|
||||||
|
ModuleConfig set_module_config;
|
||||||
|
bool confirm_set_module_config;
|
||||||
bool confirm_set_channel;
|
bool confirm_set_channel;
|
||||||
bool confirm_set_radio;
|
bool confirm_set_radio;
|
||||||
bool exit_simulator;
|
bool exit_simulator;
|
||||||
@ -76,9 +81,13 @@ typedef struct _AdminMessage {
|
|||||||
|
|
||||||
|
|
||||||
/* Helper constants for enums */
|
/* Helper constants for enums */
|
||||||
#define _AdminMessage_ConfigType_MIN AdminMessage_ConfigType_ALL
|
#define _AdminMessage_ConfigType_MIN AdminMessage_ConfigType_DEVICE_CONFIG
|
||||||
#define _AdminMessage_ConfigType_MAX AdminMessage_ConfigType_MODULE_CANNEDMSG_CONFIG
|
#define _AdminMessage_ConfigType_MAX AdminMessage_ConfigType_LORA_CONFIG
|
||||||
#define _AdminMessage_ConfigType_ARRAYSIZE ((AdminMessage_ConfigType)(AdminMessage_ConfigType_MODULE_CANNEDMSG_CONFIG+1))
|
#define _AdminMessage_ConfigType_ARRAYSIZE ((AdminMessage_ConfigType)(AdminMessage_ConfigType_LORA_CONFIG+1))
|
||||||
|
|
||||||
|
#define _AdminMessage_ModuleConfigType_MIN AdminMessage_ModuleConfigType_MQTT_CONFIG
|
||||||
|
#define _AdminMessage_ModuleConfigType_MAX AdminMessage_ModuleConfigType_CANNEDMSG_CONFIG
|
||||||
|
#define _AdminMessage_ModuleConfigType_ARRAYSIZE ((AdminMessage_ModuleConfigType)(AdminMessage_ModuleConfigType_CANNEDMSG_CONFIG+1))
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@ -103,6 +112,10 @@ extern "C" {
|
|||||||
#define AdminMessage_get_config_response_tag 11
|
#define AdminMessage_get_config_response_tag 11
|
||||||
#define AdminMessage_set_config_tag 12
|
#define AdminMessage_set_config_tag 12
|
||||||
#define AdminMessage_confirm_set_config_tag 13
|
#define AdminMessage_confirm_set_config_tag 13
|
||||||
|
#define AdminMessage_get_module_config_request_tag 14
|
||||||
|
#define AdminMessage_get_module_config_response_tag 15
|
||||||
|
#define AdminMessage_set_module_config_tag 16
|
||||||
|
#define AdminMessage_confirm_set_module_config_tag 17
|
||||||
#define AdminMessage_confirm_set_channel_tag 32
|
#define AdminMessage_confirm_set_channel_tag 32
|
||||||
#define AdminMessage_confirm_set_radio_tag 33
|
#define AdminMessage_confirm_set_radio_tag 33
|
||||||
#define AdminMessage_exit_simulator_tag 34
|
#define AdminMessage_exit_simulator_tag 34
|
||||||
@ -136,6 +149,10 @@ X(a, STATIC, ONEOF, UENUM, (variant,get_config_request,get_config_reques
|
|||||||
X(a, STATIC, ONEOF, MESSAGE, (variant,get_config_response,get_config_response), 11) \
|
X(a, STATIC, ONEOF, MESSAGE, (variant,get_config_response,get_config_response), 11) \
|
||||||
X(a, STATIC, ONEOF, MESSAGE, (variant,set_config,set_config), 12) \
|
X(a, STATIC, ONEOF, MESSAGE, (variant,set_config,set_config), 12) \
|
||||||
X(a, STATIC, ONEOF, BOOL, (variant,confirm_set_config,confirm_set_config), 13) \
|
X(a, STATIC, ONEOF, BOOL, (variant,confirm_set_config,confirm_set_config), 13) \
|
||||||
|
X(a, STATIC, ONEOF, UENUM, (variant,get_module_config_request,get_module_config_request), 14) \
|
||||||
|
X(a, STATIC, ONEOF, MESSAGE, (variant,get_module_config_response,get_module_config_response), 15) \
|
||||||
|
X(a, STATIC, ONEOF, MESSAGE, (variant,set_module_config,set_module_config), 16) \
|
||||||
|
X(a, STATIC, ONEOF, BOOL, (variant,confirm_set_module_config,confirm_set_module_config), 17) \
|
||||||
X(a, STATIC, ONEOF, BOOL, (variant,confirm_set_channel,confirm_set_channel), 32) \
|
X(a, STATIC, ONEOF, BOOL, (variant,confirm_set_channel,confirm_set_channel), 32) \
|
||||||
X(a, STATIC, ONEOF, BOOL, (variant,confirm_set_radio,confirm_set_radio), 33) \
|
X(a, STATIC, ONEOF, BOOL, (variant,confirm_set_radio,confirm_set_radio), 33) \
|
||||||
X(a, STATIC, ONEOF, BOOL, (variant,exit_simulator,exit_simulator), 34) \
|
X(a, STATIC, ONEOF, BOOL, (variant,exit_simulator,exit_simulator), 34) \
|
||||||
@ -163,6 +180,8 @@ X(a, STATIC, ONEOF, INT32, (variant,shutdown_seconds,shutdown_seconds),
|
|||||||
#define AdminMessage_variant_get_owner_response_MSGTYPE User
|
#define AdminMessage_variant_get_owner_response_MSGTYPE User
|
||||||
#define AdminMessage_variant_get_config_response_MSGTYPE Config
|
#define AdminMessage_variant_get_config_response_MSGTYPE Config
|
||||||
#define AdminMessage_variant_set_config_MSGTYPE Config
|
#define AdminMessage_variant_set_config_MSGTYPE Config
|
||||||
|
#define AdminMessage_variant_get_module_config_response_MSGTYPE ModuleConfig
|
||||||
|
#define AdminMessage_variant_set_module_config_MSGTYPE ModuleConfig
|
||||||
|
|
||||||
extern const pb_msgdesc_t AdminMessage_msg;
|
extern const pb_msgdesc_t AdminMessage_msg;
|
||||||
|
|
||||||
|
33
src/mesh/generated/module_config.pb.c
Normal file
33
src/mesh/generated/module_config.pb.c
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/* Automatically generated nanopb constant definitions */
|
||||||
|
/* Generated by nanopb-0.4.5 */
|
||||||
|
|
||||||
|
#include "module_config.pb.h"
|
||||||
|
#if PB_PROTO_HEADER_VERSION != 40
|
||||||
|
#error Regenerate this file with the current version of nanopb generator.
|
||||||
|
#endif
|
||||||
|
|
||||||
|
PB_BIND(ModuleConfig, ModuleConfig, AUTO)
|
||||||
|
|
||||||
|
|
||||||
|
PB_BIND(ModuleConfig_MQTTConfig, ModuleConfig_MQTTConfig, AUTO)
|
||||||
|
|
||||||
|
|
||||||
|
PB_BIND(ModuleConfig_SerialConfig, ModuleConfig_SerialConfig, AUTO)
|
||||||
|
|
||||||
|
|
||||||
|
PB_BIND(ModuleConfig_ExternalNotificationConfig, ModuleConfig_ExternalNotificationConfig, AUTO)
|
||||||
|
|
||||||
|
|
||||||
|
PB_BIND(ModuleConfig_StoreForwardConfig, ModuleConfig_StoreForwardConfig, AUTO)
|
||||||
|
|
||||||
|
|
||||||
|
PB_BIND(ModuleConfig_RangeTestConfig, ModuleConfig_RangeTestConfig, AUTO)
|
||||||
|
|
||||||
|
|
||||||
|
PB_BIND(ModuleConfig_TelemetryConfig, ModuleConfig_TelemetryConfig, AUTO)
|
||||||
|
|
||||||
|
|
||||||
|
PB_BIND(ModuleConfig_CannedMessageConfig, ModuleConfig_CannedMessageConfig, AUTO)
|
||||||
|
|
||||||
|
|
||||||
|
|
201
src/mesh/generated/module_config.pb.h
Normal file
201
src/mesh/generated/module_config.pb.h
Normal file
@ -0,0 +1,201 @@
|
|||||||
|
/* Automatically generated nanopb header */
|
||||||
|
/* Generated by nanopb-0.4.5 */
|
||||||
|
|
||||||
|
#ifndef PB_MODULE_CONFIG_PB_H_INCLUDED
|
||||||
|
#define PB_MODULE_CONFIG_PB_H_INCLUDED
|
||||||
|
#include <pb.h>
|
||||||
|
#include "telemetry.pb.h"
|
||||||
|
|
||||||
|
#if PB_PROTO_HEADER_VERSION != 40
|
||||||
|
#error Regenerate this file with the current version of nanopb generator.
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Struct definitions */
|
||||||
|
typedef struct _ModuleConfig_CannedMessageConfig {
|
||||||
|
char dummy_field;
|
||||||
|
} ModuleConfig_CannedMessageConfig;
|
||||||
|
|
||||||
|
typedef struct _ModuleConfig_ExternalNotificationConfig {
|
||||||
|
char dummy_field;
|
||||||
|
} ModuleConfig_ExternalNotificationConfig;
|
||||||
|
|
||||||
|
typedef struct _ModuleConfig_MQTTConfig {
|
||||||
|
char dummy_field;
|
||||||
|
} ModuleConfig_MQTTConfig;
|
||||||
|
|
||||||
|
typedef struct _ModuleConfig_RangeTestConfig {
|
||||||
|
char dummy_field;
|
||||||
|
} ModuleConfig_RangeTestConfig;
|
||||||
|
|
||||||
|
typedef struct _ModuleConfig_SerialConfig {
|
||||||
|
char dummy_field;
|
||||||
|
} ModuleConfig_SerialConfig;
|
||||||
|
|
||||||
|
typedef struct _ModuleConfig_StoreForwardConfig {
|
||||||
|
char dummy_field;
|
||||||
|
} ModuleConfig_StoreForwardConfig;
|
||||||
|
|
||||||
|
typedef struct _ModuleConfig_TelemetryConfig {
|
||||||
|
uint32_t device_update_interval;
|
||||||
|
uint32_t environment_update_interval;
|
||||||
|
bool environment_measurement_enabled;
|
||||||
|
bool environment_screen_enabled;
|
||||||
|
uint32_t environment_read_error_count_threshold;
|
||||||
|
uint32_t environment_recovery_interval;
|
||||||
|
bool environment_display_fahrenheit;
|
||||||
|
TelemetrySensorType environment_sensor_type;
|
||||||
|
uint32_t environment_sensor_pin;
|
||||||
|
} ModuleConfig_TelemetryConfig;
|
||||||
|
|
||||||
|
/* TODO: REPLACE */
|
||||||
|
typedef struct _ModuleConfig {
|
||||||
|
/* TODO: REPLACE */
|
||||||
|
pb_size_t which_payloadVariant;
|
||||||
|
union {
|
||||||
|
ModuleConfig_MQTTConfig mqtt_config;
|
||||||
|
ModuleConfig_SerialConfig serial_config;
|
||||||
|
ModuleConfig_ExternalNotificationConfig external_notification_config;
|
||||||
|
ModuleConfig_StoreForwardConfig store_forward_config;
|
||||||
|
ModuleConfig_RangeTestConfig range_test_config;
|
||||||
|
ModuleConfig_TelemetryConfig telemetry_config;
|
||||||
|
ModuleConfig_CannedMessageConfig canned_message_config;
|
||||||
|
} payloadVariant;
|
||||||
|
} ModuleConfig;
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Initializer values for message structs */
|
||||||
|
#define ModuleConfig_init_default {0, {ModuleConfig_MQTTConfig_init_default}}
|
||||||
|
#define ModuleConfig_MQTTConfig_init_default {0}
|
||||||
|
#define ModuleConfig_SerialConfig_init_default {0}
|
||||||
|
#define ModuleConfig_ExternalNotificationConfig_init_default {0}
|
||||||
|
#define ModuleConfig_StoreForwardConfig_init_default {0}
|
||||||
|
#define ModuleConfig_RangeTestConfig_init_default {0}
|
||||||
|
#define ModuleConfig_TelemetryConfig_init_default {0, 0, 0, 0, 0, 0, 0, _TelemetrySensorType_MIN, 0}
|
||||||
|
#define ModuleConfig_CannedMessageConfig_init_default {0}
|
||||||
|
#define ModuleConfig_init_zero {0, {ModuleConfig_MQTTConfig_init_zero}}
|
||||||
|
#define ModuleConfig_MQTTConfig_init_zero {0}
|
||||||
|
#define ModuleConfig_SerialConfig_init_zero {0}
|
||||||
|
#define ModuleConfig_ExternalNotificationConfig_init_zero {0}
|
||||||
|
#define ModuleConfig_StoreForwardConfig_init_zero {0}
|
||||||
|
#define ModuleConfig_RangeTestConfig_init_zero {0}
|
||||||
|
#define ModuleConfig_TelemetryConfig_init_zero {0, 0, 0, 0, 0, 0, 0, _TelemetrySensorType_MIN, 0}
|
||||||
|
#define ModuleConfig_CannedMessageConfig_init_zero {0}
|
||||||
|
|
||||||
|
/* Field tags (for use in manual encoding/decoding) */
|
||||||
|
#define ModuleConfig_TelemetryConfig_device_update_interval_tag 1
|
||||||
|
#define ModuleConfig_TelemetryConfig_environment_update_interval_tag 2
|
||||||
|
#define ModuleConfig_TelemetryConfig_environment_measurement_enabled_tag 3
|
||||||
|
#define ModuleConfig_TelemetryConfig_environment_screen_enabled_tag 4
|
||||||
|
#define ModuleConfig_TelemetryConfig_environment_read_error_count_threshold_tag 5
|
||||||
|
#define ModuleConfig_TelemetryConfig_environment_recovery_interval_tag 6
|
||||||
|
#define ModuleConfig_TelemetryConfig_environment_display_fahrenheit_tag 7
|
||||||
|
#define ModuleConfig_TelemetryConfig_environment_sensor_type_tag 8
|
||||||
|
#define ModuleConfig_TelemetryConfig_environment_sensor_pin_tag 9
|
||||||
|
#define ModuleConfig_mqtt_config_tag 1
|
||||||
|
#define ModuleConfig_serial_config_tag 2
|
||||||
|
#define ModuleConfig_external_notification_config_tag 3
|
||||||
|
#define ModuleConfig_store_forward_config_tag 4
|
||||||
|
#define ModuleConfig_range_test_config_tag 5
|
||||||
|
#define ModuleConfig_telemetry_config_tag 6
|
||||||
|
#define ModuleConfig_canned_message_config_tag 7
|
||||||
|
|
||||||
|
/* Struct field encoding specification for nanopb */
|
||||||
|
#define ModuleConfig_FIELDLIST(X, a) \
|
||||||
|
X(a, STATIC, ONEOF, MESSAGE, (payloadVariant,mqtt_config,payloadVariant.mqtt_config), 1) \
|
||||||
|
X(a, STATIC, ONEOF, MESSAGE, (payloadVariant,serial_config,payloadVariant.serial_config), 2) \
|
||||||
|
X(a, STATIC, ONEOF, MESSAGE, (payloadVariant,external_notification_config,payloadVariant.external_notification_config), 3) \
|
||||||
|
X(a, STATIC, ONEOF, MESSAGE, (payloadVariant,store_forward_config,payloadVariant.store_forward_config), 4) \
|
||||||
|
X(a, STATIC, ONEOF, MESSAGE, (payloadVariant,range_test_config,payloadVariant.range_test_config), 5) \
|
||||||
|
X(a, STATIC, ONEOF, MESSAGE, (payloadVariant,telemetry_config,payloadVariant.telemetry_config), 6) \
|
||||||
|
X(a, STATIC, ONEOF, MESSAGE, (payloadVariant,canned_message_config,payloadVariant.canned_message_config), 7)
|
||||||
|
#define ModuleConfig_CALLBACK NULL
|
||||||
|
#define ModuleConfig_DEFAULT NULL
|
||||||
|
#define ModuleConfig_payloadVariant_mqtt_config_MSGTYPE ModuleConfig_MQTTConfig
|
||||||
|
#define ModuleConfig_payloadVariant_serial_config_MSGTYPE ModuleConfig_SerialConfig
|
||||||
|
#define ModuleConfig_payloadVariant_external_notification_config_MSGTYPE ModuleConfig_ExternalNotificationConfig
|
||||||
|
#define ModuleConfig_payloadVariant_store_forward_config_MSGTYPE ModuleConfig_StoreForwardConfig
|
||||||
|
#define ModuleConfig_payloadVariant_range_test_config_MSGTYPE ModuleConfig_RangeTestConfig
|
||||||
|
#define ModuleConfig_payloadVariant_telemetry_config_MSGTYPE ModuleConfig_TelemetryConfig
|
||||||
|
#define ModuleConfig_payloadVariant_canned_message_config_MSGTYPE ModuleConfig_CannedMessageConfig
|
||||||
|
|
||||||
|
#define ModuleConfig_MQTTConfig_FIELDLIST(X, a) \
|
||||||
|
|
||||||
|
#define ModuleConfig_MQTTConfig_CALLBACK NULL
|
||||||
|
#define ModuleConfig_MQTTConfig_DEFAULT NULL
|
||||||
|
|
||||||
|
#define ModuleConfig_SerialConfig_FIELDLIST(X, a) \
|
||||||
|
|
||||||
|
#define ModuleConfig_SerialConfig_CALLBACK NULL
|
||||||
|
#define ModuleConfig_SerialConfig_DEFAULT NULL
|
||||||
|
|
||||||
|
#define ModuleConfig_ExternalNotificationConfig_FIELDLIST(X, a) \
|
||||||
|
|
||||||
|
#define ModuleConfig_ExternalNotificationConfig_CALLBACK NULL
|
||||||
|
#define ModuleConfig_ExternalNotificationConfig_DEFAULT NULL
|
||||||
|
|
||||||
|
#define ModuleConfig_StoreForwardConfig_FIELDLIST(X, a) \
|
||||||
|
|
||||||
|
#define ModuleConfig_StoreForwardConfig_CALLBACK NULL
|
||||||
|
#define ModuleConfig_StoreForwardConfig_DEFAULT NULL
|
||||||
|
|
||||||
|
#define ModuleConfig_RangeTestConfig_FIELDLIST(X, a) \
|
||||||
|
|
||||||
|
#define ModuleConfig_RangeTestConfig_CALLBACK NULL
|
||||||
|
#define ModuleConfig_RangeTestConfig_DEFAULT NULL
|
||||||
|
|
||||||
|
#define ModuleConfig_TelemetryConfig_FIELDLIST(X, a) \
|
||||||
|
X(a, STATIC, SINGULAR, UINT32, device_update_interval, 1) \
|
||||||
|
X(a, STATIC, SINGULAR, UINT32, environment_update_interval, 2) \
|
||||||
|
X(a, STATIC, SINGULAR, BOOL, environment_measurement_enabled, 3) \
|
||||||
|
X(a, STATIC, SINGULAR, BOOL, environment_screen_enabled, 4) \
|
||||||
|
X(a, STATIC, SINGULAR, UINT32, environment_read_error_count_threshold, 5) \
|
||||||
|
X(a, STATIC, SINGULAR, UINT32, environment_recovery_interval, 6) \
|
||||||
|
X(a, STATIC, SINGULAR, BOOL, environment_display_fahrenheit, 7) \
|
||||||
|
X(a, STATIC, SINGULAR, UENUM, environment_sensor_type, 8) \
|
||||||
|
X(a, STATIC, SINGULAR, UINT32, environment_sensor_pin, 9)
|
||||||
|
#define ModuleConfig_TelemetryConfig_CALLBACK NULL
|
||||||
|
#define ModuleConfig_TelemetryConfig_DEFAULT NULL
|
||||||
|
|
||||||
|
#define ModuleConfig_CannedMessageConfig_FIELDLIST(X, a) \
|
||||||
|
|
||||||
|
#define ModuleConfig_CannedMessageConfig_CALLBACK NULL
|
||||||
|
#define ModuleConfig_CannedMessageConfig_DEFAULT NULL
|
||||||
|
|
||||||
|
extern const pb_msgdesc_t ModuleConfig_msg;
|
||||||
|
extern const pb_msgdesc_t ModuleConfig_MQTTConfig_msg;
|
||||||
|
extern const pb_msgdesc_t ModuleConfig_SerialConfig_msg;
|
||||||
|
extern const pb_msgdesc_t ModuleConfig_ExternalNotificationConfig_msg;
|
||||||
|
extern const pb_msgdesc_t ModuleConfig_StoreForwardConfig_msg;
|
||||||
|
extern const pb_msgdesc_t ModuleConfig_RangeTestConfig_msg;
|
||||||
|
extern const pb_msgdesc_t ModuleConfig_TelemetryConfig_msg;
|
||||||
|
extern const pb_msgdesc_t ModuleConfig_CannedMessageConfig_msg;
|
||||||
|
|
||||||
|
/* Defines for backwards compatibility with code written before nanopb-0.4.0 */
|
||||||
|
#define ModuleConfig_fields &ModuleConfig_msg
|
||||||
|
#define ModuleConfig_MQTTConfig_fields &ModuleConfig_MQTTConfig_msg
|
||||||
|
#define ModuleConfig_SerialConfig_fields &ModuleConfig_SerialConfig_msg
|
||||||
|
#define ModuleConfig_ExternalNotificationConfig_fields &ModuleConfig_ExternalNotificationConfig_msg
|
||||||
|
#define ModuleConfig_StoreForwardConfig_fields &ModuleConfig_StoreForwardConfig_msg
|
||||||
|
#define ModuleConfig_RangeTestConfig_fields &ModuleConfig_RangeTestConfig_msg
|
||||||
|
#define ModuleConfig_TelemetryConfig_fields &ModuleConfig_TelemetryConfig_msg
|
||||||
|
#define ModuleConfig_CannedMessageConfig_fields &ModuleConfig_CannedMessageConfig_msg
|
||||||
|
|
||||||
|
/* Maximum encoded size of messages (where known) */
|
||||||
|
#define ModuleConfig_CannedMessageConfig_size 0
|
||||||
|
#define ModuleConfig_ExternalNotificationConfig_size 0
|
||||||
|
#define ModuleConfig_MQTTConfig_size 0
|
||||||
|
#define ModuleConfig_RangeTestConfig_size 0
|
||||||
|
#define ModuleConfig_SerialConfig_size 0
|
||||||
|
#define ModuleConfig_StoreForwardConfig_size 0
|
||||||
|
#define ModuleConfig_TelemetryConfig_size 38
|
||||||
|
#define ModuleConfig_size 40
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} /* extern "C" */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
@ -33,164 +33,42 @@ static void writeSecret(char *buf, const char *currentVal)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdminModule::handleGetChannel(const MeshPacket &req, uint32_t channelIndex)
|
/**
|
||||||
{
|
* @brief Handle recieved protobuf message
|
||||||
if (req.decoded.want_response) {
|
*
|
||||||
// We create the reply here
|
* @param mp Recieved MeshPacket
|
||||||
AdminMessage r = AdminMessage_init_default;
|
* @param r Decoded AdminMessage
|
||||||
r.get_channel_response = channels.getByIndex(channelIndex);
|
* @return bool
|
||||||
r.which_variant = AdminMessage_get_channel_response_tag;
|
*/
|
||||||
myReply = allocDataProtobuf(r);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void AdminModule::handleGetRadio(const MeshPacket &req)
|
|
||||||
{
|
|
||||||
if (req.decoded.want_response) {
|
|
||||||
// We create the reply here
|
|
||||||
AdminMessage r = AdminMessage_init_default;
|
|
||||||
r.get_radio_response = radioConfig;
|
|
||||||
|
|
||||||
// NOTE: The phone app needs to know the ls_secs & phone_timeout value so it can properly expect sleep behavior.
|
|
||||||
// So even if we internally use 0 to represent 'use default' we still need to send the value we are
|
|
||||||
// using to the app (so that even old phone apps work with new device loads).
|
|
||||||
r.get_radio_response.preferences.ls_secs = getPref_ls_secs();
|
|
||||||
r.get_radio_response.preferences.phone_timeout_secs = getPref_phone_timeout_secs();
|
|
||||||
// hideSecret(r.get_radio_response.preferences.wifi_ssid); // hmm - leave public for now, because only minimally private
|
|
||||||
// and useful for users to know current provisioning)
|
|
||||||
hideSecret(r.get_radio_response.preferences.wifi_password);
|
|
||||||
|
|
||||||
r.which_variant = AdminMessage_get_radio_response_tag;
|
|
||||||
myReply = allocDataProtobuf(r);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void AdminModule::handleGetConfig(const MeshPacket &req)
|
|
||||||
{
|
|
||||||
// We create the reply here
|
|
||||||
AdminMessage r = AdminMessage_init_default;
|
|
||||||
|
|
||||||
if (req.decoded.want_response) {
|
|
||||||
switch (r.get_config_request) {
|
|
||||||
case AdminMessage_ConfigType_ALL:
|
|
||||||
DEBUG_MSG("Requesting config: AdminMessage_ConfigType_ALL\n");
|
|
||||||
r.get_config_response.which_payloadVariant = AdminMessage_ConfigType_ALL;
|
|
||||||
break;
|
|
||||||
case AdminMessage_ConfigType_CORE_ONLY:
|
|
||||||
DEBUG_MSG("Requesting config: AdminMessage_ConfigType_CORE_ONLY\n");
|
|
||||||
r.get_config_response.which_payloadVariant = AdminMessage_ConfigType_CORE_ONLY;
|
|
||||||
break;
|
|
||||||
case AdminMessage_ConfigType_MODULE_ONLY:
|
|
||||||
DEBUG_MSG("Requesting config: AdminMessage_ConfigType_MODULE_ONLY\n");
|
|
||||||
r.get_config_response.which_payloadVariant = AdminMessage_ConfigType_MODULE_ONLY;
|
|
||||||
break;
|
|
||||||
case AdminMessage_ConfigType_DEVICE_CONFIG:
|
|
||||||
DEBUG_MSG("Requesting config: AdminMessage_ConfigType_DEVICE_CONFIG\n");
|
|
||||||
r.get_config_response.which_payloadVariant = AdminMessage_ConfigType_DEVICE_CONFIG;
|
|
||||||
break;
|
|
||||||
case AdminMessage_ConfigType_GPS_CONFIG:
|
|
||||||
DEBUG_MSG("Requesting config: AdminMessage_ConfigType_GPS_CONFIG\n");
|
|
||||||
r.get_config_response.which_payloadVariant = AdminMessage_ConfigType_GPS_CONFIG;
|
|
||||||
break;
|
|
||||||
case AdminMessage_ConfigType_POWER_CONFIG:
|
|
||||||
DEBUG_MSG("Requesting config: AdminMessage_ConfigType_POWER_CONFIG\n");
|
|
||||||
r.get_config_response.which_payloadVariant = AdminMessage_ConfigType_POWER_CONFIG;
|
|
||||||
break;
|
|
||||||
case AdminMessage_ConfigType_WIFI_CONFIG:
|
|
||||||
DEBUG_MSG("Requesting config: AdminMessage_ConfigType_WIFI_CONFIG\n");
|
|
||||||
r.get_config_response.which_payloadVariant = AdminMessage_ConfigType_POWER_CONFIG;
|
|
||||||
break;
|
|
||||||
case AdminMessage_ConfigType_DISPLAY_CONFIG:
|
|
||||||
DEBUG_MSG("Requesting config: AdminMessage_ConfigType_DISPLAY_CONFIG\n");
|
|
||||||
r.get_config_response.which_payloadVariant = AdminMessage_ConfigType_DISPLAY_CONFIG;
|
|
||||||
break;
|
|
||||||
case AdminMessage_ConfigType_LORA_CONFIG:
|
|
||||||
DEBUG_MSG("Requesting config: AdminMessage_ConfigType_LORA_CONFIG\n");
|
|
||||||
r.get_config_response.which_payloadVariant = AdminMessage_ConfigType_LORA_CONFIG;
|
|
||||||
break;
|
|
||||||
case AdminMessage_ConfigType_MODULE_MQTT_CONFIG:
|
|
||||||
DEBUG_MSG("Requesting config: AdminMessage_ConfigType_MODULE_MQTT_CONFIG\n");
|
|
||||||
r.get_config_response.which_payloadVariant = AdminMessage_ConfigType_MODULE_MQTT_CONFIG;
|
|
||||||
break;
|
|
||||||
case AdminMessage_ConfigType_MODULE_SERIAL_CONFIG:
|
|
||||||
DEBUG_MSG("Requesting config: AdminMessage_ConfigType_MODULE_SERIAL_CONFIG\n");
|
|
||||||
r.get_config_response.which_payloadVariant = AdminMessage_ConfigType_MODULE_SERIAL_CONFIG;
|
|
||||||
break;
|
|
||||||
case AdminMessage_ConfigType_MODULE_EXTNOTIF_CONFIG:
|
|
||||||
DEBUG_MSG("Requesting config: AdminMessage_ConfigType_MODULE_EXTNOTIF_CONFIG\n");
|
|
||||||
r.get_config_response.which_payloadVariant = AdminMessage_ConfigType_MODULE_EXTNOTIF_CONFIG;
|
|
||||||
break;
|
|
||||||
case AdminMessage_ConfigType_MODULE_STOREFORWARD_CONFIG:
|
|
||||||
DEBUG_MSG("Requesting config: AdminMessage_ConfigType_MODULE_STOREFORWARD_CONFIG\n");
|
|
||||||
r.get_config_response.which_payloadVariant = AdminMessage_ConfigType_MODULE_STOREFORWARD_CONFIG;
|
|
||||||
break;
|
|
||||||
case AdminMessage_ConfigType_MODULE_RANGETEST_CONFIG:
|
|
||||||
DEBUG_MSG("Requesting config: AdminMessage_ConfigType_MODULE_RANGETEST_CONFIG\n");
|
|
||||||
r.get_config_response.which_payloadVariant = AdminMessage_ConfigType_MODULE_RANGETEST_CONFIG;
|
|
||||||
break;
|
|
||||||
case AdminMessage_ConfigType_MODULE_TELEMETRY_CONFIG:
|
|
||||||
DEBUG_MSG("Requesting config: AdminMessage_ConfigType_MODULE_TELEMETRY_CONFIG\n");
|
|
||||||
r.get_config_response.which_payloadVariant = AdminMessage_ConfigType_MODULE_TELEMETRY_CONFIG;
|
|
||||||
r.get_config_response.payloadVariant.module_config.which_payloadVariant = Config_ModuleConfig_telemetry_config_tag;
|
|
||||||
r.get_config_response.payloadVariant.module_config.payloadVariant.telemetry_config =
|
|
||||||
config.payloadVariant.module_config.payloadVariant.telemetry_config;
|
|
||||||
break;
|
|
||||||
case AdminMessage_ConfigType_MODULE_CANNEDMSG_CONFIG:
|
|
||||||
DEBUG_MSG("Requesting config: AdminMessage_ConfigType_MODULE_CANNEDMSG_CONFIG\n");
|
|
||||||
r.get_config_response.which_payloadVariant = AdminMessage_ConfigType_MODULE_CANNEDMSG_CONFIG;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOTE: The phone app needs to know the ls_secs & phone_timeout value so it can properly expect sleep behavior.
|
|
||||||
// So even if we internally use 0 to represent 'use default' we still need to send the value we are
|
|
||||||
// using to the app (so that even old phone apps work with new device loads).
|
|
||||||
// r.get_radio_response.preferences.ls_secs = getPref_ls_secs();
|
|
||||||
// r.get_radio_response.preferences.phone_timeout_secs = getPref_phone_timeout_secs();
|
|
||||||
// hideSecret(r.get_radio_response.preferences.wifi_ssid); // hmm - leave public for now, because only minimally private
|
|
||||||
// and useful for users to know current provisioning) hideSecret(r.get_radio_response.preferences.wifi_password);
|
|
||||||
|
|
||||||
r.which_variant = AdminMessage_get_config_response_tag;
|
|
||||||
myReply = allocDataProtobuf(r);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void AdminModule::handleGetOwner(const MeshPacket &req)
|
|
||||||
{
|
|
||||||
if (req.decoded.want_response) {
|
|
||||||
// We create the reply here
|
|
||||||
AdminMessage r = AdminMessage_init_default;
|
|
||||||
r.get_owner_response = owner;
|
|
||||||
|
|
||||||
r.which_variant = AdminMessage_get_owner_response_tag;
|
|
||||||
myReply = allocDataProtobuf(r);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AdminModule::handleReceivedProtobuf(const MeshPacket &mp, AdminMessage *r)
|
bool AdminModule::handleReceivedProtobuf(const MeshPacket &mp, AdminMessage *r)
|
||||||
{
|
{
|
||||||
// if handled == false, then let others look at this message also if they want
|
// if handled == false, then let others look at this message also if they want
|
||||||
bool handled = false;
|
bool handled = false;
|
||||||
|
|
||||||
assert(r);
|
assert(r);
|
||||||
|
|
||||||
switch (r->which_variant) {
|
switch (r->which_variant) {
|
||||||
case AdminMessage_set_owner_tag:
|
|
||||||
DEBUG_MSG("Client is setting owner\n");
|
/**
|
||||||
handleSetOwner(r->set_owner);
|
* Getters
|
||||||
|
*/
|
||||||
|
case AdminMessage_get_owner_request_tag:
|
||||||
|
DEBUG_MSG("Client is getting owner\n");
|
||||||
|
handleGetOwner(mp);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AdminMessage_set_radio_tag:
|
case AdminMessage_get_radio_request_tag:
|
||||||
DEBUG_MSG("Client is setting radio\n");
|
DEBUG_MSG("Client is getting radio\n");
|
||||||
handleSetRadio(r->set_radio);
|
handleGetRadio(mp);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AdminMessage_set_channel_tag:
|
case AdminMessage_get_config_request_tag:
|
||||||
DEBUG_MSG("Client is setting channel %d\n", r->set_channel.index);
|
DEBUG_MSG("Client is getting config\n");
|
||||||
if (r->set_channel.index < 0 || r->set_channel.index >= (int)MAX_NUM_CHANNELS)
|
handleGetConfig(mp);
|
||||||
myReply = allocErrorResponse(Routing_Error_BAD_REQUEST, &mp);
|
break;
|
||||||
else
|
|
||||||
handleSetChannel(r->set_channel);
|
case AdminMessage_get_module_config_request_tag:
|
||||||
|
DEBUG_MSG("Client is getting module config\n");
|
||||||
|
handleGetModuleConfig(mp);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AdminMessage_get_channel_request_tag: {
|
case AdminMessage_get_channel_request_tag: {
|
||||||
@ -203,14 +81,17 @@ bool AdminModule::handleReceivedProtobuf(const MeshPacket &mp, AdminMessage *r)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case AdminMessage_get_radio_request_tag:
|
/**
|
||||||
DEBUG_MSG("Client is getting radio\n");
|
* Setters
|
||||||
handleGetRadio(mp);
|
*/
|
||||||
|
case AdminMessage_set_owner_tag:
|
||||||
|
DEBUG_MSG("Client is setting owner\n");
|
||||||
|
handleSetOwner(r->set_owner);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AdminMessage_get_config_request_tag:
|
case AdminMessage_set_radio_tag:
|
||||||
DEBUG_MSG("Client is getting config\n");
|
DEBUG_MSG("Client is setting radio\n");
|
||||||
handleGetConfig(mp);
|
handleSetRadio(r->set_radio);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AdminMessage_set_config_tag:
|
case AdminMessage_set_config_tag:
|
||||||
@ -218,11 +99,22 @@ bool AdminModule::handleReceivedProtobuf(const MeshPacket &mp, AdminMessage *r)
|
|||||||
handleSetConfig(r->set_config);
|
handleSetConfig(r->set_config);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AdminMessage_get_owner_request_tag:
|
case AdminMessage_set_module_config_tag:
|
||||||
DEBUG_MSG("Client is getting owner\n");
|
DEBUG_MSG("Client is setting the module config\n");
|
||||||
handleGetOwner(mp);
|
handleSetModuleConfig(r->set_module_config);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case AdminMessage_set_channel_tag:
|
||||||
|
DEBUG_MSG("Client is setting channel %d\n", r->set_channel.index);
|
||||||
|
if (r->set_channel.index < 0 || r->set_channel.index >= (int)MAX_NUM_CHANNELS)
|
||||||
|
myReply = allocErrorResponse(Routing_Error_BAD_REQUEST, &mp);
|
||||||
|
else
|
||||||
|
handleSetChannel(r->set_channel);
|
||||||
|
break;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Other
|
||||||
|
*/
|
||||||
case AdminMessage_reboot_seconds_tag: {
|
case AdminMessage_reboot_seconds_tag: {
|
||||||
int32_t s = r->reboot_seconds;
|
int32_t s = r->reboot_seconds;
|
||||||
DEBUG_MSG("Rebooting in %d seconds\n", s);
|
DEBUG_MSG("Rebooting in %d seconds\n", s);
|
||||||
@ -260,6 +152,10 @@ bool AdminModule::handleReceivedProtobuf(const MeshPacket &mp, AdminMessage *r)
|
|||||||
return handled;
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter methods
|
||||||
|
*/
|
||||||
|
|
||||||
void AdminModule::handleSetOwner(const User &o)
|
void AdminModule::handleSetOwner(const User &o)
|
||||||
{
|
{
|
||||||
int changed = 0;
|
int changed = 0;
|
||||||
@ -285,6 +181,69 @@ void AdminModule::handleSetOwner(const User &o)
|
|||||||
service.reloadOwner();
|
service.reloadOwner();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AdminModule::handleSetRadio(RadioConfig &r)
|
||||||
|
{
|
||||||
|
writeSecret(r.preferences.wifi_password, radioConfig.preferences.wifi_password);
|
||||||
|
radioConfig = r;
|
||||||
|
|
||||||
|
service.reloadConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AdminModule::handleSetConfig(const Config &c)
|
||||||
|
{
|
||||||
|
switch (c.which_payloadVariant) {
|
||||||
|
case AdminMessage_ConfigType_DEVICE_CONFIG:
|
||||||
|
DEBUG_MSG("Setting config: Device\n");
|
||||||
|
break;
|
||||||
|
case AdminMessage_ConfigType_GPS_CONFIG:
|
||||||
|
DEBUG_MSG("Setting config: GPS\n");
|
||||||
|
break;
|
||||||
|
case AdminMessage_ConfigType_POWER_CONFIG:
|
||||||
|
DEBUG_MSG("Setting config: Power\n");
|
||||||
|
break;
|
||||||
|
case AdminMessage_ConfigType_WIFI_CONFIG:
|
||||||
|
DEBUG_MSG("Setting config: WiFi\n");
|
||||||
|
break;
|
||||||
|
case AdminMessage_ConfigType_DISPLAY_CONFIG:
|
||||||
|
DEBUG_MSG("Setting config: Display\n");
|
||||||
|
break;
|
||||||
|
case AdminMessage_ConfigType_LORA_CONFIG:
|
||||||
|
DEBUG_MSG("Setting config: LoRa\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
service.reloadConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AdminModule::handleSetModuleConfig(const ModuleConfig &c)
|
||||||
|
{
|
||||||
|
switch (c.which_payloadVariant) {
|
||||||
|
case AdminMessage_ModuleConfigType_MQTT_CONFIG:
|
||||||
|
DEBUG_MSG("Setting module config: MQTT\n");
|
||||||
|
break;
|
||||||
|
case AdminMessage_ModuleConfigType_SERIAL_CONFIG:
|
||||||
|
DEBUG_MSG("Setting module config: Serial\n");
|
||||||
|
break;
|
||||||
|
case AdminMessage_ModuleConfigType_EXTNOTIF_CONFIG:
|
||||||
|
DEBUG_MSG("Setting module config: External Notification\n");
|
||||||
|
break;
|
||||||
|
case AdminMessage_ModuleConfigType_STOREFORWARD_CONFIG:
|
||||||
|
DEBUG_MSG("Setting module config: Store & Forward\n");
|
||||||
|
break;
|
||||||
|
case AdminMessage_ModuleConfigType_RANGETEST_CONFIG:
|
||||||
|
DEBUG_MSG("Setting module config: Range Test\n");
|
||||||
|
break;
|
||||||
|
case AdminMessage_ModuleConfigType_TELEMETRY_CONFIG:
|
||||||
|
DEBUG_MSG("Setting module config: Telemetry\n");
|
||||||
|
break;
|
||||||
|
case AdminMessage_ModuleConfigType_CANNEDMSG_CONFIG:
|
||||||
|
DEBUG_MSG("Setting module config: Canned Message\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
service.reloadConfig();
|
||||||
|
}
|
||||||
|
|
||||||
void AdminModule::handleSetChannel(const Channel &cc)
|
void AdminModule::handleSetChannel(const Channel &cc)
|
||||||
{
|
{
|
||||||
channels.setChannel(cc);
|
channels.setChannel(cc);
|
||||||
@ -299,72 +258,151 @@ void AdminModule::handleSetChannel(const Channel &cc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdminModule::handleSetRadio(RadioConfig &r)
|
/**
|
||||||
{
|
* Getter methods
|
||||||
writeSecret(r.preferences.wifi_password, radioConfig.preferences.wifi_password);
|
*/
|
||||||
radioConfig = r;
|
|
||||||
|
|
||||||
service.reloadConfig();
|
void AdminModule::handleGetOwner(const MeshPacket &req)
|
||||||
|
{
|
||||||
|
if (req.decoded.want_response) {
|
||||||
|
// We create the reply here
|
||||||
|
AdminMessage r = AdminMessage_init_default;
|
||||||
|
r.get_owner_response = owner;
|
||||||
|
|
||||||
|
r.which_variant = AdminMessage_get_owner_response_tag;
|
||||||
|
myReply = allocDataProtobuf(r);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdminModule::handleSetConfig(const Config &c)
|
void AdminModule::handleGetRadio(const MeshPacket &req)
|
||||||
{
|
{
|
||||||
switch (c.which_payloadVariant) {
|
if (req.decoded.want_response) {
|
||||||
case AdminMessage_ConfigType_ALL:
|
// We create the reply here
|
||||||
DEBUG_MSG("Setting config: AdminMessage_ConfigType_ALL\n");
|
AdminMessage r = AdminMessage_init_default;
|
||||||
break;
|
r.get_radio_response = radioConfig;
|
||||||
case AdminMessage_ConfigType_CORE_ONLY:
|
|
||||||
DEBUG_MSG("Setting config: AdminMessage_ConfigType_CORE_ONLY\n");
|
|
||||||
break;
|
|
||||||
case AdminMessage_ConfigType_MODULE_ONLY:
|
|
||||||
DEBUG_MSG("Setting config: AdminMessage_ConfigType_MODULE_ONLY\n");
|
|
||||||
break;
|
|
||||||
case AdminMessage_ConfigType_DEVICE_CONFIG:
|
|
||||||
DEBUG_MSG("Setting config: AdminMessage_ConfigType_DEVICE_CONFIG\n");
|
|
||||||
break;
|
|
||||||
case AdminMessage_ConfigType_GPS_CONFIG:
|
|
||||||
DEBUG_MSG("Setting config: AdminMessage_ConfigType_GPS_CONFIG\n");
|
|
||||||
break;
|
|
||||||
case AdminMessage_ConfigType_POWER_CONFIG:
|
|
||||||
DEBUG_MSG("Setting config: AdminMessage_ConfigType_POWER_CONFIG\n");
|
|
||||||
break;
|
|
||||||
case AdminMessage_ConfigType_WIFI_CONFIG:
|
|
||||||
DEBUG_MSG("Setting config: AdminMessage_ConfigType_WIFI_CONFIG\n");
|
|
||||||
break;
|
|
||||||
case AdminMessage_ConfigType_DISPLAY_CONFIG:
|
|
||||||
DEBUG_MSG("Setting config: AdminMessage_ConfigType_DISPLAY_CONFIG\n");
|
|
||||||
break;
|
|
||||||
case AdminMessage_ConfigType_LORA_CONFIG:
|
|
||||||
DEBUG_MSG("Setting config: AdminMessage_ConfigType_LORA_CONFIG\n");
|
|
||||||
break;
|
|
||||||
case AdminMessage_ConfigType_MODULE_MQTT_CONFIG:
|
|
||||||
DEBUG_MSG("Setting config: AdminMessage_ConfigType_MODULE_MQTT_CONFIG\n");
|
|
||||||
break;
|
|
||||||
case AdminMessage_ConfigType_MODULE_SERIAL_CONFIG:
|
|
||||||
DEBUG_MSG("Setting config: AdminMessage_ConfigType_MODULE_SERIAL_CONFIG\n");
|
|
||||||
break;
|
|
||||||
case AdminMessage_ConfigType_MODULE_EXTNOTIF_CONFIG:
|
|
||||||
DEBUG_MSG("Setting config: AdminMessage_ConfigType_MODULE_EXTNOTIF_CONFIG\n");
|
|
||||||
break;
|
|
||||||
case AdminMessage_ConfigType_MODULE_STOREFORWARD_CONFIG:
|
|
||||||
DEBUG_MSG("Setting config: AdminMessage_ConfigType_MODULE_STOREFORWARD_CONFIG\n");
|
|
||||||
break;
|
|
||||||
case AdminMessage_ConfigType_MODULE_RANGETEST_CONFIG:
|
|
||||||
DEBUG_MSG("Setting config: AdminMessage_ConfigType_MODULE_RANGETEST_CONFIG\n");
|
|
||||||
break;
|
|
||||||
case AdminMessage_ConfigType_MODULE_TELEMETRY_CONFIG:
|
|
||||||
DEBUG_MSG("Setting config: AdminMessage_ConfigType_MODULE_TELEMETRY_CONFIG\n");
|
|
||||||
config.payloadVariant.module_config.payloadVariant.telemetry_config =
|
|
||||||
c.payloadVariant.module_config.payloadVariant.telemetry_config;
|
|
||||||
break;
|
|
||||||
case AdminMessage_ConfigType_MODULE_CANNEDMSG_CONFIG:
|
|
||||||
DEBUG_MSG("Setting config: AdminMessage_ConfigType_MODULE_CANNEDMSG_CONFIG\n");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
service.reloadConfig();
|
// NOTE: The phone app needs to know the ls_secs & phone_timeout value so it can properly expect sleep behavior.
|
||||||
|
// So even if we internally use 0 to represent 'use default' we still need to send the value we are
|
||||||
|
// using to the app (so that even old phone apps work with new device loads).
|
||||||
|
r.get_radio_response.preferences.ls_secs = getPref_ls_secs();
|
||||||
|
r.get_radio_response.preferences.phone_timeout_secs = getPref_phone_timeout_secs();
|
||||||
|
// hideSecret(r.get_radio_response.preferences.wifi_ssid); // hmm - leave public for now, because only minimally private
|
||||||
|
// and useful for users to know current provisioning)
|
||||||
|
hideSecret(r.get_radio_response.preferences.wifi_password);
|
||||||
|
|
||||||
|
r.which_variant = AdminMessage_get_radio_response_tag;
|
||||||
|
myReply = allocDataProtobuf(r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AdminModule::handleGetConfig(const MeshPacket &req)
|
||||||
|
{
|
||||||
|
// We create the reply here
|
||||||
|
AdminMessage r = AdminMessage_init_default;
|
||||||
|
|
||||||
|
if (req.decoded.want_response) {
|
||||||
|
switch (r.get_config_request) {
|
||||||
|
case AdminMessage_ConfigType_DEVICE_CONFIG:
|
||||||
|
DEBUG_MSG("Getting config: Device\n");
|
||||||
|
r.get_config_response.which_payloadVariant = Config_device_config_tag;
|
||||||
|
break;
|
||||||
|
case AdminMessage_ConfigType_GPS_CONFIG:
|
||||||
|
DEBUG_MSG("Getting config: GPS\n");
|
||||||
|
r.get_config_response.which_payloadVariant = Config_gps_config_tag;
|
||||||
|
break;
|
||||||
|
case AdminMessage_ConfigType_POWER_CONFIG:
|
||||||
|
DEBUG_MSG("Getting config: Power\n");
|
||||||
|
r.get_config_response.which_payloadVariant = Config_power_config_tag;
|
||||||
|
break;
|
||||||
|
case AdminMessage_ConfigType_WIFI_CONFIG:
|
||||||
|
DEBUG_MSG("Getting config: WiFi\n");
|
||||||
|
r.get_config_response.which_payloadVariant = Config_wifi_config_tag;
|
||||||
|
break;
|
||||||
|
case AdminMessage_ConfigType_DISPLAY_CONFIG:
|
||||||
|
DEBUG_MSG("Getting config: Display\n");
|
||||||
|
r.get_config_response.which_payloadVariant = Config_display_config_tag;
|
||||||
|
break;
|
||||||
|
case AdminMessage_ConfigType_LORA_CONFIG:
|
||||||
|
DEBUG_MSG("Getting config: LoRa\n");
|
||||||
|
r.get_config_response.which_payloadVariant = Config_lora_config_tag;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE: The phone app needs to know the ls_secs & phone_timeout value so it can properly expect sleep behavior.
|
||||||
|
// So even if we internally use 0 to represent 'use default' we still need to send the value we are
|
||||||
|
// using to the app (so that even old phone apps work with new device loads).
|
||||||
|
// r.get_radio_response.preferences.ls_secs = getPref_ls_secs();
|
||||||
|
// r.get_radio_response.preferences.phone_timeout_secs = getPref_phone_timeout_secs();
|
||||||
|
// hideSecret(r.get_radio_response.preferences.wifi_ssid); // hmm - leave public for now, because only minimally private
|
||||||
|
// and useful for users to know current provisioning) hideSecret(r.get_radio_response.preferences.wifi_password);
|
||||||
|
// r.get_config_response.which_payloadVariant = Config_ModuleConfig_telemetry_config_tag;
|
||||||
|
r.which_variant = AdminMessage_get_config_response_tag;
|
||||||
|
myReply = allocDataProtobuf(r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AdminModule::handleGetModuleConfig(const MeshPacket &req)
|
||||||
|
{
|
||||||
|
// We create the reply here
|
||||||
|
AdminMessage r = AdminMessage_init_default;
|
||||||
|
|
||||||
|
Serial.println(r.get_module_config_request);
|
||||||
|
|
||||||
|
if (req.decoded.want_response) {
|
||||||
|
switch (r.get_module_config_request) {
|
||||||
|
case AdminMessage_ModuleConfigType_MQTT_CONFIG:
|
||||||
|
DEBUG_MSG("Getting module config: MQTT\n");
|
||||||
|
r.get_module_config_response.which_payloadVariant = ModuleConfig_mqtt_config_tag;
|
||||||
|
break;
|
||||||
|
case AdminMessage_ModuleConfigType_SERIAL_CONFIG:
|
||||||
|
DEBUG_MSG("Getting module config: Serial\n");
|
||||||
|
r.get_module_config_response.which_payloadVariant = ModuleConfig_serial_config_tag;
|
||||||
|
break;
|
||||||
|
case AdminMessage_ModuleConfigType_EXTNOTIF_CONFIG:
|
||||||
|
DEBUG_MSG("Getting module config: External Notification\n");
|
||||||
|
r.get_module_config_response.which_payloadVariant = ModuleConfig_external_notification_config_tag;
|
||||||
|
break;
|
||||||
|
case AdminMessage_ModuleConfigType_STOREFORWARD_CONFIG:
|
||||||
|
DEBUG_MSG("Getting module config: Store & Forward\n");
|
||||||
|
r.get_module_config_response.which_payloadVariant = ModuleConfig_store_forward_config_tag;
|
||||||
|
break;
|
||||||
|
case AdminMessage_ModuleConfigType_RANGETEST_CONFIG:
|
||||||
|
DEBUG_MSG("Getting module config: Range Test\n");
|
||||||
|
r.get_module_config_response.which_payloadVariant = ModuleConfig_range_test_config_tag;
|
||||||
|
break;
|
||||||
|
case AdminMessage_ModuleConfigType_TELEMETRY_CONFIG:
|
||||||
|
DEBUG_MSG("Getting module config: Telemetry\n");
|
||||||
|
r.get_module_config_response.which_payloadVariant = ModuleConfig_telemetry_config_tag;
|
||||||
|
r.get_module_config_response.payloadVariant.telemetry_config = moduleConfig.payloadVariant.telemetry_config;
|
||||||
|
break;
|
||||||
|
case AdminMessage_ModuleConfigType_CANNEDMSG_CONFIG:
|
||||||
|
DEBUG_MSG("Getting module config: Canned Message\n");
|
||||||
|
r.get_module_config_response.which_payloadVariant = ModuleConfig_canned_message_config_tag;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE: The phone app needs to know the ls_secs & phone_timeout value so it can properly expect sleep behavior.
|
||||||
|
// So even if we internally use 0 to represent 'use default' we still need to send the value we are
|
||||||
|
// using to the app (so that even old phone apps work with new device loads).
|
||||||
|
// r.get_radio_response.preferences.ls_secs = getPref_ls_secs();
|
||||||
|
// r.get_radio_response.preferences.phone_timeout_secs = getPref_phone_timeout_secs();
|
||||||
|
// hideSecret(r.get_radio_response.preferences.wifi_ssid); // hmm - leave public for now, because only minimally private
|
||||||
|
// and useful for users to know current provisioning) hideSecret(r.get_radio_response.preferences.wifi_password);
|
||||||
|
// r.get_config_response.which_payloadVariant = Config_ModuleConfig_telemetry_config_tag;
|
||||||
|
r.which_variant = AdminMessage_get_module_config_response_tag;
|
||||||
|
myReply = allocDataProtobuf(r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AdminModule::handleGetChannel(const MeshPacket &req, uint32_t channelIndex)
|
||||||
|
{
|
||||||
|
if (req.decoded.want_response) {
|
||||||
|
// We create the reply here
|
||||||
|
AdminMessage r = AdminMessage_init_default;
|
||||||
|
r.get_channel_response = channels.getByIndex(channelIndex);
|
||||||
|
r.which_variant = AdminMessage_get_channel_response_tag;
|
||||||
|
myReply = allocDataProtobuf(r);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AdminModule::AdminModule() : ProtobufModule("Admin", PortNum_ADMIN_APP, AdminMessage_fields)
|
AdminModule::AdminModule() : ProtobufModule("Admin", PortNum_ADMIN_APP, AdminMessage_fields)
|
||||||
|
@ -20,15 +20,24 @@ class AdminModule : public ProtobufModule<AdminMessage>
|
|||||||
virtual bool handleReceivedProtobuf(const MeshPacket &mp, AdminMessage *p) override;
|
virtual bool handleReceivedProtobuf(const MeshPacket &mp, AdminMessage *p) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void handleSetOwner(const User &o);
|
/**
|
||||||
void handleSetChannel(const Channel &cc);
|
* Getters
|
||||||
void handleSetRadio(RadioConfig &r);
|
*/
|
||||||
void handleSetConfig(const Config &c);
|
void handleGetOwner(const MeshPacket &req);
|
||||||
|
|
||||||
void handleGetChannel(const MeshPacket &req, uint32_t channelIndex);
|
|
||||||
void handleGetRadio(const MeshPacket &req);
|
void handleGetRadio(const MeshPacket &req);
|
||||||
void handleGetConfig(const MeshPacket &req);
|
void handleGetConfig(const MeshPacket &req);
|
||||||
void handleGetOwner(const MeshPacket &req);
|
void handleGetModuleConfig(const MeshPacket &req);
|
||||||
|
void handleGetChannel(const MeshPacket &req, uint32_t channelIndex);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setters
|
||||||
|
*/
|
||||||
|
void handleSetOwner(const User &o);
|
||||||
|
void handleSetRadio(RadioConfig &r);
|
||||||
|
void handleSetChannel(const Channel &cc);
|
||||||
|
void handleSetConfig(const Config &c);
|
||||||
|
void handleSetModuleConfig(const ModuleConfig &c);
|
||||||
|
void handleSetChannel();
|
||||||
};
|
};
|
||||||
|
|
||||||
extern AdminModule *adminModule;
|
extern AdminModule *adminModule;
|
||||||
|
Loading…
Reference in New Issue
Block a user