Skip to content

Commit 832f180

Browse files
committed
Channel mask instead of sub band ID.
1 parent 45f17ab commit 832f180

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

src/Arduino_LoRaConnectionHandler.cpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ typedef enum
4343
/******************************************************************************
4444
CTOR/DTOR
4545
******************************************************************************/
46-
LoRaConnectionHandler::LoRaConnectionHandler(char const * appeui, char const * appkey, _lora_band const band, uint8_t const sub_band_id, _lora_class const device_class)
46+
LoRaConnectionHandler::LoRaConnectionHandler(char const * appeui, char const * appkey, _lora_band const band, char const * channelMask, _lora_class const device_class)
4747
: ConnectionHandler{false}
4848
, _appeui(appeui)
4949
, _appkey(appkey)
5050
, _band(band)
51-
, _sub_band_id(sub_band_id)
51+
, _channelMask(channelMask)
5252
, _device_class(device_class)
5353
{
5454

@@ -107,17 +107,9 @@ NetworkConnectionState LoRaConnectionHandler::update_handleInit()
107107
Debug.print(DBG_ERROR, F("Something went wrong; are you indoor? Move near a window, then reset and retry."));
108108
return NetworkConnectionState::ERROR;
109109
}
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);
110+
// Set channelmask based on configuration
111+
if (_channelMask) {
112+
_modem.sendMask(_channelMask);
121113
}
122114
//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
123115
delay(100);

src/Arduino_LoRaConnectionHandler.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +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, uint8_t const sub_band_id = 0, _lora_class const device_class = _lora_class::CLASS_A);
35+
LoRaConnectionHandler(char const * appeui, char const * appkey, _lora_band const band = _lora_band::EU868, char const * channelMask = NULL, _lora_class const device_class = _lora_class::CLASS_A);
3636

3737
virtual int write(const uint8_t *buf, size_t size) override;
3838
virtual int read() override;
@@ -67,7 +67,7 @@ class LoRaConnectionHandler : public ConnectionHandler
6767
char const * _appeui;
6868
char const * _appkey;
6969
_lora_band _band;
70-
uint8_t _sub_band_id;
70+
char const * _channelMask;
7171
_lora_class _device_class;
7272
LoRaModem _modem;
7373
};

0 commit comments

Comments
 (0)