LoRaWAN application messaging support implementation.
Copyright (c) 2020 Microchip Technology Inc. and its subsidiaries.
#include "lorawan.h"
#include "radio_interface.h"
#include "sw_timer.h"
#include "msg.h"
#include "conf_app.h"
#include "log.h"
Functions | |
static uint8_t | messageGetIdByGroupAddr (uint32_t devaddr) |
static bool | messageIsDutyCyclePending (void) |
static void | messageReceiveProcess (void) |
static void | messageSendProcess (void) |
static void | messageTimerCb (void) |
void | MSG_DataCallback (void *appHandle, appCbParams_t *params) |
uint16_t | MSG_GetState (void) |
void | MSG_Init (void) |
bool | MSG_IsTxPossible (uint8_t len, uint32_t *txTime) |
void | MSG_Process (void) |
AppResult_t | MSG_Send (TransmissionType_t msgType, uint8_t port, uint8_t *data, uint8_t length, uint32_t timeout) |
void | MSG_SetDefaultRxDataAvailCallback (MsgCallback_t callback) |
void | MSG_SetFPortRxDataAvailCallback (uint8_t port, MsgCallback_t callback) |
void | MSG_SetTransactionCompleteCallback (MsgCallback_t callback) |
static void | processRxDataAvailable (void *appHandle, appCbParams_t *params) |
static void | processTransactionComplete (void *appHandle, appCbParams_t *params) |
Variables | |
uint8_t | fportCallbackAlloc |
FportCallbacks_t | fportCallbacks [MSG_FPORT_CB_MAX] |
MsgCallback_t | msgDefaultRxDataAvailCallback |
MessageRx_t | msgRx |
static MessageState_t | msgState |
MsgCallback_t | msgTransactionCompleteCallback |
MessageTx_t | msgTx |
uint8_t | rxBufMem [MSG_TX_BUFFER_SIZE] |
uint8_t | tmrMsg |
uint8_t | txBufMem [MSG_TX_BUFFER_SIZE] |
|
static |
References i, LORAWAN_GetAttr(), and MCAST_GROUP_ADDR.
Referenced by messageReceiveProcess().
|
static |
References LOGLINE_DEBUG, LORAWAN_GetAttr(), LORAWAN_SUCCESS, NULL, and PENDING_DUTY_CYCLE_TIME.
Referenced by MSG_IsTxPossible(), and processTransactionComplete().
|
static |
References DEV_ADDR, DOWNLINK_COUNTER, i, LOGLINE_DEBUG, LOGMSG_DEBUG, LORAWAN_GetAttr(), MCAST_FCNT_DOWN, messageGetIdByGroupAddr(), msgDefaultRxDataAvailCallback, NULL, _appCbParams::param, _MessageRx_t::params, _FportCallbacks_t::pFunc, _appCbParams::rxData, and _MessageState_t::rxPending.
Referenced by MSG_Process().
|
static |
References _LorawanSendReq::bufferLength, CURRENT_DATARATE, LOGLINE_DEBUG, LORAWAN_GetAttr(), LORAWAN_Send(), LORAWAN_SUCCESS, _MessageTx_t::lorawanReq, messageTimerCb(), MS_TO_US, NULL, _LorawanSendReq::port, _MessageTx_t::retries, SW_TIMEOUT_RELATIVE, SwTimerStart(), _MessageTx_t::timeout, tmrMsg, _MessageState_t::transactionInProgress, _MessageState_t::txWaiting, and UPLINK_COUNTER.
Referenced by MSG_Process().
|
static |
References APP_TASK_ID, SYSTEM_PostTask(), _MessageState_t::transactionInProgress, and _MessageState_t::txWaiting.
Referenced by messageSendProcess(), and processTransactionComplete().
void MSG_DataCallback | ( | void * | appHandle, |
appCbParams_t * | params | ||
) |
uint16_t MSG_GetState | ( | void | ) |
References _MessageState_t::value.
void MSG_Init | ( | void | ) |
bool MSG_IsTxPossible | ( | uint8_t | len, |
uint32_t * | txTime | ||
) |
References CLASS_C, _MessageState_t::classRx2Dl, _TimeOnAirParams::cr, CRC_ON, _TimeOnAirParams::crcOn, CURRENT_DATARATE, _TimeOnAirParams::dr, EDCLASS, ERROR_CODING_RATE, LOGLINE_DEBUG, LORAWAN_GetAttr(), messageIsDutyCyclePending(), MSG_CLASS_C_INTER_DOWNLINK_TIME_MS, MSG_MAX_RX_WINDOW_TIME_MS, NEXT_PAYLOAD_SIZE, NULL, PACKET_TIME_ON_AIR, _TimeOnAirParams::pktLen, PREAMBLE_LEN, _TimeOnAirParams::preambleLen, RADIO_GetAttr(), RX_DELAY2, and US_TO_MS.
void MSG_Process | ( | void | ) |
References messageReceiveProcess(), and messageSendProcess().
AppResult_t MSG_Send | ( | TransmissionType_t | msgType, |
uint8_t | port, | ||
uint8_t * | data, | ||
uint8_t | length, | ||
uint32_t | timeout | ||
) |
References APP_RESULT_BUSY, APP_RESULT_OK, APP_TASK_ID, _LorawanSendReq::buffer, _LorawanSendReq::bufferLength, _MessageState_t::classRx2Dl, _LorawanSendReq::confirmed, length, LOGLINE_WARN, _MessageTx_t::lorawanReq, _LorawanSendReq::port, _MessageTx_t::retries, SYSTEM_PostTask(), _MessageTx_t::timeout, _MessageState_t::transactionInProgress, txBufMem, and _MessageState_t::txWaiting.
void MSG_SetDefaultRxDataAvailCallback | ( | MsgCallback_t | callback | ) |
References callback, and msgDefaultRxDataAvailCallback.
void MSG_SetFPortRxDataAvailCallback | ( | uint8_t | port, |
MsgCallback_t | callback | ||
) |
References callback, fportCallbackAlloc, LOGLINE_WARN, MSG_FPORT_CB_MAX, _FportCallbacks_t::pFunc, and _FportCallbacks_t::port.
void MSG_SetTransactionCompleteCallback | ( | MsgCallback_t | callback | ) |
References callback, and msgTransactionCompleteCallback.
|
static |
References APP_TASK_ID, CLASS_C, _MessageState_t::classRx2Dl, EDCLASS, LOGLINE_DEBUG, LORAWAN_GetAttr(), NULL, _appCbParams::param, _MessageRx_t::params, rxBufMem, _appCbParams::rxData, _MessageState_t::rxPending, and SYSTEM_PostTask().
Referenced by MSG_DataCallback().
|
static |
References LOGLINE_DEBUG, LORAWAN_GetAttr(), LORAWAN_NO_ACK, LORAWAN_NO_CHANNELS_FOUND, LORAWAN_RADIO_CHANNEL_BUSY, messageIsDutyCyclePending(), messageTimerCb(), MS_TO_US, msgTransactionCompleteCallback, NULL, _appCbParams::param, PENDING_DUTY_CYCLE_TIME, _MessageTx_t::retries, SW_TIMEOUT_RELATIVE, SwTimerStart(), tmrMsg, _MessageState_t::transactionInProgress, and _appCbParams::transCmpl.
Referenced by MSG_DataCallback().
uint8_t fportCallbackAlloc |
Referenced by MSG_Init(), and MSG_SetFPortRxDataAvailCallback().
FportCallbacks_t fportCallbacks[MSG_FPORT_CB_MAX] |
MsgCallback_t msgDefaultRxDataAvailCallback |
Referenced by messageReceiveProcess(), MSG_Init(), and MSG_SetDefaultRxDataAvailCallback().
MessageRx_t msgRx |
|
static |
MsgCallback_t msgTransactionCompleteCallback |
Referenced by MSG_Init(), MSG_SetTransactionCompleteCallback(), and processTransactionComplete().
MessageTx_t msgTx |
uint8_t rxBufMem[MSG_TX_BUFFER_SIZE] |
Referenced by processRxDataAvailable().
uint8_t tmrMsg |
Referenced by messageSendProcess(), MSG_Init(), and processTransactionComplete().
uint8_t txBufMem[MSG_TX_BUFFER_SIZE] |
Referenced by MSG_Send().