Merge branch 'master' of github.com:meshtastic/Meshtastic-device

This commit is contained in:
Thomas Göttgens 2022-09-12 09:25:04 +02:00
commit cc054a13e2
16 changed files with 85 additions and 46 deletions

@ -1 +1 @@
Subproject commit f3c4aff7a9f164b10680b8504f0036b4ed84404e
Subproject commit 5e255c01ed8883c9e68d3d4574b300ca609407c5

View File

@ -313,9 +313,9 @@ uint32_t GPS::getWakeTime() const
uint32_t GPS::getSleepTime() const
{
uint32_t t = config.position.gps_update_interval;
bool gps_disabled = config.position.gps_disabled;
bool gps_enabled = config.position.gps_enabled;
if (gps_disabled)
if (!gps_enabled)
t = UINT32_MAX; // Sleep forever now
if (t == UINT32_MAX)
@ -467,7 +467,7 @@ GPS *createGps()
#if !HAS_GPS
return nullptr;
#else
if (!config.position.gps_disabled) {
if (config.position.gps_enabled) {
#ifdef GPS_ALTITUDE_HAE
DEBUG_MSG("Using HAE altitude model\n");
#else

View File

@ -87,7 +87,7 @@ uint32_t serialSinceMsec;
bool pmu_found;
// Array map of sensor types (as array index) and i2c address as value we'll find in the i2c scan
uint8_t nodeTelemetrySensorsMap[7] = { 0, 0, 0, 0, 0, 0, 0 };
uint8_t nodeTelemetrySensorsMap[TelemetrySensorType_LPS22+1] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
Router *router = NULL; // Users of router don't care what sort of subclass implements that API
@ -157,7 +157,7 @@ void setup()
#endif
#ifdef DEBUG_PORT
if (!config.device.serial_disabled) {
if (!config.has_device || config.device.serial_enabled) {
consoleInit(); // Set serial baud rate and init our mesh console
}
#endif

View File

@ -19,7 +19,7 @@ extern bool pmu_found;
extern bool isCharging;
extern bool isUSBPowered;
extern uint8_t nodeTelemetrySensorsMap[7];
extern uint8_t nodeTelemetrySensorsMap[TelemetrySensorType_LPS22+1];
// Global Screen singleton.
extern graphics::Screen *screen;

View File

@ -157,9 +157,13 @@ void NodeDB::installDefaultConfig()
config.has_power = true;
config.has_network = true;
config.has_bluetooth = true;
config.lora.tx_enabled = true; // FIXME: maybe false in the future, and setting region to enable it. (unset region forces it off)
config.lora.region = Config_LoRaConfig_RegionCode_UNSET;
config.lora.modem_preset = Config_LoRaConfig_ModemPreset_LONG_FAST;
config.lora.hop_limit = HOP_RELIABLE;
config.position.gps_enabled = true;
config.position.position_broadcast_smart_enabled = true;
config.device.serial_enabled = true;
resetRadioConfig();
strncpy(config.network.ntp_server, "0.pool.ntp.org", 32);
// FIXME: Default to bluetooth capability of platform as default
@ -173,6 +177,21 @@ void NodeDB::installDefaultConfig()
config.bluetooth.mode = hasScreen ? Config_BluetoothConfig_PairingMode_RANDOM_PIN : Config_BluetoothConfig_PairingMode_FIXED_PIN;
// for backward compat, default position flags are ALT+MSL
config.position.position_flags = (Config_PositionConfig_PositionFlags_ALTITUDE | Config_PositionConfig_PositionFlags_ALTITUDE_MSL);
initConfigIntervals();
}
void NodeDB::initConfigIntervals()
{
config.position.position_broadcast_secs = default_broadcast_interval_secs;
config.power.ls_secs = default_ls_secs;
config.power.mesh_sds_timeout_secs = default_mesh_sds_timeout_secs;
config.power.min_wake_secs = default_min_wake_secs;
config.power.sds_secs = default_sds_secs;
config.power.wait_bluetooth_secs = default_wait_bluetooth_secs;
config.display.screen_on_secs = default_screen_on_secs;
}
void NodeDB::installDefaultModuleConfig()
@ -187,6 +206,14 @@ void NodeDB::installDefaultModuleConfig()
moduleConfig.has_telemetry = true;
moduleConfig.has_external_notification = true;
moduleConfig.has_canned_message = true;
initModuleConfigIntervals();
}
void NodeDB::initModuleConfigIntervals()
{
moduleConfig.telemetry.device_update_interval = default_broadcast_interval_secs;
moduleConfig.telemetry.environment_update_interval = default_broadcast_interval_secs;
}
void NodeDB::installDefaultChannels()

View File

@ -115,6 +115,8 @@ class NodeDB
/// Return the number of nodes we've heard from recently (within the last 2 hrs?)
size_t getNumOnlineNodes();
void initConfigIntervals(), initModuleConfigIntervals();
private:
/// Find a node in our DB, create an empty NodeInfo if missing
NodeInfo *getOrCreateNode(NodeNum n);

View File

@ -121,10 +121,10 @@ ErrorCode RadioLibInterface::send(MeshPacket *p)
#ifndef DISABLE_WELCOME_UNSET
if (config.lora.region != Config_LoRaConfig_RegionCode_UNSET) {
if (disabled || config.lora.tx_disabled) {
if (disabled || !config.lora.tx_enabled) {
if (config.lora.region != Config_LoRaConfig_RegionCode_UNSET) {
if (disabled || config.lora.tx_disabled) {
if (disabled || !config.lora.tx_enabled) {
DEBUG_MSG("send - lora_tx_disabled\n");
packetPool.release(p);
return ERRNO_DISABLED;
@ -381,7 +381,7 @@ ErrorCode RadioLibInterface::send(MeshPacket *p)
void RadioLibInterface::startSend(MeshPacket * txp)
{
printPacket("Starting low level send", txp);
if (disabled || config.lora.tx_disabled) {
if (disabled || !config.lora.tx_enabled) {
DEBUG_MSG("startSend is dropping tx packet because we are disabled\n");
packetPool.release(txp);
} else {

View File

@ -17,11 +17,7 @@ ErrorCode ReliableRouter::send(MeshPacket *p)
// message will rebroadcast. But asking for hop_limit 0 in that context means the client app has no preference on hop
// counts and we want this message to get through the whole mesh, so use the default.
if (p->hop_limit == 0) {
if (config.lora.hop_limit && config.lora.hop_limit <= HOP_MAX) {
p->hop_limit = (config.lora.hop_limit >= HOP_MAX) ? HOP_MAX : config.lora.hop_limit;
} else {
p->hop_limit = HOP_RELIABLE;
}
p->hop_limit = (config.lora.hop_limit >= HOP_MAX) ? HOP_MAX : config.lora.hop_limit;
}
auto copy = packetPool.allocCopy(*p);

View File

@ -118,11 +118,7 @@ MeshPacket *Router::allocForSending()
p->which_payload_variant = MeshPacket_decoded_tag; // Assume payload is decoded at start.
p->from = nodeDB.getNodeNum();
p->to = NODENUM_BROADCAST;
if (config.lora.hop_limit && config.lora.hop_limit <= HOP_MAX) {
p->hop_limit = (config.lora.hop_limit >= HOP_MAX) ? HOP_MAX : config.lora.hop_limit;
} else {
p->hop_limit = HOP_RELIABLE;
}
p->hop_limit = (config.lora.hop_limit >= HOP_MAX) ? HOP_MAX : config.lora.hop_limit;
p->id = generatePacketId();
p->rx_time =
getValidTime(RTCQualityFromNet); // Just in case we process the packet locally - make sure it has a valid timestamp

View File

@ -54,7 +54,7 @@ extern const pb_msgdesc_t ChannelSet_msg;
#define ChannelSet_fields &ChannelSet_msg
/* Maximum encoded size of messages (where known) */
#define ChannelSet_size 557
#define ChannelSet_size 559
#ifdef __cplusplus
} /* extern "C" */

View File

@ -87,7 +87,7 @@ typedef struct _Config_BluetoothConfig {
typedef struct _Config_DeviceConfig {
Config_DeviceConfig_Role role;
bool serial_disabled;
bool serial_enabled;
bool debug_log_enabled;
} Config_DeviceConfig;
@ -99,7 +99,7 @@ typedef struct _Config_DisplayConfig {
} Config_DisplayConfig;
typedef struct _Config_LoRaConfig {
int32_t tx_power;
bool use_preset;
Config_LoRaConfig_ModemPreset modem_preset;
uint32_t bandwidth;
uint32_t spread_factor;
@ -107,7 +107,8 @@ typedef struct _Config_LoRaConfig {
float frequency_offset;
Config_LoRaConfig_RegionCode region;
uint32_t hop_limit;
bool tx_disabled;
bool tx_enabled;
int32_t tx_power;
pb_size_t ignore_incoming_count;
uint32_t ignore_incoming[3];
} Config_LoRaConfig;
@ -122,9 +123,9 @@ typedef struct _Config_NetworkConfig {
typedef struct _Config_PositionConfig {
uint32_t position_broadcast_secs;
bool position_broadcast_smart_disabled;
bool position_broadcast_smart_enabled;
bool fixed_position;
bool gps_disabled;
bool gps_enabled;
uint32_t gps_update_interval;
uint32_t gps_attempt_time;
uint32_t position_flags;
@ -196,7 +197,7 @@ extern "C" {
#define Config_PowerConfig_init_default {0, 0, 0, 0, 0, 0, 0, 0}
#define Config_NetworkConfig_init_default {0, _Config_NetworkConfig_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_LoRaConfig_init_default {0, _Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _Config_LoRaConfig_RegionCode_MIN, 0, 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}
@ -204,7 +205,7 @@ extern "C" {
#define Config_PowerConfig_init_zero {0, 0, 0, 0, 0, 0, 0, 0}
#define Config_NetworkConfig_init_zero {0, _Config_NetworkConfig_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_LoRaConfig_init_zero {0, _Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _Config_LoRaConfig_RegionCode_MIN, 0, 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) */
@ -212,13 +213,13 @@ extern "C" {
#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_serial_enabled_tag 2
#define Config_DeviceConfig_debug_log_enabled_tag 3
#define Config_DisplayConfig_screen_on_secs_tag 1
#define Config_DisplayConfig_gps_format_tag 2
#define Config_DisplayConfig_auto_screen_carousel_secs_tag 3
#define Config_DisplayConfig_compass_north_top_tag 4
#define Config_LoRaConfig_tx_power_tag 1
#define Config_LoRaConfig_use_preset_tag 1
#define Config_LoRaConfig_modem_preset_tag 2
#define Config_LoRaConfig_bandwidth_tag 3
#define Config_LoRaConfig_spread_factor_tag 4
@ -226,7 +227,8 @@ extern "C" {
#define Config_LoRaConfig_frequency_offset_tag 6
#define Config_LoRaConfig_region_tag 7
#define Config_LoRaConfig_hop_limit_tag 8
#define Config_LoRaConfig_tx_disabled_tag 9
#define Config_LoRaConfig_tx_enabled_tag 9
#define Config_LoRaConfig_tx_power_tag 10
#define Config_LoRaConfig_ignore_incoming_tag 103
#define Config_NetworkConfig_wifi_enabled_tag 1
#define Config_NetworkConfig_wifi_mode_tag 2
@ -234,9 +236,9 @@ extern "C" {
#define Config_NetworkConfig_wifi_psk_tag 4
#define Config_NetworkConfig_ntp_server_tag 5
#define Config_PositionConfig_position_broadcast_secs_tag 1
#define Config_PositionConfig_position_broadcast_smart_disabled_tag 2
#define Config_PositionConfig_position_broadcast_smart_enabled_tag 2
#define Config_PositionConfig_fixed_position_tag 3
#define Config_PositionConfig_gps_disabled_tag 4
#define Config_PositionConfig_gps_enabled_tag 4
#define Config_PositionConfig_gps_update_interval_tag 5
#define Config_PositionConfig_gps_attempt_time_tag 6
#define Config_PositionConfig_position_flags_tag 7
@ -277,16 +279,16 @@ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,bluetooth,payload_variant.bl
#define Config_DeviceConfig_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, UENUM, role, 1) \
X(a, STATIC, SINGULAR, BOOL, serial_disabled, 2) \
X(a, STATIC, SINGULAR, BOOL, serial_enabled, 2) \
X(a, STATIC, SINGULAR, BOOL, debug_log_enabled, 3)
#define Config_DeviceConfig_CALLBACK NULL
#define Config_DeviceConfig_DEFAULT NULL
#define Config_PositionConfig_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, UINT32, position_broadcast_secs, 1) \
X(a, STATIC, SINGULAR, BOOL, position_broadcast_smart_disabled, 2) \
X(a, STATIC, SINGULAR, BOOL, position_broadcast_smart_enabled, 2) \
X(a, STATIC, SINGULAR, BOOL, fixed_position, 3) \
X(a, STATIC, SINGULAR, BOOL, gps_disabled, 4) \
X(a, STATIC, SINGULAR, BOOL, gps_enabled, 4) \
X(a, STATIC, SINGULAR, UINT32, gps_update_interval, 5) \
X(a, STATIC, SINGULAR, UINT32, gps_attempt_time, 6) \
X(a, STATIC, SINGULAR, UINT32, position_flags, 7)
@ -323,7 +325,7 @@ X(a, STATIC, SINGULAR, BOOL, compass_north_top, 4)
#define Config_DisplayConfig_DEFAULT NULL
#define Config_LoRaConfig_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, INT32, tx_power, 1) \
X(a, STATIC, SINGULAR, BOOL, use_preset, 1) \
X(a, STATIC, SINGULAR, UENUM, modem_preset, 2) \
X(a, STATIC, SINGULAR, UINT32, bandwidth, 3) \
X(a, STATIC, SINGULAR, UINT32, spread_factor, 4) \
@ -331,7 +333,8 @@ X(a, STATIC, SINGULAR, UINT32, coding_rate, 5) \
X(a, STATIC, SINGULAR, FLOAT, frequency_offset, 6) \
X(a, STATIC, SINGULAR, UENUM, region, 7) \
X(a, STATIC, SINGULAR, UINT32, hop_limit, 8) \
X(a, STATIC, SINGULAR, BOOL, tx_disabled, 9) \
X(a, STATIC, SINGULAR, BOOL, tx_enabled, 9) \
X(a, STATIC, SINGULAR, INT32, tx_power, 10) \
X(a, STATIC, REPEATED, UINT32, ignore_incoming, 103)
#define Config_LoRaConfig_CALLBACK NULL
#define Config_LoRaConfig_DEFAULT NULL
@ -366,7 +369,7 @@ extern const pb_msgdesc_t Config_BluetoothConfig_msg;
#define Config_BluetoothConfig_size 10
#define Config_DeviceConfig_size 6
#define Config_DisplayConfig_size 16
#define Config_LoRaConfig_size 67
#define Config_LoRaConfig_size 69
#define Config_NetworkConfig_size 137
#define Config_PositionConfig_size 30
#define Config_PowerConfig_size 43

View File

@ -144,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 330
#define LocalConfig_size 332
#define LocalModuleConfig_size 270
#ifdef __cplusplus

View File

@ -25,7 +25,11 @@ typedef enum _TelemetrySensorType {
/* Moderate accuracy current and voltage */
TelemetrySensorType_INA219 = 5,
/* High accuracy temperature and pressure */
TelemetrySensorType_BMP280 = 6
TelemetrySensorType_BMP280 = 6,
/* High accuracy temperature and humidity */
TelemetrySensorType_SHTC3 = 7,
/* High accuracy pressure */
TelemetrySensorType_LPS22 = 8
} TelemetrySensorType;
/* Struct definitions */
@ -77,8 +81,8 @@ typedef struct _Telemetry {
/* Helper constants for enums */
#define _TelemetrySensorType_MIN TelemetrySensorType_SENSOR_UNSET
#define _TelemetrySensorType_MAX TelemetrySensorType_BMP280
#define _TelemetrySensorType_ARRAYSIZE ((TelemetrySensorType)(TelemetrySensorType_BMP280+1))
#define _TelemetrySensorType_MAX TelemetrySensorType_LPS22
#define _TelemetrySensorType_ARRAYSIZE ((TelemetrySensorType)(TelemetrySensorType_LPS22+1))
#ifdef __cplusplus

View File

@ -171,11 +171,20 @@ void AdminModule::handleSetOwner(const User &o)
void AdminModule::handleSetConfig(const Config &c)
{
bool requiresReboot = false;
bool isRouter = (config.device.role == Config_DeviceConfig_Role_ROUTER);
switch (c.which_payload_variant) {
case Config_device_tag:
DEBUG_MSG("Setting config: Device\n");
config.has_device = true;
config.device = c.payload_variant.device;
// If we're setting router role for the first time, install its intervals
if (!isRouter &&
c.payload_variant.device.role == Config_DeviceConfig_Role_ROUTER) {
nodeDB.initConfigIntervals();
nodeDB.initModuleConfigIntervals();
}
requiresReboot = true;
break;
case Config_position_tag:
DEBUG_MSG("Setting config: Position\n");

View File

@ -148,7 +148,7 @@ int32_t PositionModule::runOnce()
DEBUG_MSG("Channel utilization is >40 percent. Skipping this opportunity to send.\n");
}
} else if (!config.position.position_broadcast_smart_disabled) {
} else if (config.position.position_broadcast_smart_enabled) {
// Only send packets if the channel is less than 25% utilized.
if (airTime->channelUtilizationPercent() < 25) {

View File

@ -2,7 +2,9 @@
[env:tbeam]
extends = esp32_base
board = ttgo-t-beam
platform_packages = framework-arduinoespressif32@https://github.com/meshtastic/arduino-esp32.git#4cde0f5d412d2695184f32e8a47e9bea57b45276
lib_deps =
${esp32_base.lib_deps}
build_flags =
${esp32_base.build_flags} -D TBEAM_V10 -I variants/tbeam
${esp32_base.build_flags} -D TBEAM_V10 -I variants/tbeam
upload_speed = 921600