Skip to content

Commit a0f656f

Browse files
authored
Merge pull request #68 from ilcato/add-sub-frequency-param-to-lorawan-constructor
Add channel mask to LoraWan constructor and expose LoraWan modem getters
2 parents 0eadc4a + 832f180 commit a0f656f

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

src/Arduino_LoRaConnectionHandler.cpp

Lines changed: 6 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, char const * channelMask, _lora_class const device_class)
4847
: ConnectionHandler{false}
4948
, _appeui(appeui)
5049
, _appkey(appkey)
5150
, _band(band)
51+
, _channelMask(channelMask)
5252
, _device_class(device_class)
5353
{
5454

@@ -106,6 +106,10 @@ 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 configuration
111+
if (_channelMask) {
112+
_modem.sendMask(_channelMask);
109113
}
110114
//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
111115
delay(100);

src/Arduino_LoRaConnectionHandler.h

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,26 @@ 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, char const * channelMask = NULL, _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;
4039
virtual bool available() override;
4140

41+
inline String getVersion() { return _modem.version(); }
42+
inline String getDeviceEUI() { return _modem.deviceEUI(); }
43+
inline int getChannelMaskSize(_lora_band band) { return _modem.getChannelMaskSize(band); }
44+
inline String getChannelMask() { return _modem.getChannelMask(); }
45+
inline int isChannelEnabled(int pos) { return _modem.isChannelEnabled(pos); }
46+
inline int getDataRate() { return _modem.getDataRate(); }
47+
inline int getADR() { return _modem.getADR(); }
48+
inline String getDevAddr() { return _modem.getDevAddr(); }
49+
inline String getNwkSKey() { return _modem.getNwkSKey(); }
50+
inline String getAppSKey() { return _modem.getAppSKey(); }
51+
inline int getRX2DR() { return _modem.getRX2DR(); }
52+
inline uint32_t getRX2Freq() { return _modem.getRX2Freq(); }
53+
inline int32_t getFCU() { return _modem.getFCU(); }
54+
inline int32_t getFCD() { return _modem.getFCD(); }
4255

4356
protected:
4457

@@ -54,6 +67,7 @@ class LoRaConnectionHandler : public ConnectionHandler
5467
char const * _appeui;
5568
char const * _appkey;
5669
_lora_band _band;
70+
char const * _channelMask;
5771
_lora_class _device_class;
5872
LoRaModem _modem;
5973
};

0 commit comments

Comments
 (0)