L14-Click 1.0
STM32WLE5CC LoRaWAN Sensor Platform
Loading...
Searching...
No Matches
mysensors.h File Reference
#include "stm32wlxx_hal.h"
#include "mymems.h"
Include dependency graph for mysensors.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  sens_ProcessDef_t {
  SENS_BEGIN = 0 , SENS_INIT , SENS_START , SENS_READ ,
  SENS_STOP , SENS_DATAREADY , SENS_SERVICE , SENS_END ,
  SENS_DONE
}
 State machine states for the sensor reading process. More...

Functions

void sensors_Init (I2C_HandleTypeDef *hi2c)
 Initialization of all sensors, must be called before for store of hi2c handler.
void sensorsSeq_Init (uint32_t sensortAppBit, uint32_t mylorawanAppBit)
 the sensors sequencer initialization and set the process in sequencer
void sensors_CopyToBck ()
 The copying data from current sensors buffer to backUp - _bck_XXXXX.
uint8_t * sensors_CayennelFromBckData (uint8_t *sizeOut, SysTime_t *prevMeasureTime)
 collecting sensor data into CayenneLppGetBuffer buffer for sending them via LoRaWan, the methods works with _bck_XXXXX sensor data, not with real.
The measure time is added only if time distance is bigger than 1min:
void sensors_WriteFromBckToDataBlock (mems_DataBlock_t *data)
 filling the data block from sensor data - store to memory the methods works with _bck_XXXXX senzor, not with real at the begin is writte the timeout of sensor measuring in minutes * 100
uint8_t sensors_ReadToBckFromDataBlock (const mems_DataBlock_t *data)
 reading from memory block and filling specified sensor from memory - ready for sensors_CayennelData the methods works with _bck_XXXXX senzor, not with real
SysTime_t sensors_GetTimeFromBlock (const mems_DataBlock_t *data)
 getting the SysTime_t from block data of memory
void sensors_Retiming ()
 stop and start of sensor timer for next measure
void i2c_OnOff (uint8_t onOff)
 possible to I2C turn on/off - cumulative
void sensors_Start ()
 
  • non squncer processing start of reading - prepare of internal state machine

sens_ProcessDef_t sensors_Work ()
 
  • no sequncer processing reading data from sensor according to group specification

Enumeration Type Documentation

◆ sens_ProcessDef_t

State machine states for the sensor reading process.

The state machine is driven either by the sequencer (timer-based) or by direct polling via sensors_Start() / sensors_Work(). It progresses sequentially through the states; completion is signalled when SENS_DONE is returned.

Enumerator
SENS_BEGIN 

Entry state: I2C is initialised and the sequence is prepared

SENS_INIT 

Sensor initialisation: each active sensor is (re-)initialised if not already

SENS_START 

Sensors powered on (xxx_On() called for the current group)

SENS_READ 

Data read issued (xxx_Read() called for the current group)

SENS_STOP 

Sensors powered off (xxx_Off() called for the current group)

SENS_DATAREADY 

All sensor data collected; ready for post-processing or LoRa uplink

SENS_SERVICE 

Service actions executed (e.g. SPS30 fan cleaning); data may be unavailable

SENS_END 

Sequence complete: I2C is de-initialised for power saving

SENS_DONE 

Final state: caller may read sensor data and schedule the next cycle

Definition at line 25 of file mysensors.h.

Function Documentation

◆ i2c_OnOff()

void i2c_OnOff ( uint8_t onOff)

possible to I2C turn on/off - cumulative

Definition at line 190 of file mysensors.c.

References _i2cOnOff, MX_I2C2_DeInit(), MX_I2C2_Init(), Power3v3_Off(), and Power3v3_On().

Referenced by main(), nfc_FactoryReset(), nfc_ReadMeasureNFC(), nfc_ReadSystemParams(), nfc_WriteMeasureData(), nfc_WriteMeasureNFC(), nfc_WriteSystemParams(), and sensors_Work().

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

◆ sensors_CayennelFromBckData()

uint8_t * sensors_CayennelFromBckData ( uint8_t * sizeOut,
SysTime_t * prevMeasureTime )

collecting sensor data into CayenneLppGetBuffer buffer for sending them via LoRaWan, the methods works with _bck_XXXXX sensor data, not with real.
The measure time is added only if time distance is bigger than 1min:

  • UNIX - absolute time, if distance between times is bigger than 65353 minutes(45.5days), CayenneLppAddTimeMeasureABS
  • relative, minutes 16 - max 65535 is distance is bigger than 255 minutes (4.25h), CayenneLppAddTimeMeasureMIN16
  • relative, minute 8 - max 255, if distance between measured data is less than 255 minutes, CayenneLppAddTimeMeasureMIN16
Parameters
sizeOut- the size(bytes) in buffer, the size is max 254, uint8_t is enough
prevMeasureTimethe previous measure time, 0 or NULL - is not specified, no time is added
Returns
address of buffer or null, if no data

Definition at line 488 of file mysensors.c.

References _, _batPercLevel, _bck_bar_bmp585Data, _bck_tmphm_sht45Data, _memsMainBlock, CayenneLppAddBarometricPressure(), CayenneLppAddBatteryPerc(), CayenneLppAddConcentration(), CayenneLppAddLuminosity(), CayenneLppAddParticulateMatter_1_0(), CayenneLppAddParticulateMatter_2_5(), CayenneLppAddRelativeHumidity(), CayenneLppAddTemperature(), CayenneLppAddTimeMeasureABS(), CayenneLppAddTimeMeasureMIN16(), CayenneLppAddTimeMeasureMIN8(), CayenneLppGetBuffer(), CayenneLppGetSize(), CayenneLppReset(), mems_WriteMainBlock(), PRIf_02, PRIf_02D, sensBuffer_Add(), sensBuffer_Reset(), sensBuffer_Send(), and SYSTEMPARAMS_BATTIMESEND.

Referenced by myloraWan_PrepareSendingBuffer().

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

◆ sensors_CopyToBck()

void sensors_CopyToBck ( )

The copying data from current sensors buffer to backUp - _bck_XXXXX.

Definition at line 463 of file mysensors.c.

References _bar_bmp585Data, _bck_bar_bmp585Data, _bck_tmphm_sht45Data, and _tmphm_sht45Data.

Referenced by myloraWan_MeasureFinish().

Here is the caller graph for this function:

◆ sensors_GetTimeFromBlock()

SysTime_t sensors_GetTimeFromBlock ( const mems_DataBlock_t * data)

getting the SysTime_t from block data of memory

Return values
thetime of measure - UNIX time

Definition at line 683 of file mysensors.c.

References mems_DataBlock_t::Data.

Referenced by myLoraWan_LastDataSend(), and myloraWan_MeasureFinish().

Here is the caller graph for this function:

◆ sensors_Init()

void sensors_Init ( I2C_HandleTypeDef * hi2c)

Initialization of all sensors, must be called before for store of hi2c handler.

Parameters
hi2c

Definition at line 413 of file mysensors.c.

References _, _sensors, getCount_Sensors(), SENS_GRP_ALL, sensors_OnOff(), systemParams_IsSensorAvaiable(), and writeLog().

Referenced by main(), and sensors_Work().

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

◆ sensors_ReadToBckFromDataBlock()

uint8_t sensors_ReadToBckFromDataBlock ( const mems_DataBlock_t * data)

reading from memory block and filling specified sensor from memory - ready for sensors_CayennelData the methods works with _bck_XXXXX senzor, not with real

Return values
sizeof total read from data block, 0 - if is other than expected data

Definition at line 646 of file mysensors.c.

References _, _bck_bar_bmp585Data, _bck_tmphm_sht45Data, mems_DataBlock_t::Data, MEMS_DATATYPE_SENSOR, and mems_DataBlock_t::Type.

Referenced by myloraWan_PrepareSendingBuffer().

Here is the caller graph for this function:

◆ sensors_Retiming()

void sensors_Retiming ( )

stop and start of sensor timer for next measure

Definition at line 438 of file mysensors.c.

References _, _systemParams, and tasksensors_OnTimeout().

Referenced by main(), and tasksensors_Work().

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

◆ sensors_Start()

void sensors_Start ( )

  • non squncer processing start of reading - prepare of internal state machine

Definition at line 333 of file mysensors.c.

References _, SENS_BEGIN, sensors_NextGroup(), and sleeper_SetSleepMS().

Referenced by tasksensors_OnTimeout().

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

◆ sensors_Work()

sens_ProcessDef_t sensors_Work ( )

  • no sequncer processing reading data from sensor according to group specification

Returns
SENS_DONE - process of reading finished, otherwise current state of status machine

Definition at line 342 of file mysensors.c.

References _, _groupTiming, i2c_OnOff(), SENS_BEGIN, SENS_DATAREADY, SENS_DONE, SENS_END, SENS_INIT, SENS_READ, SENS_SERVICE, SENS_START, SENS_STOP, sensors_Init(), sensors_NextGroup(), sensors_OnOff(), sensors_Read(), sensors_Service(), sleeper_IsElapsed(), sleeper_Next(), sleeper_SetSleepMS(), and togle_LedOff().

Referenced by tasksensors_Work().

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

◆ sensors_WriteFromBckToDataBlock()

void sensors_WriteFromBckToDataBlock ( mems_DataBlock_t * data)

filling the data block from sensor data - store to memory the methods works with _bck_XXXXX senzor, not with real at the begin is writte the timeout of sensor measuring in minutes * 100

Definition at line 604 of file mysensors.c.

References _, _bck_bar_bmp585Data, _bck_tmphm_sht45Data, mems_DataBlock_t::Data, Error_Handler(), MEMS_DATATYPE_SENSOR, SENSORS_DATASIZE, mems_DataBlock_t::Size, mems_DataBlock_t::Type, and writeLog().

Referenced by myloraWan_MeasureFinish().

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

◆ sensorsSeq_Init()

void sensorsSeq_Init ( uint32_t sensortAppBit,
uint32_t mylorawanAppBit )

the sensors sequencer initialization and set the process in sequencer

  • create task
  • create timer
  • process data
  • fire event CFG_SEQ_Task_MyLoraSend - data are ready for loraWan processing
Parameters
sensortAppBit- bit for task
mylorawanAppBit- bit for event firing

the sensors sequencer initialization and set the process in sequencer

Definition at line 454 of file mysensors.c.

References _, tasksensors_OnTimeout(), and tasksensors_Work().

Referenced by main().

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