mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-23 19:20:41 +00:00
Adds a userPrefs.h file, default blank, used for default settings for custom builds (#4325)
* add a userPrefs.h file, default blank, which can be used to easily set defaults on custom builds. * Add Splash Screen to userPrefs * Add channel 0 defaults to userPrefs.h * CONFIG_LORA_IGNORE_MQTT_DEFAULT * Unify naming for USERPREFS defines --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "Channels.h"
|
||||
#include "../userPrefs.h"
|
||||
#include "CryptoEngine.h"
|
||||
#include "DisplayFormatters.h"
|
||||
#include "NodeDB.h"
|
||||
@@ -90,6 +91,7 @@ void Channels::initDefaultChannel(ChannelIndex chIndex)
|
||||
loraConfig.modem_preset = meshtastic_Config_LoRaConfig_ModemPreset_LONG_FAST; // Default to Long Range & Fast
|
||||
loraConfig.use_preset = true;
|
||||
loraConfig.tx_power = 0; // default
|
||||
loraConfig.channel_num = 0;
|
||||
uint8_t defaultpskIndex = 1;
|
||||
channelSettings.psk.bytes[0] = defaultpskIndex;
|
||||
channelSettings.psk.size = 1;
|
||||
@@ -99,6 +101,29 @@ void Channels::initDefaultChannel(ChannelIndex chIndex)
|
||||
|
||||
ch.has_settings = true;
|
||||
ch.role = meshtastic_Channel_Role_PRIMARY;
|
||||
|
||||
#ifdef LORACONFIG_MODEM_PRESET_USERPREFS
|
||||
loraConfig.modem_preset = LORACONFIG_MODEM_PRESET_USERPREFS;
|
||||
#endif
|
||||
#ifdef LORACONFIG_CHANNEL_NUM_USERPREFS
|
||||
loraConfig.channel_num = LORACONFIG_CHANNEL_NUM_USERPREFS;
|
||||
#endif
|
||||
|
||||
// Install custom defaults. Will eventually support setting multiple default channels
|
||||
if (chIndex == 0) {
|
||||
#ifdef CHANNEL_0_PSK_USERPREFS
|
||||
static const uint8_t defaultpsk[] = CHANNEL_0_PSK_USERPREFS;
|
||||
memcpy(channelSettings.psk.bytes, defaultpsk, sizeof(defaultpsk));
|
||||
channelSettings.psk.size = sizeof(defaultpsk);
|
||||
|
||||
#endif
|
||||
#ifdef CHANNEL_0_NAME_USERPREFS
|
||||
strcpy(channelSettings.name, CHANNEL_0_NAME_USERPREFS);
|
||||
#endif
|
||||
#ifdef CHANNEL_0_PRECISION_USERPREFS
|
||||
channelSettings.module_settings.position_precision = CHANNEL_0_PRECISION_USERPREFS;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
CryptoKey Channels::getKey(ChannelIndex chIndex)
|
||||
@@ -330,4 +355,4 @@ bool Channels::decryptForHash(ChannelIndex chIndex, ChannelHash channelHash)
|
||||
int16_t Channels::setActiveByIndex(ChannelIndex channelIndex)
|
||||
{
|
||||
return setCrypto(channelIndex);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
#include "../userPrefs.h"
|
||||
#include "configuration.h"
|
||||
#if !MESHTASTIC_EXCLUDE_GPS
|
||||
#include "GPS.h"
|
||||
@@ -237,10 +238,22 @@ void NodeDB::installDefaultConfig()
|
||||
config.lora.tx_enabled =
|
||||
true; // FIXME: maybe false in the future, and setting region to enable it. (unset region forces it off)
|
||||
config.lora.override_duty_cycle = false;
|
||||
#ifdef CONFIG_LORA_REGION_USERPREFS
|
||||
config.lora.region = CONFIG_LORA_REGION_USERPREFS;
|
||||
#else
|
||||
config.lora.region = meshtastic_Config_LoRaConfig_RegionCode_UNSET;
|
||||
#endif
|
||||
#ifdef LORACONFIG_MODEM_PRESET_USERPREFS
|
||||
config.lora.modem_preset = LORACONFIG_MODEM_PRESET_USERPREFS;
|
||||
#else
|
||||
config.lora.modem_preset = meshtastic_Config_LoRaConfig_ModemPreset_LONG_FAST;
|
||||
#endif
|
||||
config.lora.hop_limit = HOP_RELIABLE;
|
||||
#ifdef CONFIG_LORA_IGNORE_MQTT_USERPREFS
|
||||
config.lora.ignore_mqtt = CONFIG_LORA_IGNORE_MQTT_USERPREFS;
|
||||
#else
|
||||
config.lora.ignore_mqtt = false;
|
||||
#endif
|
||||
#ifdef PIN_GPS_EN
|
||||
config.position.gps_en_gpio = PIN_GPS_EN;
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user