L14-Click 1.0
STM32WLE5CC LoRaWAN Sensor Platform
Loading...
Searching...
No Matches
mysensors_base.h File Reference
#include "mysensors_def.h"
#include "tmphm_sht45.h"
#include "amb_tsl2591.h"
#include "bar_ils22qs.h"
#include "bar_bmp585.h"
#include "scd41.h"
#include "sps30.h"
#include "systime.h"
#include <stdint.h>
Include dependency graph for mysensors_base.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  systemParams_t
 System configuration parameters – persisted in NFC EEPROM at address 0. The structure contains all modifiable variables/settings of system, can be read/writa via NFC tool or LoRa special read/write process The structure is 92 bytes (SZ_SYSTEMPARAMS) with a CRC8 byte at the end. Fields marked RO are written by the firmware; fields marked RW can be updated by a phone app via the NFC EEPROM or via LoRa special process. More...
struct  systemParamsRef_t
 The references to systemParams_t for change values from server via downlink.
The server sends via downlink the requirements for change of systemParams_t field, one by one. This struct is reference for finding the address of valid field in systemParams_t - its position and size:
. More...
struct  measureDataNFC_t
 block of one measure data in CayennelLPP payload format
The Data field contains the same payload as in LoRaWan processing, without UTC/TIME8/TIME16 fields, because the UTC time of measure is in UTCMeasureTime field. More...
struct  measureNFC_t
 the control block of NFC on address MEASUREDATANFC_ADDR where are stored the last measure data
The EEPROM of NFC has 2kB, 2048bytes on address 128(MEASUREDATANFC_ADDR), max size for sensor data is 1920 bytes
sizeof(measureNFC_t) is 16(SZ_MEASURENFC) fixed struct size - !!! the size my be boundary 4 !!!
it is followed by measure data, on Data field
measureDataNFC_t - circular queue More...

Macros

#define SIZE_SHT45   sizeof(tmphm_sht45_t)
 Byte size of tmphm_sht45_t in the packed sensor record.
#define SIZE_SHT45_NFC   (4+3)
 Byte size of payload CayennelLpp data for NFC stored into.
#define SIZE_SHT45_NFC_NEG   0
#define SIZE_TSL2591   0
#define SIZE_TSL2591_NFC   0
#define SIZE_ILS22QS   0
#define SIZE_ILS22QS_NFC   0
#define SIZE_BMP585   sizeof(bar_bmp585_t)
 Byte size of bar_bmp585_t in the packed sensor record.
#define SIZE_BMP585_NFC   (4+0)
 Byte size of payload CayennelLpp data for NFC stored into.
#define SIZE_SCD41   0
#define SIZE_SCD41_NFC   0
#define SIZE_SPS30   0
#define SIZE_SPS30_NFC   0
#define SENSORS_DATASIZE
 Total size in bytes of one packed sensor data record. Computed as the sum of all enabled sensor struct sizes. Stored as Data_ItemSize in mems_MainBlock_t; changing the set of active sensors changes this value and requires a memory reset. The struct size contains sizeof(SysTime_t) - represent the time of measure in UTC.
#define SYSTEMPARAMS_SIGN   "MTTV"
 4-byte ASCII signature stored at offset 0 of systemParams_t to validate data integrity.
#define SZ_SYSTEMPARAMS   92
 Total size in bytes of the systemParams_t structure stored on the NFC tag and send via LoRa - the size is used for check of struct systemParams_t and it doens't match, the Error_Handler() is called the size of structure must be modulo 4.
#define SYSTEMPARAMS_STRUCTVER   1
 Total size in byte for one chunk between DEV and gateway - DR_0 #define SZ_DATACHUNK 50.
#define SYSTEMPARAMS_APPVER00   0x01
 Application firmware minor version number (plain integer).
#define SYSTEMPARAMS_APPVER01   0x01
 Application firmware major version number (plain integer) - check of validity struct together with SYSTEMPARAMS_SIGN.
#define SYSTEMPARAMS_DEFAULTALTITUDE   300
 The default sensor altitue.
#define SYSTEMPARAMS_MINSENSORTIME   30000
 Minimum allowed sensor measurement interval in milliseconds (30 seconds).
#define SYSTEMPARAMS_DEFAULTSENSORTIME   60*1000*10
 Default sensor measurement interval in milliseconds (10 minutes).
#define SYSTEMPARAMS_MAXSENSORTIME   60*1000*60*18
 Maximum allowed sensor measurement interval in milliseconds (18 hour).
#define SYSTEMPARAMS_MINTIME2OFF   10000
 Minimum idle time in milliseconds before the device enters OFF (standby) mode. Values below ~10 s are too short because the LoRaWAN stack may still be finishing a transmission when the timer fires.
#define SYSTEM_APP_EUI   00,00,00,00,00,00,00,00
 Default LoRaWAN JoinEUI / AppEUI (8 bytes, all zeros – overridden via NFC).
#define SYSTEM_APP_KEY   AB,CD,EF,01,02,03,10,11,12,05,06,07,EF,EF,EF,EF
 Default LoRaWAN AppKey (16 bytes – overridden via NFC before deployment).
#define SYSTEM_APP_DevEUI0   0x45
 First byte of the 3-byte OUI prefix used in the auto-generated DevEUI.
#define SYSTEM_APP_DevEUI1   0x87
 Second byte of the 3-byte OUI prefix used in the auto-generated DevEUI.
#define SYSTEM_APP_DevEUI2   0xF2
 Third byte of the 3-byte OUI prefix used in the auto-generated DevEUI.
#define SYSTEMPARAMS_BATTIMESEND   (12*3600)
 The time, in seconds, the battery level sending interval - 12h.
#define SYSTEMPARAMS_BATTMINWORK   2600
 the voltage (mV) for processing. The system goes to OFF mode, if current votage is lower SYSTEMPARAMS_BATTMINWORK
#define SZ_MEASURENFC   16
 The last 50 records of payload (CayeneeLPP) are store in NFC for debuging. These data can be received via mobile phone application - NFC as systemParams_t
the size of measureNFC_t.
#define MEASUREDATANFC_ADDR   128
 The address, on which is the begin of measured data in NFC. The address is modulo 4, and space between 92 - 128 is reserver for future expanded structure of systemParams_t
The address of measureNFC_t struct (nfc measure header) is on: MEASUREDATANFC_ADDR + sizeof(measureNFC_t);.
#define MEASUEREDATANFC_SIZE
 one data NFC block of measure data in payload CaynnelLPP format
32 - maximum for all sensors, can be compiled specified
The 4 - is battery perc + reserve The size should be even boundary
#define MEASUEREDATANFC_EEPROMSIZE   2048
 the maximum size EEPROM.

Enumerations

enum  systemParams_Sensors_t {
  SYSPARAM_TEMP_HUM = 0x01 , SYSPARAM_BAR = 0x02 , SYSPARAM_AMBIENT = 0x04 , SYSPARAM_CO2 = 0x08 ,
  SYSPARAM_PARTICULAR = 0x10
}
 Bitmask of sensor modules that are enabled / available for data collection. Used in systemParams_t.AvailableSensors; individual bits can be ORed together. More...
enum  loraWanPort_t { LORAWANPORT_DATA_DEFAULT = 2 , LORAWANPORT_CONFIG_GET = 100 , LORAWANPORT_CONFIG_GET_LAST = LORAWANPORT_CONFIG_GET + 1 , LORAWANPORT_CONFIG_SET_PART = 102 }
 the list of LORAWAN port.
More...

Functions

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_CheckCRC (const systemParams_t *par)
 Verify the CRC field of a systemParams_t structure.
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.
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).
The DEVEui cannot be changed - problem of rewrite of DEVUi accross devices.
uint8_t systemParams_IsSensorAvaiable (systemParams_Sensors_t sensorType)
 Check whether a particular sensor is enabled in _systemParams.AvailableSensors.
uint8_t systemParams_CorrectSystemTime ()
 setting/correction of the system time from _systemParams.MqttTime, if contains valid UNIX time(low uint32_t). MCU is reading MqttTime from NFC and compares with current system time - SysTimeGet The system time is changed(SysTimeSet) if is less that time in _systemParams.MqttTime
void systemParams_SetFromPart (const uint8_t *buffer, uint8_t bufSize)
 The setting of systemParams_t from server dowlink. The buffer contains the combination for setting of value
.
void systemParams_Log (const char *info)
 Log the current _systemParams fields to the UART debug output.
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 sensorsBase_MeasureNFCInit ()
 the default initialization of _measureNFC struct
void sensorsBase_SetCRCMeasureNFC ()
 Recalculate and store the CRC in _measureNFC.Crc.
Call this after modifying any field of _measureNFC before writing the structure to the NFC EEPROM.
uint8_t sensorsBase_CheckCRCMeasureNFC ()
 Verify the CRC field of a _measureNFC structure.

Variables

int8_t _tryInit
systemParams_t _systemParams
systemParams_t _systemParamsBck
measureNFC_t _measureNFC
uint8_t _batPercLevel

Macro Definition Documentation

◆ MEASUEREDATANFC_EEPROMSIZE

#define MEASUEREDATANFC_EEPROMSIZE   2048

the maximum size EEPROM.

Definition at line 384 of file mysensors_base.h.

Referenced by sensorsBase_Init(), and sensorsBase_MeasureNFCInit().

◆ MEASUEREDATANFC_SIZE

#define MEASUEREDATANFC_SIZE
Value:
(\
4 \
)
#define SIZE_TSL2591_NFC
#define SIZE_BMP585_NFC
Byte size of payload CayennelLpp data for NFC stored into.
#define SIZE_SCD41_NFC
#define SIZE_SPS30_NFC
#define SIZE_ILS22QS_NFC
#define SIZE_SHT45_NFC
Byte size of payload CayennelLpp data for NFC stored into.

one data NFC block of measure data in payload CaynnelLPP format
32 - maximum for all sensors, can be compiled specified
The 4 - is battery perc + reserve The size should be even boundary

Definition at line 371 of file mysensors_base.h.

◆ MEASUREDATANFC_ADDR

#define MEASUREDATANFC_ADDR   128

The address, on which is the begin of measured data in NFC. The address is modulo 4, and space between 92 - 128 is reserver for future expanded structure of systemParams_t
The address of measureNFC_t struct (nfc measure header) is on: MEASUREDATANFC_ADDR + sizeof(measureNFC_t);.

Definition at line 363 of file mysensors_base.h.

Referenced by nfc_FactoryReset(), nfc_ReadMeasureNFC(), nfc_WriteMeasureData(), nfc_WriteMeasureNFC(), sensorsBase_Init(), and sensorsBase_MeasureNFCInit().

◆ SENSORS_DATASIZE

#define SENSORS_DATASIZE
Value:
(\
sizeof(SysTime_t) \
)
#define SIZE_ILS22QS
#define SIZE_SCD41
#define SIZE_SHT45
Byte size of tmphm_sht45_t in the packed sensor record.
#define SIZE_SPS30
#define SIZE_BMP585
Byte size of bar_bmp585_t in the packed sensor record.
#define SIZE_TSL2591

Total size in bytes of one packed sensor data record. Computed as the sum of all enabled sensor struct sizes. Stored as Data_ItemSize in mems_MainBlock_t; changing the set of active sensors changes this value and requires a memory reset. The struct size contains sizeof(SysTime_t) - represent the time of measure in UTC.

sizeof(SysTime_t) // 6 bytes (uint32_t Seconds + int16_t SubSeconds)

  • SIZE_SHT45 // 9 bytes
  • SIZE_TSL2591 // 5 bytes
  • SIZE_ILS22QS // 13 bytes
  • SIZE_BMP585 // 13 bytes
  • SIZE_SCD41 // 13 bytes
  • SIZE_SPS30 // 41 bytes

Definition at line 129 of file mysensors_base.h.

Referenced by sensors_WriteFromBckToDataBlock().

◆ SYSTEM_APP_DevEUI0

#define SYSTEM_APP_DevEUI0   0x45

First byte of the 3-byte OUI prefix used in the auto-generated DevEUI.

Definition at line 188 of file mysensors_base.h.

Referenced by getDevEuiFromHardware().

◆ SYSTEM_APP_DevEUI1

#define SYSTEM_APP_DevEUI1   0x87

Second byte of the 3-byte OUI prefix used in the auto-generated DevEUI.

Definition at line 190 of file mysensors_base.h.

Referenced by getDevEuiFromHardware().

◆ SYSTEM_APP_DevEUI2

#define SYSTEM_APP_DevEUI2   0xF2

Third byte of the 3-byte OUI prefix used in the auto-generated DevEUI.

Definition at line 192 of file mysensors_base.h.

Referenced by getDevEuiFromHardware().

◆ SYSTEM_APP_EUI

#define SYSTEM_APP_EUI   00,00,00,00,00,00,00,00

Default LoRaWAN JoinEUI / AppEUI (8 bytes, all zeros – overridden via NFC).

Definition at line 182 of file mysensors_base.h.

◆ SYSTEM_APP_KEY

#define SYSTEM_APP_KEY   AB,CD,EF,01,02,03,10,11,12,05,06,07,EF,EF,EF,EF

Default LoRaWAN AppKey (16 bytes – overridden via NFC before deployment).

Definition at line 185 of file mysensors_base.h.

◆ SYSTEMPARAMS_APPVER00

#define SYSTEMPARAMS_APPVER00   0x01

Application firmware minor version number (plain integer).

Definition at line 157 of file mysensors_base.h.

◆ SYSTEMPARAMS_APPVER01

#define SYSTEMPARAMS_APPVER01   0x01

Application firmware major version number (plain integer) - check of validity struct together with SYSTEMPARAMS_SIGN.

Definition at line 160 of file mysensors_base.h.

Referenced by nfc_ReadSystemParamsToBck().

◆ SYSTEMPARAMS_BATTIMESEND

#define SYSTEMPARAMS_BATTIMESEND   (12*3600)

The time, in seconds, the battery level sending interval - 12h.

Definition at line 215 of file mysensors_base.h.

Referenced by sensors_CayennelFromBckData().

◆ SYSTEMPARAMS_BATTMINWORK

#define SYSTEMPARAMS_BATTMINWORK   2600

the voltage (mV) for processing. The system goes to OFF mode, if current votage is lower SYSTEMPARAMS_BATTMINWORK

Definition at line 218 of file mysensors_base.h.

Referenced by myLoraWan_LastDataSend().

◆ SYSTEMPARAMS_DEFAULTALTITUDE

#define SYSTEMPARAMS_DEFAULTALTITUDE   300

The default sensor altitue.

Definition at line 163 of file mysensors_base.h.

◆ SYSTEMPARAMS_DEFAULTSENSORTIME

#define SYSTEMPARAMS_DEFAULTSENSORTIME   60*1000*10

Default sensor measurement interval in milliseconds (10 minutes).

Definition at line 169 of file mysensors_base.h.

◆ SYSTEMPARAMS_MAXSENSORTIME

#define SYSTEMPARAMS_MAXSENSORTIME   60*1000*60*18

Maximum allowed sensor measurement interval in milliseconds (18 hour).

Definition at line 172 of file mysensors_base.h.

Referenced by systemParams_Correction().

◆ SYSTEMPARAMS_MINSENSORTIME

#define SYSTEMPARAMS_MINSENSORTIME   30000

Minimum allowed sensor measurement interval in milliseconds (30 seconds).

Definition at line 166 of file mysensors_base.h.

Referenced by systemParams_Correction().

◆ SYSTEMPARAMS_MINTIME2OFF

#define SYSTEMPARAMS_MINTIME2OFF   10000

Minimum idle time in milliseconds before the device enters OFF (standby) mode. Values below ~10 s are too short because the LoRaWAN stack may still be finishing a transmission when the timer fires.

Definition at line 179 of file mysensors_base.h.

Referenced by sensorsBase_StartTimerToOff(), and sensorsBase_StopTimerToOff().

◆ SYSTEMPARAMS_SIGN

#define SYSTEMPARAMS_SIGN   "MTTV"

4-byte ASCII signature stored at offset 0 of systemParams_t to validate data integrity.

Definition at line 141 of file mysensors_base.h.

Referenced by nfc_ReadSystemParamsToBck().

◆ SYSTEMPARAMS_STRUCTVER

#define SYSTEMPARAMS_STRUCTVER   1

Total size in byte for one chunk between DEV and gateway - DR_0 #define SZ_DATACHUNK 50.

Version of the systemParams_t layout; increment when fields are added or reordered.

Definition at line 154 of file mysensors_base.h.

◆ SZ_MEASURENFC

#define SZ_MEASURENFC   16

The last 50 records of payload (CayeneeLPP) are store in NFC for debuging. These data can be received via mobile phone application - NFC as systemParams_t
the size of measureNFC_t.

Definition at line 356 of file mysensors_base.h.

Referenced by sensorsBase_Init().

◆ SZ_SYSTEMPARAMS

#define SZ_SYSTEMPARAMS   92

Total size in bytes of the systemParams_t structure stored on the NFC tag and send via LoRa - the size is used for check of struct systemParams_t and it doens't match, the Error_Handler() is called the size of structure must be modulo 4.

Definition at line 147 of file mysensors_base.h.

Referenced by sensorsBase_Init().

Enumeration Type Documentation

◆ loraWanPort_t

the list of LORAWAN port.

Note
must ensure that there is no conflict with the port settings
The setting of systemParams_t is going via systemParamsRef_t - particular set the setting for each field separately in OnLoRaWANRxData function
Enumerator
LORAWANPORT_DATA_DEFAULT 

the defaullt data lorawan port - sensor data sending via this port, can be changed via NFC or downlink

LORAWANPORT_CONFIG_GET 

config port data - read - server requires the systemParams_t data, write - via this port is send block to server (not last)

LORAWANPORT_CONFIG_GET_LAST 

config port data - write - the last chunk(or only one chunk) has been send/read

LORAWANPORT_CONFIG_SET_PART 

the port for set the part of configuration in systemParams_t via references defined in systemParamsRef_t

Definition at line 240 of file mysensors_base.h.

◆ systemParams_Sensors_t

Bitmask of sensor modules that are enabled / available for data collection. Used in systemParams_t.AvailableSensors; individual bits can be ORed together.

Enumerator
SYSPARAM_TEMP_HUM 

Temperature and humidity sensor (SHT45)

SYSPARAM_BAR 

Barometric pressure sensor (ILPS22QS or BMP585)

SYSPARAM_AMBIENT 

Ambient light sensor (TSL2591)

SYSPARAM_CO2 

CO2 / temperature / humidity sensor (SCD41)

SYSPARAM_PARTICULAR 

Particular matter sensor (SPS30)

Definition at line 225 of file mysensors_base.h.

Function Documentation

◆ sensorsBase_CheckCRCMeasureNFC()

uint8_t sensorsBase_CheckCRCMeasureNFC ( )

Verify the CRC field of a _measureNFC structure.

Return values
1– CRC is valid (structure is intact).
0– CRC mismatch (structure is corrupt or uninitialised).

Definition at line 377 of file mysensors_base.c.

References _measureNFC, calculateCrc(), CLAMP, and sensorsBase_SetCRCMeasureNFC().

Referenced by nfc_Init(), and nfc_WriteMeasureData().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sensorsBase_Init()

void sensorsBase_Init ( )

Initialization of base sensor data structure.

Definition at line 225 of file mysensors_base.c.

References Error_Handler(), MEASUEREDATANFC_EEPROMSIZE, MEASUREDATANFC_ADDR, sensorsBase_MeasureNFCInit(), systemParams_getAppDevEUI(), systemParams_SetCRCSystemParams(), SZ_MEASURENFC, SZ_SYSTEMPARAMS, and writeLog().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sensorsBase_MeasureNFCInit()

void sensorsBase_MeasureNFCInit ( )

the default initialization of _measureNFC struct

Definition at line 362 of file mysensors_base.c.

References _measureNFC, MEASUEREDATANFC_EEPROMSIZE, MEASUREDATANFC_ADDR, and sensorsBase_SetCRCMeasureNFC().

Referenced by nfc_Init(), nfc_WriteMeasureData(), and sensorsBase_Init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sensorsBase_SetCRCMeasureNFC()

void sensorsBase_SetCRCMeasureNFC ( )

Recalculate and store the CRC in _measureNFC.Crc.
Call this after modifying any field of _measureNFC before writing the structure to the NFC EEPROM.

Definition at line 372 of file mysensors_base.c.

References _measureNFC, and calculateCrc().

Referenced by nfc_WriteMeasureNFC(), sensorsBase_CheckCRCMeasureNFC(), and sensorsBase_MeasureNFCInit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sensorsBase_StartTimerToOff()

void sensorsBase_StartTimerToOff ( )

start timer to off the function is called from PWR_EnterStopMode - timer is started

Definition at line 270 of file mysensors_base.c.

References _timerTick, _timerToOff, HAL_GetTick(), OnTimerToOff(), and SYSTEMPARAMS_MINTIME2OFF.

Referenced by PWR_EnterStopMode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sensorsBase_StopTimerToOff()

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 278 of file mysensors_base.c.

References _timerTick, _timerToOff, HAL_GetTick(), MODEDEVICE_OFF, setModeDevice(), and SYSTEMPARAMS_MINTIME2OFF.

Referenced by PWR_ExitStopMode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ systemParams_CheckCRC()

uint8_t systemParams_CheckCRC ( const systemParams_t * par)

Verify the CRC field of a systemParams_t structure.

Parameters
parPointer to the systemParams_t to check.
Return values
1– CRC is valid (structure is intact).
0– CRC mismatch (structure is corrupt or uninitialised).

Definition at line 219 of file mysensors_base.c.

References calculateCrc(), and systemParams_t::Crc.

Referenced by nfc_ReadSystemParamsToBck(), and OnLoRaWANRxData().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ systemParams_Correction()

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).
The DEVEui cannot be changed - problem of rewrite of DEVUi accross devices.

Definition at line 290 of file mysensors_base.c.

References _systemParams, CLAMP, GetDevAddr(), getDevEuiFromHardware(), SYSTEMPARAMS_MAXSENSORTIME, and SYSTEMPARAMS_MINSENSORTIME.

Referenced by nfc_Init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ systemParams_CorrectSystemTime()

uint8_t systemParams_CorrectSystemTime ( )

setting/correction of the system time from _systemParams.MqttTime, if contains valid UNIX time(low uint32_t). MCU is reading MqttTime from NFC and compares with current system time - SysTimeGet The system time is changed(SysTimeSet) if is less that time in _systemParams.MqttTime

Return values
0- no changes
1- the system time has been update
2- the _systemParams.MqttTime

Definition at line 310 of file mysensors_base.c.

References _systemParams.

Referenced by main(), and OnTimeSynchronized().

Here is the caller graph for this function:

◆ systemParams_getAppDevEUI()

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.

Returns
Pointer to the 8-byte DevEUI array inside _systemParams.

Definition at line 189 of file mysensors_base.c.

References _systemParams, GetDevAddr(), and getDevEuiFromHardware().

Referenced by LoRaWAN_Init(), and sensorsBase_Init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ systemParams_getAppEUI()

uint8_t * systemParams_getAppEUI ( )

Return a pointer to the AppEUI (JoinEUI) stored in _systemParams. Used by the LoRaWAN stack during the OTAA join procedure.

Returns
Pointer to the 8-byte AppEUI array inside _systemParams.

Definition at line 203 of file mysensors_base.c.

References _systemParams.

Referenced by LoRaWAN_Init().

Here is the caller graph for this function:

◆ systemParams_getAppKey()

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.

Returns
Pointer to the 16-byte AppKey array inside _systemParams.

Definition at line 208 of file mysensors_base.c.

References _systemParams.

Referenced by LoRaWAN_Init().

Here is the caller graph for this function:

◆ systemParams_IsSensorAvaiable()

uint8_t systemParams_IsSensorAvaiable ( systemParams_Sensors_t sensorType)

Check whether a particular sensor is enabled in _systemParams.AvailableSensors.

Parameters
sensorTypeOne of the systemParams_Sensors_t bitmask values.
Return values
1– sensor is marked as available and should be polled.
0– sensor is disabled in the configuration.

Definition at line 305 of file mysensors_base.c.

References _systemParams.

Referenced by sensors_Init(), sensors_OnOff(), sensors_Read(), and sensors_Service().

Here is the caller graph for this function:

◆ systemParams_Log()

void systemParams_Log ( const char * info)

Log the current _systemParams fields to the UART debug output.

Parameters
infoOptional prefix string printed before the dump (e.g. "LOAD" or "SAVE").

Definition at line 489 of file mysensors_base.c.

References _measureNFC, _systemParamRef, _systemParams, COUNT_OF, SYS_WR, SYS_WR_ARR, SYS_WR_STR, SYS_WR_TIME, and writeLog().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ systemParams_SetCRCSystemParams()

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 214 of file mysensors_base.c.

References _systemParams, and calculateCrc().

Referenced by nfc_WriteSystemParams(), OnLoRaWANRxData(), sensorsBase_Init(), and systemParams_SetFromPart().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ systemParams_SetFromPart()

void systemParams_SetFromPart ( const uint8_t * buffer,
uint8_t bufSize )

The setting of systemParams_t from server dowlink. The buffer contains the combination for setting of value
.

2-SensTimeoutMeasure,4,
[2][C0D40100] - the setting for SensTimeoutMeasure -> inx:2 size:4, value:4bytes (120000)
3-SensAltitude,2
[3][4803] - the setting for SensAltitude -> inx:3 size:2, value:2bytes (840)
in buffer: [2][C0D40100]|[3][4803] or [3][4803]|[2][C0D40100]

Definition at line 329 of file mysensors_base.c.

References _systemParamRef, _systemParams, systemParams_SetCRCSystemParams(), systemParamsRef_Get(), and writeLog().

Referenced by OnLoRaWANRxData().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ _batPercLevel

uint8_t _batPercLevel
extern

The battery percentage level on start - the value is stored in CayeneeLPP buffer

level of battery percentage on start

Definition at line 136 of file mysensors_base.c.

Referenced by main(), and sensors_CayennelFromBckData().

◆ _measureNFC

measureNFC_t _measureNFC
extern

◆ _systemParams

◆ _systemParamsBck

systemParams_t _systemParamsBck
extern

Global system parameters backup buffer for NFC reading and and for sending via downlink to server

Definition at line 85 of file mysensors_base.c.

Referenced by nfc_Init(), nfc_ReadSystemParams(), nfc_ReadSystemParamsToBck(), and OnLoRaWANRxData().

◆ _tryInit

int8_t _tryInit
extern

Flag used by xxx_Is() calls; when set to 1, the Is function attempts to (re-)initialize the sensor

Definition at line 134 of file mysensors_base.c.

Referenced by nfc_FactoryReset(), nfc_ReadMeasureNFC(), nfc_ReadSystemParams(), nfc_ReadSystemParamsToBck(), nfc_WriteMeasureData(), nfc_WriteMeasureNFC(), nfc_WriteSystemParams(), and sensors_Read().