49#define SERVER_REG_NEED_SET (0)
50#define SERVER_REG_NEED_CLEAR (1)
51#define CO2_READ_TIMER_EXPIRE_SET (1)
52#define CO2_READ_TIMER_EXPIRE_CLEAR (0)
53#define OBSERVE_COMPLETE_SET (1)
54#define OBSERVE_COMPLETE_CLEAR (0)
55#define UART_RECEIVE_COMPLETE_SET (0x00)
56#define UART_RECEIVE_COMPLETE_CLEAR (0xFF)
57#define TIME_180SEC (pdMS_TO_TICKS(180000))
58#define TIME_90SEC (pdMS_TO_TICKS(90000))
59#define TIMER_ID_CLEAR (0)
63#define CO2_APP_STACK_SIZE (512)
70#define LWM2M_SERVER_MONITORING_TIME (TIME_180SEC)
71#define CO2_SENSOR_READ_TIME (TIME_90SEC)
77#define CO2_CMD_ID_21 (0x21)
78#define CO2_CMD_ID_23 (0x23)
80 .sop=0x5B,.ver=0x01,.cmd=0x23,.len=1,.data=0,.crc=0x0A74,.eop=0x5D};
82 .sop=0x5B,.ver=0x01,.cmd=0x21,.len=1,.data=0,.crc=0x8A5F,.eop=0x5D};
104#define CRC_TABLE_SIZE 256
105#define CRC16_POLY 0x8005
106#define CRC16_INIT_REM 0x0000
107#define CRC16_FINAL_XOR 0x0000
121 const unsigned short *table,
122 unsigned char *pbuffer,
123 unsigned int length);
131#define MZ_ADDONCO2_INSTANCE (LPUART1)
132#define MZ_ADDONCO2_INIT_BAUDRATE (57600)
133#define MZ_ADDONCO2_INIT_WORDLENGTH (UART_WORDLENGTH_8B)
134#define MZ_ADDONCO2_INIT_STOPBITS (UART_STOPBITS_1)
135#define MZ_ADDONCO2_INIT_PARITY (UART_PARITY_NONE)
136#define MZ_ADDONCO2_INIT_MODE (UART_MODE_TX_RX)
137#define MZ_ADDONCO2_INIT_HWFLOWCTL (UART_HWCONTROL_NONE)
138#define MZ_ADDONCO2_INIT_OVERSAMPLING (UART_OVERSAMPLING_16)
139#define MZ_ADDONCO2_INIT_ONEBITSAMPLING (UART_ONE_BIT_SAMPLE_DISABLE)
140#define MZ_ADDONCO2_ADVANCEDINIT_ADVFEATUREINIT (UART_ADVFEATURE_NO_INIT)
141#define MZ_ADDONCO2_UART_INSTANCE (_LPUART1)
267 mz_puts(
"Server monitoring timer creation failed\r\n");
275 mz_puts(
"Server re-reg sequence started\r\n");
280 mz_puts(
"Server re-reg sequence failed\r\n");
325 mz_puts(
"Notify send to MonoZ_Lib\r\n");
465 mz_puts(
"Server monitoring timer started\r\n");
481 mz_puts(
"co2 sensor reading timer started\r\n");
574 if(
MZ_OK != _ret)
goto clean;
595 if(
MZ_OK != _ret)
goto clean;
597 if(
MZ_OK != _ret)
goto clean;
637 mz_puts(
"Observe received\r\n");
639 if(e->lw_Obj_id == 19 && e->lw_Obj_Ins_id == 0 && e->lw_Res_id == 0)
647 mz_puts(
"Notify send to server\r\n");
651 mz_puts(
"Notify send acknowledge\r\n");
655 mz_puts(
"Notify send failed\r\n");
701 0x0000, 0x8005, 0x800F, 0x000A,
702 0x801B, 0x001E, 0x0014, 0x8011,
703 0x8033, 0x0036, 0x003C, 0x8039,
704 0x0028, 0x802D, 0x8027, 0x0022,
705 0x8063, 0x0066, 0x006C, 0x8069,
706 0x0078, 0x807D, 0x8077, 0x0072,
707 0x0050, 0x8055, 0x805F, 0x005A,
708 0x804B, 0x004E, 0x0044, 0x8041,
709 0x80C3, 0x00C6, 0x00CC, 0x80C9,
710 0x00D8, 0x80DD, 0x80D7, 0x00D2,
711 0x00F0, 0x80F5, 0x80FF, 0x00FA,
712 0x80EB, 0x00EE, 0x00E4, 0x80E1,
713 0x00A0, 0x80A5, 0x80AF, 0x00AA,
714 0x80BB, 0x00BE, 0x00B4, 0x80B1,
715 0x8093, 0x0096, 0x009C, 0x8099,
716 0x0088, 0x808D, 0x8087, 0x0082,
717 0x8183, 0x0186, 0x018C, 0x8189,
718 0x0198, 0x819D, 0x8197, 0x0192,
719 0x01B0, 0x81B5, 0x81BF, 0x01BA,
720 0x81AB, 0x01AE, 0x01A4, 0x81A1,
721 0x01E0, 0x81E5, 0x81EF, 0x01EA,
722 0x81FB, 0x01FE, 0x01F4, 0x81F1,
723 0x81D3, 0x01D6, 0x01DC, 0x81D9,
724 0x01C8, 0x81CD, 0x81C7, 0x01C2,
725 0x0140, 0x8145, 0x814F, 0x014A,
726 0x815B, 0x015E, 0x0154, 0x8151,
727 0x8173, 0x0176, 0x017C, 0x8179,
728 0x0168, 0x816D, 0x8167, 0x0162,
729 0x8123, 0x0126, 0x012C, 0x8129,
730 0x0138, 0x813D, 0x8137, 0x0132,
731 0x0110, 0x8115, 0x811F, 0x011A,
732 0x810B, 0x010E, 0x0104, 0x8101,
733 0x8303, 0x0306, 0x030C, 0x8309,
734 0x0318, 0x831D, 0x8317, 0x0312,
735 0x0330, 0x8335, 0x833F, 0x033A,
736 0x832B, 0x032E, 0x0324, 0x8321,
737 0x0360, 0x8365, 0x836F, 0x036A,
738 0x837B, 0x037E, 0x0374, 0x8371,
739 0x8353, 0x0356, 0x035C, 0x8359,
740 0x0348, 0x834D, 0x8347, 0x0342,
741 0x03C0, 0x83C5, 0x83CF, 0x03CA,
742 0x83DB, 0x03DE, 0x03D4, 0x83D1,
743 0x83F3, 0x03F6, 0x03FC, 0x83F9,
744 0x03E8, 0x83ED, 0x83E7, 0x03E2,
745 0x83A3, 0x03A6, 0x03AC, 0x83A9,
746 0x03B8, 0x83BD, 0x83B7, 0x03B2,
747 0x0390, 0x8395, 0x839F, 0x039A,
748 0x838B, 0x038E, 0x0384, 0x8381,
749 0x0280, 0x8285, 0x828F, 0x028A,
750 0x829B, 0x029E, 0x0294, 0x8291,
751 0x82B3, 0x02B6, 0x02BC, 0x82B9,
752 0x02A8, 0x82AD, 0x82A7, 0x02A2,
753 0x82E3, 0x02E6, 0x02EC, 0x82E9,
754 0x02F8, 0x82FD, 0x82F7, 0x02F2,
755 0x02D0, 0x82D5, 0x82DF, 0x02DA,
756 0x82CB, 0x02CE, 0x02C4, 0x82C1,
757 0x8243, 0x0246, 0x024C, 0x8249,
758 0x0258, 0x825D, 0x8257, 0x0252,
759 0x0270, 0x8275, 0x827F, 0x027A,
760 0x826B, 0x026E, 0x0264, 0x8261,
761 0x0220, 0x8225, 0x822F, 0x022A,
762 0x823B, 0x023E, 0x0234, 0x8231,
763 0x8213, 0x0216, 0x021C, 0x8219,
764 0x0208, 0x820D, 0x8207, 0x0202
778 const unsigned short *table,
779 unsigned char *pbuffer,
784 crc = table[((crc >> 8) ^ *pbuffer++)] ^ (crc << 8);
static void create_lwm2m_payload(void)
LWM2M Create payload API - START This API will be used to create the payload string/buffer from co2 f...
#define CO2_READ_TIMER_EXPIRE_CLEAR
Clear the Timer Expire for CO2 read.
#define MZ_ADDONCO2_INIT_PARITY
Defines the initial parity.
static void process_resp23(void)
CO2 sensor resp23 processing API - START This API will be used to process the response received from ...
#define CO2_CMD_ID_23
Defines cmd23 id.
#define MZ_ADDONCO2_INIT_HWFLOWCTL
Defines initial hardware flow control.
static char lwm2m_server_rereg_flag
const unsigned short crc16Table[CRC_TABLE_SIZE]
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 rea...
static mz_error_t co2_uart_init(void)
CO2 UART related initialization - START This Timer callback will be called after the server monitorin...
#define CO2_SENSOR_READ_TIME
Set 90 seconds timer for read sensor data.
static volatile char co2_uart_recv_complete_flag
MZ_UART_INIT_ST co2_lpuart1_instance
static void lwm2m_server_monitoring_timer_cb(TimerHandle_t xTimer)
LWM2M server registration monitoring timer callback - START This Timer callback will be called after ...
static st_co2_cmd_resp21 resp21
#define MZ_ADDONCO2_INSTANCE
Defines the instance.
#define TIMER_ID_CLEAR
Clear the timer id.
#define MZ_ADDONCO2_INIT_ONEBITSAMPLING
Defines the initial one bit sampling.
static mz_thread_t co2_thread_id
static void process_resp21(void)
CO2 sensor resp21 processing API - START This API will be used to process the response received from ...
#define SERVER_REG_NEED_CLEAR
Clear the server Registration.
static unsigned char decimal_place
#define MZ_ADDONCO2_INIT_OVERSAMPLING
Defines the initial oversampling.
#define UART_RECEIVE_COMPLETE_CLEAR
Clear the UART Receive.
#define MZ_ADDONCO2_UART_INSTANCE
Defimes the UART instance.
#define SERVER_REG_NEED_SET
Sets the server registration.
static unsigned short crc16MakeTableMethod(unsigned short crc, const unsigned short *table, unsigned char *pbuffer, unsigned int length)
calculating crc value
static char co2_read_timer_expire_flag
#define CO2_CMD_ID_21
Defines cmd21 id.
void mz_reboot_sequence(void *arg)
This is the function prototype used for sending AT cmds used in server re-registration.
#define OBSERVE_COMPLETE_CLEAR
Clear the Observe Complete.
#define CO2_READ_TIMER_EXPIRE_SET
Set the Timer Expire for CO2 read.
static char observe_receive_flag
#define CRC_TABLE_SIZE
Defines the crc table size.
void lwm2m_event_process(void *event)
LWM2M user defined callback function.
mz_error_t co2_app_init(void)
CO2 Application initialization API.
static st_co2_cmd_resp23 resp23
#define CRC16_INIT_REM
Defines the CRC16_INIT_REM value.
#define CRC16_FINAL_XOR
Defines the CRC16_FINAL_XOR value.
static void co2_lpuart1_rx_intr(void *arg)
CO2 UART related callback - START This UART callback will be called after completion of uart receive.
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.
#define MZ_ADDONCO2_ADVANCEDINIT_ADVFEATUREINIT
Defines the Uart advance features.
#define OBSERVE_COMPLETE_SET
Set the Observe Complete.
static StackType_t co2_stack[CO2_APP_STACK_SIZE]
#define MZ_ADDONCO2_INIT_BAUDRATE
Defines the baud rate.
static volatile long int final_co2_value
#define MZ_ADDONCO2_INIT_MODE
Defines the mode.
#define MZ_ADDONCO2_INIT_STOPBITS
Defines the stop bits.
#define CO2_APP_STACK_SIZE
Stack size for the thread */.
#define MZ_ADDONCO2_INIT_WORDLENGTH
Defines the initial word length.
static void lwm2m_server_reregistration(void)
LWM2M server re-registration API - START This API will be used to start the Server re-registration pr...
static volatile long int co2_raw
static char payload_string[11]
#define UART_RECEIVE_COMPLETE_SET
Sets the UART Receive.
static size_t lwm2m_server_monitoring_timer_id
static void co2_app_thread(void *arg)
CO2 main Application thread.
#define LWM2M_SERVER_MONITORING_TIME
Set 180 seconds timer for server Monitoring.
static StaticTask_t co2_cb_mem
monoZ LWM2M public Protocol
@ LW_EV_CLIENT_NOTIFY_SEND
@ LW_EV_CLIENT_NOTIFY_SEND_ACK
monoZ Modem public Protocol
mz_error_t
Enumeration of monoZ Error Flags.
monoZ system CMSIS OS2 This is an abstraction layer and includes FreeRTOS configuration,...
osThreadId_t mz_thread_t
mz_thread_t variable of type osThreadId_t
This file contains APIs for create,delete,start and stop of timers. Maximum 5 timers can be created....
monoZ Type Converter This file contains the APIs used to hex to ascii and ascii to hex conversion
This file includes monoZ Uart Related APIs.
const char * mz_error_to_str(mz_error_t e)
This function is used to convert the monoZ error code to corresponding error message.
mz_error_t mz_set_value_Ob19_0_0(char *src)
This function writes 19/0/0 value to internal resource structure.
mz_error_t mz_set_value_Ob19_1_0(char *src)
This function writes 19/1/0 value to internal resource structure.
mz_error_t mz_set_and_notify_Ob19_0_0(char *src)
This function writes 19/0/0 value to internal resource structure and then notify to server.
mz_error_t MZ_modem_config_set(_mz_fp _fp)
This function is used to check modem configuration is set or not set.
int mz_puts(void *__ch)
This function prints the given string.
uint8_t mz_thread_create(mz_thread_t *t, const char *name, mz_fn thread_func, void *const arg, mz_thread_prio_t prio, StackType_t *stack_mem, size_t stack_size, StaticTask_t *cb_mem, uint32_t cb_size)
This function is used to check the message queue object validity Create a thread and add it to Active...
mz_error_t mz_tm_create_start_recursive(char *_name, TickType_t _tick, mz_tm_cb _cb)
Function to Create and Start One Shot Timers.
mz_error_t mz_tm_start(size_t _id)
Function to Start the Timer.
size_t mz_tm_create_one(char *_name, TickType_t _tick, mz_tm_cb _cb)
Function to Create a One Shot Timer.
mz_error_t MZ_UART_Transmit(uint8_t uart_no, uint8_t *pData, uint16_t Size, uint32_t Timeout)
This function is used to transmit data using UART in polling mode.
mz_error_t MZ_UART_register_intr_cb_rx(uint8_t uart_no, _uart_api cb)
This function registers the RX complete callback function for the specific UART.
mz_error_t MZ_UART_Receive_IT(uint8_t uart_no, uint8_t *pData, uint16_t Size)
This function is used to receive data using UART in interrupt mode.
Structure for monoZ UART Initialization parameters.
CO2 sensor Receive response structure format for cmd21.
CO2 sensor Receive response structure format for cmd23.
CO2 sensor Transmit cmd structure format.