Split config structure in two

This commit is contained in:
Sacha Weatherstone
2022-05-02 22:00:24 +10:00
parent 399e053ebd
commit f84286d138
8 changed files with 581 additions and 269 deletions

View File

@@ -7,6 +7,7 @@
#include "channel.pb.h"
#include "config.pb.h"
#include "mesh.pb.h"
#include "module_config.pb.h"
#include "radioconfig.pb.h"
#if PB_PROTO_HEADER_VERSION != 40
@@ -15,24 +16,24 @@
/* Enum definitions */
typedef enum _AdminMessage_ConfigType {
AdminMessage_ConfigType_ALL = 0,
AdminMessage_ConfigType_CORE_ONLY = 1,
AdminMessage_ConfigType_MODULE_ONLY = 2,
AdminMessage_ConfigType_DEVICE_CONFIG = 3,
AdminMessage_ConfigType_GPS_CONFIG = 4,
AdminMessage_ConfigType_POWER_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_DEVICE_CONFIG = 0,
AdminMessage_ConfigType_GPS_CONFIG = 1,
AdminMessage_ConfigType_POWER_CONFIG = 2,
AdminMessage_ConfigType_WIFI_CONFIG = 3,
AdminMessage_ConfigType_DISPLAY_CONFIG = 4,
AdminMessage_ConfigType_LORA_CONFIG = 5
} 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 */
/* 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.
@@ -54,6 +55,10 @@ typedef struct _AdminMessage {
Config get_config_response;
Config 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_radio;
bool exit_simulator;
@@ -76,9 +81,13 @@ typedef struct _AdminMessage {
/* Helper constants for enums */
#define _AdminMessage_ConfigType_MIN AdminMessage_ConfigType_ALL
#define _AdminMessage_ConfigType_MAX AdminMessage_ConfigType_MODULE_CANNEDMSG_CONFIG
#define _AdminMessage_ConfigType_ARRAYSIZE ((AdminMessage_ConfigType)(AdminMessage_ConfigType_MODULE_CANNEDMSG_CONFIG+1))
#define _AdminMessage_ConfigType_MIN AdminMessage_ConfigType_DEVICE_CONFIG
#define _AdminMessage_ConfigType_MAX AdminMessage_ConfigType_LORA_CONFIG
#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
@@ -103,6 +112,10 @@ extern "C" {
#define AdminMessage_get_config_response_tag 11
#define AdminMessage_set_config_tag 12
#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_radio_tag 33
#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,set_config,set_config), 12) \
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_radio,confirm_set_radio), 33) \
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_config_response_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;

View 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)

View 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