kopia lustrzana https://github.com/meshtastic/firmware
Add ntp server config option, remove old region logic
rodzic
e91dedaab5
commit
2035ddf5a9
2
proto
2
proto
|
@ -1 +1 @@
|
|||
Subproject commit 0277a6dd4f0c2469a56cef758434904eb4d1d0f1
|
||||
Subproject commit f1e495cbba4ef235a23446709b9df292636937d6
|
|
@ -146,6 +146,7 @@ bool NodeDB::resetRadioConfig()
|
|||
void NodeDB::installDefaultConfig()
|
||||
{
|
||||
memset(&config, 0, sizeof(config));
|
||||
config.payloadVariant.device.ntp_server[0] = '0.pool.ntp.org';
|
||||
}
|
||||
|
||||
void NodeDB::installDefaultModuleConfig()
|
||||
|
@ -172,10 +173,6 @@ void NodeDB::installDefaultChannels()
|
|||
|
||||
void NodeDB::installDefaultDeviceState()
|
||||
{
|
||||
// We try to preserve the region setting because it will really bum users out if we discard it
|
||||
String oldRegion = myNodeInfo.region;
|
||||
Config_LoRaConfig_RegionCode oldRegionCode = config.payloadVariant.lora.region;
|
||||
|
||||
memset(&devicestate, 0, sizeof(devicestate));
|
||||
|
||||
*numNodes = 0; // Forget node DB
|
||||
|
@ -203,12 +200,6 @@ void NodeDB::installDefaultDeviceState()
|
|||
sprintf(owner.id, "!%08x", getNodeNum()); // Default node ID now based on nodenum
|
||||
memcpy(owner.macaddr, ourMacAddr, sizeof(owner.macaddr));
|
||||
|
||||
// Restore region if possible
|
||||
if (oldRegionCode != Config_LoRaConfig_RegionCode_Unset)
|
||||
config.payloadVariant.lora.region = oldRegionCode;
|
||||
if (oldRegion.length()) // If the old style region was set, try to keep it up-to-date
|
||||
strcpy(myNodeInfo.region, oldRegion.c_str());
|
||||
|
||||
installDefaultChannels();
|
||||
installDefaultConfig();
|
||||
}
|
||||
|
|
|
@ -92,6 +92,7 @@ typedef struct _Config_DeviceConfig {
|
|||
bool serial_disabled;
|
||||
bool factory_reset;
|
||||
bool debug_log_enabled;
|
||||
char ntp_server[33];
|
||||
} Config_DeviceConfig;
|
||||
|
||||
typedef struct _Config_DisplayConfig {
|
||||
|
@ -194,14 +195,14 @@ extern "C" {
|
|||
|
||||
/* Initializer values for message structs */
|
||||
#define Config_init_default {0, {Config_DeviceConfig_init_default}}
|
||||
#define Config_DeviceConfig_init_default {_Config_DeviceConfig_Role_MIN, 0, 0, 0}
|
||||
#define Config_DeviceConfig_init_default {_Config_DeviceConfig_Role_MIN, 0, 0, 0, ""}
|
||||
#define Config_PositionConfig_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
#define Config_PowerConfig_init_default {_Config_PowerConfig_ChargeCurrent_MIN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
#define Config_WiFiConfig_init_default {"", "", 0}
|
||||
#define Config_DisplayConfig_init_default {0, _Config_DisplayConfig_GpsCoordinateFormat_MIN, 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_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, 0, 0, 0}
|
||||
#define Config_PowerConfig_init_zero {_Config_PowerConfig_ChargeCurrent_MIN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
#define Config_WiFiConfig_init_zero {"", "", 0}
|
||||
|
@ -213,6 +214,7 @@ extern "C" {
|
|||
#define Config_DeviceConfig_serial_disabled_tag 2
|
||||
#define Config_DeviceConfig_factory_reset_tag 3
|
||||
#define Config_DeviceConfig_debug_log_enabled_tag 4
|
||||
#define Config_DeviceConfig_ntp_server_tag 5
|
||||
#define Config_DisplayConfig_screen_on_secs_tag 1
|
||||
#define Config_DisplayConfig_gps_format_tag 2
|
||||
#define Config_DisplayConfig_auto_screen_carousel_secs_tag 3
|
||||
|
@ -279,7 +281,8 @@ X(a, STATIC, ONEOF, MESSAGE, (payloadVariant,lora,payloadVariant.lora),
|
|||
X(a, STATIC, SINGULAR, UENUM, role, 1) \
|
||||
X(a, STATIC, SINGULAR, BOOL, serial_disabled, 2) \
|
||||
X(a, STATIC, SINGULAR, BOOL, factory_reset, 3) \
|
||||
X(a, STATIC, SINGULAR, BOOL, debug_log_enabled, 4)
|
||||
X(a, STATIC, SINGULAR, BOOL, debug_log_enabled, 4) \
|
||||
X(a, STATIC, SINGULAR, STRING, ntp_server, 5)
|
||||
#define Config_DeviceConfig_CALLBACK NULL
|
||||
#define Config_DeviceConfig_DEFAULT NULL
|
||||
|
||||
|
@ -359,7 +362,7 @@ extern const pb_msgdesc_t Config_LoRaConfig_msg;
|
|||
#define Config_LoRaConfig_fields &Config_LoRaConfig_msg
|
||||
|
||||
/* Maximum encoded size of messages (where known) */
|
||||
#define Config_DeviceConfig_size 8
|
||||
#define Config_DeviceConfig_size 42
|
||||
#define Config_DisplayConfig_size 14
|
||||
#define Config_LoRaConfig_size 67
|
||||
#define Config_PositionConfig_size 40
|
||||
|
|
|
@ -159,7 +159,7 @@ extern const pb_msgdesc_t OEMStore_msg;
|
|||
|
||||
/* Maximum encoded size of messages (where known) */
|
||||
#define ChannelFile_size 624
|
||||
#define DeviceState_size 19197
|
||||
#define DeviceState_size 19184
|
||||
#define OEMStore_size 2106
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -281,14 +281,6 @@ typedef struct _MyNodeInfo {
|
|||
Not the same as UserPreferences.location_sharing */
|
||||
bool has_gps;
|
||||
/* The maximum number of 'software' channels that can be set on this node. */
|
||||
char region[12];
|
||||
/* Deprecated! ONLY USED IN DEVICE CODE (for upgrading old 1.0 firmwares) DO NOT READ ELSEWHERE.
|
||||
The region code for my radio (US, CN, etc...)
|
||||
Note: This string is deprecated.
|
||||
The 1.0 builds populate it based on the flashed firmware name.
|
||||
But for newer builds this string will be unpopulated (missing/null).
|
||||
For those builds you should instead look at the new read/write region enum in UserSettings
|
||||
The format of this string was 1.0-US or 1.0-CN etc.. Or empty string if unset. */
|
||||
char firmware_version[18];
|
||||
/* 0.0.5 etc... */
|
||||
CriticalErrorCode error_code;
|
||||
|
@ -714,7 +706,7 @@ extern "C" {
|
|||
#define Location_init_default {0, 0, 0, 0, 0}
|
||||
#define MeshPacket_init_default {0, 0, 0, 0, {Data_init_default}, 0, 0, 0, 0, 0, _MeshPacket_Priority_MIN, 0, _MeshPacket_Delayed_MIN}
|
||||
#define NodeInfo_init_default {0, false, User_init_default, false, Position_init_default, 0, 0, false, DeviceMetrics_init_default}
|
||||
#define MyNodeInfo_init_default {0, 0, "", "", _CriticalErrorCode_MIN, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}, 0, {0, 0, 0, 0, 0, 0, 0, 0}, 0, 0, 0}
|
||||
#define MyNodeInfo_init_default {0, 0, "", _CriticalErrorCode_MIN, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}, 0, {0, 0, 0, 0, 0, 0, 0, 0}, 0, 0, 0}
|
||||
#define LogRecord_init_default {"", 0, "", _LogRecord_Level_MIN}
|
||||
#define FromRadio_init_default {0, 0, {MyNodeInfo_init_default}}
|
||||
#define ToRadio_init_default {0, {MeshPacket_init_default}}
|
||||
|
@ -728,7 +720,7 @@ extern "C" {
|
|||
#define Location_init_zero {0, 0, 0, 0, 0}
|
||||
#define MeshPacket_init_zero {0, 0, 0, 0, {Data_init_zero}, 0, 0, 0, 0, 0, _MeshPacket_Priority_MIN, 0, _MeshPacket_Delayed_MIN}
|
||||
#define NodeInfo_init_zero {0, false, User_init_zero, false, Position_init_zero, 0, 0, false, DeviceMetrics_init_zero}
|
||||
#define MyNodeInfo_init_zero {0, 0, "", "", _CriticalErrorCode_MIN, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}, 0, {0, 0, 0, 0, 0, 0, 0, 0}, 0, 0, 0}
|
||||
#define MyNodeInfo_init_zero {0, 0, "", _CriticalErrorCode_MIN, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}, 0, {0, 0, 0, 0, 0, 0, 0, 0}, 0, 0, 0}
|
||||
#define LogRecord_init_zero {"", 0, "", _LogRecord_Level_MIN}
|
||||
#define FromRadio_init_zero {0, 0, {MyNodeInfo_init_zero}}
|
||||
#define ToRadio_init_zero {0, {MeshPacket_init_zero}}
|
||||
|
@ -749,7 +741,6 @@ extern "C" {
|
|||
#define LogRecord_level_tag 4
|
||||
#define MyNodeInfo_my_node_num_tag 1
|
||||
#define MyNodeInfo_has_gps_tag 2
|
||||
#define MyNodeInfo_region_tag 4
|
||||
#define MyNodeInfo_firmware_version_tag 6
|
||||
#define MyNodeInfo_error_code_tag 7
|
||||
#define MyNodeInfo_error_address_tag 8
|
||||
|
@ -954,7 +945,6 @@ X(a, STATIC, OPTIONAL, MESSAGE, device_metrics, 6)
|
|||
#define MyNodeInfo_FIELDLIST(X, a) \
|
||||
X(a, STATIC, SINGULAR, UINT32, my_node_num, 1) \
|
||||
X(a, STATIC, SINGULAR, BOOL, has_gps, 2) \
|
||||
X(a, STATIC, SINGULAR, STRING, region, 4) \
|
||||
X(a, STATIC, SINGULAR, STRING, firmware_version, 6) \
|
||||
X(a, STATIC, SINGULAR, UENUM, error_code, 7) \
|
||||
X(a, STATIC, SINGULAR, UINT32, error_address, 8) \
|
||||
|
@ -1055,7 +1045,7 @@ extern const pb_msgdesc_t Compressed_msg;
|
|||
#define Location_size 24
|
||||
#define LogRecord_size 81
|
||||
#define MeshPacket_size 347
|
||||
#define MyNodeInfo_size 210
|
||||
#define MyNodeInfo_size 197
|
||||
#define NodeInfo_size 281
|
||||
#define Position_size 142
|
||||
#define RouteDiscovery_size 40
|
||||
|
|
|
@ -28,7 +28,7 @@ DNSServer dnsServer;
|
|||
WiFiUDP ntpUDP;
|
||||
|
||||
#ifndef DISABLE_NTP
|
||||
NTPClient timeClient(ntpUDP, "0.pool.ntp.org");
|
||||
NTPClient timeClient(ntpUDP, config.payloadVariant.device.ntp_server);
|
||||
#endif
|
||||
|
||||
uint8_t wifiDisconnectReason = 0;
|
||||
|
|
Ładowanie…
Reference in New Issue