Start terminal config

This commit is contained in:
Terra 2022-04-24 22:31:25 +02:00
parent 3c53f94c1b
commit 700d676d4c
3 changed files with 48 additions and 4 deletions

View File

@ -196,7 +196,13 @@ void loadMemory()
void refreshConfig()
{
radio.setFrequency(configuration.modem_frequency);
float frequency = configuration.modem_frequency;
if (MODEM_FREQ_LOWER < value && value < MODEM_FREQ_UPPER)
radio.setFrequency(configuration.modem_frequency);
else
radio.setFrequency(0);
// The default transmitter power is 13dBm, using PA_BOOST.
// If you are using RFM95/96/97/98 modules which uses the PA_BOOST transmitter pin, then
@ -308,7 +314,7 @@ bool receive()
{
case MT_Time:
rtc_offset = server_message_id - RTC->MODE1.COUNT.reg;
if (server_message_id > message_id) // Ensure that IDs are sequential
message_id = server_message_id;

View File

@ -12,7 +12,8 @@
#define MODEM_CONFIG RH_RF95::Bw125Cr45Sf128
#define MODEM_POWER 13
#define MODEM_FREQ 868.0
#define MODEM_FREQ_LOWER 863
#define MODEM_FREQ_UPPER 870
#define HASH_LENGTH 8 // 8 bytes
#define RF_SS_PIN 1

View File

@ -124,6 +124,43 @@ void loop()
case 's':
saveMemory();
break;
case 'T':
case 't':
String in_str = "";
while (in_str != "END")
{
in_str = SerialUSB.readStringUntil('\n');
in_str.trim();
if (in_str[0] != '#')
{
in_str.toLowerCase();
in_str.replace("\t", " ");
while (in_str.indexOf(" ") != -1)
in_str.replace(" ", " ");
int space_index = in_str.indexOf(" ");
String option = in_str.substring(0, space_index);
if (option == "frequency")
{
float value = in_str.substring(space_index, in_str.indexOf(" ", space_index + 1)).toFloat();
if (MODEM_FREQ_LOWER < value && value < MODEM_FREQ_UPPER)
configuration.modem_frequency = value;
else
SerialUSB.print("Frequency out of range!")
}
else if (option == "power")
int value = in_str.substring(space_index, in_str.indexOf(" ", space_index + 1)).toInt();
if (2 < value && value < 20)
configuration.modem_power = value;
else
SerialUSB.print("Power out of range!")
}
}
break;
}
}
@ -154,7 +191,7 @@ void loop()
long next_tick_device_dt = next_tick_device - now_time;
long next_tick_sensors_dt = next_tick_sensors - now_time;
long min_delay = min(next_tick_device_dt, next_tick_sensors_dt);
if (min_delay > 1000 && !USBDevice.connected() && message_id > 1000000000) // Listen until the time is initialized
{
power_sleep(min_delay);