mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-09-11 17:14:27 +00:00
[LoRaWAN] Reduce build size + more sensible default settings.
This commit is contained in:
@@ -34,7 +34,7 @@ bool rn2xx3::getAsyncMode() const {
|
||||
bool rn2xx3::autobaud()
|
||||
{
|
||||
// FIXME TD-er: Must fix this, as it is not working well.
|
||||
String response = "";
|
||||
String response;
|
||||
|
||||
// Try a maximum of 10 times with a 1 second delay
|
||||
for (uint8_t i = 0; i < 10 && response.length() == 0; i++)
|
||||
|
||||
@@ -9,6 +9,11 @@ rn2xx3_handler::rn2xx3_handler(Stream& serial) : _serial(serial)
|
||||
clearSerialBuffer();
|
||||
}
|
||||
|
||||
String rn2xx3_handler::sendRawCommand(const __FlashStringHelper* command)
|
||||
{
|
||||
return sendRawCommand(String(command));
|
||||
}
|
||||
|
||||
String rn2xx3_handler::sendRawCommand(const String& command)
|
||||
{
|
||||
unsigned long timer = millis();
|
||||
@@ -254,14 +259,16 @@ bool rn2xx3_handler::init()
|
||||
// may not be successful after a factory reset if not all fields are set.
|
||||
|
||||
// Set OTAA keys
|
||||
sendMacSet(F("deveui"), _deveui);
|
||||
sendMacSet(F("appeui"), _appeui);
|
||||
sendMacSet(F("appkey"), _appkey);
|
||||
|
||||
// Set ABP keys
|
||||
sendMacSet(F("nwkskey"), _nwkskey);
|
||||
sendMacSet(F("appskey"), _appskey);
|
||||
sendMacSet(F("devaddr"), _devaddr);
|
||||
if (_otaa) {
|
||||
sendMacSet(F("deveui"), _deveui);
|
||||
sendMacSet(F("appeui"), _appeui);
|
||||
sendMacSet(F("appkey"), _appkey);
|
||||
} else {
|
||||
// Set ABP keys
|
||||
sendMacSet(F("nwkskey"), _nwkskey);
|
||||
sendMacSet(F("appskey"), _appskey);
|
||||
sendMacSet(F("devaddr"), _devaddr);
|
||||
}
|
||||
|
||||
// Set max. allowed power.
|
||||
// 868 MHz EU : 1 -> 14 dBm
|
||||
@@ -272,14 +279,14 @@ bool rn2xx3_handler::init()
|
||||
// Switch off automatic replies, because this library can not
|
||||
// handle more than one mac_rx per tx. See RN2483 datasheet,
|
||||
// 2.4.8.14, page 27 and the scenario on page 19.
|
||||
setAutomaticReply(false);
|
||||
setAutomaticReply(true);
|
||||
|
||||
// Semtech and TTN both use a non default RX2 window freq and SF.
|
||||
// Maybe we should not specify this for other networks.
|
||||
// if (_moduleType == RN2xx3_datatypes::Model::RN2483)
|
||||
// {
|
||||
// set2ndRecvWindow(3, 869525000);
|
||||
// }
|
||||
if (_moduleType == RN2xx3_datatypes::Model::RN2483)
|
||||
{
|
||||
set2ndRecvWindow(3, 869525000);
|
||||
}
|
||||
// Disabled for now because an OTAA join seems to work fine without.
|
||||
|
||||
if (_asyncMode) {
|
||||
@@ -366,6 +373,16 @@ bool rn2xx3_handler::initABP(const String& devAddr, const String& AppSKey, const
|
||||
return init();
|
||||
}
|
||||
|
||||
RN2xx3_datatypes::TX_return_type rn2xx3_handler::txCommand(
|
||||
const __FlashStringHelper* command,
|
||||
const String& data,
|
||||
bool shouldEncode,
|
||||
uint8_t port)
|
||||
{
|
||||
return txCommand(String(command), data, shouldEncode, port);
|
||||
}
|
||||
|
||||
|
||||
RN2xx3_datatypes::TX_return_type rn2xx3_handler::txCommand(const String& command, const String& data, bool shouldEncode, uint8_t port)
|
||||
{
|
||||
if (get_state() == RN_state::must_perform_init) {
|
||||
@@ -710,6 +727,11 @@ String rn2xx3_handler::getLastError()
|
||||
return res;
|
||||
}
|
||||
|
||||
void rn2xx3_handler::setLastError(const __FlashStringHelper* error)
|
||||
{
|
||||
setLastError(String(error));
|
||||
}
|
||||
|
||||
void rn2xx3_handler::setLastError(const String& error)
|
||||
{
|
||||
if (_extensive_debug) {
|
||||
@@ -1207,6 +1229,11 @@ void rn2xx3_handler::handle_reply_received() {
|
||||
}
|
||||
}
|
||||
|
||||
int rn2xx3_handler::readIntValue(const __FlashStringHelper* command)
|
||||
{
|
||||
return readIntValue(String(command));
|
||||
}
|
||||
|
||||
int rn2xx3_handler::readIntValue(const String& command)
|
||||
{
|
||||
String value = sendRawCommand(command);
|
||||
@@ -1215,6 +1242,11 @@ int rn2xx3_handler::readIntValue(const String& command)
|
||||
return value.toInt();
|
||||
}
|
||||
|
||||
bool rn2xx3_handler::readUIntMacGet(const __FlashStringHelper* param, uint32_t& value)
|
||||
{
|
||||
return readUIntMacGet(String(param), value);
|
||||
}
|
||||
|
||||
bool rn2xx3_handler::readUIntMacGet(const String& param, uint32_t& value)
|
||||
{
|
||||
String command;
|
||||
@@ -1232,6 +1264,11 @@ bool rn2xx3_handler::readUIntMacGet(const String& param, uint32_t& value)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool rn2xx3_handler::sendMacSet(const __FlashStringHelper* param, const String& value)
|
||||
{
|
||||
return sendMacSet(String(param), value);
|
||||
}
|
||||
|
||||
bool rn2xx3_handler::sendMacSet(const String& param, const String& value)
|
||||
{
|
||||
String command;
|
||||
@@ -1249,7 +1286,7 @@ bool rn2xx3_handler::sendMacSet(const String& param, const String& value)
|
||||
return RN2xx3_received_types::determineReceivedDataType(sendRawCommand(command)) == RN2xx3_received_types::ok;
|
||||
}
|
||||
|
||||
bool rn2xx3_handler::sendMacSetEnabled(const String& param, bool enabled)
|
||||
bool rn2xx3_handler::sendMacSetEnabled(const __FlashStringHelper* param, bool enabled)
|
||||
{
|
||||
return sendMacSet(param, enabled ? F("on") : F("off"));
|
||||
}
|
||||
@@ -1272,6 +1309,14 @@ bool rn2xx3_handler::sendMacSetCh(const String& param, unsigned int channel, uin
|
||||
return sendMacSetCh(param, channel, String(value));
|
||||
}
|
||||
|
||||
bool rn2xx3_handler::sendMacSetCh(const __FlashStringHelper* param,
|
||||
unsigned int channel,
|
||||
uint32_t value)
|
||||
{
|
||||
return sendMacSetCh(String(param), channel, String(value));
|
||||
}
|
||||
|
||||
|
||||
bool rn2xx3_handler::setChannelDutyCycle(unsigned int channel, unsigned int dutyCycle)
|
||||
{
|
||||
return sendMacSetCh(F("dcycle"), channel, dutyCycle);
|
||||
@@ -1394,7 +1439,7 @@ bool rn2xx3_handler::check_set_keys()
|
||||
{
|
||||
// The default address to use on TTN if no address is defined.
|
||||
// This one falls in the "testing" address space.
|
||||
_devaddr = F("03FFBEEF");
|
||||
_devaddr = F("00000000");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -31,6 +31,7 @@ public:
|
||||
|
||||
rn2xx3_handler(Stream& serial);
|
||||
|
||||
String sendRawCommand(const __FlashStringHelper* command);
|
||||
String sendRawCommand(const String& command);
|
||||
|
||||
bool prepare_raw_command(const String& command);
|
||||
@@ -113,6 +114,12 @@ public:
|
||||
uint8_t *DevEui);
|
||||
|
||||
|
||||
RN2xx3_datatypes::TX_return_type txCommand(const __FlashStringHelper* command,
|
||||
const String& data,
|
||||
bool shouldEncode,
|
||||
uint8_t port);
|
||||
|
||||
|
||||
RN2xx3_datatypes::TX_return_type txCommand(const String&,
|
||||
const String&,
|
||||
bool,
|
||||
@@ -180,6 +187,7 @@ public:
|
||||
String getLastError();
|
||||
|
||||
// Set specific error string.
|
||||
void setLastError(const __FlashStringHelper* error);
|
||||
void setLastError(const String& error);
|
||||
|
||||
RN_state get_state() const;
|
||||
@@ -282,15 +290,21 @@ public:
|
||||
|
||||
// Convenience functions
|
||||
|
||||
int readIntValue(const __FlashStringHelper* command);
|
||||
int readIntValue(const String& command);
|
||||
|
||||
|
||||
bool readUIntMacGet(const __FlashStringHelper* param,
|
||||
uint32_t & value);
|
||||
bool readUIntMacGet(const String& param,
|
||||
uint32_t & value);
|
||||
|
||||
// All "mac set ..." commands return either "ok" or "invalid_param"
|
||||
bool sendMacSet(const __FlashStringHelper* param,
|
||||
const String& value);
|
||||
bool sendMacSet(const String& param,
|
||||
const String& value);
|
||||
bool sendMacSetEnabled(const String& param,
|
||||
bool sendMacSetEnabled(const __FlashStringHelper* param,
|
||||
bool enabled);
|
||||
bool sendMacSetCh(const String& param,
|
||||
unsigned int channel,
|
||||
@@ -298,6 +312,9 @@ public:
|
||||
bool sendMacSetCh(const String& param,
|
||||
unsigned int channel,
|
||||
uint32_t value);
|
||||
bool sendMacSetCh(const __FlashStringHelper* param,
|
||||
unsigned int channel,
|
||||
uint32_t value);
|
||||
bool setChannelDutyCycle(unsigned int channel,
|
||||
unsigned int dutyCycle);
|
||||
bool setChannelFrequency(unsigned int channel,
|
||||
|
||||
Reference in New Issue
Block a user