|
L14-Click 1.0
STM32WLE5CC LoRaWAN Sensor Platform
|
#include "mysensors_base.h"#include "mysensors.h"#include "main.h"#include "se-identity.h"#include "lora_app.h"#include "sys_app.h"#include "utils/mydefs.h"Go to the source code of this file.
Macros | |
| #define | SYS_WR(inst, member) |
| #define | SYS_WR_ARR(inst, member, len) |
| #define | SYS_WR_STR(inst, member) |
Functions | |
| static void | OnTimerToOff (void *) |
| |
| static void | getDevEuiFromHardware (uint8_t *devEui) |
| uint8_t * | systemParams_getAppDevEUI () |
| Return a pointer to the DevEUI stored in _systemParams. The DevEUI is auto-generated from the chip UID during initialisation and is read-only from the phone app's perspective. | |
| uint8_t * | systemParams_getAppEUI () |
| Return a pointer to the AppEUI (JoinEUI) stored in _systemParams. Used by the LoRaWAN stack during the OTAA join procedure. | |
| uint8_t * | systemParams_getAppKey () |
| Return a pointer to the AppKey stored in _systemParams. Used by the LoRaWAN stack to derive session keys during OTAA join. | |
| uint8_t | systemParams_CalculateCrc (uint8_t *data, uint8_t len) |
| Calculate a CRC-8 checksum (Sensirion polynomial) over a byte buffer. Used to validate sensor I2C response packets as well as the CRC field of systemParams_t. | |
| void | systemParams_SetCRCSystemParams () |
| Recalculate and store the CRC in _systemParams.Crc. Call this after modifying any field of _systemParams before writing the structure to the NFC EEPROM. | |
| uint8_t | systemParams_CheckCRC (const systemParams_t *par) |
| Verify the CRC field of a systemParams_t structure. | |
| void | sensorsBase_Init () |
| Initialization of base sensor data structure. | |
| void | sensorsBase_StartTimerToOff () |
| start timer to off the function is called from PWR_EnterStopMode - timer is started | |
| void | sensorsBase_StopTimerToOff () |
| stop timer to off the function is called from PWR_ExitStopMode - the timer value is checked and the PWR_ExitStopMode was invoked from this times, system goes to OFF mode setModeDevice(MODEDEVICE_OFF) | |
| void | systemParams_Correction () |
| Clamp all RW fields of _systemParams to their valid ranges. Called after loading parameters from NFC to ensure no out-of-range values are used (e.g. port numbers, timeouts, data rates). | |
| uint8_t | systemParams_IsSensorAvaiable (systemParams_Sensors_t sensorType) |
| Check whether a particular sensor is enabled in _systemParams.AvailableSensors. | |
| void | systemParams_Log (const char *info) |
| Log the current _systemParams fields to the UART debug output. | |
Variables | |
| systemParams_t | _systemParams |
| int8_t | _tryInit = 1 |
| static UTIL_TIMER_Object_t | _timerToOff = {} |
| static uint32_t | _timerTick = 0 |
| #define SYS_WR | ( | inst, | |
| member ) |
Definition at line 244 of file mysensors_base.c.
Referenced by systemParams_Log().
| #define SYS_WR_ARR | ( | inst, | |
| member, | |||
| len ) |
Definition at line 251 of file mysensors_base.c.
Referenced by systemParams_Log().
| #define SYS_WR_STR | ( | inst, | |
| member ) |
Definition at line 264 of file mysensors_base.c.
Referenced by systemParams_Log().
|
static |
Definition at line 117 of file mysensors_base.c.
References SYSTEM_APP_DevEUI0, SYSTEM_APP_DevEUI1, SYSTEM_APP_DevEUI2, and systemParams_CalculateCrc().
Referenced by systemParams_getAppDevEUI().
|
static |
Definition at line 69 of file mysensors_base.c.
Referenced by sensorsBase_StartTimerToOff().
| void sensorsBase_Init | ( | ) |
Initialization of base sensor data structure.
Definition at line 195 of file mysensors_base.c.
References Error_Handler(), systemParams_getAppDevEUI(), systemParams_SetCRCSystemParams(), SZ_SYSTEMPARAMS, and writeLog().
Referenced by main().
| void sensorsBase_StartTimerToOff | ( | ) |
start timer to off the function is called from PWR_EnterStopMode - timer is started
Definition at line 206 of file mysensors_base.c.
References _timerTick, _timerToOff, HAL_GetTick(), OnTimerToOff(), and SYSTEMPARAMS_MINTIME2OFF.
Referenced by PWR_EnterStopMode().
| void sensorsBase_StopTimerToOff | ( | ) |
stop timer to off the function is called from PWR_ExitStopMode - the timer value is checked and the PWR_ExitStopMode was invoked from this times, system goes to OFF mode setModeDevice(MODEDEVICE_OFF)
Definition at line 214 of file mysensors_base.c.
References _timerTick, _timerToOff, HAL_GetTick(), MODEDEVICE_OFF, sensors_Retiming(), setModeDevice(), and SYSTEMPARAMS_MINTIME2OFF.
Referenced by PWR_ExitStopMode().
| uint8_t systemParams_CalculateCrc | ( | uint8_t * | data, |
| uint8_t | len ) |
Calculate a CRC-8 checksum (Sensirion polynomial) over a byte buffer. Used to validate sensor I2C response packets as well as the CRC field of systemParams_t.
| data | Pointer to the data buffer. |
| len | Number of bytes to include in the calculation. |
Definition at line 167 of file mysensors_base.c.
Referenced by getDevEuiFromHardware(), scd41_IsDataReady(), scd41_Read(), scd41_WriteWithCRC(), sps30_GetAutoCleanInterval(), sps30_On(), sps30_Read(), sps30_SetAutoCleanInterval(), systemParams_CheckCRC(), and systemParams_SetCRCSystemParams().
| uint8_t systemParams_CheckCRC | ( | const systemParams_t * | par | ) |
Verify the CRC field of a systemParams_t structure.
| par | Pointer to the systemParams_t to check. |
| 1 | – CRC is valid (structure is intact). |
| 0 | – CRC mismatch (structure is corrupt or uninitialised). |
Definition at line 189 of file mysensors_base.c.
References systemParams_t::Crc, and systemParams_CalculateCrc().
Referenced by nfc_ReadSystemParamsToBck().
| void systemParams_Correction | ( | ) |
Clamp all RW fields of _systemParams to their valid ranges. Called after loading parameters from NFC to ensure no out-of-range values are used (e.g. port numbers, timeouts, data rates).
Definition at line 226 of file mysensors_base.c.
References _systemParams, CLAMP, SYSTEMPARAMS_MAXLORAWANPORT, SYSTEMPARAMS_MAXSENSORTIME, SYSTEMPARAMS_MINLORAWANPORT, and SYSTEMPARAMS_MINSENSORTIME.
Referenced by nfc_Init().
| uint8_t * systemParams_getAppDevEUI | ( | ) |
Return a pointer to the DevEUI stored in _systemParams. The DevEUI is auto-generated from the chip UID during initialisation and is read-only from the phone app's perspective.
Definition at line 140 of file mysensors_base.c.
References _systemParams, GetDevAddr(), and getDevEuiFromHardware().
Referenced by LoRaWAN_Init(), and sensorsBase_Init().
| uint8_t * systemParams_getAppEUI | ( | ) |
Return a pointer to the AppEUI (JoinEUI) stored in _systemParams. Used by the LoRaWAN stack during the OTAA join procedure.
Definition at line 154 of file mysensors_base.c.
References _systemParams.
Referenced by LoRaWAN_Init().
| uint8_t * systemParams_getAppKey | ( | ) |
Return a pointer to the AppKey stored in _systemParams. Used by the LoRaWAN stack to derive session keys during OTAA join.
Definition at line 159 of file mysensors_base.c.
References _systemParams.
Referenced by LoRaWAN_Init().
| uint8_t systemParams_IsSensorAvaiable | ( | systemParams_Sensors_t | sensorType | ) |
Check whether a particular sensor is enabled in _systemParams.AvailableSensors.
| sensorType | One of the systemParams_Sensors_t bitmask values. |
| 1 | – sensor is marked as available and should be polled. |
| 0 | – sensor is disabled in the configuration. |
Definition at line 238 of file mysensors_base.c.
References _systemParams.
Referenced by sensors_Init(), sensors_OnOff(), sensors_Read(), and sensors_Service().
| void systemParams_Log | ( | const char * | info | ) |
Log the current _systemParams fields to the UART debug output.
| info | Optional prefix string printed before the dump (e.g. "LOAD" or "SAVE"). |
Definition at line 271 of file mysensors_base.c.
References _systemParams, SYS_WR, SYS_WR_ARR, SYS_WR_STR, and writeLog().
Referenced by main().
| void systemParams_SetCRCSystemParams | ( | ) |
Recalculate and store the CRC in _systemParams.Crc. Call this after modifying any field of _systemParams before writing the structure to the NFC EEPROM.
Definition at line 184 of file mysensors_base.c.
References _systemParams, and systemParams_CalculateCrc().
Referenced by nfc_WriteSystemParams(), and sensorsBase_Init().
| systemParams_t _systemParams |
Global system parameters read from / written to the NFC tag EEPROM
Definition at line 20 of file mysensors_base.c.
Referenced by bar_bmp585_Read(), bar_ils22qs_Read(), checkResetRestart(), main(), mems_WriteToSystemParams(), myLoraWan_LastDataSend(), myloraWan_MeasureFinish(), nfc_Init(), nfc_ReadSystemParams(), nfc_WriteSystemParams(), OnLoRaWanConnected(), scd41_Init(), sensors_Retiming(), sensors_WriteFromBckToDataBlock(), sensorsSeq_Init(), systemParams_Correction(), systemParams_getAppDevEUI(), systemParams_getAppEUI(), systemParams_getAppKey(), systemParams_IsSensorAvaiable(), systemParams_Log(), systemParams_SetCRCSystemParams(), systemParams_SetLoRaWanParams(), and tasksensors_OnTimeout().
|
static |
Definition at line 64 of file mysensors_base.c.
Referenced by sensorsBase_StartTimerToOff(), and sensorsBase_StopTimerToOff().
|
static |
Definition at line 63 of file mysensors_base.c.
Referenced by sensorsBase_StartTimerToOff(), and sensorsBase_StopTimerToOff().
| int8_t _tryInit = 1 |
Flag used by xxx_Is() calls; when set to 1, the Is function attempts to (re-)initialise the sensor
Definition at line 60 of file mysensors_base.c.
Referenced by nfc_FactoryReset(), nfc_ReadSystemParams(), nfc_ReadSystemParamsToBck(), nfc_WriteSystemParams(), and sensors_Read().