diff --git a/protobufs b/protobufs index c473ed7a6..2fadf011e 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit c473ed7a6aa83c4be80382aa9abf8f8258be40a3 +Subproject commit 2fadf011e574c180afb395bc2a751b3f7e56839c diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index f30e21d1e..01ddf2245 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -150,14 +150,17 @@ void NodeDB::installDefaultConfig() config.has_position = true; config.has_power = true; config.has_wifi = true; + config.has_bluetooth = true; config.lora.region = Config_LoRaConfig_RegionCode_Unset; config.lora.modem_preset = Config_LoRaConfig_ModemPreset_LongFast; resetRadioConfig(); 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 - config.position.position_flags = - (Config_PositionConfig_PositionFlags_POS_ALTITUDE | Config_PositionConfig_PositionFlags_POS_ALT_MSL); + config.position.position_flags = (Config_PositionConfig_PositionFlags_POS_ALTITUDE | Config_PositionConfig_PositionFlags_POS_ALT_MSL); } void NodeDB::installDefaultModuleConfig() @@ -452,6 +455,7 @@ void NodeDB::saveToDisk() config.has_position = true; config.has_power = true; config.has_wifi = true; + config.has_bluetooth = true; saveProto(configFileName, LocalConfig_size, sizeof(LocalConfig), LocalConfig_fields, &config); moduleConfig.has_canned_message = true; diff --git a/src/mesh/NodeDB.h b/src/mesh/NodeDB.h index 054caa11b..952b684aa 100644 --- a/src/mesh/NodeDB.h +++ b/src/mesh/NodeDB.h @@ -13,7 +13,7 @@ DeviceState versions used to be defined in the .proto file but really only this #define here. */ -#define DEVICESTATE_CUR_VER 14 +#define DEVICESTATE_CUR_VER 15 #define DEVICESTATE_MIN_VER DEVICESTATE_CUR_VER extern DeviceState devicestate; diff --git a/src/mesh/PhoneAPI.cpp b/src/mesh/PhoneAPI.cpp index e5b1b26c2..26030ec7a 100644 --- a/src/mesh/PhoneAPI.cpp +++ b/src/mesh/PhoneAPI.cpp @@ -189,15 +189,18 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf) fromRadioScratch.config.which_payloadVariant = Config_lora_tag; fromRadioScratch.config.payloadVariant.lora = config.lora; 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. // 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). config_state++; // 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; config_state = ModuleConfig_mqtt_tag; } diff --git a/src/mesh/generated/admin.pb.h b/src/mesh/generated/admin.pb.h index 20dd6130d..f0a80d3d6 100644 --- a/src/mesh/generated/admin.pb.h +++ b/src/mesh/generated/admin.pb.h @@ -21,7 +21,8 @@ typedef enum _AdminMessage_ConfigType { AdminMessage_ConfigType_POWER_CONFIG = 2, AdminMessage_ConfigType_WIFI_CONFIG = 3, AdminMessage_ConfigType_DISPLAY_CONFIG = 4, - AdminMessage_ConfigType_LORA_CONFIG = 5 + AdminMessage_ConfigType_LORA_CONFIG = 5, + AdminMessage_ConfigType_BLUETOOTH_CONFIG = 6 } AdminMessage_ConfigType; typedef enum _AdminMessage_ModuleConfigType { @@ -88,30 +89,12 @@ typedef struct _AdminMessage { bool exit_simulator; /* Tell the node to reboot in this many seconds (or <0 to cancel reboot) */ int32_t reboot_seconds; - /* Get the Canned Message Module message part1 in the response to this message. */ - bool get_canned_message_module_part1_request; - /* TODO: REPLACE */ - char get_canned_message_module_part1_response[201]; - /* Get the Canned Message Module message part2 in the response to this message. */ - bool get_canned_message_module_part2_request; - /* 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]; + /* Get the Canned Message Module messages in the response to this message. */ + bool get_canned_message_module_messages_request; + /* Get the Canned Message Module messages in the response to this message. */ + char get_canned_message_module_messages_response[201]; + /* Set the Canned Message Module messages text. */ + char set_canned_message_module_messages[201]; /* Tell the node to shutdown in this many seconds (or <0 to cancel shutdown) */ int32_t shutdown_seconds; /* Request the node to send device metadata (firmware, protobuf version, etc) */ @@ -124,8 +107,8 @@ typedef struct _AdminMessage { /* Helper constants for enums */ #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_ConfigType_MAX AdminMessage_ConfigType_BLUETOOTH_CONFIG +#define _AdminMessage_ConfigType_ARRAYSIZE ((AdminMessage_ConfigType)(AdminMessage_ConfigType_BLUETOOTH_CONFIG+1)) #define _AdminMessage_ModuleConfigType_MIN AdminMessage_ModuleConfigType_MQTT_CONFIG #define _AdminMessage_ModuleConfigType_MAX AdminMessage_ModuleConfigType_CANNEDMSG_CONFIG @@ -160,18 +143,9 @@ extern "C" { #define AdminMessage_confirm_set_radio_tag 33 #define AdminMessage_exit_simulator_tag 34 #define AdminMessage_reboot_seconds_tag 35 -#define AdminMessage_get_canned_message_module_part1_request_tag 36 -#define AdminMessage_get_canned_message_module_part1_response_tag 37 -#define AdminMessage_get_canned_message_module_part2_request_tag 38 -#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_get_canned_message_module_messages_request_tag 36 +#define AdminMessage_get_canned_message_module_messages_response_tag 37 +#define AdminMessage_set_canned_message_module_messages_tag 44 #define AdminMessage_shutdown_seconds_tag 51 #define AdminMessage_get_device_metadata_request_tag 52 #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,exit_simulator,exit_simulator), 34) \ 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, STRING, (variant,get_canned_message_module_part1_response,get_canned_message_module_part1_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,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, 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_messages_response,get_canned_message_module_messages_response), 37) \ +X(a, STATIC, ONEOF, STRING, (variant,set_canned_message_module_messages,set_canned_message_module_messages), 44) \ 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, MESSAGE, (variant,get_device_metadata_response,get_device_metadata_response), 53) diff --git a/src/mesh/generated/cannedmessages.pb.c b/src/mesh/generated/cannedmessages.pb.c index 67e963894..faea133e6 100644 --- a/src/mesh/generated/cannedmessages.pb.c +++ b/src/mesh/generated/cannedmessages.pb.c @@ -6,7 +6,7 @@ #error Regenerate this file with the current version of nanopb generator. #endif -PB_BIND(CannedMessageModuleConfig, CannedMessageModuleConfig, 2) +PB_BIND(CannedMessageModuleConfig, CannedMessageModuleConfig, AUTO) diff --git a/src/mesh/generated/cannedmessages.pb.h b/src/mesh/generated/cannedmessages.pb.h index 9d2e0019d..274601e4c 100644 --- a/src/mesh/generated/cannedmessages.pb.h +++ b/src/mesh/generated/cannedmessages.pb.h @@ -13,13 +13,7 @@ /* Canned message module configuration. */ typedef struct _CannedMessageModuleConfig { /* Predefined messages for canned message module separated by '|' characters. */ - char messagesPart1[201]; - /* TODO: REPLACE */ - char messagesPart2[201]; - /* TODO: REPLACE */ - char messagesPart3[201]; - /* TODO: REPLACE */ - char messagesPart4[201]; + char messages[201]; } CannedMessageModuleConfig; @@ -28,21 +22,15 @@ extern "C" { #endif /* Initializer values for message structs */ -#define CannedMessageModuleConfig_init_default {"", "", "", ""} -#define CannedMessageModuleConfig_init_zero {"", "", "", ""} +#define CannedMessageModuleConfig_init_default {""} +#define CannedMessageModuleConfig_init_zero {""} /* Field tags (for use in manual encoding/decoding) */ -#define CannedMessageModuleConfig_messagesPart1_tag 11 -#define CannedMessageModuleConfig_messagesPart2_tag 12 -#define CannedMessageModuleConfig_messagesPart3_tag 13 -#define CannedMessageModuleConfig_messagesPart4_tag 14 +#define CannedMessageModuleConfig_messages_tag 1 /* Struct field encoding specification for nanopb */ #define CannedMessageModuleConfig_FIELDLIST(X, a) \ -X(a, STATIC, SINGULAR, STRING, messagesPart1, 11) \ -X(a, STATIC, SINGULAR, STRING, messagesPart2, 12) \ -X(a, STATIC, SINGULAR, STRING, messagesPart3, 13) \ -X(a, STATIC, SINGULAR, STRING, messagesPart4, 14) +X(a, STATIC, SINGULAR, STRING, messages, 1) #define CannedMessageModuleConfig_CALLBACK NULL #define CannedMessageModuleConfig_DEFAULT NULL @@ -52,7 +40,7 @@ extern const pb_msgdesc_t CannedMessageModuleConfig_msg; #define CannedMessageModuleConfig_fields &CannedMessageModuleConfig_msg /* Maximum encoded size of messages (where known) */ -#define CannedMessageModuleConfig_size 812 +#define CannedMessageModuleConfig_size 203 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/config.pb.c b/src/mesh/generated/config.pb.c index e6503667c..e9b9df84f 100644 --- a/src/mesh/generated/config.pb.c +++ b/src/mesh/generated/config.pb.c @@ -27,6 +27,10 @@ PB_BIND(Config_DisplayConfig, Config_DisplayConfig, AUTO) PB_BIND(Config_LoRaConfig, Config_LoRaConfig, 2) +PB_BIND(Config_BluetoothConfig, Config_BluetoothConfig, AUTO) + + + diff --git a/src/mesh/generated/config.pb.h b/src/mesh/generated/config.pb.h index bc24c844c..7896f42b3 100644 --- a/src/mesh/generated/config.pb.h +++ b/src/mesh/generated/config.pb.h @@ -92,7 +92,19 @@ typedef enum _Config_LoRaConfig_ModemPreset { Config_LoRaConfig_ModemPreset_ShortFast = 6 } 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 */ +typedef struct _Config_BluetoothConfig { + bool enabled; + Config_BluetoothConfig_PairingMode mode; + uint32_t fixed_pin; +} Config_BluetoothConfig; + typedef struct _Config_DeviceConfig { Config_DeviceConfig_Role role; bool serial_disabled; @@ -160,6 +172,7 @@ typedef struct _Config { Config_WiFiConfig wifi; Config_DisplayConfig display; Config_LoRaConfig lora; + Config_BluetoothConfig bluetooth; } payloadVariant; } Config; @@ -193,6 +206,10 @@ typedef struct _Config { #define _Config_LoRaConfig_ModemPreset_MAX Config_LoRaConfig_ModemPreset_ShortFast #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 extern "C" { @@ -206,6 +223,7 @@ extern "C" { #define Config_WiFiConfig_init_default {0, _Config_WiFiConfig_WiFiMode_MIN, "", ""} #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_BluetoothConfig_init_default {0, _Config_BluetoothConfig_PairingMode_MIN, 0} #define Config_init_zero {0, {Config_DeviceConfig_init_zero}} #define Config_DeviceConfig_init_zero {_Config_DeviceConfig_Role_MIN, 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_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_BluetoothConfig_init_zero {0, _Config_BluetoothConfig_PairingMode_MIN, 0} /* 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_serial_disabled_tag 2 #define Config_DeviceConfig_factory_reset_tag 3 @@ -260,6 +282,7 @@ extern "C" { #define Config_wifi_tag 4 #define Config_display_tag 5 #define Config_lora_tag 6 +#define Config_bluetooth_tag 7 /* Struct field encoding specification for nanopb */ #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,wifi,payloadVariant.wifi), 4) \ 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_DEFAULT NULL #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_display_MSGTYPE Config_DisplayConfig #define Config_payloadVariant_lora_MSGTYPE Config_LoRaConfig +#define Config_payloadVariant_bluetooth_MSGTYPE Config_BluetoothConfig #define Config_DeviceConfig_FIELDLIST(X, a) \ 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_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_DeviceConfig_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_DisplayConfig_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 */ #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_DisplayConfig_fields &Config_DisplayConfig_msg #define Config_LoRaConfig_fields &Config_LoRaConfig_msg +#define Config_BluetoothConfig_fields &Config_BluetoothConfig_msg /* Maximum encoded size of messages (where known) */ +#define Config_BluetoothConfig_size 10 #define Config_DeviceConfig_size 42 #define Config_DisplayConfig_size 16 #define Config_LoRaConfig_size 67 diff --git a/src/mesh/generated/deviceonly.pb.h b/src/mesh/generated/deviceonly.pb.h index 23b3b6a08..228edbb00 100644 --- a/src/mesh/generated/deviceonly.pb.h +++ b/src/mesh/generated/deviceonly.pb.h @@ -165,7 +165,7 @@ extern const pb_msgdesc_t OEMStore_msg; /* Maximum encoded size of messages (where known) */ #define ChannelFile_size 630 -#define DeviceState_size 23994 +#define DeviceState_size 22536 #define OEMStore_size 2106 #ifdef __cplusplus diff --git a/src/mesh/generated/localonly.pb.h b/src/mesh/generated/localonly.pb.h index 71c845f30..eac4444da 100644 --- a/src/mesh/generated/localonly.pb.h +++ b/src/mesh/generated/localonly.pb.h @@ -31,6 +31,9 @@ typedef struct _LocalConfig { /* The part of the config that is specific to the Lora Radio */ bool has_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 incompatible changes This integer is set at build time and is private to NodeDB.cpp in the device code. */ @@ -71,9 +74,9 @@ extern "C" { #endif /* 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 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} /* Field tags (for use in manual encoding/decoding) */ @@ -83,7 +86,8 @@ extern "C" { #define LocalConfig_wifi_tag 4 #define LocalConfig_display_tag 5 #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_serial_tag 2 #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, display, 5) \ 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_DEFAULT NULL #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_display_MSGTYPE Config_DisplayConfig #define LocalConfig_lora_MSGTYPE Config_LoRaConfig +#define LocalConfig_bluetooth_MSGTYPE Config_BluetoothConfig #define LocalModuleConfig_FIELDLIST(X, a) \ X(a, STATIC, OPTIONAL, MESSAGE, mqtt, 1) \ @@ -138,7 +144,7 @@ extern const pb_msgdesc_t LocalModuleConfig_msg; #define LocalModuleConfig_fields &LocalModuleConfig_msg /* Maximum encoded size of messages (where known) */ -#define LocalConfig_size 321 +#define LocalConfig_size 333 #define LocalModuleConfig_size 268 #ifdef __cplusplus diff --git a/src/mesh/generated/mesh.pb.h b/src/mesh/generated/mesh.pb.h index d6b188816..ab7a3dd83 100644 --- a/src/mesh/generated/mesh.pb.h +++ b/src/mesh/generated/mesh.pb.h @@ -459,17 +459,6 @@ typedef struct _User { If this user is a licensed operator, set this flag. Also, "long_name" should be their licence number. */ 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; typedef PB_BYTES_ARRAY_T(237) Data_payload_t; @@ -738,7 +727,7 @@ extern "C" { /* 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 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 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} @@ -752,7 +741,7 @@ extern "C" { #define ToRadio_PeerInfo_init_default {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 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 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} @@ -827,9 +816,6 @@ extern "C" { #define User_macaddr_tag 4 #define User_hw_model_tag 6 #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_payload_tag 2 #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, FIXED_LENGTH_BYTES, macaddr, 4) \ X(a, STATIC, SINGULAR, UENUM, hw_model, 6) \ -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) +X(a, STATIC, SINGULAR, BOOL, is_licensed, 7) #define User_CALLBACK NULL #define User_DEFAULT NULL @@ -1093,13 +1076,13 @@ extern const pb_msgdesc_t Compressed_msg; #define LogRecord_size 81 #define MeshPacket_size 480 #define MyNodeInfo_size 197 -#define NodeInfo_size 281 +#define NodeInfo_size 263 #define Position_size 142 #define RouteDiscovery_size 40 #define Routing_size 42 #define ToRadio_PeerInfo_size 8 #define ToRadio_size 483 -#define User_size 95 +#define User_size 77 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index f933da9d6..acd8d3d6e 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -201,6 +201,11 @@ void AdminModule::handleSetConfig(const Config &c) config.has_lora = true; config.lora = c.payloadVariant.lora; break; + case Config_bluetooth_tag: + DEBUG_MSG("Setting config: Bluetooth\n"); + config.has_bluetooth = true; + config.bluetooth = c.payloadVariant.bluetooth; + break; } service.reloadConfig(); @@ -209,41 +214,41 @@ void AdminModule::handleSetConfig(const Config &c) void AdminModule::handleSetModuleConfig(const ModuleConfig &c) { switch (c.which_payloadVariant) { - case ModuleConfig_mqtt_tag: - DEBUG_MSG("Setting module config: MQTT\n"); - moduleConfig.has_mqtt = true; - moduleConfig.mqtt = c.payloadVariant.mqtt; - break; - case ModuleConfig_serial_tag: - DEBUG_MSG("Setting module config: Serial\n"); - moduleConfig.has_serial = true; - moduleConfig.serial = c.payloadVariant.serial; - break; - case ModuleConfig_external_notification_tag: - DEBUG_MSG("Setting module config: External Notification\n"); - moduleConfig.has_external_notification = true; - moduleConfig.external_notification = c.payloadVariant.external_notification; - break; - case ModuleConfig_store_forward_tag: - DEBUG_MSG("Setting module config: Store & Forward\n"); - moduleConfig.has_store_forward = true; - moduleConfig.store_forward = c.payloadVariant.store_forward; - break; - case ModuleConfig_range_test_tag: - DEBUG_MSG("Setting module config: Range Test\n"); - moduleConfig.has_range_test = true; - moduleConfig.range_test = c.payloadVariant.range_test; - break; - case ModuleConfig_telemetry_tag: - DEBUG_MSG("Setting module config: Telemetry\n"); - moduleConfig.has_telemetry = true; - moduleConfig.telemetry = c.payloadVariant.telemetry; - break; - case ModuleConfig_canned_message_tag: - DEBUG_MSG("Setting module config: Canned Message\n"); - moduleConfig.has_canned_message = true; - moduleConfig.canned_message = c.payloadVariant.canned_message; - break; + case ModuleConfig_mqtt_tag: + DEBUG_MSG("Setting module config: MQTT\n"); + moduleConfig.has_mqtt = true; + moduleConfig.mqtt = c.payloadVariant.mqtt; + break; + case ModuleConfig_serial_tag: + DEBUG_MSG("Setting module config: Serial\n"); + moduleConfig.has_serial = true; + moduleConfig.serial = c.payloadVariant.serial; + break; + case ModuleConfig_external_notification_tag: + DEBUG_MSG("Setting module config: External Notification\n"); + moduleConfig.has_external_notification = true; + moduleConfig.external_notification = c.payloadVariant.external_notification; + break; + case ModuleConfig_store_forward_tag: + DEBUG_MSG("Setting module config: Store & Forward\n"); + moduleConfig.has_store_forward = true; + moduleConfig.store_forward = c.payloadVariant.store_forward; + break; + case ModuleConfig_range_test_tag: + DEBUG_MSG("Setting module config: Range Test\n"); + moduleConfig.has_range_test = true; + moduleConfig.range_test = c.payloadVariant.range_test; + break; + case ModuleConfig_telemetry_tag: + DEBUG_MSG("Setting module config: Telemetry\n"); + moduleConfig.has_telemetry = true; + moduleConfig.telemetry = c.payloadVariant.telemetry; + break; + case ModuleConfig_canned_message_tag: + DEBUG_MSG("Setting module config: Canned Message\n"); + moduleConfig.has_canned_message = true; + moduleConfig.canned_message = c.payloadVariant.canned_message; + break; } 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.payloadVariant.lora = config.lora; 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. // 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). diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp index 6959093e0..48c711287 100644 --- a/src/modules/CannedMessageModule.cpp +++ b/src/modules/CannedMessageModule.cpp @@ -46,16 +46,14 @@ CannedMessageModule::CannedMessageModule() * * @return int Returns the number of messages found. */ +// FIXME: This is just one set of messages now int CannedMessageModule::splitConfiguredMessages() { int messageIndex = 0; int i = 0; // collect all the message parts - strcpy(this->messageStore, cannedMessageModuleConfig.messagesPart1); - strcat(this->messageStore, cannedMessageModuleConfig.messagesPart2); - strcat(this->messageStore, cannedMessageModuleConfig.messagesPart3); - strcat(this->messageStore, cannedMessageModuleConfig.messagesPart4); + strcpy(this->messageStore, cannedMessageModuleConfig.messages); // The first message points to the beginning of the store. this->messages[messageIndex++] = this->messageStore; @@ -294,10 +292,7 @@ bool CannedMessageModule::saveProtoForModule() */ void CannedMessageModule::installDefaultCannedMessageModuleConfig() { - memset(cannedMessageModuleConfig.messagesPart1, 0, sizeof(cannedMessageModuleConfig.messagesPart1)); - memset(cannedMessageModuleConfig.messagesPart2, 0, sizeof(cannedMessageModuleConfig.messagesPart2)); - memset(cannedMessageModuleConfig.messagesPart3, 0, sizeof(cannedMessageModuleConfig.messagesPart3)); - memset(cannedMessageModuleConfig.messagesPart4, 0, sizeof(cannedMessageModuleConfig.messagesPart4)); + memset(cannedMessageModuleConfig.messages, 0, sizeof(cannedMessageModuleConfig.messages)); } /** @@ -315,51 +310,15 @@ AdminMessageHandleResult CannedMessageModule::handleAdminMessageForModule(const AdminMessageHandleResult result; switch (request->which_variant) { - case AdminMessage_get_canned_message_module_part1_request_tag: - DEBUG_MSG("Client is getting radio canned message part1\n"); - this->handleGetCannedMessageModulePart1(mp, response); + case AdminMessage_get_canned_message_module_messages_request_tag: + DEBUG_MSG("Client is getting radio canned messages\n"); + this->handleGetCannedMessageModuleMessages(mp, response); result = AdminMessageHandleResult::HANDLED_WITH_RESPONSE; break; - case AdminMessage_get_canned_message_module_part2_request_tag: - DEBUG_MSG("Client is getting radio canned message part2\n"); - this->handleGetCannedMessageModulePart2(mp, response); - 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); + case AdminMessage_set_canned_message_module_messages_tag: + DEBUG_MSG("Client is setting radio canned messages\n"); + this->handleSetCannedMessageModuleMessages(request->set_canned_message_module_messages); result = AdminMessageHandleResult::HANDLED; break; @@ -370,49 +329,23 @@ AdminMessageHandleResult CannedMessageModule::handleAdminMessageForModule(const 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); - response->which_variant = AdminMessage_get_canned_message_module_part1_response_tag; - strcpy(response->get_canned_message_module_part1_response, cannedMessageModuleConfig.messagesPart1); + response->which_variant = AdminMessage_get_canned_message_module_messages_response_tag; + 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; - 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) +void CannedMessageModule::handleSetCannedMessageModuleMessages(const char *from_msg) { int changed = 0; if (*from_msg) { - changed |= strcmp(cannedMessageModuleConfig.messagesPart1, from_msg); - strcpy(cannedMessageModuleConfig.messagesPart1, from_msg); + changed |= strcmp(cannedMessageModuleConfig.messages, from_msg); + strcpy(cannedMessageModuleConfig.messages, 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 \ No newline at end of file diff --git a/src/modules/CannedMessageModule.h b/src/modules/CannedMessageModule.h index f703ba516..2bd2927e1 100644 --- a/src/modules/CannedMessageModule.h +++ b/src/modules/CannedMessageModule.h @@ -39,15 +39,8 @@ class CannedMessageModule : void eventDown(); void eventSelect(); - void handleGetCannedMessageModulePart1(const MeshPacket &req, AdminMessage *response); - void handleGetCannedMessageModulePart2(const MeshPacket &req, AdminMessage *response); - 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); + void handleGetCannedMessageModuleMessages(const MeshPacket &req, AdminMessage *response); + void handleSetCannedMessageModuleMessages(const char *from_msg); protected: