|
L14-Click 1.0
STM32WLE5CC LoRaWAN Sensor Platform
|
#include "mylora_process.h"#include "main.h"#include "rtc.h"#include "mysensors.h"#include "mysensors_base.h"#include "sys_app.h"#include "stm32_seq.h"#include "lora_app.h"#include "mymems.h"#include "CayenneLpp.h"#include "LoRaMac.h"#include <stdio.h>Go to the source code of this file.
Functions | |
| static uint8_t | myLoRaWAN_GetMaxPayloadSize (void) |
| Get the maximum application payload size for the current data rate. Returns 0 if the query fails or channel is not available. | |
| static void | myLoraWan_Reconnect () |
| static void | myLoraWan_StartReconnect () |
| static LmHandlerErrorStatus_t | LoRaWAN_SendConfirmedData (uint8_t *data, uint8_t dataSize, uint8_t port) |
| Send confirmed data to LoRaWAN network. | |
| static uint8_t | myloraWan_PrepareSendingBuffer (const mems_DataBlock_t *data, uint8_t reset, uint8_t maxSize) |
| the preparing _currentSendingDataBuffer/_currentSendingDataSz from CayennelLpp to send data to LoRaWan gateway | |
| static void | myloraWan_MeasureFinish () |
| the measure has been finished, sensor data save to memory or local buffer, if no memory is exist or is not storing set _currentSendingDataBuffer - contains data _currentSendingDataSz - size of data in _currentSendingDataBuffer after measure is started myLoraWan_LastDataSend | |
| static void | myLoraWan_LastDataSend () |
| take data from LIFO - last data and send. Cannot be nested only if is LoRa connected | |
| void | GetTimeDate () |
| Filled up _currentTime & _currentDate. | |
| void | OnLoRaWanConnected (void) |
| Called after LoRaWAN successfully connects to the server. | |
| void | OnTimeSynchronized (void) |
| Called after date/time has been synchronized from LoRaWAN. | |
| void | OnLoRaWANRxData (LmHandlerAppData_t *appData, LmHandlerRxParams_t *params) |
| Handle received downlink data from LoRaWAN server. | |
| void | OnLoRaWANTxData (LmHandlerTxParams_t *params) |
| Handle transmission event callback. | |
| void | myloraWan_Init (uint32_t myloraWanAppBit) |
| initialization of myloraWan process, sequencer | |
Variables | |
| static struct tm | _localTime = {} |
| static uint32_t | _myloraWanAppBit = 0 |
| static uint8_t | _connectedCount = 0 |
| static uint8_t | _isDataSending = 0 |
| static uint8_t | _isConnected = 0 |
| static uint8_t | _currentSendingDataBuffer [256] |
| static uint8_t | _currentSendingDataSz = 0 |
| static uint8_t | _fromEndInx = 0 |
| void GetTimeDate | ( | ) |
Filled up _currentTime & _currentDate.
Definition at line 291 of file mylora_process.c.
References _localTime.
Referenced by main(), and OnTimeSynchronized().
|
static |
Send confirmed data to LoRaWAN network.
This function sends data that requires acknowledgment from the server. The server must respond with a downlink acknowledgment. This is useful for critical data that must be verified as received.
| data | Pointer to the data buffer to send |
| dataSize | Size of the data in bytes (max 242 bytes) |
| port | LoRaWAN application port (typically 2) |
Definition at line 91 of file mylora_process.c.
References myLoraWan_StartReconnect(), and writeLog().
Referenced by myLoraWan_LastDataSend().
|
static |
Get the maximum application payload size for the current data rate. Returns 0 if the query fails or channel is not available.
Definition at line 37 of file mylora_process.c.
Referenced by myLoraWan_LastDataSend().
| void myloraWan_Init | ( | uint32_t | myloraWanAppBit | ) |
initialization of myloraWan process, sequencer
Definition at line 474 of file mylora_process.c.
References _myloraWanAppBit, myLoraWan_LastDataSend(), myloraWan_MeasureFinish(), and myLoraWan_Reconnect().
Referenced by main().
|
static |
take data from LIFO - last data and send. Cannot be nested only if is LoRa connected
Definition at line 204 of file mylora_process.c.
References _currentSendingDataBuffer, _currentSendingDataSz, _fromEndInx, _isConnected, _isDataSending, _memsMainBlock, _systemParams, CayenneLppMaxBuffer(), LoRaWAN_SendConfirmedData(), mems_GetLastData(), myLoRaWAN_GetMaxPayloadSize(), myloraWan_PrepareSendingBuffer(), and writeLog().
Referenced by myloraWan_Init().
|
static |
the measure has been finished, sensor data save to memory or local buffer, if no memory is exist or is not storing set _currentSendingDataBuffer - contains data _currentSendingDataSz - size of data in _currentSendingDataBuffer after measure is started myLoraWan_LastDataSend
Definition at line 167 of file mylora_process.c.
References _memsMainBlock, _myloraWanAppBit, _systemParams, CFG_SEQ_Prio_0, mems_AddData(), MEMS_DATATYPE_SENSOR, mems_InicBuffer(), myloraWan_PrepareSendingBuffer(), sensors_CopyToBck(), sensors_WriteFromBckToDataBlock(), and writeLog().
Referenced by myloraWan_Init().
|
static |
the preparing _currentSendingDataBuffer/_currentSendingDataSz from CayennelLpp to send data to LoRaWan gateway
| data | - memory data block, sensors measured values |
| reset | - the sending buffer is reset or not(adding for _systemParams.SendInOnePacket == 1) |
| maxSize | - the max size of payload for current datarate, 0 - no buffer is checked |
Definition at line 143 of file mylora_process.c.
References _currentSendingDataBuffer, _currentSendingDataSz, sensors_CayennelFromBckData(), and sensors_ReadToBckFromDataBlock().
Referenced by myLoraWan_LastDataSend(), and myloraWan_MeasureFinish().
|
static |
Definition at line 51 of file mylora_process.c.
References _isConnected, LORAWAN_DEFAULT_ACTIVATION_TYPE, and writeLog().
Referenced by myloraWan_Init().
|
static |
Definition at line 65 of file mylora_process.c.
References _connectedCount, _myloraWanAppBit, CFG_SEQ_Prio_0, and writeLog().
Referenced by LoRaWAN_SendConfirmedData(), and OnLoRaWANTxData().
| void OnLoRaWanConnected | ( | void | ) |
Called after LoRaWAN successfully connects to the server.
This function is called when the LoRaWAN join process completes successfully. It performs time synchronization with the LoRaWAN server by requesting the device time, which updates the RTC with the server's time.
Definition at line 304 of file mylora_process.c.
References _connectedCount, _isConnected, _myloraWanAppBit, _systemParams, CFG_SEQ_Prio_0, and writeLog().
Referenced by OnJoinRequest().
| void OnLoRaWANRxData | ( | LmHandlerAppData_t * | appData, |
| LmHandlerRxParams_t * | params ) |
Handle received downlink data from LoRaWAN server.
This callback function is triggered when the device receives data from the LoRaWAN server. This can be a response to a confirmed uplink or an application-level downlink message.
| appData | Received application data including buffer and port |
| params | Receive parameters including RSSI, SNR, and downlink counter |
Definition at line 355 of file mylora_process.c.
References writeLog().
Referenced by OnRxData().
| void OnLoRaWANTxData | ( | LmHandlerTxParams_t * | params | ) |
Handle transmission event callback.
This callback is triggered after a transmission attempt, whether successful or not. It provides information about whether an ACK was received for confirmed messages.
| params | Transmission parameters including status and ACK received flag |
Definition at line 431 of file mylora_process.c.
References _currentSendingDataSz, _fromEndInx, _isConnected, _isDataSending, _myloraWanAppBit, CFG_SEQ_Prio_0, mems_RemoveLastData(), myLoraWan_StartReconnect(), and writeLog().
Referenced by OnTxData().
| void OnTimeSynchronized | ( | void | ) |
Called after date/time has been synchronized from LoRaWAN.
This function is called when the device receives a time synchronization response (DeviceTimeAns) from the LoRaWAN server. The RTC has already been updated with the server's time when this function is called.
Add your custom code here to perform actions after time synchronization, such as updating time-dependent schedules, logging the sync event, or triggering time-based operations.
Definition at line 338 of file mylora_process.c.
References _localTime, GetTimeDate(), and writeLog().
Referenced by OnSysTimeUpdate().
|
static |
Definition at line 26 of file mylora_process.c.
Referenced by myLoraWan_StartReconnect(), and OnLoRaWanConnected().
|
static |
Definition at line 29 of file mylora_process.c.
Referenced by myLoraWan_LastDataSend(), and myloraWan_PrepareSendingBuffer().
|
static |
Definition at line 30 of file mylora_process.c.
Referenced by myLoraWan_LastDataSend(), myloraWan_PrepareSendingBuffer(), and OnLoRaWANTxData().
|
static |
Definition at line 31 of file mylora_process.c.
Referenced by myLoraWan_LastDataSend(), and OnLoRaWANTxData().
|
static |
Definition at line 28 of file mylora_process.c.
Referenced by myLoraWan_LastDataSend(), myLoraWan_Reconnect(), OnLoRaWanConnected(), and OnLoRaWANTxData().
|
static |
Definition at line 27 of file mylora_process.c.
Referenced by myLoraWan_LastDataSend(), and OnLoRaWANTxData().
|
static |
Definition at line 24 of file mylora_process.c.
Referenced by GetTimeDate(), and OnTimeSynchronized().
|
static |
Definition at line 25 of file mylora_process.c.
Referenced by myloraWan_Init(), myloraWan_MeasureFinish(), myLoraWan_StartReconnect(), OnLoRaWanConnected(), and OnLoRaWANTxData().