Nol.A SDK Library 26.11.2
For IoT System Software Development
Loading...
Searching...
No Matches
LoRaMac Class Referenceabstract

LoRaWAN 단말 장치들을 위한 MAC 프로토콜 More...

#include <LoRaMac.hpp>

Inheritance diagram for LoRaMac:
PacketRadio LoRaMacCN779 LoRaMacEU433 LoRaMacEU863 LoRaMacKR920 LoRaMacLBT LoRaMacUS902 LoRaMacKR920SKT LoRaMacAS923Japan LoRaMacUS902Hybrid

Classes

class  ChannelParams_t
struct  DatarateParams_t
union  Header_t
struct  RxWindowClosedEvent

Public Types

enum  DeviceClass_t { CLASS_A = 0 , CLASS_B = 1 , CLASS_C = 2 }
enum  BatteryLevel_t { BAT_LEVEL_EXT_SRC = 0x00 , BAT_LEVEL_EMPTY = 0x01 , BAT_LEVEL_FULL = 0xFE , BAT_LEVEL_NO_MEASURE = 0xFF }
enum  { ERROR_INVALID_FREQUENCY = -100 , ERROR_INVALID_DATARATE = -101 , ERROR_INVALID_FREQ_AND_DR = -102 }
Public Types inherited from PacketRadio
enum  { TX_FIFO_SIZE = 10 , RX_FIFO_SIZE = 10 , TX_DONE_FIFO_SIZE = 10 }

Public Member Functions

 LoRaMac (LoRaRadioChip &, int8_t defTxPower, int8_t defDatarate, bool dutyCycleOn, uint8_t numChannels, const DatarateParams_t *drTable, uint8_t maxDatarate, uint8_t minTxPower, uint8_t maxTxPower, uint8_t adrAckLimit, uint8_t adrAckDelay, uint32_t maxFCntGap, uint16_t radioWakeupTime=1)
virtual error_t begin (uint8_t(*getBatteryLevel)()=NULL)
 LoRaMAC layer initialization.
virtual error_t addChannel (uint8_t id, ChannelParams_t params)=0
 Add a channel.
virtual error_t removeChannel (uint8_t id)=0
 LoRaMAC channel remove service.
error_t linkMulticastChannel (MulticastParams_t *channelParam)
 LoRaMAC multicast channel link service.
error_t unlinkMulticastChannel (MulticastParams_t *channelParam)
 LoRaMAC multicast channel unlink service.
virtual error_t beginJoining (const uint8_t *devEui, const uint8_t *appEui, const uint8_t *appKey)
 Over-the-Air Activation (OTAA) 방식의 join을 시도합니다.
error_t beginJoining (const uint8_t *devEui, const uint8_t *appKey)
bool isJoining ()
 현재 OTAA Join 중인지 확인합니다.
void onJoin (void(*func)(LoRaMac &mac, bool result, const uint8_t *devEui, const uint8_t *appEui, const uint8_t *appKey, const uint8_t *nwkSKey, const uint8_t *appSKey, uint32_t devAddr, const RadioPacket &frame, uint32_t airTime))
 Join이 완료되었을 때 호출될 콜백함수를 지정합니다.
void onJoinRequested (void(*func)(LoRaMac &, uint32_t frequencyHz, const DatarateParams_t &))
 JoinRequest 메시지를 보낼 때 호출될 콜백함수를 지정합니다.
virtual void setABP (const uint8_t *nwkSKey, const uint8_t *appSKey, uint32_t devAddr)
 ABP를 사용하도록 설정합니다.
void setPublicNetwork (bool enable)
 공용 LoRaWAN 네트워크를 사용할지 설정합니다.
DeviceClass_t getDeviceClass ()
 Device class를 가져옵니다.
error_t setDeviceClass (DeviceClass_t c)
 Device class를 설정합니다.
error_t setDeviceClass (DeviceClass_t c, bool sendDeviceModeInd, void(*func)(LoRaMac &, DeviceClass_t))
virtual const ChannelParams_t * getChannel (uint8_t index)=0
 채널 정보를 가져옵니다.
const DatarateParams_t * getDatarate (uint8_t index) const
 Datarate 정보를 가져옵니다.
uint8_t getRx2Datarate ()
 Rx2에서 사용할 DR을 가져옵니다.
void setRx2Datarate (uint8_t dr)
 Rx2에서 사용할 DR을 임의로 설정합니다.
uint32_t getRx2Frequency ()
 Rx2에서 사용할 주파수를 가져옵니다.
void setRx2Frequency (uint32_t f)
 Rx2에서 사용할 주파수를 임의로 설정합니다.
uint8_t getRx1DrOffset ()
 Rx1에 적용될 DR offset을 가져옵니다.
virtual uint8_t getRx1Datarate ()
 Rx1에 사용될, DR offset이 적용된 DR을 가져옵니다.
virtual uint32_t getRx1Frequency ()=0
 Rx1에서 사용할 주파수를 가져옵니다.
int32_t getNetworkID ()
 Network ID를 가져옵니다.
uint32_t getDeviceAddress ()
 Device address를 가져옵니다.
uint16_t getRx1Delay ()
 Tx 종료 후 Rx1 window가 열릴 때까지의 지연 시간(단위: 밀리초)을 가져옵니다.
uint16_t getRx2Delay ()
 Tx 종료 후 Rx2 window가 열릴 때까지의 지연 시간(단위: 밀리초)을 가져옵니다.
uint16_t getJoinAcceptDelay1 ()
 JoinRequest 송신 후 Rx1 window가 열릴 때까지의 지연 시간(단위: 밀리초)을 가져옵니다.
uint16_t getJoinAcceptDelay2 ()
 JoinRequest 송신 후 Rx2 window가 열릴 때까지의 지연 시간(단위: 밀리초)을 가져옵니다.
uint8_t getCurrentDatarateIndex ()
 현재 설정된 기본 datarate 인덱스를 가져옵니다.
error_t setCurrentDatarateIndex (uint8_t index)
 기본 datarate를 설정합니다.
uint8_t getCurrentTxPowerIndex ()
 기본 Tx power index를 가져옵니다.
error_t setCurrentTxPowerIndex (uint8_t index)
 기본 Tx power를 설정합니다.
uint32_t getUpLinkCounter ()
 Uplink용 frame counter (fCntUp) 를 가져옵니다.
virtual void setUpLinkCounter (uint32_t)
 Uplink용 frame counter (fCntUp) 를 설정합니다.
uint32_t getDownLinkCounter ()
 Downlink용 frame counter (fCntDown) 를 가져옵니다.
virtual void setDownLinkCounter (uint32_t)
 Downlink용 frame counter (fCntDown) 를 설정합니다.
uint8_t getNumRepetitions ()
 현재 설정된 unconfirmed uplink frame에 적용되는 반복 전송 횟수를 가져옵니다.
uint8_t getMaxDutyCycle ()
 현재의 최대 duty cycle을 가져옵니다.
error_t send (LoRaMacFrame *frame)
 frame 을 전송합니다.
error_t cancelSend (LoRaMacFrame *frame)
 frame 전송을 취소합니다.
void onSendDone (void(*sendDoneHandler)(LoRaMac &, LoRaMacFrame *))
 전송이 완료될 때 호출될 함수를 지정합니다.
void onReceive (void(*receiveHandler)(LoRaMac &radio, const LoRaMacFrame *frame))
 수신이 완료될 때 호출될 함수를 지정합니다.
void onReceiveErrorFrame (void(*receiveHandler)(LoRaMac &radio, const RadioPacket &frame))
 비정상 프레임 수신시 호출될 함수를 지정합니다.
virtual uint8_t getMaxPayload (uint8_t dr, bool repeater=false)=0
 최대 application payload 길이(N)를 가져옵니다.
uint8_t getPendingMacCommandsLength ()
 현재 송신 대기 중인 MAC commands의 길이를 가져옵니다.
std::array< uint8_t, 8 > getDevEui ()
 Device EUI를 가져옵니다.
std::array< uint8_t, 8 > getAppEui ()
 Application EUI를 가져옵니다.
std::array< uint8_t, 16 > getAppKey ()
 AppKey를 가져옵니다.
std::array< uint8_t, 16 > getNwkSKey ()
 NwkSKey를 가져옵니다.
std::array< uint8_t, 16 > getAppSKey ()
 AppSKey를 가져옵니다.
Public Member Functions inherited from PacketRadio
error_t send (RadioPacket *frame)
 frame 을 전송합니다.
error_t cancelSend (RadioPacket *frame)
 frame 전송을 취소합니다.
void onSendDone (void(*sendDoneHandler)(PacketRadio &, RadioPacket *))
 전송이 완료될 때 호출될 함수를 지정합니다.
uint8_t getNumPendingSendFrames ()
 전송 대기 중인 프레임 갯수를 구합니다.
void onReceive (void(*receiveHandler)(PacketRadio &, const RadioPacket *))
 수신이 완료될 때 호출될 함수를 지정합니다.
void setEventListener (PacketRadioEventListener &)
 전송 완료 및 수신 이벤트에 대해 PacketRadioEventListener 를 구현한 클래스로 콜백합니다.

Static Public Member Functions

static void ComputeMic (const uint8_t *buffer, uint16_t size, const uint8_t *key, uint32_t address, uint8_t dir, uint32_t sequenceCounter, uint32_t *mic)
static void PayloadEncrypt (const uint8_t *buffer, uint16_t size, const uint8_t *key, uint32_t address, uint8_t dir, uint32_t sequenceCounter, uint8_t *encBuffer)
static void PayloadDecrypt (const uint8_t *buffer, uint16_t size, const uint8_t *key, uint32_t address, uint8_t dir, uint32_t sequenceCounter, uint8_t *decBuffer)
static void JoinComputeMic (const uint8_t *buffer, uint16_t size, const uint8_t *key, uint32_t *mic)
static void JoinDecrypt (const uint8_t *buffer, uint16_t size, const uint8_t *key, uint8_t *decBuffer)
static void JoinComputeSKeys (const uint8_t *key, const uint8_t *appNonce, uint16_t devNonce, uint8_t *nwkSKey, uint8_t *appSKey)

Public Attributes

uint8_t const MaxNumChannels
 최대 채널 수
const DatarateParams_t * DR_TABLE
uint8_t const MaxDatarate
 지정된 최대 datarate index. 칩이 지원하지 않는 SF는 별도로 제외합니다.
uint8_t const MinTxPower
 Minimum Tx power index.
uint8_t const MaxTxPower
 Maximum Tx power index.
uint8_t const AdrAckLimit
 ADR_ACK_LIMIT.
uint8_t const AdrAckDelay
 ADR_ACK_DELAY.
uint32_t const MAX_FCNT_GAP
uint16_t const RadioWakeupTime
bool useADR = true
 ADR 사용여부를 설정합니다.
bool receivesDuplicate = false
 중복 프레임을 수신 여부를 설정합니다.
bool framePending = false
 Frame pending.
void(* onUplinkDone )(LoRaMac &, LoRaMacFrame *) = nullptr
 Uplink (Tx) 전송이 완료될 때 호출될 함수를 지정합니다.
void(* onRxWindowClosed )(LoRaMac &mac, uint8_t window, struct timeval nextWindowAt) = nullptr
 Class A RX1 또는 RX2 수신 창이 닫힌 뒤 작업 문맥에서 호출됩니다.

Protected Types

enum  FrameType_t {
  FRAME_TYPE_JOIN_REQ = 0x00 , FRAME_TYPE_JOIN_ACCEPT = 0x01 , FRAME_TYPE_DATA_UNCONFIRMED_UP = 0x02 , FRAME_TYPE_DATA_UNCONFIRMED_DOWN = 0x03 ,
  FRAME_TYPE_DATA_CONFIRMED_UP = 0x04 , FRAME_TYPE_DATA_CONFIRMED_DOWN = 0x05 , FRAME_TYPE_RFU = 0x06 , FRAME_TYPE_PROPRIETARY = 0x07
}
enum  {
  ADR_ACK_LIMIT = 64 , ADR_ACK_DELAY = 32 , PHY_PAYLOAD_MAX_LENGTH = 255 , MAC_COMMAND_MAX_LENGTH = 15 ,
  FRM_PAYLOAD_MAX_LENGTH = 242
}
enum  EventInfoStatus_t {
  EVENT_INFO_STATUS_OK = 0 , EVENT_INFO_STATUS_ERROR , EVENT_INFO_STATUS_TX_TIMEOUT , EVENT_INFO_STATUS_RX1_TIMEOUT ,
  EVENT_INFO_STATUS_RX2_TIMEOUT , EVENT_INFO_STATUS_JOIN_FAIL , EVENT_INFO_STATUS_DOWNLINK_REPEATED , EVENT_INFO_STATUS_ADDRESS_FAIL ,
  EVENT_INFO_STATUS_MIC_FAIL , EVENT_INFO_STATUS_CHANNEL_BUSY
}
enum  {
  MAC_IDLE = 0x00000000ul , MAC_TX_RUNNING = 0x00000001ul , MAC_RX = 0x00000002ul , MAC_ACK_REQ = 0x00000004ul ,
  MAC_ACK_RETRY = 0x00000008ul , MAC_TX_DELAYED = 0x00000010ul , MAC_TX_CONFIG = 0x00000020ul
}
enum  FCntDownStatus_t { NEW_FCNT_OK = 0 , NEW_FCNT_DUPLICATE , NEW_FCNT_MAX_GAP_EXCEEDED }

Protected Member Functions

void resetSessionState ()
virtual void resetRegionState ()
virtual void updateTxTime (uint32_t now)=0
virtual void updateChannels (const uint8_t *CFList, uint8_t CFListLen)=0
virtual void enableDefaultChannels ()=0
virtual uint8_t applyADRConfig (uint16_t chMask, uint8_t chMaskCntl, int8_t txPower, int8_t datarate, uint8_t nbRep)=0
virtual void applyRxParamConfig (uint8_t &status, int8_t datarate, int8_t drOffset, uint32_t freq)=0
virtual uint8_t applyNewChannelConfig (const uint8_t *payload)=0
virtual int8_t applyDlChannel (const uint8_t *payload)
virtual void applyTxParamSetup (uint8_t payload)
virtual bool checkTxFrame (LoRaMacFrame *frame)
virtual void sendDone (RadioPacket *frame, RadioPacket::Result_t)
virtual void receive (LoRaMacFrame *frame)
virtual void notifyJoin ()
virtual error_t SendFrameOnChannel (const ChannelParams_t &channel)
int8_t getChannelIndex (uint32_t frequency)
int8_t getDatarateIndex (DatarateParams_t &dr)
int8_t getDatarateIndex (LoRaMacFrame &f)
int8_t getDatarateIndex (LoRaMacFrame *f)
bool checkTxFrame (RadioPacket *frame)
void handleRxFrame (RadioPacket *frame)
void log (const char *name, const char *msg)
void logTx (const char *name, uint32_t freq, uint8_t drIndex, int8_t power)
void logRx (const char *name, uint32_t freq, uint8_t drIndex, uint8_t window)
error_t setupRxWindow (uint8_t slot)
void onRxWindow2TimerEvent ()
void closeRxWindow ()
virtual FCntDownStatus_t getFCntDown (uint16_t fCntFHDR, uint32_t &newFCnt)
bool requestsAck ()
virtual void eventTxDelayed ()
virtual bool isAvailableDR (uint8_t drIndex, void *chMask=nullptr)=0
virtual bool channelSupportsDR (const ChannelParams_t &channel, uint8_t dr) const
 Checks whether a channel's DRRange includes the given datarate. Override to interpret region-specific non-contiguous ranges. Radio capability and datarate validity are checked separately.
void computeRxWindowParameters (uint8_t drIndex, uint16_t *timeout, int16_t *offset, uint8_t minRxSymbols=6, uint32_t systemMaxRxError=10)
virtual uint8_t parseDevTimeAns (const uint8_t *payload, uint8_t len, struct timeval *t)
 DevTimeAns에 대한 parser.
Protected Member Functions inherited from PacketRadio
virtual void receive (RadioPacket *frame)
RadioPacket * getNextTxFrame ()
error_t enqueueTxFrame (RadioPacket *frame)
virtual void notifySendDone (RadioPacket *frame)
virtual void notifyReceive (RadioPacket *frame)

Static Protected Member Functions

static void resetChannels (ChannelParams_t *channels, uint8_t count, const ChannelParams_t *defaults=nullptr, uint8_t defaultCount=0)
static void resetChannelMask (uint16_t *mask, uint8_t words, uint8_t enabledCount)
static void OnTxDelayedTimerEvent (void *)
static void OnMacStateCheckTimerEvent (void *)
static void dispatchRxWindowClosedEvents (void *ctx)

Protected Attributes

bool PublicNetwork = true
bool RepeaterSupport = false
bool joining = false
bool isLinkCheckRequested = false
bool isDeviceTimeRequested = false
bool isLinkCheckSent = false
bool isDeviceTimeSent = false
bool serverAckRequested = false
bool DutyCycleOn
bool ackTimeoutRetry = false
bool stateCheckerPosted = false
bool isOptNegSet = false
LoRaRadioChip & Radio
std::array< uint8_t, 8 > devEui
std::array< uint8_t, 8 > appEui
std::array< uint8_t, 16 > appKey
std::array< uint8_t, 16 > nwkSKey
std::array< uint8_t, 16 > appSKey
uint16_t LoRaMacDevNonce
int32_t netID = -1
uint32_t LoRaMacDevAddr
MulticastParams_t * MulticastChannels = NULL
DeviceClass_t deviceClass = CLASS_A
uint8_t Buffer [PHY_PAYLOAD_MAX_LENGTH]
uint16_t BufferPktLen = 0
uint8_t LoRaMacPayload [PHY_PAYLOAD_MAX_LENGTH]
uint32_t UpLinkCounter = 1
uint32_t DownLinkCounter = 0
uint32_t AdrAckCounter = 0
uint8_t MacCommandsBufferIndex = 0
uint8_t MacCommandsBuffer [MAC_COMMAND_MAX_LENGTH]
struct { 
   uint32_t   Frequency 
   uint8_t   Datarate 
} Rx2Channel
uint8_t Rx1DrOffset = 0
int8_t ChannelsTxPower
int8_t ChannelsDefaultTxPower
int8_t ChannelsDatarate
int8_t ChannelsDefaultDatarate
uint8_t ChannelsNbRepDefault = 1
uint8_t ChannelsNbRep
uint8_t ChannelsNbRepCounter = 0
uint8_t MaxDCycle = 0
uint16_t AggregatedDCycle = 1
uint32_t AggregatedLastTxDoneTime = 0
uint32_t AggregatedTimeOff = 0
uint8_t currentCH
uint32_t LoRaMacState = MAC_IDLE
Timer MacStateCheckTimer
uint8_t(* getBatteryLevel )()
Timer TxDelayedTimer
Timer RxWindowTimer1
Timer RxWindowTimer2
bool rxWindowActive = false
struct timeval rxWindow2At = {}
Timer TxTimeoutTimer
uint16_t ReceiveDelay1
uint16_t ReceiveDelay2
uint16_t JoinAcceptDelay1
uint16_t JoinAcceptDelay2
uint16_t rxWindow1Delay
uint16_t rxWindow2Delay
uint16_t rxWindow1Timeout
uint16_t rxWindow2Timeout
int16_t rxWindow1Offset
int16_t rxWindow2Offset
Timer AckTimeoutTimer
uint8_t AckTimeoutRetries = 1
uint8_t AckTimeoutRetriesCounter = 1
uint32_t TxTimeOnAir
struct { 
   EventInfoStatus_t   Status 
} McpsIndication
struct { 
   EventInfoStatus_t   Status 
   bool   AckReceived 
   uint32_t   UpLinkCounter 
} McpsConfirm
struct timeval tDevTimeRequested
RTCCalendar * rtc = NULL
uint8_t RxSlot = 0
bool isMcpsReq = false
bool isMcpsInd = false
bool isMacDone = false
LoRaMacFrame * txFrame = NULL
LoRaMacFrame * rxFrame = NULL
void(* joinHandler )(LoRaMac &, bool result, const uint8_t *devEui, const uint8_t *appEui, const uint8_t *appKey, const uint8_t *nwkSKey, const uint8_t *appSKey, uint32_t devAddr, const RadioPacket &frame, uint32_t airTime) = NULL
void(* receiveErrorFrameHandler )(LoRaMac &, const RadioPacket &frame) = nullptr
Protected Attributes inherited from PacketRadio
Queue< RadioPacket * > txFifo
Queue< RadioPacket * > rxFifo
Queue< RadioPacket * > txDoneFifo
void(* callbackSendDone )(PacketRadio &, RadioPacket *)
void(* callbackReceive )(PacketRadio &, const RadioPacket *)
PacketRadioEventListener * eventListener

MAC Commands

enum  MacCmd_t {
  MAC_CMD_LINK_CHECK = 0x02 , MAC_CMD_LINK_ADR = 0x03 , MAC_CMD_DUTY_CYCLE = 0x04 , MAC_CMD_RX_PARAM_SETUP = 0x05 ,
  MAC_CMD_DEV_STATUS = 0x06 , MAC_CMD_NEW_CHANNEL = 0x07 , MAC_CMD_RX_TIMING_SETUP = 0x08 , MAC_CMD_TX_PARAM_SETUP = 0x09 ,
  MAC_CMD_DL_CHANNEL = 0x0A , MAC_CMD_DEV_TIME = 0x0D
}
void(* onMACCommandReceived )(LoRaMac &mac, MacCmd_t cid, const uint8_t *reqData, int16_t reqLen, const uint8_t *ansData, int16_t ansLen) = nullptr
 MAC command 수신시 호출될 함수 포인터
void(* onMACCommandSend )(LoRaMac &mac, MacCmd_t cid, const uint8_t *data, uint8_t len) = nullptr
 MAC command 송신시 호출될 함수 포인터
virtual error_t requestLinkCheck ()
 LinkCheckReq MAC command를 요청합니다.
error_t requestLinkCheck (void(*func)(LoRaMac &))
 LinkCheckReq MAC command를 요청합니다.
void onLinkChecked (void(*func)(LoRaMac &, uint8_t demodMargin, uint8_t numGateways))
 LinkCheckReq MAC command에 대한 응답(LinkCheckAns)이 올 경우 호출될 콜백함수를 지정합니다.
error_t requestDeviceTime (RTCCalendar *rtc)
 DeviceTimeReq MAC command를 요청합니다.
error_t requestDeviceTime (RTCCalendar *rtc, void(*func)(LoRaMac &))
 DeviceTimeReq MAC command를 요청합니다.
error_t requestDeviceTime (void(*func)(LoRaMac &)=nullptr)
 DeviceTimeReq MAC command를 요청합니다.
void onDeviceTimeAnswered (void(*func)(LoRaMac &, bool success, uint32_t tSeconds, uint8_t tFracSeconds), RTCCalendar *rtc)
 DeviceTimeReq MAC command에 대한 응답(DeviceTimeAns)이 올 경우 호출될 콜백함수와 RTCCalendar 를 지정합니다.
void onLinkADRReqReceived (void(*func)(LoRaMac &, const uint8_t *))
 LinkADRReq MAC command를 수신시 호출될 콜백함수를 지정합니다.
void onLinkADRAnsSent (void(*func)(LoRaMac &, uint8_t status))
 LinkADRAns MAC command를 송신시 호출될 콜백함수를 지정합니다.
void onDutyCycleReqReceived (void(*func)(LoRaMac &, const uint8_t *))
 DutyCycleReq MAC command를 수신시 호출될 콜백함수를 지정합니다.
void onDutyCycleAnsSent (void(*func)(LoRaMac &))
 DutyCycleAns MAC command를 송신시 호출될 콜백함수를 지정합니다.
void onRxParamSetupReqReceived (void(*func)(LoRaMac &, const uint8_t *))
 RxParamSetupReq MAC command를 수신시 호출될 콜백함수를 지정합니다.
void onRxParamSetupAnsSent (void(*func)(LoRaMac &, uint8_t status))
 RxParamSetupAns MAC command를 송신시 호출될 콜백함수를 지정합니다.
void onDevStatusReqReceived (void(*func)(LoRaMac &))
 DevStatusReq MAC command를 수신시 호출될 콜백함수를 지정합니다.
void onDevStatusAnsSent (void(*func)(LoRaMac &, uint8_t bat, uint8_t margin))
 DevStatusAns MAC command를 송신시 호출될 콜백함수를 지정합니다.
void onNewChannelReqReceived (void(*func)(LoRaMac &, const uint8_t *))
 NewChannelReq MAC command를 수신시 호출될 콜백함수를 지정합니다.
void onNewChannelAnsSent (void(*func)(LoRaMac &, uint8_t status))
 NewChannelAns MAC command를 송신시 호출될 콜백함수를 지정합니다.
void onRxTimingSetupReqReceived (void(*func)(LoRaMac &, const uint8_t *))
 RxTimingSetupReq MAC command를 수신시 호출될 콜백함수를 지정합니다.
void onRxTimingSetupAnsSent (void(*func)(LoRaMac &))
 RxTimingSetupReq MAC command를 수신시 호출될 콜백함수를 지정합니다.

Detailed Description

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
ERROR_INVALID_FREQUENCY 

잘못된 주파수

ERROR_INVALID_DATARATE 

잘못된 datarate

ERROR_INVALID_FREQ_AND_DR 

잘못된 주파수와 datarate

478 {
484
490
496 };
@ ERROR_INVALID_FREQUENCY
잘못된 주파수
Definition LoRaMac.hpp:483
@ ERROR_INVALID_DATARATE
잘못된 datarate
Definition LoRaMac.hpp:489
@ ERROR_INVALID_FREQ_AND_DR
잘못된 주파수와 datarate
Definition LoRaMac.hpp:495

◆ anonymous enum

anonymous enum
protected
1845 {
1846 MAC_IDLE = 0x00000000ul,
1847 MAC_TX_RUNNING = 0x00000001ul,
1848 MAC_RX = 0x00000002ul,
1849 MAC_ACK_REQ = 0x00000004ul,
1850 MAC_ACK_RETRY = 0x00000008ul,
1851 MAC_TX_DELAYED = 0x00000010ul,
1852 MAC_TX_CONFIG = 0x00000020ul,
1853 };

◆ anonymous enum

anonymous enum
protected
1757 {
1758 ADR_ACK_LIMIT = 64,
1759 ADR_ACK_DELAY = 32,
1760 PHY_PAYLOAD_MAX_LENGTH = 255,
1761 MAC_COMMAND_MAX_LENGTH = 15,
1762 FRM_PAYLOAD_MAX_LENGTH = 242,
1763 };

◆ BatteryLevel_t

enum LoRaMac::BatteryLevel_t
352 {
353 BAT_LEVEL_EXT_SRC = 0x00,
354 BAT_LEVEL_EMPTY = 0x01,
355 BAT_LEVEL_FULL = 0xFE,
356 BAT_LEVEL_NO_MEASURE = 0xFF,
357 } BatteryLevel_t;

◆ DeviceClass_t

Enumerator
CLASS_A 

LoRaWAN Classs A.

CLASS_B 

LoRaWAN Class B (not supported currently).

CLASS_C 

LoRaWAN Class C.

255 {
259 CLASS_A = 0,
260
264 CLASS_B = 1,
265
269 CLASS_C = 2,
DeviceClass_t
Definition LoRaMac.hpp:255
@ CLASS_B
LoRaWAN Class B (not supported currently).
Definition LoRaMac.hpp:264
@ CLASS_A
LoRaWAN Classs A.
Definition LoRaMac.hpp:259
@ CLASS_C
LoRaWAN Class C.
Definition LoRaMac.hpp:269

◆ EventInfoStatus_t

enum LoRaMac::EventInfoStatus_t
protected
1765 {
1766 EVENT_INFO_STATUS_OK = 0,
1767 EVENT_INFO_STATUS_ERROR,
1768 EVENT_INFO_STATUS_TX_TIMEOUT,
1769 EVENT_INFO_STATUS_RX1_TIMEOUT,
1770 EVENT_INFO_STATUS_RX2_TIMEOUT,
1771 EVENT_INFO_STATUS_JOIN_FAIL,
1772 EVENT_INFO_STATUS_DOWNLINK_REPEATED,
1773 EVENT_INFO_STATUS_ADDRESS_FAIL,
1774 EVENT_INFO_STATUS_MIC_FAIL,
1775 EVENT_INFO_STATUS_CHANNEL_BUSY,
1776 } EventInfoStatus_t;

◆ FCntDownStatus_t

enum LoRaMac::FCntDownStatus_t
protected
1969{ NEW_FCNT_OK = 0, NEW_FCNT_DUPLICATE, NEW_FCNT_MAX_GAP_EXCEEDED };

◆ FrameType_t

enum LoRaMac::FrameType_t
protected
1746 {
1747 FRAME_TYPE_JOIN_REQ = 0x00,
1748 FRAME_TYPE_JOIN_ACCEPT = 0x01,
1749 FRAME_TYPE_DATA_UNCONFIRMED_UP = 0x02,
1750 FRAME_TYPE_DATA_UNCONFIRMED_DOWN = 0x03,
1751 FRAME_TYPE_DATA_CONFIRMED_UP = 0x04,
1752 FRAME_TYPE_DATA_CONFIRMED_DOWN = 0x05,
1753 FRAME_TYPE_RFU = 0x06,
1754 FRAME_TYPE_PROPRIETARY = 0x07,
1755 }FrameType_t;

◆ MacCmd_t

enum LoRaMac::MacCmd_t
641 { MAC_CMD_LINK_CHECK = 0x02,
642 MAC_CMD_LINK_ADR = 0x03,
643 MAC_CMD_DUTY_CYCLE = 0x04,
644 MAC_CMD_RX_PARAM_SETUP = 0x05,
645 MAC_CMD_DEV_STATUS = 0x06,
646 MAC_CMD_NEW_CHANNEL = 0x07,
647 MAC_CMD_RX_TIMING_SETUP = 0x08,
648 MAC_CMD_TX_PARAM_SETUP = 0x09,
649 MAC_CMD_DL_CHANNEL = 0x0A,
650 MAC_CMD_DEV_TIME = 0x0D } MacCmd_t;

Member Function Documentation

◆ addChannel()

virtual error_t LoRaMac::addChannel ( uint8_t id,
ChannelParams_t params )
pure virtual

Add a channel.

Adds a new channel to the channel list and activates the id in the channel mask. The frequency and DR specified in the params MUST be valid values for each regional parameters specification.

Parameters
[IN]id - Id of the channel.
[IN]params - Channel parameters to set.
Returns

Implemented in LoRaMacAS923Japan, LoRaMacCN779, LoRaMacEU433, LoRaMacEU863, LoRaMacKR920, and LoRaMacUS902.

◆ applyDlChannel()

virtual int8_t LoRaMac::applyDlChannel ( const uint8_t * payload)
inlineprotectedvirtual
1936 {
1937 return -1; /* not supported */
1938 }

◆ applyTxParamSetup()

virtual void LoRaMac::applyTxParamSetup ( uint8_t payload)
inlineprotectedvirtual
1939 {
1940 }

◆ begin()

virtual error_t LoRaMac::begin ( uint8_t(* getBatteryLevel )() = NULL)
virtual

◆ beginJoining() [1/2]

virtual error_t LoRaMac::beginJoining ( const uint8_t * devEui,
const uint8_t * appEui,
const uint8_t * appKey )
virtual

Over-the-Air Activation (OTAA) 방식의 join을 시도합니다.

Parameters
devEuiDevice EUI (MSB first)
appEuiApplication EUI (MSB first)
appKeyApplication Key
static void eventLoRaWANJoin(
bool joined,
const uint8_t *joinedDevEui,
const uint8_t *joinedAppEui,
const uint8_t *joinedAppKey,
const uint8_t *joinedNwkSKey,
const uint8_t *joinedAppSKey,
uint32_t joinedDevAddr,
const RadioPacket &frame,
uint32_t airTime
) {
#if (OVER_THE_AIR_ACTIVATION == 1)
if (joined) {
if (joinedNwkSKey && joinedAppSKey) {
// Status is OK, node has joined the network
printf("* Joined to the network!\n");
postTask(taskPeriodicSend, NULL);
} else {
printf("* PseudoAppKey joining done!\n");
}
} else {
printf("* Join failed. Retry to join\n");
LoRaWAN.beginJoining(devEui, appEui, appKey);
}
#endif
}

Join은 1회만 시도하므로, 계속 join을 시도해야 할 경우 이 함수를 다시 호출하여야 합니다.

Reimplemented in LoRaMacKR920SKT, LoRaMacUS902, and LoRaMacUS902Hybrid.

Examples
feather-m0/AMG88xx_IoT.own/main.cpp, feather-m0/LoRaWAN/main.cpp, feather-m0/TFMini-I2C/main.cpp, feather-m0/UltimateGPS+OLED/main.cpp, plm100s/IPv6overLoRaWAN/main.cpp, plm100s/PLS100W_AM1005-P-485/main.cpp, plm100s/PLS100W_HRXL-MaxSonar-WR/main.cpp, plm100s/PLS100W_SSD1306-I2C/main.cpp, plm100s/PLS100W_T9602-I2C/main.cpp, plm100s/PLS100W_TFmini-UART/main.cpp, and plm100s/veml6030/main.cpp.

◆ beginJoining() [2/2]

error_t LoRaMac::beginJoining ( const uint8_t * devEui,
const uint8_t * appKey )
inline
580 {
581 return beginJoining(devEui, (const uint8_t *) "\x00\x00\x00\x00\x00\x00\x00\x00", appKey);
582 }
virtual error_t beginJoining(const uint8_t *devEui, const uint8_t *appEui, const uint8_t *appKey)
Over-the-Air Activation (OTAA) 방식의 join을 시도합니다.

◆ cancelSend()

error_t LoRaMac::cancelSend ( LoRaMacFrame * frame)

frame 전송을 취소합니다.

취소가 된 프레임은 onSendDone() 에 설정된 콜백함수에 의해 RadioPacket::CANCELED 결과로 호출됩니다.

Parameters
frame취소할 프레임
Returns

◆ channelSupportsDR()

virtual bool LoRaMac::channelSupportsDR ( const ChannelParams_t & channel,
uint8_t dr ) const
protectedvirtual

Checks whether a channel's DRRange includes the given datarate. Override to interpret region-specific non-contiguous ranges. Radio capability and datarate validity are checked separately.

Reimplemented in LoRaMacKR920.

◆ checkTxFrame()

bool LoRaMac::checkTxFrame ( RadioPacket * frame)
protectedvirtual

Implements PacketRadio.

◆ ComputeMic()

void LoRaMac::ComputeMic ( const uint8_t * buffer,
uint16_t size,
const uint8_t * key,
uint32_t address,
uint8_t dir,
uint32_t sequenceCounter,
uint32_t * mic )
static

Computes the LoRaMAC frame MIC field

Parameters
[IN]buffer - Data buffer
[IN]size - Data buffer size
[IN]key - AES key to be used
[IN]address - Frame address
[IN]dir - Frame direction [0: uplink, 1: downlink]
[IN]sequenceCounter - Frame sequence counter
[OUT]mic - Computed MIC field

◆ getAppEui()

std::array< uint8_t, 8 > LoRaMac::getAppEui ( )

Application EUI를 가져옵니다.

Byte order는 MSB first 입니다.

auto appEui = LoRaWAN.getAppEui();
for (uint8_t x : appEui) {
printf("%02X ", x);
}
printf("\n");

◆ getAppKey()

std::array< uint8_t, 16 > LoRaMac::getAppKey ( )

AppKey를 가져옵니다.

auto appKey = LoRaWAN.getAppKey();
for (uint8_t x : appKey) {
printf("%02X ", x);
}
printf("\n");

◆ getAppSKey()

std::array< uint8_t, 16 > LoRaMac::getAppSKey ( )

AppSKey를 가져옵니다.

auto appSKey = LoRaWAN.getAppSKey();
for (uint8_t x : appSKey) {
printf("%02X ", x);
}
printf("\n");

◆ getChannel()

virtual const ChannelParams_t * LoRaMac::getChannel ( uint8_t index)
pure virtual

채널 정보를 가져옵니다.

Parameters
index채널 번호 (0 ~ MaxNumChannels)
Returns
  • Non-NULL: 유효한 채널 정보
  • NULL: 유효하지 않은 index, 또는 비활성화된 채널

    다음 예제와 같이 현재 설정된 채널 정보들을 출력할 수 있습니다.

static void printChannelInformation(LoRaMac &lw) {
for (uint8_t i = 0; i < lw.MaxNumChannels; i++) {
if (p) {
printf(" - [%u] Frequency:%lu Hz\n", i, p->Frequency);
} else {
printf(" - [%u] disabled\n", i);
}
}
printf(" - Default DR%u:", lw.getCurrentDatarateIndex());
if (dr->mod == Radio::MOD_LORA) {
printf("LoRa(SF%u BW:", dr->param.LoRa.sf);
switch (dr->param.LoRa.bw) {
case Radio::BW_125kHz: printf("125kHz\n"); break;
case Radio::BW_250kHz: printf("250kHz\n"); break;
case Radio::BW_500kHz: printf("500kHz\n"); break;
default: printf("(unexpected:%u)\n", dr->param.LoRa.bw); break;
}
} else if (dr->mod == Radio::MOD_FSK) {
printf("FSK\n");
} else {
printf("Unknown modulation\n");
}
printf(" - Default Tx index: %d\n", lw.getCurrentTxPowerIndex());
printf(
" - # of repetitions of unconfirmed uplink frames: %u\n",
);
}

Implemented in LoRaMacAS923Japan, LoRaMacCN779, LoRaMacEU433, LoRaMacEU863, LoRaMacKR920, and LoRaMacUS902.

Examples
nordic-nrf52-dk/LoRaWAN-Class-A/main.cpp, plm100s/IPv6overLoRaWAN/main.cpp, plm100s/LoRaWAN-Class-A/main.cpp, plm100s/veml6030/main.cpp, plm150/LoRaWAN-Class-A/main.cpp, st-nucleo-f429zi/LoRaWAN/main.cpp, and st-nucleo-l152re/LoRaWAN-Class-A/main.cpp.

◆ getCurrentDatarateIndex()

uint8_t LoRaMac::getCurrentDatarateIndex ( )

현재 설정된 기본 datarate 인덱스를 가져옵니다.

LoRaMacFrame 에서 별도로 파라미터를 지정하지 않은 경우 이 기본 datarate를 사용합니다. ADR을 사용하도록 설정되어 있으면 이 값은 네트워크 서버에 의해 변경됩니다. 여기서 반환된 datarate 인덱스를 getDatarate() 에 입력하여 자세한 정보를 가져올 수 있습니다.

Examples
nordic-nrf52-dk/LoRaWAN-Class-A/main.cpp, plm100s/IPv6overLoRaWAN/main.cpp, plm100s/LoRaWAN-Class-A/main.cpp, plm100s/veml6030/main.cpp, plm150/LoRaWAN-Class-A/main.cpp, st-nucleo-f429zi/LoRaWAN/main.cpp, and st-nucleo-l152re/LoRaWAN-Class-A/main.cpp.

◆ getCurrentTxPowerIndex()

uint8_t LoRaMac::getCurrentTxPowerIndex ( )

기본 Tx power index를 가져옵니다.

LoRaMacFrame 에서 별도로 파라미터를 지정하지 않은 경우 이 기본 Tx power를 사용합니다. ADR을 사용하도록 설정되어 있으면 이 값은 네트워크 서버에 의해 변경됩니다.

Returns
Tx power index
Examples
nordic-nrf52-dk/LoRaWAN-Class-A/main.cpp, plm100s/IPv6overLoRaWAN/main.cpp, plm100s/LoRaWAN-Class-A/main.cpp, plm100s/veml6030/main.cpp, plm150/LoRaWAN-Class-A/main.cpp, st-nucleo-f429zi/LoRaWAN/main.cpp, and st-nucleo-l152re/LoRaWAN-Class-A/main.cpp.

◆ getDatarate()

const DatarateParams_t * LoRaMac::getDatarate ( uint8_t index) const

Datarate 정보를 가져옵니다.

Parameters
indexDatarate index
Returns
  • Non nullptr : 유효한 datarate 정보
  • nullptr : 상한 밖의 index, RFU 또는 칩이 지원하지 않는 datarate

    다음 예제와 같이 getCurrentDatarateIndex() 와 조합하여 현재의 기본 datarate 정보를 가져올 수 있습니다.

static void printChannelInformation(LoRaMac &lw) {
for (uint8_t i = 0; i < lw.MaxNumChannels; i++) {
if (p) {
printf(" - [%u] Frequency:%lu Hz\n", i, p->Frequency);
} else {
printf(" - [%u] disabled\n", i);
}
}
printf(" - Default DR%u:", lw.getCurrentDatarateIndex());
if (dr->mod == Radio::MOD_LORA) {
printf("LoRa(SF%u BW:", dr->param.LoRa.sf);
switch (dr->param.LoRa.bw) {
case Radio::BW_125kHz: printf("125kHz\n"); break;
case Radio::BW_250kHz: printf("250kHz\n"); break;
case Radio::BW_500kHz: printf("500kHz\n"); break;
default: printf("(unexpected:%u)\n", dr->param.LoRa.bw); break;
}
} else if (dr->mod == Radio::MOD_FSK) {
printf("FSK\n");
} else {
printf("Unknown modulation\n");
}
printf(" - Default Tx index: %d\n", lw.getCurrentTxPowerIndex());
printf(
" - # of repetitions of unconfirmed uplink frames: %u\n",
);
}
Examples
nordic-nrf52-dk/LoRaWAN-Class-A/main.cpp, plm100s/IPv6overLoRaWAN/main.cpp, plm100s/LoRaWAN-Class-A/main.cpp, plm100s/veml6030/main.cpp, plm150/LoRaWAN-Class-A/main.cpp, st-nucleo-f429zi/LoRaWAN/main.cpp, and st-nucleo-l152re/LoRaWAN-Class-A/main.cpp.

◆ getDevEui()

std::array< uint8_t, 8 > LoRaMac::getDevEui ( )

Device EUI를 가져옵니다.

Byte order는 MSB first 입니다.

auto devEui = LoRaWAN.getDevEui();
for (uint8_t x : devEui) {
printf("%02X ", x);
}
printf("\n");

◆ getDeviceClass()

DeviceClass_t LoRaMac::getDeviceClass ( )

Device class를 가져옵니다.

Returns
Device class
Examples
st-nucleo-f429zi/LoRaWAN/main.cpp, and st-nucleo-l152re/LoRaWAN-Class-A/main.cpp.

◆ getDownLinkCounter()

uint32_t LoRaMac::getDownLinkCounter ( )

Downlink용 frame counter (fCntDown) 를 가져옵니다.

이 값은 마지막으로 수신한 downlink 프레임에서 사용된 값입니다.

◆ getMaxPayload()

virtual uint8_t LoRaMac::getMaxPayload ( uint8_t dr,
bool repeater = false )
pure virtual

최대 application payload 길이(N)를 가져옵니다.

Parameters
drDR index
repeaterRepeater mode 사용 여부
Returns
  • 0이 아닌 값: 최대 application payload 길이
  • 0: 잘못된 DR

최대 application payload 길이(N)는 최대 payload 길이(M)에서 FOpt 길이를 뺀 값입니다. FOpt의 길이는 최소 8-byte 이며 더 커질 수도 있습니다.

Implemented in LoRaMacAS923Japan, LoRaMacCN779, LoRaMacEU433, LoRaMacEU863, LoRaMacKR920, LoRaMacKR920SKT, and LoRaMacUS902.

◆ getNetworkID()

int32_t LoRaMac::getNetworkID ( )

Network ID를 가져옵니다.

Returns
  • 0 이상의 값: 유효한 network ID
  • 0 보다 작은 값: 유효하지 않은 network ID (아직 join되지 않은 상태)

◆ getNwkSKey()

std::array< uint8_t, 16 > LoRaMac::getNwkSKey ( )

NwkSKey를 가져옵니다.

auto nwkSKey = LoRaWAN.getNwkSKey();
for (uint8_t x : nwkSKey) {
printf("%02X ", x);
}
printf("\n");

◆ getPendingMacCommandsLength()

uint8_t LoRaMac::getPendingMacCommandsLength ( )

현재 송신 대기 중인 MAC commands의 길이를 가져옵니다.

송신 대기 중인 MAC commands의 길이에 따라 현재 전송 가능한 최대 MAC payload 길이가 달라질 수 있습니다.

예를 들어, DR0에서 현재 전송 가능한 payload 길이를 구하기 위해서는 다음과 같이 할 수 있습니다.

uint8_t length = LoRaWAN.getMaxPayload(0) - LoRaWAN.getPendingMacCommandsLength();

만약, Link Check 등 MAC commands가 pending 되었다면, 이 메서드는 0보다 큰 값을 반환합니다.

LoRaWAN.requestLinkCheck();
LoRaWAN.requestDeviceTime();
printf(
"* Max payload length: %u - %u = %u\n",
LoRaWAN.getMaxPayload(0),
LoRaWAN.getPendingMacCommandsLength(),
LoRaWAN.getMaxPayload(0) - LoRaWAN.getPendingMacCommandsLength()
);

위와 같이 Link Check Request 와 Device Time Request MAC commands가 송신 대기되면, 이 메서드는 2를 반환합니다. 위 예제에서 LoRaWAN 인스턴스가 LoRaMacKR920 이면, 다음과 같이 출력될 것입니다.

Max payload length: 51 - 2 = 49

◆ getRx1Datarate()

virtual uint8_t LoRaMac::getRx1Datarate ( )
inlinevirtual

Rx1에 사용될, DR offset이 적용된 DR을 가져옵니다.

일반적으로 Rx1의 DR은 uplink의 DR에서 DR offset이 감소한 값을 사용되나, 대역별로 달라질 수 있습니다.

Reimplemented in LoRaMacAS923Japan, LoRaMacKR920, and LoRaMacUS902.

1296 {
1297 int8_t dr = this->ChannelsDatarate - this->Rx1DrOffset;
1298 if (dr < 0) {
1299 return 0;
1300 } else {
1301 return (uint8_t) dr;
1302 }
1303 }

◆ getRx1DrOffset()

uint8_t LoRaMac::getRx1DrOffset ( )
inline

◆ getRx1Frequency()

virtual uint32_t LoRaMac::getRx1Frequency ( )
pure virtual

Rx1에서 사용할 주파수를 가져옵니다.

Implemented in LoRaMacAS923Japan, LoRaMacCN779, LoRaMacEU433, LoRaMacEU863, LoRaMacKR920, and LoRaMacUS902.

◆ getRx2Datarate()

uint8_t LoRaMac::getRx2Datarate ( )
inline

◆ getRx2Frequency()

uint32_t LoRaMac::getRx2Frequency ( )
inline

◆ getUpLinkCounter()

uint32_t LoRaMac::getUpLinkCounter ( )

Uplink용 frame counter (fCntUp) 를 가져옵니다.

이 값은 다음 uplink 프레임 전송 시 사용될 값입니다.

◆ handleRxFrame()

void LoRaMac::handleRxFrame ( RadioPacket * frame)
protectedvirtual

Implements PacketRadio.

◆ isJoining()

bool LoRaMac::isJoining ( )
inline

현재 OTAA Join 중인지 확인합니다.

Returns
Join 중이면 true, 그렇지 않으면 false
589 {
590 return this->joining;
591 }

◆ JoinComputeMic()

void LoRaMac::JoinComputeMic ( const uint8_t * buffer,
uint16_t size,
const uint8_t * key,
uint32_t * mic )
static

Computes the LoRaMAC Join Request frame MIC field

Parameters
[IN]buffer - Data buffer
[IN]size - Data buffer size
[IN]key - AES key to be used
[OUT]mic - Computed MIC field

◆ JoinComputeSKeys()

void LoRaMac::JoinComputeSKeys ( const uint8_t * key,
const uint8_t * appNonce,
uint16_t devNonce,
uint8_t * nwkSKey,
uint8_t * appSKey )
static

Computes the LoRaMAC join frame decryption

Parameters
[IN]key - AES key to be used
[IN]appNonce - Application nonce
[IN]devNonce - Device nonce
[OUT]nwkSKey - Network session key
[OUT]appSKey - Application session key

◆ JoinDecrypt()

void LoRaMac::JoinDecrypt ( const uint8_t * buffer,
uint16_t size,
const uint8_t * key,
uint8_t * decBuffer )
static

Computes the LoRaMAC join frame decryption

Parameters
[IN]buffer - Data buffer
[IN]size - Data buffer size
[IN]key - AES key to be used
[OUT]decBuffer - Decrypted buffer

◆ linkMulticastChannel()

error_t LoRaMac::linkMulticastChannel ( MulticastParams_t * channelParam)

LoRaMAC multicast channel link service.

Links a multicast channel into the linked list.

Parameters
[IN]channelParam - Multicast channel parameters to link.
Returns

◆ onDeviceTimeAnswered()

void LoRaMac::onDeviceTimeAnswered ( void(* func )(LoRaMac &, bool success, uint32_t tSeconds, uint8_t tFracSeconds),
RTCCalendar * rtc )

DeviceTimeReq MAC command에 대한 응답(DeviceTimeAns)이 올 경우 호출될 콜백함수와 RTCCalendar 를 지정합니다.

Parameters
func콜백함수 포인터
rtc시간이 조정될 RTCCalendar 의 포인터

rtc 가 지정이 되면 해당 시계의 시간이 조정됩니다. 콜백함수는 그 이후에 호출됩니다.

Deprecated
LoRaMac::onMACCommandReceived 를 대신 사용하십시오.
Note
자세한 내용은 LoRaWAN L2 Specification 1.0.4의 5.9 End-Device Time Commands (DeviceTimeReq, DeviceTimeAns) 를 참고하십시오.

◆ onDevStatusAnsSent()

void LoRaMac::onDevStatusAnsSent ( void(* func )(LoRaMac &, uint8_t bat, uint8_t margin))

DevStatusAns MAC command를 송신시 호출될 콜백함수를 지정합니다.

다음과 같이 콜백함수에서 응답한 bat 와 margin 을 확인할 수 있습니다.

static void eventLoRaWANDevStatusAnsSent(LoRaMac &lw, uint8_t bat, uint8_t margin) {
printf("* LoRaWAN DevStatusAns sent. (");
if (bat == 0) {
printf("Powered by external power source. ");
} else if (bat == 255) {
printf("Battery level cannot be measured. ");
} else {
printf("Battery: %lu %%. ", map(bat, 1, 254, 0, 100));
}
if (bitRead(margin, 5) == 1) {
margin |= bit(7) | bit(6);
}
printf(" SNR: %d)\n", (int8_t) margin);
}
Note
자세한 내용은 LoRaWAN Specification 1.0.2의 5.5 End-Device Status 를 참고하십시오.
Deprecated
LoRaMac::onMACCommandSend 를 대신 사용하십시오.
Examples
nordic-nrf52-dk/LoRaWAN-Class-A/main.cpp, plm100s/veml6030/main.cpp, st-nucleo-f429zi/LoRaWAN/main.cpp, and st-nucleo-l152re/LoRaWAN-Class-A/main.cpp.

◆ onDevStatusReqReceived()

void LoRaMac::onDevStatusReqReceived ( void(* func )(LoRaMac &))

DevStatusReq MAC command를 수신시 호출될 콜백함수를 지정합니다.

MAC command 처리에 대한 결과를 원한다면 LoRaMac::onMACCommandReceived 를 사용하시기 바랍니다.

Note
자세한 내용은 LoRaWAN L2 Specification 1.0.4의 5.5 End-Device Status (DevStatusReq, DevStatusAns) 를 참고하십시오.
Deprecated
LoRaMac::onMACCommandReceived 를 대신 사용하십시오.
Examples
nordic-nrf52-dk/LoRaWAN-Class-A/main.cpp, plm100s/veml6030/main.cpp, st-nucleo-f429zi/LoRaWAN/main.cpp, and st-nucleo-l152re/LoRaWAN-Class-A/main.cpp.

◆ onDutyCycleAnsSent()

void LoRaMac::onDutyCycleAnsSent ( void(* func )(LoRaMac &))

DutyCycleAns MAC command를 송신시 호출될 콜백함수를 지정합니다.

Note
자세한 내용은 LoRaWAN L2 Specification 1.0.4의 5.3 End-Device Transmit Duty Cycle (DutyCycleReq, DutyCycleAns) 을 참고하십시오.
Deprecated
LoRaMac::onMACCommandSend 를 대신 사용하십시오.
Examples
nordic-nrf52-dk/LoRaWAN-Class-A/main.cpp, plm100s/veml6030/main.cpp, st-nucleo-f429zi/LoRaWAN/main.cpp, and st-nucleo-l152re/LoRaWAN-Class-A/main.cpp.

◆ onDutyCycleReqReceived()

void LoRaMac::onDutyCycleReqReceived ( void(* func )(LoRaMac &, const uint8_t *))

DutyCycleReq MAC command를 수신시 호출될 콜백함수를 지정합니다.

콜백함수는 MAC command 처리 후, 호출됩니다.

MAC command 처리에 대한 결과를 원한다면 LoRaMac::onMACCommandReceived 를 사용하시기 바랍니다.

Note
자세한 내용은 LoRaWAN L2 Specification 1.0.4의 5.3 End-Device Transmit Duty Cycle (DutyCycleReq, DutyCycleAns) 을 참고하십시오.
Deprecated
LoRaMac::onMACCommandReceived 를 대신 사용하십시오.
Examples
nordic-nrf52-dk/LoRaWAN-Class-A/main.cpp, plm100s/veml6030/main.cpp, st-nucleo-f429zi/LoRaWAN/main.cpp, and st-nucleo-l152re/LoRaWAN-Class-A/main.cpp.

◆ onJoin()

void LoRaMac::onJoin ( void(* func )(LoRaMac &mac, bool result, const uint8_t *devEui, const uint8_t *appEui, const uint8_t *appKey, const uint8_t *nwkSKey, const uint8_t *appSKey, uint32_t devAddr, const RadioPacket &frame, uint32_t airTime))

Join이 완료되었을 때 호출될 콜백함수를 지정합니다.

Parameters
func콜백함수 포인터
  • mac : LoRaWAN MAC 인스턴스의 참조자
  • result : Join 결과 (true: 성공, false: 실패)
  • devEui : Join 에 사용한 DevEUI (MSB first)
  • appEui : Join 에 사용한 AppEUI (MSB first)
  • appKey : Join 에 사용한 AppKey
  • nwkSKey : Join으로 생성된 network session key
  • appSKey : Join으로 생성된 application session key
  • devAddr : Join으로 생성된 device address
  • frame : JoinAccept 프레임의 raw를 확인하기 위한 프레임 참조자
  • airTime : JoinRequest 프레임 전송에 사용된 점유 시간. (단위: 마이크로초) LoRaWAN v1.1의 7. Retransmissions back-off 구현에 사용될 수 있습니다.
Examples
nordic-nrf52-dk/LoRaWAN-Class-A/main.cpp, plm100s/IPv6overLoRaWAN/main.cpp, plm100s/PLS100W_AM1005-P-485/main.cpp, plm100s/PLS100W_HRXL-MaxSonar-WR/main.cpp, plm100s/PLS100W_SSD1306-I2C/main.cpp, plm100s/PLS100W_T9602-I2C/main.cpp, plm100s/PLS100W_TFmini-UART/main.cpp, plm100s/veml6030/main.cpp, st-nucleo-f429zi/LoRaWAN/main.cpp, and st-nucleo-l152re/LoRaWAN-Class-A/main.cpp.

◆ onJoinRequested()

void LoRaMac::onJoinRequested ( void(* func )(LoRaMac &, uint32_t frequencyHz, const DatarateParams_t &))

JoinRequest 메시지를 보낼 때 호출될 콜백함수를 지정합니다.

Parameters
func콜백함수 포인터

setup() 등에서 초기화 시 다음과 같이 설정합니다.

LoRaWAN.onJoinRequested(eventLoRaWANJoinRequested);

설정한 콜백함수가 호출되면 다음과 같이 사용할 수 있습니다.

static void eventLoRaWANJoinRequested(LoRaMac &, uint32_t frequencyHz, const LoRaMac::DatarateParams_t &dr) {
printf("* JoinRequested(Frequency: %lu Hz, Modulation: ", frequencyHz);
if (dr.mod == Radio::MOD_FSK) {
printf("FSK\n");
} else if (dr.mod == Radio::MOD_LORA) {
const char *strLoRaBW[] = { "UNKNOWN", "125kHz", "250kHz", "500kHz" };
printf("LoRa, SF:%u, BW:%s\n", dr.param.LoRa.sf, strLoRaBW[dr.param.LoRa.bw]);
}
}
Examples
nordic-nrf52-dk/LoRaWAN-Class-A/main.cpp, plm100s/IPv6overLoRaWAN/main.cpp, plm100s/veml6030/main.cpp, st-nucleo-f429zi/LoRaWAN/main.cpp, and st-nucleo-l152re/LoRaWAN-Class-A/main.cpp.

◆ onLinkADRAnsSent()

void LoRaMac::onLinkADRAnsSent ( void(* func )(LoRaMac &, uint8_t status))

LinkADRAns MAC command를 송신시 호출될 콜백함수를 지정합니다.

Note
자세한 내용은 LoRaWAN L2 Specification 1.0.4의 5.2 Link ADR commands (LinkADRReq, LinkADRAns) 를 참고하십시오.
Deprecated
LoRaMac::onMACCommandSend 를 대신 사용하십시오.
Examples
nordic-nrf52-dk/LoRaWAN-Class-A/main.cpp, plm100s/veml6030/main.cpp, st-nucleo-f429zi/LoRaWAN/main.cpp, and st-nucleo-l152re/LoRaWAN-Class-A/main.cpp.

◆ onLinkADRReqReceived()

void LoRaMac::onLinkADRReqReceived ( void(* func )(LoRaMac &, const uint8_t *))

LinkADRReq MAC command를 수신시 호출될 콜백함수를 지정합니다.

콜백함수는 MAC command 처리 후, 호출됩니다.

MAC command 처리에 대한 결과를 원한다면 LoRaMac::onMACCommandReceived 를 사용하시기 바랍니다.

Deprecated
LoRaMac::onMACCommandReceived 를 대신 사용하십시오.
Note
자세한 내용은 LoRaWAN L2 Specification 1.0.4의 5.2 Link ADR commands (LinkADRReq, LinkADRAns) 를 참고하십시오.
Examples
nordic-nrf52-dk/LoRaWAN-Class-A/main.cpp, plm100s/veml6030/main.cpp, st-nucleo-f429zi/LoRaWAN/main.cpp, and st-nucleo-l152re/LoRaWAN-Class-A/main.cpp.

◆ onLinkChecked()

void LoRaMac::onLinkChecked ( void(* func )(LoRaMac &, uint8_t demodMargin, uint8_t numGateways))

LinkCheckReq MAC command에 대한 응답(LinkCheckAns)이 올 경우 호출될 콜백함수를 지정합니다.

콜백함수는 MAC command 처리 후, 호출됩니다.

Deprecated
LoRaMac::onMACCommandReceived 를 대신 사용하십시오.
Note
자세한 내용은 LoRaWAN L2 Specification 1.0.4의 5.1 Link Check commands 를 참고하십시오.

◆ onNewChannelAnsSent()

void LoRaMac::onNewChannelAnsSent ( void(* func )(LoRaMac &, uint8_t status))

NewChannelAns MAC command를 송신시 호출될 콜백함수를 지정합니다.

다음과 같이 콜백함수에서 응답한 status 와 함께 getChannel() 등을 사용하여 현재 활성화된 채널 정보를 확인할 수 있습니다.

static void eventLoRaWANNewChannelAnsSent(LoRaMac &lw, uint8_t status) {
printf("* LoRaWAN NewChannelAns sent with (Datarate range %s and channel frequency %s).\n", (bitRead(status, 1) == 1) ? "OK" : "NOT OK", (bitRead(status, 0) == 1) ? "OK" : "NOT OK");
for (uint8_t i = 0; i < lw.MaxNumChannels; i++) {
if (p) {
printf(" - [%u] Frequency:%lu Hz\n", i, p->Frequency);
} else {
printf(" - [%u] disabled\n", i);
}
}
}
Note
자세한 내용은 LoRaWAN Specification 1.0.2의 5.6 Creation / Modification of a Channel 을 참고하십시오.
Deprecated
LoRaMac::onMACCommandSend 를 대신 사용하십시오.
Examples
nordic-nrf52-dk/LoRaWAN-Class-A/main.cpp, plm100s/veml6030/main.cpp, st-nucleo-f429zi/LoRaWAN/main.cpp, and st-nucleo-l152re/LoRaWAN-Class-A/main.cpp.

◆ onNewChannelReqReceived()

void LoRaMac::onNewChannelReqReceived ( void(* func )(LoRaMac &, const uint8_t *))

NewChannelReq MAC command를 수신시 호출될 콜백함수를 지정합니다.

콜백함수는 MAC command 처리 후, 호출됩니다.

MAC command 처리에 대한 결과를 원한다면 LoRaMac::onMACCommandReceived 를 사용하시기 바랍니다.

Note
자세한 내용은 LoRaWAN L2 Specification 1.0.4의 5.6 Creation / Modification of a Channel (NewChannelReq, NewChannelAns, DlChannelReq, DlChannelAns) 를 참고하십시오.
Deprecated
LoRaMac::onMACCommandReceived 를 대신 사용하십시오.
Examples
nordic-nrf52-dk/LoRaWAN-Class-A/main.cpp, plm100s/veml6030/main.cpp, st-nucleo-f429zi/LoRaWAN/main.cpp, and st-nucleo-l152re/LoRaWAN-Class-A/main.cpp.

◆ onReceive()

void LoRaMac::onReceive ( void(* receiveHandler )(LoRaMac &radio, const LoRaMacFrame *frame))

수신이 완료될 때 호출될 함수를 지정합니다.

Parameters
sendDoneHandler콜백 함수 포인터

setup() 등에서 초기화 시 다음과 같이 설정합니다.

LoRaWAN.onReceive(eventLoRaWANReceive);

설정한 콜백함수가 호출되면 다음과 같이 사용할 수 있습니다.

static void eventLoRaWANReceive(LoRaMac &lw, const LoRaMacFrame *frame) {
printf("* Received:");
for (uint8_t i = 0; i < frame->len; i++) {
printf(" %02X", frame->buf[i]);
}
printf(" (");
frame->printTo(Serial);
printf(")\n");
if (
) {
// If there is no pending send frames, send an empty frame to ack or pull more frames.
LoRaMacFrame *emptyFrame = new LoRaMacFrame(0);
if (emptyFrame) {
error_t err = LoRaWAN.send(emptyFrame);
if (err != ERROR_SUCCESS) {
delete emptyFrame;
}
}
}
}
Examples
nordic-nrf52-dk/LoRaWAN-Class-A/main.cpp, plm100s/PLS100W_AM1005-P-485/main.cpp, plm100s/PLS100W_HRXL-MaxSonar-WR/main.cpp, plm100s/PLS100W_SSD1306-I2C/main.cpp, plm100s/PLS100W_T9602-I2C/main.cpp, plm100s/PLS100W_TFmini-UART/main.cpp, plm100s/veml6030/main.cpp, st-nucleo-f429zi/LoRaWAN/main.cpp, and st-nucleo-l152re/LoRaWAN-Class-A/main.cpp.

◆ onReceiveErrorFrame()

void LoRaMac::onReceiveErrorFrame ( void(* receiveHandler )(LoRaMac &radio, const RadioPacket &frame))
inline

비정상 프레임 수신시 호출될 함수를 지정합니다.

DevAddr 또는 MIC가 달라, 정상적으로 복호화할 수 없는 프레임 수신시 호출될 함수를 지정합니다.

1550 {
1551 this->receiveErrorFrameHandler = receiveHandler;
1552 }

◆ onRxParamSetupAnsSent()

void LoRaMac::onRxParamSetupAnsSent ( void(* func )(LoRaMac &, uint8_t status))

RxParamSetupAns MAC command를 송신시 호출될 콜백함수를 지정합니다.

Note
자세한 내용은 LoRaWAN L2 Specification 1.0.4의 5.4 Receive Windows Parameters (RXParamSetupReq, RXParamSetupAns) 를 참고하십시오.
Deprecated
LoRaMac::onMACCommandSend 를 대신 사용하십시오.
Examples
nordic-nrf52-dk/LoRaWAN-Class-A/main.cpp, plm100s/veml6030/main.cpp, st-nucleo-f429zi/LoRaWAN/main.cpp, and st-nucleo-l152re/LoRaWAN-Class-A/main.cpp.

◆ onRxParamSetupReqReceived()

void LoRaMac::onRxParamSetupReqReceived ( void(* func )(LoRaMac &, const uint8_t *))

RxParamSetupReq MAC command를 수신시 호출될 콜백함수를 지정합니다.

MAC command 처리에 대한 결과를 원한다면 LoRaMac::onMACCommandReceived 를 사용하시기 바랍니다.

Note
자세한 내용은 LoRaWAN L2 Specification 1.0.4의 5.4 Receive Windows Parameters (RXParamSetupReq, RXParamSetupAns) 를 참고하십시오.
Deprecated
LoRaMac::onMACCommandReceived 를 대신 사용하십시오.
Examples
nordic-nrf52-dk/LoRaWAN-Class-A/main.cpp, plm100s/veml6030/main.cpp, st-nucleo-f429zi/LoRaWAN/main.cpp, and st-nucleo-l152re/LoRaWAN-Class-A/main.cpp.

◆ onRxTimingSetupAnsSent()

void LoRaMac::onRxTimingSetupAnsSent ( void(* func )(LoRaMac &))

RxTimingSetupReq MAC command를 수신시 호출될 콜백함수를 지정합니다.

다음과 같이 콜백함수에서 getRx1Delay(), getRx2Delay() 등을 사용하여 Rx windows의 시작 시간을 확인할 수 있습니다.

static void eventLoRaWANRxTimingSetupAnsSent(LoRaMac &lw) {
printf("* LoRaWAN RxTimingSetupAns sent. Current Rx1 delay is %u msec, and Rx2 delay is %u msec.\n", lw.getRx1Delay(), lw.getRx2Delay());
}
Note
자세한 내용은 LoRaWAN Specification 1.0.2의 5.7 Setting delay between Tx and Rx 를 참고하십시오.
Deprecated
LoRaMac::onMACCommandSend 를 대신 사용하십시오.
Examples
nordic-nrf52-dk/LoRaWAN-Class-A/main.cpp, plm100s/veml6030/main.cpp, st-nucleo-f429zi/LoRaWAN/main.cpp, and st-nucleo-l152re/LoRaWAN-Class-A/main.cpp.

◆ onRxTimingSetupReqReceived()

void LoRaMac::onRxTimingSetupReqReceived ( void(* func )(LoRaMac &, const uint8_t *))

RxTimingSetupReq MAC command를 수신시 호출될 콜백함수를 지정합니다.

콜백함수는 MAC command 처리 후, 호출됩니다.

MAC command 처리에 대한 결과를 원한다면 LoRaMac::onMACCommandReceived 를 사용하시기 바랍니다.

Note
자세한 내용은 LoRaWAN L2 Specification 1.0.4의 5.7 Setting Delay between TX and RX (RXTimingSetupReq, RXTimingSetupAns) 를 참고하십시오.
Deprecated
LoRaMac::onMACCommandReceived 를 대신 사용하십시오.
Examples
nordic-nrf52-dk/LoRaWAN-Class-A/main.cpp, plm100s/veml6030/main.cpp, st-nucleo-f429zi/LoRaWAN/main.cpp, and st-nucleo-l152re/LoRaWAN-Class-A/main.cpp.

◆ onSendDone()

void LoRaMac::onSendDone ( void(* sendDoneHandler )(LoRaMac &, LoRaMacFrame *))

전송이 완료될 때 호출될 함수를 지정합니다.

Parameters
sendDoneHandler콜백 함수 포인터

전송 완료는 Tx 및 필요한 Rx1, Rx2 완료까지를 의미합니다.

setup() 등에서 초기화 시 다음과 같이 설정합니다.

LoRaWAN.onSendDone(eventLoRaWANSendDone);

설정한 콜백함수가 호출되면 다음과 같이 사용할 수 있습니다.

static void eventLoRaWANSendDone(LoRaMac &, LoRaMacFrame *frame) {
printf("* Send done(%d): [%p] destined for port[%u], Freq:%lu Hz, Power:%d dBm, # of Tx:%u, ", frame->result, frame, frame->port, frame->freq, frame->power, frame->numTrials);
if (frame->modulation == Radio::MOD_LORA) {
const char *strBW[] = { "Unknown", "125kHz", "250kHz", "500kHz", "Unexpected value" };
if (frame->meta.LoRa.bw > 3) {
frame->meta.LoRa.bw = (Radio::LoRaBW_t) 4;
}
printf("LoRa, SF:%u, BW:%s, ", frame->meta.LoRa.sf, strBW[frame->meta.LoRa.bw]);
} else if (frame->modulation == Radio::MOD_FSK) {
printf("FSK, ");
} else {
printf("Unkndown modulation, ");
}
printf("UNCONFIRMED");
} else if (frame->type == LoRaMacFrame::CONFIRMED) {
printf("CONFIRMED");
} else if (frame->type == LoRaMacFrame::MULTICAST) {
printf("MULTICAST (error)");
} else if (frame->type == LoRaMacFrame::PROPRIETARY) {
printf("PROPRIETARY");
} else {
printf("unknown type");
}
printf(" frame\n");
delete frame;
timerSend.startOneShot(10000);
}
Examples
nordic-nrf52-dk/LoRaWAN-Class-A/main.cpp, plm100s/PLS100W_AM1005-P-485/main.cpp, plm100s/PLS100W_HRXL-MaxSonar-WR/main.cpp, plm100s/PLS100W_SSD1306-I2C/main.cpp, plm100s/PLS100W_T9602-I2C/main.cpp, plm100s/PLS100W_TFmini-UART/main.cpp, plm100s/veml6030/main.cpp, st-nucleo-f429zi/LoRaWAN/main.cpp, and st-nucleo-l152re/LoRaWAN-Class-A/main.cpp.

◆ parseDevTimeAns()

virtual uint8_t LoRaMac::parseDevTimeAns ( const uint8_t * payload,
uint8_t len,
struct timeval * t )
inlineprotectedvirtual

DevTimeAns에 대한 parser.

Parameters
[IN]payload DevTimeAns의 payload 부분
[IN]len 남은 MAC command 버퍼 길이
[OUT]t Parse 결과를 struct timeval 로 표현한 값
Returns
DevTimeAns 파싱에 사용된 payload 길이

Reimplemented in LoRaMacKR920SKT.

1998 {
1999 if (len < 5) {
2000 return 0;
2001 }
2002
2003 t->tv_sec = (((uint32_t) payload[0] << 0) |
2004 ((uint32_t) payload[1] << 8) |
2005 ((uint32_t) payload[2] << 16) |
2006 ((uint32_t) payload[3] << 24));
2007 t->tv_sec += 315964800ul; // Ticks from 1970. 1. 1. to 1980. 1. 6.
2008 t->tv_sec -= 18; // Leap ticks from 1980. 1. 6. to now (2025).
2009 t->tv_usec = payload[4] * 1000000ul / 256;
2010 return 5;
2011 }

◆ PayloadDecrypt()

void LoRaMac::PayloadDecrypt ( const uint8_t * buffer,
uint16_t size,
const uint8_t * key,
uint32_t address,
uint8_t dir,
uint32_t sequenceCounter,
uint8_t * decBuffer )
static

Computes the LoRaMAC payload decryption

Parameters
[IN]buffer - Data buffer
[IN]size - Data buffer size
[IN]key - AES key to be used
[IN]address - Frame address
[IN]dir - Frame direction [0: uplink, 1: downlink]
[IN]sequenceCounter - Frame sequence counter
[OUT]decBuffer - Decrypted buffer

◆ PayloadEncrypt()

void LoRaMac::PayloadEncrypt ( const uint8_t * buffer,
uint16_t size,
const uint8_t * key,
uint32_t address,
uint8_t dir,
uint32_t sequenceCounter,
uint8_t * encBuffer )
static

Computes the LoRaMAC payload encryption

Parameters
[IN]buffer - Data buffer
[IN]size - Data buffer size
[IN]key - AES key to be used
[IN]address - Frame address
[IN]dir - Frame direction [0: uplink, 1: downlink]
[IN]sequenceCounter - Frame sequence counter
[OUT]encBuffer - Encrypted buffer

◆ removeChannel()

virtual error_t LoRaMac::removeChannel ( uint8_t id)
pure virtual

LoRaMAC channel remove service.

Deactivates the id in the channel mask.

Parameters
[IN]id - Id of the channel.
Returns

Implemented in LoRaMacAS923Japan, LoRaMacCN779, LoRaMacEU433, LoRaMacEU863, LoRaMacKR920, and LoRaMacUS902.

◆ requestDeviceTime() [1/3]

error_t LoRaMac::requestDeviceTime ( RTCCalendar * rtc)

DeviceTimeReq MAC command를 요청합니다.

Parameters
funcDeviceTimeReq MAC command가 실제 전송될 때 호출될 콜백함수

이 MAC command는 다음 uplink 메시지 전송시 함께 전송됩니다. 즉시 전송을 원한다면 길이가 0인 빈 LoRaMacFrame 을 전송하십시오.

이 MAC command가 전송될 때 LoRaMac::onMACCommandSend 가 가리키는 함수가 콜백됩니다.

DeviceTimeReq에 대한 응답으로 DeviceTimeAns가 오면 onMACCommandReceived 에서 지정한 콜백함수가 호출됩니다.

Note
자세한 내용은 LoRaWAN L2 Specification 1.0.4의 5.9 End-Device Time Commands (DeviceTimeReq, DeviceTimeAns) 를 참고하십시오.

◆ requestDeviceTime() [2/3]

error_t LoRaMac::requestDeviceTime ( RTCCalendar * rtc,
void(* func )(LoRaMac &) )

DeviceTimeReq MAC command를 요청합니다.

Parameters
funcDeviceTimeReq MAC command가 실제 전송될 때 호출될 콜백함수
Deprecated
LoRaMac::requestDeviceTime(RTCCalendar *) 과 LoRaMac::onMACCommandSend 를 대신 사용하십시오.

◆ requestDeviceTime() [3/3]

error_t LoRaMac::requestDeviceTime ( void(* func )(LoRaMac &) = nullptr)

DeviceTimeReq MAC command를 요청합니다.

Parameters
funcDeviceTimeReq MAC command가 실제 전송될 때 호출될 콜백함수

이 함수는 LoRaMac::requestDeviceTime(&System, ...) 과 같습니다.

Deprecated
LoRaMac::requestDeviceTime(RTCCalendar *) 과 LoRaMac::onMACCommandSend 를 대신 사용하십시오.

◆ requestLinkCheck() [1/2]

virtual error_t LoRaMac::requestLinkCheck ( )
virtual

LinkCheckReq MAC command를 요청합니다.

이 MAC command는 다음 uplink 메시지 전송시 함께 전송됩니다. 즉시 전송을 원한다면 길이가 0인 빈 LoRaMacFrame 을 전송하십시오.

이 MAC command가 전송될 때 LoRaMac::onMACCommandSend 가 가리키는 함수가 콜백됩니다.

LinkCheckReq에 대한 응답으로 LinkCheckAns가 오면 LoRaMac::onMACCommandReceived 가 가리키는 함수가 콜백됩니다.

Note
자세한 내용은 LoRaWAN L2 Specification 1.0.4의 5.1 Link Check commands 를 참고하십시오.

Reimplemented in LoRaMacKR920SKT.

◆ requestLinkCheck() [2/2]

error_t LoRaMac::requestLinkCheck ( void(* func )(LoRaMac &))

LinkCheckReq MAC command를 요청합니다.

Parameters
funcLinkCheckReq MAC command가 실제 전송될 때 호출될 콜백함수
Deprecated
requestLinkCheck() 를 대신 사용하십시오.

◆ resetRegionState()

virtual void LoRaMac::resetRegionState ( )
inlineprotectedvirtual
1917{}

◆ send()

error_t LoRaMac::send ( LoRaMacFrame * frame)

frame 을 전송합니다.

Parameters
frame전송할 프레임
Returns
  • ERROR_SUCCESS : 전송 큐에 성공적으로 입력됨
  • ERROR_FAIL : port 가 0, 지원하지 않는 datarate 또는 채널을 지정하는 등 프레임 오류로 인한 실패
  • ERROR_BUSY : 전송 큐가 가득차서 실패

다음과 같이 사용할 수 있습니다.

static void taskPeriodicSend(void *) {
LoRaMacFrame *f = new LoRaMacFrame(255);
if (!f) {
printf("* Out of memory\n");
return;
}
f->port = 1;
strcpy((char *) f->buf, "Test");
f->len = strlen((char *) f->buf);
/* Uncomment below lines to specify parameters manually. */
// f->freq = 922500000;
// f->modulation = Radio::MOD_LORA;
// f->meta.LoRa.bw = Radio::BW_125kHz;
// f->meta.LoRa.sf = Radio::SF7;
// f->power = 1; /* Index 1 => MaxEIRP - 2 dBm */
f->numTrials = 5;
error_t err = LoRaWAN.send(f);
printf("* Sending periodic report (%p:%s (%u byte)): %d\n", f, f->buf, f->len, err);
if (err != ERROR_SUCCESS) {
delete f;
timerSend.startOneShot(10000);
}
}

frame 의 길이가 현재 DR에서 전송이 가능하나 송신 대기 중인 MAC commands가 있어 전송이 불가능한 경우, FPort를 0으로 하여 송신 대기 중인 MAC commands만 먼저 전송하고, 이후에 frame 을 전송합니다.

송신 대기 중인 MAC commands 존재 여부와 상관없이 frame 길이 자체가 현재 DR로 전송이 불가한 경우, frame 의 result 가 RadioPacket::TOO_BIG 으로 설정되어 sendDone() 으로 콜백됩니다.

ADR을 사용하고, confirmed uplink 재전송을 사용하는 경우 (LoRaMacFrame::numTrials > 1), 전송 실패시마다 DR이 줄어들어, 전송 가능한 payload 길이가 줄어들 수 있습니다. 이 경우, 전송 가능한 DR 까지만 내려갑니다. 즉, frame 길이가 DR3 까지는 전송이 가능하다면, DR3 까지만 떨어집니다.

DR 별 전송 가능한 MAC payload 길이를 알고 싶거나, 현재 송신 대기 중인 MAC commands 길이를 알고 싶은 경우, 각각 getMaxPayload() 와 getPendingMacCommandsLength() 메서드를 참고하세요.

Examples
nordic-nrf52-dk/LoRaWAN-Class-A/main.cpp, plm100s/PLS100W_AM1005-P-485/main.cpp, plm100s/PLS100W_HRXL-MaxSonar-WR/main.cpp, plm100s/PLS100W_SSD1306-I2C/main.cpp, plm100s/PLS100W_T9602-I2C/main.cpp, plm100s/PLS100W_TFmini-UART/main.cpp, plm100s/veml6030/main.cpp, st-nucleo-f429zi/LoRaWAN/main.cpp, and st-nucleo-l152re/LoRaWAN-Class-A/main.cpp.

◆ sendDone()

virtual void LoRaMac::sendDone ( RadioPacket * frame,
RadioPacket::Result_t  )
protectedvirtual

Reimplemented from PacketRadio.

◆ setABP()

virtual void LoRaMac::setABP ( const uint8_t * nwkSKey,
const uint8_t * appSKey,
uint32_t devAddr )
virtual

ABP를 사용하도록 설정합니다.

Parameters
[in]nwkSKeyNetwork session key
[in]appSKeyApplication session key
[in]devAddrDevice address

Reimplemented in LoRaMacKR920SKT.

Examples
plm100s/IPv6overLoRaWAN/main.cpp, and plm100s/veml6030/main.cpp.

◆ setCurrentDatarateIndex()

error_t LoRaMac::setCurrentDatarateIndex ( uint8_t index)

기본 datarate를 설정합니다.

성공한 설정값은 새 OTAA 세션에서도 기본값으로 사용합니다.

Parameters
index사용할 datarate index
Returns

◆ setCurrentTxPowerIndex()

error_t LoRaMac::setCurrentTxPowerIndex ( uint8_t index)

기본 Tx power를 설정합니다.

성공한 설정값은 새 OTAA 세션에서도 기본값으로 사용합니다. 서버 ADR에 의한 출력 변경은 이 기본값을 바꾸지 않습니다.

Parameters
index사용할 Tx power index
Returns

◆ setDeviceClass() [1/2]

error_t LoRaMac::setDeviceClass ( DeviceClass_t c)

Device class를 설정합니다.

이 함수는 Tx가 진행 중일 때가 아니면 즉시 새로운 클래스 c 로 변경됩니다.

Parameters
c새로운 class
Returns
Examples
plm100s/PLS100W_SSD1306-I2C/main.cpp, st-nucleo-f429zi/LoRaWAN/main.cpp, and st-nucleo-l152re/LoRaWAN-Class-A/main.cpp.

◆ setDeviceClass() [2/2]

error_t LoRaMac::setDeviceClass ( DeviceClass_t c,
bool sendDeviceModeInd,
void(* func )(LoRaMac &, DeviceClass_t) )
inline
1214 {
1215 return setDeviceClass(c);
1216 }
error_t setDeviceClass(DeviceClass_t c)
Device class를 설정합니다.

◆ setDownLinkCounter()

virtual void LoRaMac::setDownLinkCounter ( uint32_t )
virtual

Downlink용 frame counter (fCntDown) 를 설정합니다.

설정된 값은 마지막으로 수신한 downlink 프레임에서 사용된 값으로 가정합니다.

Reimplemented in LoRaMacKR920SKT.

◆ setPublicNetwork()

void LoRaMac::setPublicNetwork ( bool enable)

공용 LoRaWAN 네트워크를 사용할지 설정합니다.

공용 LoRaWAN 네트워크에서는 활성 데이터 레이트에 따라 라디오 SyncWord가 설정됩니다. SF7~SF12는 0x34, SF5/SF6는 0x12를 사용합니다.

Parameters
[IN]enable true 이면 공용 네트워크를 사용합니다.
Examples
nordic-nrf52-dk/LoRaWAN-Class-A/main.cpp, plm100s/IPv6overLoRaWAN/main.cpp, plm100s/PLS100W_AM1005-P-485/main.cpp, plm100s/PLS100W_HRXL-MaxSonar-WR/main.cpp, plm100s/PLS100W_SSD1306-I2C/main.cpp, plm100s/PLS100W_T9602-I2C/main.cpp, plm100s/PLS100W_TFmini-UART/main.cpp, plm100s/veml6030/main.cpp, st-nucleo-f429zi/LoRaWAN/main.cpp, and st-nucleo-l152re/LoRaWAN-Class-A/main.cpp.

◆ setRx2Datarate()

void LoRaMac::setRx2Datarate ( uint8_t dr)
inline

Rx2에서 사용할 DR을 임의로 설정합니다.

1262 {
1263 this->Rx2Channel.Datarate = dr;
1264 }

◆ setRx2Frequency()

void LoRaMac::setRx2Frequency ( uint32_t f)
inline

Rx2에서 사용할 주파수를 임의로 설정합니다.

1278 {
1279 this->Rx2Channel.Frequency = f;
1280 }

◆ setUpLinkCounter()

virtual void LoRaMac::setUpLinkCounter ( uint32_t )
virtual

Uplink용 frame counter (fCntUp) 를 설정합니다.

설정된 값은 다음 uplink 프레임 전송 시 사용됩니다.

Reimplemented in LoRaMacKR920SKT.

◆ unlinkMulticastChannel()

error_t LoRaMac::unlinkMulticastChannel ( MulticastParams_t * channelParam)

LoRaMAC multicast channel unlink service.

Unlinks a multicast channel from the linked list.

Parameters
[IN]channelParam - Multicast channel parameters to unlink.
Returns

Member Data Documentation

◆ framePending

bool LoRaMac::framePending = false

Frame pending.

네트워크 서버에서 더 보낼 데이터가 있음을 의미합니다. Downlink 후에 값이 변합니다. onReceive() 에서 지정한 콜백함수 등에서 이 값을 참고하여 추가적인 uplink를 전송할지 여부를 결정할 수 있습니다.

Note
LoRaWAN v1.1 4.3.1.4 Frame Pending bit 및 19.3 을 참고하세요.
Examples
feather-m0/LoRaWAN/main.cpp, nordic-nrf52-dk/LoRaWAN-Class-A/main.cpp, plm100s/LoRaWAN-Class-A/main.cpp, plm100s/PLS100W_AM1005-P-485/main.cpp, plm100s/PLS100W_HRXL-MaxSonar-WR/main.cpp, plm100s/PLS100W_SSD1306-I2C/main.cpp, plm100s/PLS100W_T9602-I2C/main.cpp, plm100s/PLS100W_TFmini-UART/main.cpp, plm100s/veml6030/main.cpp, plm150/LoRaWAN-Class-A/main.cpp, plm150/PLS100W_RD-WSD-M-02/main.cpp, st-nucleo-f429zi/LoRaWAN/main.cpp, and st-nucleo-l152re/LoRaWAN-Class-A/main.cpp.

◆ onMACCommandReceived

void(* LoRaMac::onMACCommandReceived) (LoRaMac &mac, MacCmd_t cid, const uint8_t *reqData, int16_t reqLen, const uint8_t *ansData, int16_t ansLen) = nullptr

MAC command 수신시 호출될 함수 포인터

이 함수 포인터에 함수를 지정하면 MAC command 수신시 호출됩니다.

함수 포인터의 파라미터는 다음과 같습니다.

Parameters
macLoRaWAN MAC instance
cidMAC command ID
reqDataRequest data. 이번에 수신한 MAC command가 answer인 경우, 이전에 송신한 request.
reqLenRequest data의 길이. 수신한 응답에 대해 요청한 적 없는 MAC command인 경우 -1.
ansDataAnswer data. 이번에 수신한 MAC command가 request인 경우, 곧 송신할 answer.
ansLenAnswer data의 길이. 응답을 보낼 수 없는 경우 -1. 또는 기 요청에 대한 응답이 오지 않은 경우 -1.

reqData, reqLen, ansData, 및 ansLen 는 CID를 포함하지 않습니다.

여러 MAC command 수신시 순차적으로 호출됩니다.

다음 코드를 참고하세요.

LoRaWAN.onMACCommandReceived = [](LoRaMac &mac, uint8_t cid, const uint8_t *reqData, int16_t reqLen, const uint8_t *ansData, int16_t ansLen) {
if (cid == lw.MAC_CMD_LINK_CHECK) {
printf("LinkCheckReq (0x%02x) was sent:", cid);
for (uint8_t i = 0; i < reqLen; i++) {
printf(" %02x", reqData[i]);
}
printf("\n");
printf("LinkCheckAns (0x%02x) was received:", cid);
for (uint8_t i = 0; i < ansLen; i++) {
printf(" %02x", ansData[i]);
}
printf("\n");
// Do something...
} else if (cid == lw.MAC_CMD_LINK_ADR) {
printf("LinkADRReq (0x%02x) was received:", cid);
for (uint8_t i = 0; i < reqLen; i++) {
printf(" %02x", reqData[i]);
}
printf("\n");
printf("LinkADRAns (0x%02x) will be sent:", cid);
for (uint8_t i = 0; i < ansLen; i++) {
printf(" %02x", ansData[i]);
}
printf("\n");
// Do something...
} else if (cid == lw.MAC_CMD_DUTY_CYCLE) {
printf("DutyCycleReq (0x%02x) was received:", cid);
for (uint8_t i = 0; i < reqLen; i++) {
printf(" %02x", reqData[i]);
}
printf("\n");
printf("DutyCycleAns (0x%02x) will be sent:", cid);
for (uint8_t i = 0; i < ansLen; i++) {
printf(" %02x", ansData[i]);
}
printf("\n");
// Do something...
} else if (cid == lw.MAC_CMD_RX_PARAM_SETUP) {
printf("RXParamSetupReq (0x%02x) received:", cid);
for (uint8_t i = 0; i < reqLen; i++) {
printf(" %02x", reqData[i]);
}
printf("\n");
printf("RXParamSetupAns (0x%02x) will be sent:", cid);
for (uint8_t i = 0; i < ansLen; i++) {
printf(" %02x", ansData[i]);
}
printf("\n");
// Do something...
} else if (cid == lw.MAC_CMD_DEV_STATUS) {
printf("DevStatusReq (0x%02x) was received:", cid);
for (uint8_t i = 0; i < reqLen; i++) {
printf(" %02x", reqData[i]);
}
printf("\n");
printf("DevStatusAns (0x%02x) will be sent:", cid);
for (uint8_t i = 0; i < ansLen; i++) {
printf(" %02x", ansData[i]);
}
printf("\n");
// Do something...
} else if (cid == lw.MAC_CMD_NEW_CHANNEL) {
printf("NewChannelReq (0x%02x) was received:", cid);
for (uint8_t i = 0; i < reqLen; i++) {
printf(" %02x", reqData[i]);
}
printf("\n");
printf("NewChannelAns (0x%02x) will be sent:", cid);
for (uint8_t i = 0; i < ansLen; i++) {
printf(" %02x", ansData[i]);
}
printf("\n");
// Do something...
} else if (cid == lw.MAC_CMD_RX_TIMING_SETUP) {
printf("RXTimingSetupReq (0x%02x) was received:", cid);
for (uint8_t i = 0; i < reqLen; i++) {
printf(" %02x", reqData[i]);
}
printf("\n");
printf("RXTimingSetupAns (0x%02x) will be sent:", cid);
for (uint8_t i = 0; i < ansLen; i++) {
printf(" %02x", ansData[i]);
}
printf("\n");
// Do something...
} else if (cid == lw.MAC_CMD_TX_PARAM_SETUP) {
printf("TXParamSetupReq (0x%02x) was received:", cid);
for (uint8_t i = 0; i < reqLen; i++) {
printf(" %02x", reqData[i]);
}
printf("\n");
printf("TXParamSetupAns (0x%02x) will be sent:", cid);
for (uint8_t i = 0; i < ansLen; i++) {
printf(" %02x", ansData[i]);
}
printf("\n");
// Do something...
} else if (cid == lw.MAC_CMD_DL_CHANNEL) {
printf("DlChannelReq (0x%02x) was received:", cid);
for (uint8_t i = 0; i < reqLen; i++) {
printf(" %02x", reqData[i]);
}
printf("\n");
printf("DlChannelAns (0x%02x) will be sent:", cid);
for (uint8_t i = 0; i < ansLen; i++) {
printf(" %02x", ansData[i]);
}
printf("\n");
// Do something...
} else if (cid == lw.MAC_CMD_DEV_TIME) {
printf("DevTimeReq (0x%02x) was sent:", cid);
for (uint8_t i = 0; i < reqLen; i++) {
printf(" %02x", reqData[i]);
}
printf("\n");
printf("DevTimeAns (0x%02x) was received:", cid);
for (uint8_t i = 0; i < ansLen; i++) {
printf(" %02x", ansData[i]);
}
printf("\n");
// Do something...
} else {
printf("Unknown request (0x%02x):", cid);
for (uint8_t i = 0; i < reqLen; i++) {
printf(" %02x", reqData[i]);
}
printf("\n");
printf("Unknown answer (0x%02x):", cid);
for (uint8_t i = 0; i < ansLen; i++) {
printf(" %02x", ansData[i]);
}
printf("\n");
// Do something...
}
};

지정한 콜백 함수 내에서는 별도로 취해야할 동작은 없습니다. 수신한 MAC command에 대한 처리는 LoRaMac 에서 수행합니다.

수신한 MAC command가 request인 경우, answer는 다음 uplink 시 송신됩니다. 즉, ansData, 및 ansLen 은 다음 uplink시 송신될 MAC command 입니다. 실제 송신될 시점의 콜백은 LoRaMac::onMACCommandSend 를 참고하십시오.

See also
LoRaMac::onMACCommandSend
Note
자세한 내용은 LoRaWAN L2 Specification 1.0.4의 5 MAC Commands를 참고하십시오.
Warning
이 변수를 다음 함수들과 함께 사용하지 마십시오. 다음 함수들은 이 변수를 수정합니다.

◆ onMACCommandSend

void(* LoRaMac::onMACCommandSend) (LoRaMac &mac, MacCmd_t cid, const uint8_t *data, uint8_t len) = nullptr

MAC command 송신시 호출될 함수 포인터

이 함수 포인터에 함수를 지정하면 MAC command 송신시 호출됩니다.

함수 포인터의 파라미터는 다음과 같습니다.

Parameters
macLoRaWAN MAC instance
cidMAC command ID
data송신한 MAC command data
len송신한 MAC command 길이

여러 MAC command 송신시 순차적으로 호출됩니다.

See also
LoRaMac::onMACCommandReceived
Note
자세한 내용은 LoRaWAN L2 Specification 1.0.4의 5 MAC Commands를 참고하십시오.
Warning
이 변수를 다음 함수들과 함께 사용하지 마십시오. 다음 함수들은 이 변수를 수정합니다.

◆ onRxWindowClosed

void(* LoRaMac::onRxWindowClosed) (LoRaMac &mac, uint8_t window, struct timeval nextWindowAt) = nullptr

Class A RX1 또는 RX2 수신 창이 닫힌 뒤 작업 문맥에서 호출됩니다.

window 는 1 (RX1) 또는 2 (RX2)입니다. nextWindowAt 은 다음 수신 창이 열리도록 예약된 부팅 후 시각이며, 다음 창이 없으면 {0, 0}입니다. 작업 큐에서 실행되므로 콜백 시점에는 이 시각이 이미 지났을 수 있습니다.

◆ onUplinkDone

void(* LoRaMac::onUplinkDone) (LoRaMac &, LoRaMacFrame *) = nullptr

Uplink (Tx) 전송이 완료될 때 호출될 함수를 지정합니다.

Uplink Tx 완료 후 호출됩니다. 콜백 후 Rx1, 및 Rx2가 이어질 수 있습니다.

◆ receivesDuplicate

bool LoRaMac::receivesDuplicate = false

중복 프레임을 수신 여부를 설정합니다.

중복된 fCntDown 값을 가진 downlink 프레임에 대한 수신 여부를 설정합니다. true 이면, 중복 confirmed down 프레임에 대한 acknowleged 처리와 함께 onReceive() 콜백을 호출하여 해당 프레임을 애플리케이션에서 처리할 수 있도록 합니다.

◆ rxWindow2At

struct timeval LoRaMac::rxWindow2At = {}
protected
1868{};

◆ useADR

bool LoRaMac::useADR = true

ADR 사용여부를 설정합니다.

ADR을 사용하면 네트워크 서버에 의해 전송시 사용할 datarate 및 Tx power 가 변경됩니다. 이 값은 getCurrentDatarateIndex() 및 getCurrentTxPowerIndex() 로 확인할 수 있습니다. LoRaMacFrame 에 전송 파라미터를 설정하기 앞서 이 변수를 false 로 지정해야 합니다. 그렇지 않으면 ADR 에 따른 DR 및 Tx power로 프레임을 전송합니다.

Examples
plm100s/PLS100W_AM1005-P-485/main.cpp, and plm100s/veml6030/main.cpp.

The documentation for this class was generated from the following file: