New bluetooth config protos and canned messages consolidation (#1632)

* Bluetooth and canned messages refactor

* More can of worms messages

* Set has_bluetooth and default pin

* Defaults
This commit is contained in:
Ben Meadors 2022-08-15 21:06:55 -05:00 committed by GitHub
parent aadaf332cf
commit 86d3759f55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 156 additions and 274 deletions

@ -1 +1 @@
Subproject commit c473ed7a6aa83c4be80382aa9abf8f8258be40a3 Subproject commit 2fadf011e574c180afb395bc2a751b3f7e56839c

View File

@ -150,14 +150,17 @@ void NodeDB::installDefaultConfig()
config.has_position = true; config.has_position = true;
config.has_power = true; config.has_power = true;
config.has_wifi = true; config.has_wifi = true;
config.has_bluetooth = true;
config.lora.region = Config_LoRaConfig_RegionCode_Unset; config.lora.region = Config_LoRaConfig_RegionCode_Unset;
config.lora.modem_preset = Config_LoRaConfig_ModemPreset_LongFast; config.lora.modem_preset = Config_LoRaConfig_ModemPreset_LongFast;
resetRadioConfig(); resetRadioConfig();
strncpy(config.device.ntp_server, "0.pool.ntp.org", 32); strncpy(config.device.ntp_server, "0.pool.ntp.org", 32);
// FIXME: Default to bluetooth capability of platform as default
config.bluetooth.enabled = true;
config.bluetooth.fixed_pin = defaultBLEPin;
// for backward compat, default position flags are ALT+MSL // for backward compat, default position flags are ALT+MSL
config.position.position_flags = config.position.position_flags = (Config_PositionConfig_PositionFlags_POS_ALTITUDE | Config_PositionConfig_PositionFlags_POS_ALT_MSL);
(Config_PositionConfig_PositionFlags_POS_ALTITUDE | Config_PositionConfig_PositionFlags_POS_ALT_MSL);
} }
void NodeDB::installDefaultModuleConfig() void NodeDB::installDefaultModuleConfig()
@ -452,6 +455,7 @@ void NodeDB::saveToDisk()
config.has_position = true; config.has_position = true;
config.has_power = true; config.has_power = true;
config.has_wifi = true; config.has_wifi = true;
config.has_bluetooth = true;
saveProto(configFileName, LocalConfig_size, sizeof(LocalConfig), LocalConfig_fields, &config); saveProto(configFileName, LocalConfig_size, sizeof(LocalConfig), LocalConfig_fields, &config);
moduleConfig.has_canned_message = true; moduleConfig.has_canned_message = true;

View File

@ -13,7 +13,7 @@ DeviceState versions used to be defined in the .proto file but really only this
#define here. #define here.
*/ */
#define DEVICESTATE_CUR_VER 14 #define DEVICESTATE_CUR_VER 15
#define DEVICESTATE_MIN_VER DEVICESTATE_CUR_VER #define DEVICESTATE_MIN_VER DEVICESTATE_CUR_VER
extern DeviceState devicestate; extern DeviceState devicestate;

View File

@ -189,15 +189,18 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
fromRadioScratch.config.which_payloadVariant = Config_lora_tag; fromRadioScratch.config.which_payloadVariant = Config_lora_tag;
fromRadioScratch.config.payloadVariant.lora = config.lora; fromRadioScratch.config.payloadVariant.lora = config.lora;
break; break;
case Config_bluetooth_tag:
fromRadioScratch.config.which_payloadVariant = Config_bluetooth_tag;
fromRadioScratch.config.payloadVariant.bluetooth = config.bluetooth;
break;
} }
// NOTE: The phone app needs to know the ls_secs value so it can properly expect sleep behavior. // NOTE: The phone app needs to know the ls_secs 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 // 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). // using to the app (so that even old phone apps work with new device loads).
config_state++; config_state++;
// Advance when we have sent all of our config objects // Advance when we have sent all of our config objects
if (config_state > Config_lora_tag) { if (config_state > Config_bluetooth_tag) {
state = STATE_SEND_MODULECONFIG; state = STATE_SEND_MODULECONFIG;
config_state = ModuleConfig_mqtt_tag; config_state = ModuleConfig_mqtt_tag;
} }

View File

@ -21,7 +21,8 @@ typedef enum _AdminMessage_ConfigType {
AdminMessage_ConfigType_POWER_CONFIG = 2, AdminMessage_ConfigType_POWER_CONFIG = 2,
AdminMessage_ConfigType_WIFI_CONFIG = 3, AdminMessage_ConfigType_WIFI_CONFIG = 3,
AdminMessage_ConfigType_DISPLAY_CONFIG = 4, AdminMessage_ConfigType_DISPLAY_CONFIG = 4,
AdminMessage_ConfigType_LORA_CONFIG = 5 AdminMessage_ConfigType_LORA_CONFIG = 5,
AdminMessage_ConfigType_BLUETOOTH_CONFIG = 6
} AdminMessage_ConfigType; } AdminMessage_ConfigType;
typedef enum _AdminMessage_ModuleConfigType { typedef enum _AdminMessage_ModuleConfigType {
@ -88,30 +89,12 @@ typedef struct _AdminMessage {
bool exit_simulator; bool exit_simulator;
/* Tell the node to reboot in this many seconds (or <0 to cancel reboot) */ /* Tell the node to reboot in this many seconds (or <0 to cancel reboot) */
int32_t reboot_seconds; int32_t reboot_seconds;
/* Get the Canned Message Module message part1 in the response to this message. */ /* Get the Canned Message Module messages in the response to this message. */
bool get_canned_message_module_part1_request; bool get_canned_message_module_messages_request;
/* TODO: REPLACE */ /* Get the Canned Message Module messages in the response to this message. */
char get_canned_message_module_part1_response[201]; char get_canned_message_module_messages_response[201];
/* Get the Canned Message Module message part2 in the response to this message. */ /* Set the Canned Message Module messages text. */
bool get_canned_message_module_part2_request; char set_canned_message_module_messages[201];
/* TODO: REPLACE */
char get_canned_message_module_part2_response[201];
/* Get the Canned Message Module message part3 in the response to this message. */
bool get_canned_message_module_part3_request;
/* TODO: REPLACE */
char get_canned_message_module_part3_response[201];
/* Get the Canned Message Module message part4 in the response to this message. */
bool get_canned_message_module_part4_request;
/* TODO: REPLACE */
char get_canned_message_module_part4_response[201];
/* Set the canned message module part 1 text. */
char set_canned_message_module_part1[201];
/* Set the canned message module part 2 text. */
char set_canned_message_module_part2[201];
/* Set the canned message module part 3 text. */
char set_canned_message_module_part3[201];
/* Set the canned message module part 4 text. */
char set_canned_message_module_part4[201];
/* Tell the node to shutdown in this many seconds (or <0 to cancel shutdown) */ /* Tell the node to shutdown in this many seconds (or <0 to cancel shutdown) */
int32_t shutdown_seconds; int32_t shutdown_seconds;
/* Request the node to send device metadata (firmware, protobuf version, etc) */ /* Request the node to send device metadata (firmware, protobuf version, etc) */
@ -124,8 +107,8 @@ typedef struct _AdminMessage {
/* Helper constants for enums */ /* Helper constants for enums */
#define _AdminMessage_ConfigType_MIN AdminMessage_ConfigType_DEVICE_CONFIG #define _AdminMessage_ConfigType_MIN AdminMessage_ConfigType_DEVICE_CONFIG
#define _AdminMessage_ConfigType_MAX AdminMessage_ConfigType_LORA_CONFIG #define _AdminMessage_ConfigType_MAX AdminMessage_ConfigType_BLUETOOTH_CONFIG
#define _AdminMessage_ConfigType_ARRAYSIZE ((AdminMessage_ConfigType)(AdminMessage_ConfigType_LORA_CONFIG+1)) #define _AdminMessage_ConfigType_ARRAYSIZE ((AdminMessage_ConfigType)(AdminMessage_ConfigType_BLUETOOTH_CONFIG+1))
#define _AdminMessage_ModuleConfigType_MIN AdminMessage_ModuleConfigType_MQTT_CONFIG #define _AdminMessage_ModuleConfigType_MIN AdminMessage_ModuleConfigType_MQTT_CONFIG
#define _AdminMessage_ModuleConfigType_MAX AdminMessage_ModuleConfigType_CANNEDMSG_CONFIG #define _AdminMessage_ModuleConfigType_MAX AdminMessage_ModuleConfigType_CANNEDMSG_CONFIG
@ -160,18 +143,9 @@ extern "C" {
#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
#define AdminMessage_reboot_seconds_tag 35 #define AdminMessage_reboot_seconds_tag 35
#define AdminMessage_get_canned_message_module_part1_request_tag 36 #define AdminMessage_get_canned_message_module_messages_request_tag 36
#define AdminMessage_get_canned_message_module_part1_response_tag 37 #define AdminMessage_get_canned_message_module_messages_response_tag 37
#define AdminMessage_get_canned_message_module_part2_request_tag 38 #define AdminMessage_set_canned_message_module_messages_tag 44
#define AdminMessage_get_canned_message_module_part2_response_tag 39
#define AdminMessage_get_canned_message_module_part3_request_tag 40
#define AdminMessage_get_canned_message_module_part3_response_tag 41
#define AdminMessage_get_canned_message_module_part4_request_tag 42
#define AdminMessage_get_canned_message_module_part4_response_tag 43
#define AdminMessage_set_canned_message_module_part1_tag 44
#define AdminMessage_set_canned_message_module_part2_tag 45
#define AdminMessage_set_canned_message_module_part3_tag 46
#define AdminMessage_set_canned_message_module_part4_tag 47
#define AdminMessage_shutdown_seconds_tag 51 #define AdminMessage_shutdown_seconds_tag 51
#define AdminMessage_get_device_metadata_request_tag 52 #define AdminMessage_get_device_metadata_request_tag 52
#define AdminMessage_get_device_metadata_response_tag 53 #define AdminMessage_get_device_metadata_response_tag 53
@ -197,18 +171,9 @@ X(a, STATIC, ONEOF, BOOL, (variant,confirm_set_channel,confirm_set_chan
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) \
X(a, STATIC, ONEOF, INT32, (variant,reboot_seconds,reboot_seconds), 35) \ X(a, STATIC, ONEOF, INT32, (variant,reboot_seconds,reboot_seconds), 35) \
X(a, STATIC, ONEOF, BOOL, (variant,get_canned_message_module_part1_request,get_canned_message_module_part1_request), 36) \ X(a, STATIC, ONEOF, BOOL, (variant,get_canned_message_module_messages_request,get_canned_message_module_messages_request), 36) \
X(a, STATIC, ONEOF, STRING, (variant,get_canned_message_module_part1_response,get_canned_message_module_part1_response), 37) \ X(a, STATIC, ONEOF, STRING, (variant,get_canned_message_module_messages_response,get_canned_message_module_messages_response), 37) \
X(a, STATIC, ONEOF, BOOL, (variant,get_canned_message_module_part2_request,get_canned_message_module_part2_request), 38) \ X(a, STATIC, ONEOF, STRING, (variant,set_canned_message_module_messages,set_canned_message_module_messages), 44) \
X(a, STATIC, ONEOF, STRING, (variant,get_canned_message_module_part2_response,get_canned_message_module_part2_response), 39) \
X(a, STATIC, ONEOF, BOOL, (variant,get_canned_message_module_part3_request,get_canned_message_module_part3_request), 40) \
X(a, STATIC, ONEOF, STRING, (variant,get_canned_message_module_part3_response,get_canned_message_module_part3_response), 41) \
X(a, STATIC, ONEOF, BOOL, (variant,get_canned_message_module_part4_request,get_canned_message_module_part4_request), 42) \
X(a, STATIC, ONEOF, STRING, (variant,get_canned_message_module_part4_response,get_canned_message_module_part4_response), 43) \
X(a, STATIC, ONEOF, STRING, (variant,set_canned_message_module_part1,set_canned_message_module_part1), 44) \
X(a, STATIC, ONEOF, STRING, (variant,set_canned_message_module_part2,set_canned_message_module_part2), 45) \
X(a, STATIC, ONEOF, STRING, (variant,set_canned_message_module_part3,set_canned_message_module_part3), 46) \
X(a, STATIC, ONEOF, STRING, (variant,set_canned_message_module_part4,set_canned_message_module_part4), 47) \
X(a, STATIC, ONEOF, INT32, (variant,shutdown_seconds,shutdown_seconds), 51) \ X(a, STATIC, ONEOF, INT32, (variant,shutdown_seconds,shutdown_seconds), 51) \
X(a, STATIC, ONEOF, UINT32, (variant,get_device_metadata_request,get_device_metadata_request), 52) \ X(a, STATIC, ONEOF, UINT32, (variant,get_device_metadata_request,get_device_metadata_request), 52) \
X(a, STATIC, ONEOF, MESSAGE, (variant,get_device_metadata_response,get_device_metadata_response), 53) X(a, STATIC, ONEOF, MESSAGE, (variant,get_device_metadata_response,get_device_metadata_response), 53)

View File

@ -6,7 +6,7 @@
#error Regenerate this file with the current version of nanopb generator. #error Regenerate this file with the current version of nanopb generator.
#endif #endif
PB_BIND(CannedMessageModuleConfig, CannedMessageModuleConfig, 2) PB_BIND(CannedMessageModuleConfig, CannedMessageModuleConfig, AUTO)

View File

@ -13,13 +13,7 @@
/* Canned message module configuration. */ /* Canned message module configuration. */
typedef struct _CannedMessageModuleConfig { typedef struct _CannedMessageModuleConfig {
/* Predefined messages for canned message module separated by '|' characters. */ /* Predefined messages for canned message module separated by '|' characters. */
char messagesPart1[201]; char messages[201];
/* TODO: REPLACE */
char messagesPart2[201];
/* TODO: REPLACE */
char messagesPart3[201];
/* TODO: REPLACE */
char messagesPart4[201];
} CannedMessageModuleConfig; } CannedMessageModuleConfig;
@ -28,21 +22,15 @@ extern "C" {
#endif #endif
/* Initializer values for message structs */ /* Initializer values for message structs */
#define CannedMessageModuleConfig_init_default {"", "", "", ""} #define CannedMessageModuleConfig_init_default {""}
#define CannedMessageModuleConfig_init_zero {"", "", "", ""} #define CannedMessageModuleConfig_init_zero {""}
/* Field tags (for use in manual encoding/decoding) */ /* Field tags (for use in manual encoding/decoding) */
#define CannedMessageModuleConfig_messagesPart1_tag 11 #define CannedMessageModuleConfig_messages_tag 1
#define CannedMessageModuleConfig_messagesPart2_tag 12
#define CannedMessageModuleConfig_messagesPart3_tag 13
#define CannedMessageModuleConfig_messagesPart4_tag 14
/* Struct field encoding specification for nanopb */ /* Struct field encoding specification for nanopb */
#define CannedMessageModuleConfig_FIELDLIST(X, a) \ #define CannedMessageModuleConfig_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, STRING, messagesPart1, 11) \ X(a, STATIC, SINGULAR, STRING, messages, 1)
X(a, STATIC, SINGULAR, STRING, messagesPart2, 12) \
X(a, STATIC, SINGULAR, STRING, messagesPart3, 13) \
X(a, STATIC, SINGULAR, STRING, messagesPart4, 14)
#define CannedMessageModuleConfig_CALLBACK NULL #define CannedMessageModuleConfig_CALLBACK NULL
#define CannedMessageModuleConfig_DEFAULT NULL #define CannedMessageModuleConfig_DEFAULT NULL
@ -52,7 +40,7 @@ extern const pb_msgdesc_t CannedMessageModuleConfig_msg;
#define CannedMessageModuleConfig_fields &CannedMessageModuleConfig_msg #define CannedMessageModuleConfig_fields &CannedMessageModuleConfig_msg
/* Maximum encoded size of messages (where known) */ /* Maximum encoded size of messages (where known) */
#define CannedMessageModuleConfig_size 812 #define CannedMessageModuleConfig_size 203
#ifdef __cplusplus #ifdef __cplusplus
} /* extern "C" */ } /* extern "C" */

View File

@ -27,6 +27,10 @@ PB_BIND(Config_DisplayConfig, Config_DisplayConfig, AUTO)
PB_BIND(Config_LoRaConfig, Config_LoRaConfig, 2) PB_BIND(Config_LoRaConfig, Config_LoRaConfig, 2)
PB_BIND(Config_BluetoothConfig, Config_BluetoothConfig, AUTO)

View File

@ -92,7 +92,19 @@ typedef enum _Config_LoRaConfig_ModemPreset {
Config_LoRaConfig_ModemPreset_ShortFast = 6 Config_LoRaConfig_ModemPreset_ShortFast = 6
} Config_LoRaConfig_ModemPreset; } Config_LoRaConfig_ModemPreset;
typedef enum _Config_BluetoothConfig_PairingMode {
Config_BluetoothConfig_PairingMode_RandomPin = 0,
Config_BluetoothConfig_PairingMode_FixedPin = 1,
Config_BluetoothConfig_PairingMode_NoPin = 2
} Config_BluetoothConfig_PairingMode;
/* Struct definitions */ /* Struct definitions */
typedef struct _Config_BluetoothConfig {
bool enabled;
Config_BluetoothConfig_PairingMode mode;
uint32_t fixed_pin;
} Config_BluetoothConfig;
typedef struct _Config_DeviceConfig { typedef struct _Config_DeviceConfig {
Config_DeviceConfig_Role role; Config_DeviceConfig_Role role;
bool serial_disabled; bool serial_disabled;
@ -160,6 +172,7 @@ typedef struct _Config {
Config_WiFiConfig wifi; Config_WiFiConfig wifi;
Config_DisplayConfig display; Config_DisplayConfig display;
Config_LoRaConfig lora; Config_LoRaConfig lora;
Config_BluetoothConfig bluetooth;
} payloadVariant; } payloadVariant;
} Config; } Config;
@ -193,6 +206,10 @@ typedef struct _Config {
#define _Config_LoRaConfig_ModemPreset_MAX Config_LoRaConfig_ModemPreset_ShortFast #define _Config_LoRaConfig_ModemPreset_MAX Config_LoRaConfig_ModemPreset_ShortFast
#define _Config_LoRaConfig_ModemPreset_ARRAYSIZE ((Config_LoRaConfig_ModemPreset)(Config_LoRaConfig_ModemPreset_ShortFast+1)) #define _Config_LoRaConfig_ModemPreset_ARRAYSIZE ((Config_LoRaConfig_ModemPreset)(Config_LoRaConfig_ModemPreset_ShortFast+1))
#define _Config_BluetoothConfig_PairingMode_MIN Config_BluetoothConfig_PairingMode_RandomPin
#define _Config_BluetoothConfig_PairingMode_MAX Config_BluetoothConfig_PairingMode_NoPin
#define _Config_BluetoothConfig_PairingMode_ARRAYSIZE ((Config_BluetoothConfig_PairingMode)(Config_BluetoothConfig_PairingMode_NoPin+1))
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -206,6 +223,7 @@ extern "C" {
#define Config_WiFiConfig_init_default {0, _Config_WiFiConfig_WiFiMode_MIN, "", ""} #define Config_WiFiConfig_init_default {0, _Config_WiFiConfig_WiFiMode_MIN, "", ""}
#define Config_DisplayConfig_init_default {0, _Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0} #define Config_DisplayConfig_init_default {0, _Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0}
#define Config_LoRaConfig_init_default {0, _Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, {0, 0, 0}} #define Config_LoRaConfig_init_default {0, _Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, {0, 0, 0}}
#define Config_BluetoothConfig_init_default {0, _Config_BluetoothConfig_PairingMode_MIN, 0}
#define Config_init_zero {0, {Config_DeviceConfig_init_zero}} #define Config_init_zero {0, {Config_DeviceConfig_init_zero}}
#define Config_DeviceConfig_init_zero {_Config_DeviceConfig_Role_MIN, 0, 0, 0, ""} #define Config_DeviceConfig_init_zero {_Config_DeviceConfig_Role_MIN, 0, 0, 0, ""}
#define Config_PositionConfig_init_zero {0, 0, 0, 0, 0, 0, 0} #define Config_PositionConfig_init_zero {0, 0, 0, 0, 0, 0, 0}
@ -213,8 +231,12 @@ extern "C" {
#define Config_WiFiConfig_init_zero {0, _Config_WiFiConfig_WiFiMode_MIN, "", ""} #define Config_WiFiConfig_init_zero {0, _Config_WiFiConfig_WiFiMode_MIN, "", ""}
#define Config_DisplayConfig_init_zero {0, _Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0} #define Config_DisplayConfig_init_zero {0, _Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0}
#define Config_LoRaConfig_init_zero {0, _Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, {0, 0, 0}} #define Config_LoRaConfig_init_zero {0, _Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, {0, 0, 0}}
#define Config_BluetoothConfig_init_zero {0, _Config_BluetoothConfig_PairingMode_MIN, 0}
/* Field tags (for use in manual encoding/decoding) */ /* Field tags (for use in manual encoding/decoding) */
#define Config_BluetoothConfig_enabled_tag 1
#define Config_BluetoothConfig_mode_tag 2
#define Config_BluetoothConfig_fixed_pin_tag 3
#define Config_DeviceConfig_role_tag 1 #define Config_DeviceConfig_role_tag 1
#define Config_DeviceConfig_serial_disabled_tag 2 #define Config_DeviceConfig_serial_disabled_tag 2
#define Config_DeviceConfig_factory_reset_tag 3 #define Config_DeviceConfig_factory_reset_tag 3
@ -260,6 +282,7 @@ extern "C" {
#define Config_wifi_tag 4 #define Config_wifi_tag 4
#define Config_display_tag 5 #define Config_display_tag 5
#define Config_lora_tag 6 #define Config_lora_tag 6
#define Config_bluetooth_tag 7
/* Struct field encoding specification for nanopb */ /* Struct field encoding specification for nanopb */
#define Config_FIELDLIST(X, a) \ #define Config_FIELDLIST(X, a) \
@ -268,7 +291,8 @@ X(a, STATIC, ONEOF, MESSAGE, (payloadVariant,position,payloadVariant.posit
X(a, STATIC, ONEOF, MESSAGE, (payloadVariant,power,payloadVariant.power), 3) \ X(a, STATIC, ONEOF, MESSAGE, (payloadVariant,power,payloadVariant.power), 3) \
X(a, STATIC, ONEOF, MESSAGE, (payloadVariant,wifi,payloadVariant.wifi), 4) \ X(a, STATIC, ONEOF, MESSAGE, (payloadVariant,wifi,payloadVariant.wifi), 4) \
X(a, STATIC, ONEOF, MESSAGE, (payloadVariant,display,payloadVariant.display), 5) \ X(a, STATIC, ONEOF, MESSAGE, (payloadVariant,display,payloadVariant.display), 5) \
X(a, STATIC, ONEOF, MESSAGE, (payloadVariant,lora,payloadVariant.lora), 6) X(a, STATIC, ONEOF, MESSAGE, (payloadVariant,lora,payloadVariant.lora), 6) \
X(a, STATIC, ONEOF, MESSAGE, (payloadVariant,bluetooth,payloadVariant.bluetooth), 7)
#define Config_CALLBACK NULL #define Config_CALLBACK NULL
#define Config_DEFAULT NULL #define Config_DEFAULT NULL
#define Config_payloadVariant_device_MSGTYPE Config_DeviceConfig #define Config_payloadVariant_device_MSGTYPE Config_DeviceConfig
@ -277,6 +301,7 @@ X(a, STATIC, ONEOF, MESSAGE, (payloadVariant,lora,payloadVariant.lora),
#define Config_payloadVariant_wifi_MSGTYPE Config_WiFiConfig #define Config_payloadVariant_wifi_MSGTYPE Config_WiFiConfig
#define Config_payloadVariant_display_MSGTYPE Config_DisplayConfig #define Config_payloadVariant_display_MSGTYPE Config_DisplayConfig
#define Config_payloadVariant_lora_MSGTYPE Config_LoRaConfig #define Config_payloadVariant_lora_MSGTYPE Config_LoRaConfig
#define Config_payloadVariant_bluetooth_MSGTYPE Config_BluetoothConfig
#define Config_DeviceConfig_FIELDLIST(X, a) \ #define Config_DeviceConfig_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, UENUM, role, 1) \ X(a, STATIC, SINGULAR, UENUM, role, 1) \
@ -341,6 +366,13 @@ X(a, STATIC, REPEATED, UINT32, ignore_incoming, 103)
#define Config_LoRaConfig_CALLBACK NULL #define Config_LoRaConfig_CALLBACK NULL
#define Config_LoRaConfig_DEFAULT NULL #define Config_LoRaConfig_DEFAULT NULL
#define Config_BluetoothConfig_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, BOOL, enabled, 1) \
X(a, STATIC, SINGULAR, UENUM, mode, 2) \
X(a, STATIC, SINGULAR, UINT32, fixed_pin, 3)
#define Config_BluetoothConfig_CALLBACK NULL
#define Config_BluetoothConfig_DEFAULT NULL
extern const pb_msgdesc_t Config_msg; extern const pb_msgdesc_t Config_msg;
extern const pb_msgdesc_t Config_DeviceConfig_msg; extern const pb_msgdesc_t Config_DeviceConfig_msg;
extern const pb_msgdesc_t Config_PositionConfig_msg; extern const pb_msgdesc_t Config_PositionConfig_msg;
@ -348,6 +380,7 @@ extern const pb_msgdesc_t Config_PowerConfig_msg;
extern const pb_msgdesc_t Config_WiFiConfig_msg; extern const pb_msgdesc_t Config_WiFiConfig_msg;
extern const pb_msgdesc_t Config_DisplayConfig_msg; extern const pb_msgdesc_t Config_DisplayConfig_msg;
extern const pb_msgdesc_t Config_LoRaConfig_msg; extern const pb_msgdesc_t Config_LoRaConfig_msg;
extern const pb_msgdesc_t Config_BluetoothConfig_msg;
/* Defines for backwards compatibility with code written before nanopb-0.4.0 */ /* Defines for backwards compatibility with code written before nanopb-0.4.0 */
#define Config_fields &Config_msg #define Config_fields &Config_msg
@ -357,8 +390,10 @@ extern const pb_msgdesc_t Config_LoRaConfig_msg;
#define Config_WiFiConfig_fields &Config_WiFiConfig_msg #define Config_WiFiConfig_fields &Config_WiFiConfig_msg
#define Config_DisplayConfig_fields &Config_DisplayConfig_msg #define Config_DisplayConfig_fields &Config_DisplayConfig_msg
#define Config_LoRaConfig_fields &Config_LoRaConfig_msg #define Config_LoRaConfig_fields &Config_LoRaConfig_msg
#define Config_BluetoothConfig_fields &Config_BluetoothConfig_msg
/* Maximum encoded size of messages (where known) */ /* Maximum encoded size of messages (where known) */
#define Config_BluetoothConfig_size 10
#define Config_DeviceConfig_size 42 #define Config_DeviceConfig_size 42
#define Config_DisplayConfig_size 16 #define Config_DisplayConfig_size 16
#define Config_LoRaConfig_size 67 #define Config_LoRaConfig_size 67

View File

@ -165,7 +165,7 @@ extern const pb_msgdesc_t OEMStore_msg;
/* Maximum encoded size of messages (where known) */ /* Maximum encoded size of messages (where known) */
#define ChannelFile_size 630 #define ChannelFile_size 630
#define DeviceState_size 23994 #define DeviceState_size 22536
#define OEMStore_size 2106 #define OEMStore_size 2106
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -31,6 +31,9 @@ typedef struct _LocalConfig {
/* The part of the config that is specific to the Lora Radio */ /* The part of the config that is specific to the Lora Radio */
bool has_lora; bool has_lora;
Config_LoRaConfig lora; Config_LoRaConfig lora;
/* The part of the config that is specific to the Bluetooth settings */
bool has_bluetooth;
Config_BluetoothConfig bluetooth;
/* A version integer used to invalidate old save files when we make /* A version integer used to invalidate old save files when we make
incompatible changes This integer is set at build time and is private to incompatible changes This integer is set at build time and is private to
NodeDB.cpp in the device code. */ NodeDB.cpp in the device code. */
@ -71,9 +74,9 @@ extern "C" {
#endif #endif
/* Initializer values for message structs */ /* Initializer values for message structs */
#define LocalConfig_init_default {false, Config_DeviceConfig_init_default, false, Config_PositionConfig_init_default, false, Config_PowerConfig_init_default, false, Config_WiFiConfig_init_default, false, Config_DisplayConfig_init_default, false, Config_LoRaConfig_init_default, 0} #define LocalConfig_init_default {false, Config_DeviceConfig_init_default, false, Config_PositionConfig_init_default, false, Config_PowerConfig_init_default, false, Config_WiFiConfig_init_default, false, Config_DisplayConfig_init_default, false, Config_LoRaConfig_init_default, false, Config_BluetoothConfig_init_default, 0}
#define LocalModuleConfig_init_default {false, ModuleConfig_MQTTConfig_init_default, false, ModuleConfig_SerialConfig_init_default, false, ModuleConfig_ExternalNotificationConfig_init_default, false, ModuleConfig_StoreForwardConfig_init_default, false, ModuleConfig_RangeTestConfig_init_default, false, ModuleConfig_TelemetryConfig_init_default, false, ModuleConfig_CannedMessageConfig_init_default, 0} #define LocalModuleConfig_init_default {false, ModuleConfig_MQTTConfig_init_default, false, ModuleConfig_SerialConfig_init_default, false, ModuleConfig_ExternalNotificationConfig_init_default, false, ModuleConfig_StoreForwardConfig_init_default, false, ModuleConfig_RangeTestConfig_init_default, false, ModuleConfig_TelemetryConfig_init_default, false, ModuleConfig_CannedMessageConfig_init_default, 0}
#define LocalConfig_init_zero {false, Config_DeviceConfig_init_zero, false, Config_PositionConfig_init_zero, false, Config_PowerConfig_init_zero, false, Config_WiFiConfig_init_zero, false, Config_DisplayConfig_init_zero, false, Config_LoRaConfig_init_zero, 0} #define LocalConfig_init_zero {false, Config_DeviceConfig_init_zero, false, Config_PositionConfig_init_zero, false, Config_PowerConfig_init_zero, false, Config_WiFiConfig_init_zero, false, Config_DisplayConfig_init_zero, false, Config_LoRaConfig_init_zero, false, Config_BluetoothConfig_init_zero, 0}
#define LocalModuleConfig_init_zero {false, ModuleConfig_MQTTConfig_init_zero, false, ModuleConfig_SerialConfig_init_zero, false, ModuleConfig_ExternalNotificationConfig_init_zero, false, ModuleConfig_StoreForwardConfig_init_zero, false, ModuleConfig_RangeTestConfig_init_zero, false, ModuleConfig_TelemetryConfig_init_zero, false, ModuleConfig_CannedMessageConfig_init_zero, 0} #define LocalModuleConfig_init_zero {false, ModuleConfig_MQTTConfig_init_zero, false, ModuleConfig_SerialConfig_init_zero, false, ModuleConfig_ExternalNotificationConfig_init_zero, false, ModuleConfig_StoreForwardConfig_init_zero, false, ModuleConfig_RangeTestConfig_init_zero, false, ModuleConfig_TelemetryConfig_init_zero, false, ModuleConfig_CannedMessageConfig_init_zero, 0}
/* Field tags (for use in manual encoding/decoding) */ /* Field tags (for use in manual encoding/decoding) */
@ -83,7 +86,8 @@ extern "C" {
#define LocalConfig_wifi_tag 4 #define LocalConfig_wifi_tag 4
#define LocalConfig_display_tag 5 #define LocalConfig_display_tag 5
#define LocalConfig_lora_tag 6 #define LocalConfig_lora_tag 6
#define LocalConfig_version_tag 7 #define LocalConfig_bluetooth_tag 7
#define LocalConfig_version_tag 8
#define LocalModuleConfig_mqtt_tag 1 #define LocalModuleConfig_mqtt_tag 1
#define LocalModuleConfig_serial_tag 2 #define LocalModuleConfig_serial_tag 2
#define LocalModuleConfig_external_notification_tag 3 #define LocalModuleConfig_external_notification_tag 3
@ -101,7 +105,8 @@ X(a, STATIC, OPTIONAL, MESSAGE, power, 3) \
X(a, STATIC, OPTIONAL, MESSAGE, wifi, 4) \ X(a, STATIC, OPTIONAL, MESSAGE, wifi, 4) \
X(a, STATIC, OPTIONAL, MESSAGE, display, 5) \ X(a, STATIC, OPTIONAL, MESSAGE, display, 5) \
X(a, STATIC, OPTIONAL, MESSAGE, lora, 6) \ X(a, STATIC, OPTIONAL, MESSAGE, lora, 6) \
X(a, STATIC, SINGULAR, UINT32, version, 7) X(a, STATIC, OPTIONAL, MESSAGE, bluetooth, 7) \
X(a, STATIC, SINGULAR, UINT32, version, 8)
#define LocalConfig_CALLBACK NULL #define LocalConfig_CALLBACK NULL
#define LocalConfig_DEFAULT NULL #define LocalConfig_DEFAULT NULL
#define LocalConfig_device_MSGTYPE Config_DeviceConfig #define LocalConfig_device_MSGTYPE Config_DeviceConfig
@ -110,6 +115,7 @@ X(a, STATIC, SINGULAR, UINT32, version, 7)
#define LocalConfig_wifi_MSGTYPE Config_WiFiConfig #define LocalConfig_wifi_MSGTYPE Config_WiFiConfig
#define LocalConfig_display_MSGTYPE Config_DisplayConfig #define LocalConfig_display_MSGTYPE Config_DisplayConfig
#define LocalConfig_lora_MSGTYPE Config_LoRaConfig #define LocalConfig_lora_MSGTYPE Config_LoRaConfig
#define LocalConfig_bluetooth_MSGTYPE Config_BluetoothConfig
#define LocalModuleConfig_FIELDLIST(X, a) \ #define LocalModuleConfig_FIELDLIST(X, a) \
X(a, STATIC, OPTIONAL, MESSAGE, mqtt, 1) \ X(a, STATIC, OPTIONAL, MESSAGE, mqtt, 1) \
@ -138,7 +144,7 @@ extern const pb_msgdesc_t LocalModuleConfig_msg;
#define LocalModuleConfig_fields &LocalModuleConfig_msg #define LocalModuleConfig_fields &LocalModuleConfig_msg
/* Maximum encoded size of messages (where known) */ /* Maximum encoded size of messages (where known) */
#define LocalConfig_size 321 #define LocalConfig_size 333
#define LocalModuleConfig_size 268 #define LocalModuleConfig_size 268
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -459,17 +459,6 @@ typedef struct _User {
If this user is a licensed operator, set this flag. If this user is a licensed operator, set this flag.
Also, "long_name" should be their licence number. */ Also, "long_name" should be their licence number. */
bool is_licensed; bool is_licensed;
/* Transmit power at antenna connector, in decibel-milliwatt
An optional self-reported value useful in network planning, discovery
and positioning - along with ant_gain_dbi and ant_azimuth below */
uint32_t tx_power_dbm;
/* Antenna gain (applicable to both Tx and Rx), in decibel-isotropic */
uint32_t ant_gain_dbi;
/* Directional antenna true azimuth *if applicable*, in degrees (0-360)
Only applicable in case of stationary nodes with a directional antenna
Zero = not applicable (mobile or omni) or not specified
(use a value of 360 to indicate an antenna azimuth of zero degrees) */
uint32_t ant_azimuth;
} User; } User;
typedef PB_BYTES_ARRAY_T(237) Data_payload_t; typedef PB_BYTES_ARRAY_T(237) Data_payload_t;
@ -738,7 +727,7 @@ extern "C" {
/* Initializer values for message structs */ /* Initializer values for message structs */
#define Position_init_default {0, 0, 0, 0, _Position_LocSource_MIN, _Position_AltSource_MIN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define Position_init_default {0, 0, 0, 0, _Position_LocSource_MIN, _Position_AltSource_MIN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
#define User_init_default {"", "", "", {0}, _HardwareModel_MIN, 0, 0, 0, 0} #define User_init_default {"", "", "", {0}, _HardwareModel_MIN, 0}
#define RouteDiscovery_init_default {0, {0, 0, 0, 0, 0, 0, 0, 0}} #define RouteDiscovery_init_default {0, {0, 0, 0, 0, 0, 0, 0, 0}}
#define Routing_init_default {0, {RouteDiscovery_init_default}} #define Routing_init_default {0, {RouteDiscovery_init_default}}
#define Data_init_default {_PortNum_MIN, {0, {0}}, 0, 0, 0, 0, 0, 0, false, Location_init_default} #define Data_init_default {_PortNum_MIN, {0, {0}}, 0, 0, 0, 0, 0, 0, false, Location_init_default}
@ -752,7 +741,7 @@ extern "C" {
#define ToRadio_PeerInfo_init_default {0, 0} #define ToRadio_PeerInfo_init_default {0, 0}
#define Compressed_init_default {_PortNum_MIN, {0, {0}}} #define Compressed_init_default {_PortNum_MIN, {0, {0}}}
#define Position_init_zero {0, 0, 0, 0, _Position_LocSource_MIN, _Position_AltSource_MIN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define Position_init_zero {0, 0, 0, 0, _Position_LocSource_MIN, _Position_AltSource_MIN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
#define User_init_zero {"", "", "", {0}, _HardwareModel_MIN, 0, 0, 0, 0} #define User_init_zero {"", "", "", {0}, _HardwareModel_MIN, 0}
#define RouteDiscovery_init_zero {0, {0, 0, 0, 0, 0, 0, 0, 0}} #define RouteDiscovery_init_zero {0, {0, 0, 0, 0, 0, 0, 0, 0}}
#define Routing_init_zero {0, {RouteDiscovery_init_zero}} #define Routing_init_zero {0, {RouteDiscovery_init_zero}}
#define Data_init_zero {_PortNum_MIN, {0, {0}}, 0, 0, 0, 0, 0, 0, false, Location_init_zero} #define Data_init_zero {_PortNum_MIN, {0, {0}}, 0, 0, 0, 0, 0, 0, false, Location_init_zero}
@ -827,9 +816,6 @@ extern "C" {
#define User_macaddr_tag 4 #define User_macaddr_tag 4
#define User_hw_model_tag 6 #define User_hw_model_tag 6
#define User_is_licensed_tag 7 #define User_is_licensed_tag 7
#define User_tx_power_dbm_tag 10
#define User_ant_gain_dbi_tag 11
#define User_ant_azimuth_tag 12
#define Data_portnum_tag 1 #define Data_portnum_tag 1
#define Data_payload_tag 2 #define Data_payload_tag 2
#define Data_want_response_tag 3 #define Data_want_response_tag 3
@ -908,10 +894,7 @@ X(a, STATIC, SINGULAR, STRING, long_name, 2) \
X(a, STATIC, SINGULAR, STRING, short_name, 3) \ X(a, STATIC, SINGULAR, STRING, short_name, 3) \
X(a, STATIC, SINGULAR, FIXED_LENGTH_BYTES, macaddr, 4) \ X(a, STATIC, SINGULAR, FIXED_LENGTH_BYTES, macaddr, 4) \
X(a, STATIC, SINGULAR, UENUM, hw_model, 6) \ X(a, STATIC, SINGULAR, UENUM, hw_model, 6) \
X(a, STATIC, SINGULAR, BOOL, is_licensed, 7) \ X(a, STATIC, SINGULAR, BOOL, is_licensed, 7)
X(a, STATIC, SINGULAR, UINT32, tx_power_dbm, 10) \
X(a, STATIC, SINGULAR, UINT32, ant_gain_dbi, 11) \
X(a, STATIC, SINGULAR, UINT32, ant_azimuth, 12)
#define User_CALLBACK NULL #define User_CALLBACK NULL
#define User_DEFAULT NULL #define User_DEFAULT NULL
@ -1093,13 +1076,13 @@ extern const pb_msgdesc_t Compressed_msg;
#define LogRecord_size 81 #define LogRecord_size 81
#define MeshPacket_size 480 #define MeshPacket_size 480
#define MyNodeInfo_size 197 #define MyNodeInfo_size 197
#define NodeInfo_size 281 #define NodeInfo_size 263
#define Position_size 142 #define Position_size 142
#define RouteDiscovery_size 40 #define RouteDiscovery_size 40
#define Routing_size 42 #define Routing_size 42
#define ToRadio_PeerInfo_size 8 #define ToRadio_PeerInfo_size 8
#define ToRadio_size 483 #define ToRadio_size 483
#define User_size 95 #define User_size 77
#ifdef __cplusplus #ifdef __cplusplus
} /* extern "C" */ } /* extern "C" */

View File

@ -201,6 +201,11 @@ void AdminModule::handleSetConfig(const Config &c)
config.has_lora = true; config.has_lora = true;
config.lora = c.payloadVariant.lora; config.lora = c.payloadVariant.lora;
break; break;
case Config_bluetooth_tag:
DEBUG_MSG("Setting config: Bluetooth\n");
config.has_bluetooth = true;
config.bluetooth = c.payloadVariant.bluetooth;
break;
} }
service.reloadConfig(); service.reloadConfig();
@ -309,8 +314,12 @@ void AdminModule::handleGetConfig(const MeshPacket &req, const uint32_t configTy
res.get_config_response.which_payloadVariant = Config_lora_tag; res.get_config_response.which_payloadVariant = Config_lora_tag;
res.get_config_response.payloadVariant.lora = config.lora; res.get_config_response.payloadVariant.lora = config.lora;
break; break;
case AdminMessage_ConfigType_BLUETOOTH_CONFIG:
DEBUG_MSG("Getting config: Bluetooth\n");
res.get_config_response.which_payloadVariant = Config_bluetooth_tag;
res.get_config_response.payloadVariant.bluetooth = config.bluetooth;
break;
} }
// NOTE: The phone app needs to know the ls_secs value so it can properly expect sleep behavior. // NOTE: The phone app needs to know the ls_secs 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 // 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). // using to the app (so that even old phone apps work with new device loads).

View File

@ -46,16 +46,14 @@ CannedMessageModule::CannedMessageModule()
* *
* @return int Returns the number of messages found. * @return int Returns the number of messages found.
*/ */
// FIXME: This is just one set of messages now
int CannedMessageModule::splitConfiguredMessages() int CannedMessageModule::splitConfiguredMessages()
{ {
int messageIndex = 0; int messageIndex = 0;
int i = 0; int i = 0;
// collect all the message parts // collect all the message parts
strcpy(this->messageStore, cannedMessageModuleConfig.messagesPart1); strcpy(this->messageStore, cannedMessageModuleConfig.messages);
strcat(this->messageStore, cannedMessageModuleConfig.messagesPart2);
strcat(this->messageStore, cannedMessageModuleConfig.messagesPart3);
strcat(this->messageStore, cannedMessageModuleConfig.messagesPart4);
// The first message points to the beginning of the store. // The first message points to the beginning of the store.
this->messages[messageIndex++] = this->messageStore; this->messages[messageIndex++] = this->messageStore;
@ -294,10 +292,7 @@ bool CannedMessageModule::saveProtoForModule()
*/ */
void CannedMessageModule::installDefaultCannedMessageModuleConfig() void CannedMessageModule::installDefaultCannedMessageModuleConfig()
{ {
memset(cannedMessageModuleConfig.messagesPart1, 0, sizeof(cannedMessageModuleConfig.messagesPart1)); memset(cannedMessageModuleConfig.messages, 0, sizeof(cannedMessageModuleConfig.messages));
memset(cannedMessageModuleConfig.messagesPart2, 0, sizeof(cannedMessageModuleConfig.messagesPart2));
memset(cannedMessageModuleConfig.messagesPart3, 0, sizeof(cannedMessageModuleConfig.messagesPart3));
memset(cannedMessageModuleConfig.messagesPart4, 0, sizeof(cannedMessageModuleConfig.messagesPart4));
} }
/** /**
@ -315,51 +310,15 @@ AdminMessageHandleResult CannedMessageModule::handleAdminMessageForModule(const
AdminMessageHandleResult result; AdminMessageHandleResult result;
switch (request->which_variant) { switch (request->which_variant) {
case AdminMessage_get_canned_message_module_part1_request_tag: case AdminMessage_get_canned_message_module_messages_request_tag:
DEBUG_MSG("Client is getting radio canned message part1\n"); DEBUG_MSG("Client is getting radio canned messages\n");
this->handleGetCannedMessageModulePart1(mp, response); this->handleGetCannedMessageModuleMessages(mp, response);
result = AdminMessageHandleResult::HANDLED_WITH_RESPONSE; result = AdminMessageHandleResult::HANDLED_WITH_RESPONSE;
break; break;
case AdminMessage_get_canned_message_module_part2_request_tag: case AdminMessage_set_canned_message_module_messages_tag:
DEBUG_MSG("Client is getting radio canned message part2\n"); DEBUG_MSG("Client is setting radio canned messages\n");
this->handleGetCannedMessageModulePart2(mp, response); this->handleSetCannedMessageModuleMessages(request->set_canned_message_module_messages);
result = AdminMessageHandleResult::HANDLED_WITH_RESPONSE;
break;
case AdminMessage_get_canned_message_module_part3_request_tag:
DEBUG_MSG("Client is getting radio canned message part3\n");
this->handleGetCannedMessageModulePart3(mp, response);
result = AdminMessageHandleResult::HANDLED_WITH_RESPONSE;
break;
case AdminMessage_get_canned_message_module_part4_request_tag:
DEBUG_MSG("Client is getting radio canned message part4\n");
this->handleGetCannedMessageModulePart4(mp, response);
result = AdminMessageHandleResult::HANDLED_WITH_RESPONSE;
break;
case AdminMessage_set_canned_message_module_part1_tag:
DEBUG_MSG("Client is setting radio canned message part 1\n");
this->handleSetCannedMessageModulePart1(request->set_canned_message_module_part1);
result = AdminMessageHandleResult::HANDLED;
break;
case AdminMessage_set_canned_message_module_part2_tag:
DEBUG_MSG("Client is setting radio canned message part 2\n");
this->handleSetCannedMessageModulePart2(request->set_canned_message_module_part2);
result = AdminMessageHandleResult::HANDLED;
break;
case AdminMessage_set_canned_message_module_part3_tag:
DEBUG_MSG("Client is setting radio canned message part 3\n");
this->handleSetCannedMessageModulePart3(request->set_canned_message_module_part3);
result = AdminMessageHandleResult::HANDLED;
break;
case AdminMessage_set_canned_message_module_part4_tag:
DEBUG_MSG("Client is setting radio canned message part 4\n");
this->handleSetCannedMessageModulePart4(request->set_canned_message_module_part4);
result = AdminMessageHandleResult::HANDLED; result = AdminMessageHandleResult::HANDLED;
break; break;
@ -370,49 +329,23 @@ AdminMessageHandleResult CannedMessageModule::handleAdminMessageForModule(const
return result; return result;
} }
void CannedMessageModule::handleGetCannedMessageModulePart1(const MeshPacket &req, AdminMessage *response) void CannedMessageModule::handleGetCannedMessageModuleMessages(const MeshPacket &req, AdminMessage *response)
{ {
DEBUG_MSG("*** handleGetCannedMessageModulePart1\n"); DEBUG_MSG("*** handleGetCannedMessageModuleMessages\n");
assert(req.decoded.want_response); assert(req.decoded.want_response);
response->which_variant = AdminMessage_get_canned_message_module_part1_response_tag; response->which_variant = AdminMessage_get_canned_message_module_messages_response_tag;
strcpy(response->get_canned_message_module_part1_response, cannedMessageModuleConfig.messagesPart1); strcpy(response->get_canned_message_module_messages_response, cannedMessageModuleConfig.messages);
} }
void CannedMessageModule::handleGetCannedMessageModulePart2(const MeshPacket &req, AdminMessage *response)
{
DEBUG_MSG("*** handleGetCannedMessageModulePart2\n");
assert(req.decoded.want_response);
response->which_variant = AdminMessage_get_canned_message_module_part2_response_tag; void CannedMessageModule::handleSetCannedMessageModuleMessages(const char *from_msg)
strcpy(response->get_canned_message_module_part2_response, cannedMessageModuleConfig.messagesPart2);
}
void CannedMessageModule::handleGetCannedMessageModulePart3(const MeshPacket &req, AdminMessage *response)
{
DEBUG_MSG("*** handleGetCannedMessageModulePart3\n");
assert(req.decoded.want_response);
response->which_variant = AdminMessage_get_canned_message_module_part3_response_tag;
strcpy(response->get_canned_message_module_part3_response, cannedMessageModuleConfig.messagesPart3);
}
void CannedMessageModule::handleGetCannedMessageModulePart4(const MeshPacket &req, AdminMessage *response)
{
DEBUG_MSG("*** handleGetCannedMessageModulePart4\n");
assert(req.decoded.want_response);
response->which_variant = AdminMessage_get_canned_message_module_part4_response_tag;
strcpy(response->get_canned_message_module_part4_response, cannedMessageModuleConfig.messagesPart4);
}
void CannedMessageModule::handleSetCannedMessageModulePart1(const char *from_msg)
{ {
int changed = 0; int changed = 0;
if (*from_msg) { if (*from_msg) {
changed |= strcmp(cannedMessageModuleConfig.messagesPart1, from_msg); changed |= strcmp(cannedMessageModuleConfig.messages, from_msg);
strcpy(cannedMessageModuleConfig.messagesPart1, from_msg); strcpy(cannedMessageModuleConfig.messages, from_msg);
DEBUG_MSG("*** from_msg.text:%s\n", from_msg); DEBUG_MSG("*** from_msg.text:%s\n", from_msg);
} }
@ -421,45 +354,4 @@ void CannedMessageModule::handleSetCannedMessageModulePart1(const char *from_msg
} }
} }
void CannedMessageModule::handleSetCannedMessageModulePart2(const char *from_msg)
{
int changed = 0;
if (*from_msg) {
changed |= strcmp(cannedMessageModuleConfig.messagesPart2, from_msg);
strcpy(cannedMessageModuleConfig.messagesPart2, from_msg);
}
if (changed) {
this->saveProtoForModule();
}
}
void CannedMessageModule::handleSetCannedMessageModulePart3(const char *from_msg)
{
int changed = 0;
if (*from_msg) {
changed |= strcmp(cannedMessageModuleConfig.messagesPart3, from_msg);
strcpy(cannedMessageModuleConfig.messagesPart3, from_msg);
}
if (changed) {
this->saveProtoForModule();
}
}
void CannedMessageModule::handleSetCannedMessageModulePart4(const char *from_msg)
{
int changed = 0;
if (*from_msg) {
changed |= strcmp(cannedMessageModuleConfig.messagesPart4, from_msg);
strcpy(cannedMessageModuleConfig.messagesPart4, from_msg);
}
if (changed) {
this->saveProtoForModule();
}
}
#endif #endif

View File

@ -39,15 +39,8 @@ class CannedMessageModule :
void eventDown(); void eventDown();
void eventSelect(); void eventSelect();
void handleGetCannedMessageModulePart1(const MeshPacket &req, AdminMessage *response); void handleGetCannedMessageModuleMessages(const MeshPacket &req, AdminMessage *response);
void handleGetCannedMessageModulePart2(const MeshPacket &req, AdminMessage *response); void handleSetCannedMessageModuleMessages(const char *from_msg);
void handleGetCannedMessageModulePart3(const MeshPacket &req, AdminMessage *response);
void handleGetCannedMessageModulePart4(const MeshPacket &req, AdminMessage *response);
void handleSetCannedMessageModulePart1(const char *from_msg);
void handleSetCannedMessageModulePart2(const char *from_msg);
void handleSetCannedMessageModulePart3(const char *from_msg);
void handleSetCannedMessageModulePart4(const char *from_msg);
protected: protected: