monoZ docs
|
This is the example for read the CO2 sensor data and send it to platform. More...
#include "MZ_Addon_board_CO2.h"
#include "MZ_sys_cmsis_os2.h"
#include "MZ_error_handler.h"
#include "MZ_timer.h"
#include "MZ_print.h"
#include "MZ_Lwm2m_public.h"
#include "MZ_type_converter.h"
#include "MZ_Modem_public.h"
#include "MZ_uart.h"
#include "MZ_main.h"
#include "stdlib.h"
Go to the source code of this file.
Macros | |
#define | SERVER_REG_NEED_SET (0) |
Sets the server registration. More... | |
#define | SERVER_REG_NEED_CLEAR (1) |
Clear the server Registration. More... | |
#define | CO2_READ_TIMER_EXPIRE_SET (1) |
Set the Timer Expire for CO2 read. More... | |
#define | CO2_READ_TIMER_EXPIRE_CLEAR (0) |
Clear the Timer Expire for CO2 read. More... | |
#define | OBSERVE_COMPLETE_SET (1) |
Set the Observe Complete. More... | |
#define | OBSERVE_COMPLETE_CLEAR (0) |
Clear the Observe Complete. More... | |
#define | UART_RECEIVE_COMPLETE_SET (0x00) |
Sets the UART Receive. More... | |
#define | UART_RECEIVE_COMPLETE_CLEAR (0xFF) |
Clear the UART Receive. More... | |
#define | TIME_180SEC (pdMS_TO_TICKS(180000)) |
Timer is set for 180 seconds. More... | |
#define | TIME_90SEC (pdMS_TO_TICKS(90000)) |
Timer is set for 90 seconds. More... | |
#define | TIMER_ID_CLEAR (0) |
Clear the timer id. More... | |
#define | CO2_APP_STACK_SIZE (512) |
Stack size for the thread */. More... | |
#define | LWM2M_SERVER_MONITORING_TIME (TIME_180SEC) |
Set 180 seconds timer for server Monitoring. More... | |
#define | CO2_SENSOR_READ_TIME (TIME_90SEC) |
Set 90 seconds timer for read sensor data. More... | |
#define | CO2_CMD_ID_21 (0x21) |
Defines cmd21 id. More... | |
#define | CO2_CMD_ID_23 (0x23) |
Defines cmd23 id. More... | |
#define | CRC_TABLE_SIZE 256 |
Defines the crc table size. More... | |
#define | CRC16_POLY 0x8005 |
Defines the CRC16_POLY value. More... | |
#define | CRC16_INIT_REM 0x0000 |
Defines the CRC16_INIT_REM value. More... | |
#define | CRC16_FINAL_XOR 0x0000 |
Defines the CRC16_FINAL_XOR value. More... | |
#define | MZ_ADDONCO2_INSTANCE (LPUART1) |
Defines the instance. More... | |
#define | MZ_ADDONCO2_INIT_BAUDRATE (57600) |
Defines the baud rate. More... | |
#define | MZ_ADDONCO2_INIT_WORDLENGTH (UART_WORDLENGTH_8B) |
Defines the initial word length. More... | |
#define | MZ_ADDONCO2_INIT_STOPBITS (UART_STOPBITS_1) |
Defines the stop bits. More... | |
#define | MZ_ADDONCO2_INIT_PARITY (UART_PARITY_NONE) |
Defines the initial parity. More... | |
#define | MZ_ADDONCO2_INIT_MODE (UART_MODE_TX_RX) |
Defines the mode. More... | |
#define | MZ_ADDONCO2_INIT_HWFLOWCTL (UART_HWCONTROL_NONE) |
Defines initial hardware flow control. More... | |
#define | MZ_ADDONCO2_INIT_OVERSAMPLING (UART_OVERSAMPLING_16) |
Defines the initial oversampling. More... | |
#define | MZ_ADDONCO2_INIT_ONEBITSAMPLING (UART_ONE_BIT_SAMPLE_DISABLE) |
Defines the initial one bit sampling. More... | |
#define | MZ_ADDONCO2_ADVANCEDINIT_ADVFEATUREINIT (UART_ADVFEATURE_NO_INIT) |
Defines the Uart advance features. More... | |
#define | MZ_ADDONCO2_UART_INSTANCE (_LPUART1) |
Defimes the UART instance. More... | |
Functions | |
void | mz_reboot_sequence (void *arg) |
This is the function prototype used for sending AT cmds used in server re-registration. More... | |
static mz_error_t | co2_uart_init (void) |
CO2 UART related initialization - START This Timer callback will be called after the server monitoring timer is expired.The timer value is set as LWM2M_SERVER_MONITORING_TIME. More... | |
static void | lwm2m_server_monitoring_timer_cb (TimerHandle_t xTimer) |
LWM2M server registration monitoring timer callback - START This Timer callback will be called after the server monitoring timer is expired.The timer value is set as LWM2M_SERVER_MONITORING_TIME. More... | |
static void | co2_sensor_read_timer_cb (TimerHandle_t xTimer) |
co2 sensor reading timer callback - START This Timer callback will be called after the co2 sensor reading timer is expired.The timer value is set as CO2_SENSOR_READ_TIME More... | |
static void | lwm2m_server_reregistration (void) |
LWM2M server re-registration API - START This API will be used to start the Server re-registration process. More... | |
static void | create_lwm2m_payload (void) |
LWM2M Create payload API - START This API will be used to create the payload string/buffer from co2 final value received after processing of raw value. More... | |
static void | send_payload_to_server (void) |
LWM2M send payload API - START This API will be used to send the payload string/buffer to MonoZ_Lib. More... | |
static void | process_resp23 (void) |
CO2 sensor resp23 processing API - START This API will be used to process the response received from co2 sensor for cmd23. More... | |
static void | process_resp21 (void) |
CO2 sensor resp21 processing API - START This API will be used to process the response received from co2 sensor for cmd21. More... | |
static void | co2_app_thread (void *arg) |
CO2 main Application thread. More... | |
static unsigned short | crc16MakeTableMethod (unsigned short crc, const unsigned short *table, unsigned char *pbuffer, unsigned int length) |
calculating crc value More... | |
static void | co2_lpuart1_rx_intr (void *arg) |
CO2 UART related callback - START This UART callback will be called after completion of uart receive. More... | |
mz_error_t | co2_app_init (void) |
CO2 Application initialization API. More... | |
void | lwm2m_event_process (void *event) |
LWM2M user defined callback function. More... | |
Variables | |
static mz_thread_t | co2_thread_id = NULL |
static StaticTask_t | co2_cb_mem |
static StackType_t | co2_stack [CO2_APP_STACK_SIZE] |
static size_t | lwm2m_server_monitoring_timer_id = TIMER_ID_CLEAR |
static char | co2_read_timer_expire_flag = CO2_READ_TIMER_EXPIRE_CLEAR |
static st_co2_cmd | cmd23 |
static st_co2_cmd | cmd21 |
static st_co2_cmd_resp23 | resp23 |
static st_co2_cmd_resp21 | resp21 |
static unsigned char | decimal_place = 0 |
static volatile long int | co2_raw = 0 |
static volatile long int | final_co2_value = 0 |
static char | lwm2m_server_rereg_flag = SERVER_REG_NEED_CLEAR |
static char | observe_receive_flag = OBSERVE_COMPLETE_CLEAR |
static char | payload_string [11] = "" |
const unsigned short | crc16Table [CRC_TABLE_SIZE] |
MZ_UART_INIT_ST | co2_lpuart1_instance |
static volatile char | co2_uart_recv_complete_flag = UART_RECEIVE_COMPLETE_CLEAR |
This is the example for read the CO2 sensor data and send it to platform.
Definition in file MZ_Addon_board_CO2.c.
#define SERVER_REG_NEED_SET (0) |
Sets the server registration.
Definition at line 49 of file MZ_Addon_board_CO2.c.
#define SERVER_REG_NEED_CLEAR (1) |
Clear the server Registration.
Definition at line 50 of file MZ_Addon_board_CO2.c.
#define CO2_READ_TIMER_EXPIRE_SET (1) |
Set the Timer Expire for CO2 read.
Definition at line 51 of file MZ_Addon_board_CO2.c.
#define CO2_READ_TIMER_EXPIRE_CLEAR (0) |
Clear the Timer Expire for CO2 read.
Definition at line 52 of file MZ_Addon_board_CO2.c.
#define OBSERVE_COMPLETE_SET (1) |
Set the Observe Complete.
Definition at line 53 of file MZ_Addon_board_CO2.c.
#define OBSERVE_COMPLETE_CLEAR (0) |
Clear the Observe Complete.
Definition at line 54 of file MZ_Addon_board_CO2.c.
#define UART_RECEIVE_COMPLETE_SET (0x00) |
Sets the UART Receive.
Definition at line 55 of file MZ_Addon_board_CO2.c.
#define UART_RECEIVE_COMPLETE_CLEAR (0xFF) |
Clear the UART Receive.
Definition at line 56 of file MZ_Addon_board_CO2.c.
#define TIME_180SEC (pdMS_TO_TICKS(180000)) |
Timer is set for 180 seconds.
Definition at line 57 of file MZ_Addon_board_CO2.c.
#define TIME_90SEC (pdMS_TO_TICKS(90000)) |
Timer is set for 90 seconds.
Definition at line 58 of file MZ_Addon_board_CO2.c.
#define TIMER_ID_CLEAR (0) |
Clear the timer id.
Definition at line 59 of file MZ_Addon_board_CO2.c.
#define CO2_APP_STACK_SIZE (512) |
Stack size for the thread */.
Definition at line 63 of file MZ_Addon_board_CO2.c.
#define LWM2M_SERVER_MONITORING_TIME (TIME_180SEC) |
Set 180 seconds timer for server Monitoring.
Definition at line 70 of file MZ_Addon_board_CO2.c.
#define CO2_SENSOR_READ_TIME (TIME_90SEC) |
Set 90 seconds timer for read sensor data.
Definition at line 71 of file MZ_Addon_board_CO2.c.
#define CO2_CMD_ID_21 (0x21) |
Defines cmd21 id.
Definition at line 77 of file MZ_Addon_board_CO2.c.
#define CO2_CMD_ID_23 (0x23) |
Defines cmd23 id.
Definition at line 78 of file MZ_Addon_board_CO2.c.
#define CRC_TABLE_SIZE 256 |
Defines the crc table size.
Definition at line 104 of file MZ_Addon_board_CO2.c.
#define CRC16_POLY 0x8005 |
Defines the CRC16_POLY value.
Definition at line 105 of file MZ_Addon_board_CO2.c.
#define CRC16_INIT_REM 0x0000 |
Defines the CRC16_INIT_REM value.
Definition at line 106 of file MZ_Addon_board_CO2.c.
#define CRC16_FINAL_XOR 0x0000 |
Defines the CRC16_FINAL_XOR value.
Definition at line 107 of file MZ_Addon_board_CO2.c.
#define MZ_ADDONCO2_INSTANCE (LPUART1) |
Defines the instance.
Definition at line 131 of file MZ_Addon_board_CO2.c.
#define MZ_ADDONCO2_INIT_BAUDRATE (57600) |
Defines the baud rate.
Definition at line 132 of file MZ_Addon_board_CO2.c.
#define MZ_ADDONCO2_INIT_WORDLENGTH (UART_WORDLENGTH_8B) |
Defines the initial word length.
Definition at line 133 of file MZ_Addon_board_CO2.c.
#define MZ_ADDONCO2_INIT_STOPBITS (UART_STOPBITS_1) |
Defines the stop bits.
Definition at line 134 of file MZ_Addon_board_CO2.c.
#define MZ_ADDONCO2_INIT_PARITY (UART_PARITY_NONE) |
Defines the initial parity.
Definition at line 135 of file MZ_Addon_board_CO2.c.
#define MZ_ADDONCO2_INIT_MODE (UART_MODE_TX_RX) |
Defines the mode.
Definition at line 136 of file MZ_Addon_board_CO2.c.
#define MZ_ADDONCO2_INIT_HWFLOWCTL (UART_HWCONTROL_NONE) |
Defines initial hardware flow control.
Definition at line 137 of file MZ_Addon_board_CO2.c.
#define MZ_ADDONCO2_INIT_OVERSAMPLING (UART_OVERSAMPLING_16) |
Defines the initial oversampling.
Definition at line 138 of file MZ_Addon_board_CO2.c.
#define MZ_ADDONCO2_INIT_ONEBITSAMPLING (UART_ONE_BIT_SAMPLE_DISABLE) |
Defines the initial one bit sampling.
Definition at line 139 of file MZ_Addon_board_CO2.c.
#define MZ_ADDONCO2_ADVANCEDINIT_ADVFEATUREINIT (UART_ADVFEATURE_NO_INIT) |
Defines the Uart advance features.
Definition at line 140 of file MZ_Addon_board_CO2.c.
#define MZ_ADDONCO2_UART_INSTANCE (_LPUART1) |
Defimes the UART instance.
Definition at line 141 of file MZ_Addon_board_CO2.c.
void mz_reboot_sequence | ( | void * | arg | ) |
This is the function prototype used for sending AT cmds used in server re-registration.
This function is defined in MZ_modem_config.c
arg | void |
Definition at line 135 of file MZ_modem_config.c.
|
static |
CO2 UART related initialization - START This Timer callback will be called after the server monitoring timer is expired.The timer value is set as LWM2M_SERVER_MONITORING_TIME.
Definition at line 196 of file MZ_Addon_board_CO2.c.
|
static |
LWM2M server registration monitoring timer callback - START This Timer callback will be called after the server monitoring timer is expired.The timer value is set as LWM2M_SERVER_MONITORING_TIME.
xTimer | TimerHandle_t |
Definition at line 229 of file MZ_Addon_board_CO2.c.
|
static |
co2 sensor reading timer callback - START This Timer callback will be called after the co2 sensor reading timer is expired.The timer value is set as CO2_SENSOR_READ_TIME
xTimer | TimerHandle_t |
Definition at line 246 of file MZ_Addon_board_CO2.c.
|
static |
LWM2M server re-registration API - START This API will be used to start the Server re-registration process.
Definition at line 259 of file MZ_Addon_board_CO2.c.
|
static |
LWM2M Create payload API - START This API will be used to create the payload string/buffer from co2 final value received after processing of raw value.
Definition at line 290 of file MZ_Addon_board_CO2.c.
|
static |
LWM2M send payload API - START This API will be used to send the payload string/buffer to MonoZ_Lib.
It will also print if the sending of payload to MonoZ_Lib was successful or any error occurred
Definition at line 316 of file MZ_Addon_board_CO2.c.
|
static |
CO2 sensor resp23 processing API - START This API will be used to process the response received from co2 sensor for cmd23.
Definition at line 344 of file MZ_Addon_board_CO2.c.
|
static |
CO2 sensor resp21 processing API - START This API will be used to process the response received from co2 sensor for cmd21.
Definition at line 391 of file MZ_Addon_board_CO2.c.
|
static |
CO2 main Application thread.
START
arg | void |
Definition at line 437 of file MZ_Addon_board_CO2.c.
|
static |
calculating crc value
crc | unsigned short |
table | const unsigned short *, |
pbuffer | unsigned char * |
length | unsigned int |
Definition at line 777 of file MZ_Addon_board_CO2.c.
|
static |
CO2 UART related callback - START This UART callback will be called after completion of uart receive.
arg | void |
Definition at line 181 of file MZ_Addon_board_CO2.c.
mz_error_t co2_app_init | ( | void | ) |
CO2 Application initialization API.
START
Definition at line 564 of file MZ_Addon_board_CO2.c.
void lwm2m_event_process | ( | void * | event | ) |
LWM2M user defined callback function.
Process LWM2M Event.
event | void |
Definition at line 623 of file MZ_Addon_board_CO2.c.
|
static |
Thread id handler
Definition at line 64 of file MZ_Addon_board_CO2.c.
|
static |
Thread control block
Definition at line 65 of file MZ_Addon_board_CO2.c.
|
static |
Thread stack
Definition at line 66 of file MZ_Addon_board_CO2.c.
|
static |
Lwm2m server monitoring timer id - Initialize it to 0
Definition at line 72 of file MZ_Addon_board_CO2.c.
|
static |
Flag is created and cleared for sensor data read
Definition at line 73 of file MZ_Addon_board_CO2.c.
|
static |
Create the CO2 sensor cmd23. The data for each field is found in the sensor data sheet
Definition at line 79 of file MZ_Addon_board_CO2.c.
|
static |
Create the CO2 sensor cmd21. The data for each field is found in the sensor data sheet
Definition at line 81 of file MZ_Addon_board_CO2.c.
|
static |
Create a response buffer for cmd23
Definition at line 83 of file MZ_Addon_board_CO2.c.
|
static |
Create a response buffer for cmd21
Definition at line 84 of file MZ_Addon_board_CO2.c.
|
static |
Store Decimal place location received from Co2 sensor
Definition at line 85 of file MZ_Addon_board_CO2.c.
|
static |
Store co2 sensor raw value received from Co2 sensor
Definition at line 86 of file MZ_Addon_board_CO2.c.
|
static |
Store final co2 value after calculation from raw value and decimal place
Definition at line 87 of file MZ_Addon_board_CO2.c.
|
static |
Flag to monitor if server re-registration is required or not
Definition at line 91 of file MZ_Addon_board_CO2.c.
|
static |
Flag to check if observe is received or not
Definition at line 92 of file MZ_Addon_board_CO2.c.
|
static |
payload string buffer to pass the final payload information to MonoZ_Lib
Definition at line 93 of file MZ_Addon_board_CO2.c.
const unsigned short crc16Table |
Definition at line 700 of file MZ_Addon_board_CO2.c.
MZ_UART_INIT_ST co2_lpuart1_instance |
Definition at line 157 of file MZ_Addon_board_CO2.c.
|
static |
Flag to hold if the uart receive is complete or not
Definition at line 173 of file MZ_Addon_board_CO2.c.