Skip to content

Commit 45f17ab

Browse files
committed
Added subfrequency band index parameter and managed it
1 parent 54146f1 commit 45f17ab

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/Arduino_LoRaConnectionHandler.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ typedef enum
4343
/******************************************************************************
4444
CTOR/DTOR
4545
******************************************************************************/
46-
47-
LoRaConnectionHandler::LoRaConnectionHandler(char const * appeui, char const * appkey, _lora_band const band, _lora_class const device_class)
46+
LoRaConnectionHandler::LoRaConnectionHandler(char const * appeui, char const * appkey, _lora_band const band, uint8_t const sub_band_id, _lora_class const device_class)
4847
: ConnectionHandler{false}
4948
, _appeui(appeui)
5049
, _appkey(appkey)
5150
, _band(band)
51+
, _sub_band_id(sub_band_id)
5252
, _device_class(device_class)
5353
{
5454

@@ -106,6 +106,18 @@ NetworkConnectionState LoRaConnectionHandler::update_handleInit()
106106
{
107107
Debug.print(DBG_ERROR, F("Something went wrong; are you indoor? Move near a window, then reset and retry."));
108108
return NetworkConnectionState::ERROR;
109+
}
110+
// Set channelmask based on frequency sub band index
111+
if (_sub_band_id) {
112+
String mask;
113+
for (int i = 12; i > 0; i--) {
114+
if (i == _sub_band_id) {
115+
mask.concat("FF");
116+
} else {
117+
mask.concat("00");
118+
}
119+
}
120+
_modem.sendMask(mask);
109121
}
110122
//A delay is required between _modem.begin(band) and _modem.joinOTAA(appeui, appkey) in order to let the chip to be correctly initialized before the connection attempt
111123
delay(100);

src/Arduino_LoRaConnectionHandler.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ class LoRaConnectionHandler : public ConnectionHandler
3232
{
3333
public:
3434

35-
LoRaConnectionHandler(char const * appeui, char const * appkey, _lora_band const band = _lora_band::EU868, _lora_class const device_class = _lora_class::CLASS_A);
36-
35+
LoRaConnectionHandler(char const * appeui, char const * appkey, _lora_band const band = _lora_band::EU868, uint8_t const sub_band_id = 0, _lora_class const device_class = _lora_class::CLASS_A);
3736

3837
virtual int write(const uint8_t *buf, size_t size) override;
3938
virtual int read() override;
@@ -68,6 +67,7 @@ class LoRaConnectionHandler : public ConnectionHandler
6867
char const * _appeui;
6968
char const * _appkey;
7069
_lora_band _band;
70+
uint8_t _sub_band_id;
7171
_lora_class _device_class;
7272
LoRaModem _modem;
7373
};

0 commit comments

Comments
 (0)