Skip to content

Add channel mask to LoraWan constructor and expose LoraWan modem getters #68

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/Arduino_LoRaConnectionHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ typedef enum
/******************************************************************************
CTOR/DTOR
******************************************************************************/

LoRaConnectionHandler::LoRaConnectionHandler(char const * appeui, char const * appkey, _lora_band const band, _lora_class const device_class)
LoRaConnectionHandler::LoRaConnectionHandler(char const * appeui, char const * appkey, _lora_band const band, char const * channelMask, _lora_class const device_class)
: ConnectionHandler{false}
, _appeui(appeui)
, _appkey(appkey)
, _band(band)
, _channelMask(channelMask)
, _device_class(device_class)
{

Expand Down Expand Up @@ -106,6 +106,10 @@ NetworkConnectionState LoRaConnectionHandler::update_handleInit()
{
Debug.print(DBG_ERROR, F("Something went wrong; are you indoor? Move near a window, then reset and retry."));
return NetworkConnectionState::ERROR;
}
// Set channelmask based on configuration
if (_channelMask) {
_modem.sendMask(_channelMask);
}
//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
delay(100);
Expand Down
18 changes: 16 additions & 2 deletions src/Arduino_LoRaConnectionHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,26 @@ class LoRaConnectionHandler : public ConnectionHandler
{
public:

LoRaConnectionHandler(char const * appeui, char const * appkey, _lora_band const band = _lora_band::EU868, _lora_class const device_class = _lora_class::CLASS_A);

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);

virtual int write(const uint8_t *buf, size_t size) override;
virtual int read() override;
virtual bool available() override;

inline String getVersion() { return _modem.version(); }
inline String getDeviceEUI() { return _modem.deviceEUI(); }
inline int getChannelMaskSize(_lora_band band) { return _modem.getChannelMaskSize(band); }
inline String getChannelMask() { return _modem.getChannelMask(); }
inline int isChannelEnabled(int pos) { return _modem.isChannelEnabled(pos); }
inline int getDataRate() { return _modem.getDataRate(); }
inline int getADR() { return _modem.getADR(); }
inline String getDevAddr() { return _modem.getDevAddr(); }
inline String getNwkSKey() { return _modem.getNwkSKey(); }
inline String getAppSKey() { return _modem.getAppSKey(); }
inline int getRX2DR() { return _modem.getRX2DR(); }
inline uint32_t getRX2Freq() { return _modem.getRX2Freq(); }
inline int32_t getFCU() { return _modem.getFCU(); }
inline int32_t getFCD() { return _modem.getFCD(); }

protected:

Expand All @@ -54,6 +67,7 @@ class LoRaConnectionHandler : public ConnectionHandler
char const * _appeui;
char const * _appkey;
_lora_band _band;
char const * _channelMask;
_lora_class _device_class;
LoRaModem _modem;
};
Expand Down