Files
kunlun/app/smart_grid_extend/cco/iot_cusapp_cco.c

722 lines
21 KiB
C
Raw Normal View History

2024-09-28 14:24:04 +08:00
/****************************************************************************
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
be copied by any method or incorporated into another program without
the express written consent of Aerospace C.Power. This Information or any portion
thereof remains the property of Aerospace C.Power. The Information contained herein
is believed to be accurate and Aerospace C.Power assumes no responsibility or
liability for its use in any way and conveys no license or title under
any patent or copyright and makes no representation or warranty that this
Information is free from patent or copyright infringement.
****************************************************************************/
/* iot common header files */
#include "iot_io_api.h"
#include "iot_module_api.h"
#include "iot_errno_api.h"
#include "iot_task_api.h"
#include "iot_pkt_api.h"
#include "iot_ipc_api.h"
#include "iot_sg_ext_api.h"
#include "iot_board_api.h"
#include "iot_cusapp.h"
#include "iot_socket_api.h"
#include "iot_plc_msg_api.h"
#include "iot_plc_api.h"
#include "iot_app_api.h"
#include "iot_plc_msg_cco_api.h"
#include "iot_sg_ext_cco_api.h"
#include "iot_plc_cco_api.h"
#include "iot_utils_api.h"
#include "proto_3762.h"
extern iot_cusapp_t g_iot_cus_lib;
extern iot_ipc_addr_t iot_cusapp_ext_sgapp_addr;
void iot_cusapp_cco_qry_nw_topo_info(uint16_t start, uint16_t cnt)
{
iot_plc_query_nw_topo(g_iot_cus_lib.app_handle, IOT_PLC_API_REQ_ID_DEFAULT,
IOT_PLC_CCO_TOPO_REQ_DATA_VER_V1, IOT_PLC_QUERY_TOPO_START_AS_INDEX,
start, cnt);
}
void iot_cusapp_cco_qry_wlii_cnt()
{
uint16_t pkt_len;
iot_pkt_t *pkt;
iot_sg_ext_header_t *p_hdr;
pkt_len = sizeof(*p_hdr);
pkt = iot_ipc_pkt_alloc(pkt_len, IOT_SMART_GRID_MID);
if (!pkt) {
goto out;
}
p_hdr = (iot_sg_ext_header_t *)iot_pkt_put(pkt, pkt_len);
p_hdr->mid = IOT_SG_EXT_MID_COMMAND;
p_hdr->arg = IOT_SG_EXT_SID_WLII_CNT_GET;
iot_ipc_send(g_iot_cus_lib.ipc_h, &iot_cusapp_ext_sgapp_addr, pkt);
out:
return;
}
void iot_cusapp_cco_wlii_addr_is_exist(uint8_t *wlii_addr)
{
uint16_t pkt_len;
iot_pkt_t *pkt;
iot_sg_ext_header_t *p_hdr;
iot_sg_ext_qry_wlii_adrr_exist_t *wlii_exist;
if (wlii_addr == NULL) {
return;
}
pkt_len = sizeof(*p_hdr) + sizeof(*wlii_exist);
pkt = iot_ipc_pkt_alloc(pkt_len, IOT_SMART_GRID_MID);
if (!pkt) {
goto out;
}
p_hdr = (iot_sg_ext_header_t *)iot_pkt_put(pkt, pkt_len);
p_hdr->mid = IOT_SG_EXT_MID_COMMAND;
p_hdr->arg = IOT_SG_EXT_SID_WLII_ADDR_EXIST_QRY;
wlii_exist = (iot_sg_ext_qry_wlii_adrr_exist_t *)(p_hdr + 1);
iot_mac_addr_cpy(wlii_exist->wlii_addr, wlii_addr);
iot_ipc_send(g_iot_cus_lib.ipc_h, &iot_cusapp_ext_sgapp_addr, pkt);
out:
return;
}
void iot_cusapp_cco_reset_wlii()
{
uint16_t pkt_len;
iot_pkt_t *pkt;
iot_sg_ext_header_t *p_hdr;
pkt_len = sizeof(*p_hdr);
pkt = iot_ipc_pkt_alloc(pkt_len, IOT_SMART_GRID_MID);
if (!pkt) {
goto out;
}
p_hdr = (iot_sg_ext_header_t *)iot_pkt_put(pkt, pkt_len);
p_hdr->mid = IOT_SG_EXT_MID_COMMAND;
p_hdr->arg = IOT_SG_EXT_SID_WLII_RESET_SET;
iot_ipc_send(g_iot_cus_lib.ipc_h, &iot_cusapp_ext_sgapp_addr, pkt);
out:
return;
}
void iot_cusapp_cco_add_wlii(uint8_t *wlii_addr, uint8_t addr_cnt)
{
uint16_t pkt_len;
iot_pkt_t *pkt;
iot_sg_ext_header_t *p_hdr;
iot_sg_ext_wlii_op_info_t *ext_wl_op;
uint8_t *addr_ptr;
uint8_t i;
if (wlii_addr == NULL || addr_cnt == 0) {
return;
}
addr_ptr = wlii_addr;
pkt_len = sizeof(*p_hdr) + sizeof(*ext_wl_op) +
sizeof(iot_sg_ext_wlii_op_entry_t) * addr_cnt;
pkt = iot_ipc_pkt_alloc(pkt_len, IOT_SMART_GRID_MID);
if (!pkt) {
goto out;
}
p_hdr = (iot_sg_ext_header_t *)iot_pkt_put(pkt, pkt_len);
p_hdr->mid = IOT_SG_EXT_MID_COMMAND;
p_hdr->arg = IOT_SG_EXT_SID_WLII_ADD_SET;
ext_wl_op = (iot_sg_ext_wlii_op_info_t *)(p_hdr + 1);
ext_wl_op->count = addr_cnt;
for (i = 0; i < addr_cnt; ++i) {
iot_mac_addr_cpy(ext_wl_op->node_info[i].mac, addr_ptr);
ext_wl_op->node_info[i].proto_type = PROTO_TYPE_645_2007;
addr_ptr = addr_ptr + IOT_MAC_ADDR_LEN;
}
iot_ipc_send(g_iot_cus_lib.ipc_h, &iot_cusapp_ext_sgapp_addr, pkt);
out:
return;
}
void iot_cusapp_cco_del_wlii(uint8_t *wlii_addr, uint8_t addr_cnt)
{
uint16_t pkt_len;
iot_pkt_t *pkt;
iot_sg_ext_header_t *p_hdr;
iot_sg_ext_wlii_del_t *wlii_del;
uint8_t *addr_ptr;
uint8_t i;
if (wlii_addr == NULL || addr_cnt == 0) {
return;
}
addr_ptr = wlii_addr;
pkt_len = sizeof(*p_hdr) + sizeof(*wlii_del) +
IOT_MAC_ADDR_LEN * addr_cnt;
pkt = iot_ipc_pkt_alloc(pkt_len, IOT_SMART_GRID_MID);
if (!pkt) {
goto out;
}
p_hdr = (iot_sg_ext_header_t *)iot_pkt_put(pkt, pkt_len);
p_hdr->mid = IOT_SG_EXT_MID_COMMAND;
p_hdr->arg = IOT_SG_EXT_SID_WLII_DEL_SET;
wlii_del = (iot_sg_ext_wlii_del_t *)(p_hdr + 1);
wlii_del->count = addr_cnt;
for (i = 0; i < addr_cnt; ++i) {
iot_mac_addr_cpy(wlii_del->wlii_addr[i], addr_ptr);
addr_ptr = addr_ptr + IOT_MAC_ADDR_LEN;
}
iot_ipc_send(g_iot_cus_lib.ipc_h, &iot_cusapp_ext_sgapp_addr, pkt);
out:
return;
}
void iot_cusapp_cco_query_wlii_info(uint16_t start_index, uint8_t cnt)
{
uint16_t pkt_len;
iot_pkt_t *pkt;
iot_sg_ext_header_t *p_hdr;
iot_sg_ext_wlii_info_query_t *wlii_qry;
if (start_index == 0 || cnt == 0) {
return;
}
pkt_len = sizeof(*p_hdr) + sizeof(*wlii_qry);
pkt = iot_ipc_pkt_alloc(pkt_len, IOT_SMART_GRID_MID);
if (!pkt) {
goto out;
}
p_hdr = (iot_sg_ext_header_t *)iot_pkt_put(pkt, pkt_len);
p_hdr->mid = IOT_SG_EXT_MID_COMMAND;
p_hdr->arg = IOT_SG_EXT_SID_WLII_INFO_QRY;
wlii_qry = (iot_sg_ext_wlii_info_query_t *)(p_hdr + 1);
wlii_qry->start_index = start_index;
wlii_qry->cnt = cnt;
iot_ipc_send(g_iot_cus_lib.ipc_h, &iot_cusapp_ext_sgapp_addr, pkt);
out:
return;
}
/**
* @brief iot_cusapp_cco_plc_msg_process() - process data from plc.
* @param p_cus_msg: message received from plc. p_cus_msg->data
* will be freed by this handle but p_cus_msg will not.
*/
static void iot_cusapp_cco_plc_msg_process(iot_cusapp_msg_t *p_cus_msg)
{
iot_pkt_t *p_pkt = (iot_pkt_t *)p_cus_msg->data;
IOT_ASSERT(p_pkt);
iot_plc_msg_header_t *hdr = NULL;
hdr = (iot_plc_msg_header_t*)iot_pkt_block_ptr(p_pkt, IOT_PKT_BLOCK_DATA);
iot_plc_app_t *host_app = g_iot_cus_lib.app_handle;
uint8_t consumed = 0;
iot_cus_printf("%s recv plc msg, app id:%lu, msg id:%lu, req id:%lu\n",
__FUNCTION__, hdr->app_id, hdr->msg_id, hdr->req_id);
if (hdr->app_id != IOT_PLC_APP_ID_BCAST &&
host_app->app_id != hdr->app_id) {
iot_pkt_free(p_pkt);
return;
}
switch (hdr->msg_id) {
case IOT_PLC_MSG_DEV_STATE_CHANGE_RPT:
{
iot_plc_dev_state_change_rpt_t *dev_state;
dev_state = (iot_plc_dev_state_change_rpt_t*)(hdr + 1);
iot_cus_printf("dev state change, local_mac:"
"[%02X:%02X:%02X:%02X:%02X:%02X], cco_mac:"
"[%02X:%02X:%02X:%02X:%02X:%02X] \n", dev_state->local_mac[0],
dev_state->local_mac[1], dev_state->local_mac[2],
dev_state->local_mac[3], dev_state->local_mac[4],
dev_state->local_mac[5], dev_state->cco_mac[0],
dev_state->cco_mac[1], dev_state->cco_mac[2],
dev_state->cco_mac[3], dev_state->cco_mac[4],
dev_state->cco_mac[5]);
break;
}
case IOT_PLC_MSG_PHASE_RPT:
{
iot_plc_phase_rpt_t *phase;
phase = (iot_plc_phase_rpt_t*)(hdr + 1);
iot_cus_printf("phase info, phy_phase:%lu, opposite:%lu, opposite_3p"
":%lu \n", phase->phy_phase, phase->opposite_phase,
phase->opposite_3p);
break;
}
case IOT_PLC_MSG_STA_PHASE_UPDATED:
{
iot_plc_sta_phase_update_t *phase_update;
phase_update = (iot_plc_sta_phase_update_t*)(hdr + 1);
iot_cus_printf("sta phase update, sta_cnt:%lu \n",
phase_update->sta_count);
break;
}
case IOT_PLC_MSG_STA_JOIN_REJECTED:
{
iot_plc_sta_join_rejected_t *join_reject;
join_reject = (iot_plc_sta_join_rejected_t*)(hdr + 1);
iot_cus_printf("sta join rejected, addr[%02X:%02X:%02X:%02X:%02X:%02X]"
", reason:%lu \n", join_reject->addr[0], join_reject->addr[1],
join_reject->addr[2], join_reject->addr[3], join_reject->addr[4],
join_reject->addr[5], join_reject->reason);
break;
}
case IOT_PLC_MSG_STA_PROXY_CHANGED:
{
iot_plc_sta_proxy_changed_t *proxy_changed;
proxy_changed = (iot_plc_sta_proxy_changed_t*)(hdr + 1);
iot_cus_printf("sta proxy changed, total_pco_cnt:%lu, total_sta_cnt:%lu"
", sta_tei:%lu, sta_addr[%02X:%02X:%02X:%02X:%02X:%02X] \n",
proxy_changed->total_pco_cnt, proxy_changed->total_sta_cnt,
proxy_changed->sta_tei, proxy_changed->sta_addr[0],
proxy_changed->sta_addr[1], proxy_changed->sta_addr[2],
proxy_changed->sta_addr[3], proxy_changed->sta_addr[4],
proxy_changed->sta_addr[5]);
break;
}
case IOT_PLC_MSG_STA_JOIN_INFO:
{
iot_plc_sta_join_info_t *join_info;
join_info = (iot_plc_sta_join_info_t*)(hdr + 1);
iot_cus_printf("sta join info, total_node_cnt:%lu \n",
join_info->total_node_count);
break;
}
case IOT_PLC_MSG_STA_ONLINE_INFO:
{
iot_plc_sta_online_info_t *online_info;
online_info = (iot_plc_sta_online_info_t*)(hdr + 1);
iot_cus_printf("sta online info, tei:%lu, proxy:%lu,"
"mac_addr[%02X:%02X:%02X:%02X:%02X:%02X] \n", online_info->tei,
online_info->proxy, online_info->mac_addr[0],
online_info->mac_addr[1], online_info->mac_addr[2],
online_info->mac_addr[3], online_info->mac_addr[4],
online_info->mac_addr[5]);
break;
}
case IOT_PLC_MSG_STA_LEAVE_INFO:
{
iot_plc_sta_leave_info_t *leave_info;
leave_info = (iot_plc_sta_leave_info_t*)(hdr + 1);
iot_cus_printf("sta leave info, total_node_cnt:%lu, sta_cnt:%lu \n",
leave_info->total_node_count, leave_info->sta_count);
break;
}
case IOT_PLC_MSG_STA_OFFLINE_INFO:
{
iot_plc_sta_offline_info_t *offline_info;
offline_info = (iot_plc_sta_offline_info_t*)(hdr + 1);
iot_cus_printf("sta offline info, sta_cnt:%lu \n",
offline_info->sta_count);
break;
}
case IOT_PLC_MSG_NW_TOPO_RPT:
{
iot_plc_nw_topo_rpt_t *topo_rpt;
topo_rpt = (iot_plc_nw_topo_rpt_t*)(hdr + 1);
iot_cus_printf("nw topo rpt, version:%lu, start_type:%lu \n",
topo_rpt->version, topo_rpt->start_type);
break;
}
case IOT_PLC_MSG_NW_NEIGHBOR_RPT:
{
iot_plc_nb_nw_rpt_t *nb_nw_rpt;
nb_nw_rpt= (iot_plc_nb_nw_rpt_t*)(hdr + 1);
iot_cus_printf("nw neighbor rpt, cnt:%lu \n", nb_nw_rpt->count);
break;
}
default:
break;
}
/* TODO: cost in this module or give to other module. */
if (!consumed) {
iot_pkt_free(p_pkt);
}
return;
}
/**
* @brief iot_cusapp_cco_wl_msg_process() - process data from wireless device.
* @param p_cus_msg: message received from wireless device. p_cus_msg->data
* will be freed by this handle but p_cus_msg will not.
*/
static void iot_cusapp_cco_wl_msg_process(iot_cusapp_msg_t *p_cus_msg)
{
/* TODO: cost in this module or give to other module. */
iot_pkt_free((iot_pkt_t *)p_cus_msg->data);
return;
}
/**
* @brief iot_cusapp_cco_handle_msdu_data() - handle msdu data.
* @param data: msdu data.
*/
static void iot_cusapp_cco_handle_msdu_data(iot_pkt_t *pkt)
{
iot_plc_msdu_recv_t *msdu;
if (pkt == NULL) {
return;
}
msdu = (iot_plc_msdu_recv_t *)iot_pkt_data(pkt);
(void)msdu;
/* modify condition according to actual demand, and return unwanted msdu
* data to sg.
*/
if (0) {
/* handle msdu data deal with cusapp's demand */
} else {
iot_cusapp_send_msdu_to_sg(pkt);
}
}
/**
* @brief iot_cusapp_sta_command_exe() - command execute top function.
* @param sid: id of command.
* @param data: data for this command.
*/
static void iot_cusapp_cco_command_exe(uint32_t sid, void *data)
{
switch(sid)
{
case IOT_SG_EXT_SID_UART_CFG:
{
iot_cusapp_cmd_uart_config(data);
break;
}
case IOT_SG_EXT_SID_WLII_CNT_RPT:
{
iot_sg_ext_wlii_cnt_rpt_t *wlii_cnt_rpt =
(iot_sg_ext_wlii_cnt_rpt_t *)data;
iot_cus_printf("wlii cnt is %lu, max cnt :%lu \n",
wlii_cnt_rpt->wlii_cnt, wlii_cnt_rpt->wlii_max_cnt);
break;
}
case IOT_SG_EXT_SID_WLII_ADDR_EXIST_RPT:
{
iot_sg_ext_wlii_exist_t *wlii_exist =
(iot_sg_ext_wlii_exist_t *)data;
iot_cus_printf("wlii addr exist:%lu \n", wlii_exist->exist);
break;
}
case IOT_SG_EXT_SID_WLII_RESET_RPT:
{
iot_sg_ext_rsp_result_t *rsp_result =
(iot_sg_ext_rsp_result_t *)data;
iot_cus_printf("wlii reset result:%lu \n", rsp_result->result);
break;
}
case IOT_SG_EXT_SID_WLII_ADD_RPT:
{
iot_sg_ext_rsp_result_t *rsp_result =
(iot_sg_ext_rsp_result_t *)data;
iot_cus_printf("wlii add result:%lu \n", rsp_result->result);
break;
}
case IOT_SG_EXT_SID_WLII_DEL_RPT:
{
iot_sg_ext_rsp_result_t *rsp_result =
(iot_sg_ext_rsp_result_t *)data;
iot_cus_printf("wlii del result:%lu \n", rsp_result->result);
break;
}
case IOT_SG_EXT_SID_WLII_INFO_RPT:
{
iot_sg_ext_wlii_info_transfer_t *wlii_info =
(iot_sg_ext_wlii_info_transfer_t *)data;
iot_cus_printf("wlii info, total cnt:%lu, count:%lu \n",
wlii_info->total_count, wlii_info->count);
for (uint8_t i = 0; i < wlii_info->count; ++i) {
iot_cus_printf("index:%lu, mac[%02X:%02X:%02X:%02X:%02X:%02X] \n",
i, wlii_info->info[i].mac_addr[0],
wlii_info->info[i].mac_addr[1],
wlii_info->info[i].mac_addr[2],
wlii_info->info[i].mac_addr[3],
wlii_info->info[i].mac_addr[4],
wlii_info->info[i].mac_addr[5]);
}
break;
}
default:
{
IOT_ASSERT(0);
break;
}
}
return;
}
static uint32_t iot_cusapp_cco_uart_data_process_drv(uint8_t channel,
uint8_t *data, uint16_t data_len)
{
(void)channel;
(void)data;
(void)data_len;
return 1;
}
/**
* @brief iot_cusapp_cco_sg_msg_process() - process the data from sg-app.
* @param p_cus_msg: message received from sg-app. p_cus_msg->data
* will be freed by this handle but p_cus_msg will not.
*/
static void iot_cusapp_cco_sg_msg_process(iot_cusapp_msg_t *p_cus_msg)
{
iot_pkt_t *p_pkt = (iot_pkt_t *)p_cus_msg->data;
iot_sg_ext_header_t *p_header;
p_header = (iot_sg_ext_header_t *)iot_pkt_data(p_pkt);
switch (p_header->mid)
{
case IOT_SG_EXT_MID_UART_DATA_FROM_SG:
{
uint32_t is_forward;
uint8_t channel = IOT_SG_EXT_UART_CHNN_GET(p_header->arg);
/* Pull header out of packet. */
iot_pkt_pull(p_pkt, sizeof(*p_header));
is_forward = iot_cusapp_cco_uart_data_process_drv(channel,
iot_pkt_data(p_pkt), iot_pkt_data_len(p_pkt));
if (is_forward) {
#if !IOT_CUSAPP_SOCKET_TO_CCTT_ENABLE
/* Send to uart port. */
iot_cusapp_uart_send(p_pkt);
#else
/* Send data by eth socket */
iot_socket_udp_send(g_iot_cus_lib.socket_h, iot_pkt_data(p_pkt),
iot_pkt_data_len(p_pkt), 0, IOT_CUSAPP_SOCKET_REMOTE_IP,
IOT_CUSAPP_SOCKET_REMOTE_PORT);
iot_pkt_free(p_pkt);
#endif
} else {
iot_pkt_free(p_pkt);
}
/* Set p_pkt as NULL avoid of free() repeatly. */
p_pkt = NULL;
break;
}
case IOT_SG_EXT_MID_COMMAND:
{
iot_cusapp_cco_command_exe(((uint32_t)p_header->arg) & 0xFF,
p_header->data);
break;
}
case IOT_SG_EXT_MID_TRANS_MSDU_FROM_SG:
{
/* Pull header out of packet. */
iot_pkt_pull(p_pkt, sizeof(*p_header));
iot_cusapp_cco_handle_msdu_data(p_pkt);
/* Set p_pkt as NULL avoid of free() repeatly. */
p_pkt = NULL;
break;
}
default:
{
IOT_ASSERT(0);
break;
}
}
if (NULL != p_pkt)
{
iot_pkt_free(p_pkt);
}
return;
}
static void iot_cusapp_uart_data_send_to_sg(uint8_t channel, iot_pkt_t *pkt,
uint8_t is_full_frame)
{
uint32_t path;
iot_sg_ext_header_t *p_header;
path = iot_cusapp_data_path_get();
if ((CUSAPP_PT_MAX <= path)
|| (NULL == g_iot_cus_lib.path[path])) {
/* drop this packet. */
iot_pkt_free(pkt);
return;
}
switch (path) {
case CUSAPP_PT_PLC:
{
p_header = (iot_sg_ext_header_t *)iot_pkt_push(pkt,
sizeof(*p_header));
p_header->mid = IOT_SG_EXT_MID_UART_DATA_FROM_CUS;
if (is_full_frame) {
IOT_SG_EXT_UART_FULL_FRAME_SET(p_header->arg);
}
IOT_SG_EXT_UART_CHNN_SET(p_header->arg, channel);
g_iot_cus_lib.path[CUSAPP_PT_PLC](pkt, 0);
break;
}
case CUSAPP_PT_WIERLESS:
{
/* TODO */
g_iot_cus_lib.path[CUSAPP_PT_WIERLESS](pkt, 0);
break;
}
default:
{
iot_pkt_free(pkt);
IOT_ASSERT(0);
break;
}
}
}
static uint32_t iot_cusapp_cco_uart_data_process_cctt(uint8_t *data,
uint16_t data_len, uint8_t is_full_frame)
{
(void)data;
(void)data_len;
(void)is_full_frame;
return 1;
}
/**
* @brief iot_cusapp_cco_uart_msg_process() - process the data from uart.
* @param p_cus_msg: message received from uart. p_cus_msg->data will be
* freed by this handle but p_cus_msg will not.
*/
static void iot_cusapp_cco_uart_msg_process(iot_cusapp_msg_t *p_cus_msg)
{
uint32_t is_forward;
iot_pkt_t *pkt = (iot_pkt_t *)p_cus_msg->data;
uint8_t is_full_frame = (p_cus_msg->data2) ? IOT_SG_EXT_DF_FULL :
IOT_SG_EXT_DF_PART;
is_forward = iot_cusapp_cco_uart_data_process_cctt(iot_pkt_data(pkt),
iot_pkt_data_len(pkt), is_full_frame);
if (is_forward) {
iot_cusapp_uart_data_send_to_sg(IOT_SG_EXT_UART_DATA_CCTT, pkt,
is_full_frame);
} else {
iot_pkt_free(pkt);
}
}
static void iot_cusapp_cco_msg_exe_func(iot_cusapp_msg_t *msg)
{
switch (msg->task_msg.type) {
#if !IOT_CUSAPP_SOCKET_TO_CCTT_ENABLE
case IOT_CUSAPP_MT_UART:
{
iot_cusapp_cco_uart_msg_process(msg);
break;
}
#else
case IOT_CUSAPP_MT_SOCKET:
{
iot_cusapp_cco_uart_msg_process(msg);
break;
}
#endif /* !IOT_CUSAPP_SOCKET_TO_CCTT_ENABLE */
case IOT_CUSAPP_MT_SG:
{
iot_cusapp_cco_sg_msg_process(msg);
break;
}
case IOT_CUSAPP_MT_WL:
{
iot_cusapp_cco_wl_msg_process(msg);
break;
}
case IOT_CUSAPP_MT_PLC:
{
iot_cusapp_cco_plc_msg_process(msg);
break;
}
default:
{
iot_pkt_free(msg->data);
IOT_ASSERT(0);
break;
}
}
iot_task_free_msg(g_iot_cus_lib.task_h, &msg->task_msg);
}
static void iot_cusapp_cco_msg_cancel_func(iot_cusapp_msg_t *msg)
{
switch(msg->task_msg.type)
{
#if IOT_CUSAPP_SOCKET_TO_CCTT_ENABLE
case IOT_CUSAPP_MT_SOCKET:
#else
case IOT_CUSAPP_MT_UART:
#endif
case IOT_CUSAPP_MT_SG:
case IOT_CUSAPP_MT_WL:
case IOT_CUSAPP_MT_PLC:
{
iot_pkt_free(msg->data);
break;
}
default:
{
IOT_ASSERT(0);
break;
}
}
iot_task_free_msg(g_iot_cus_lib.task_h, &msg->task_msg);
return;
}
uint32_t iot_cusapp_cco_init()
{
uint32_t ret = ERR_OK;
g_iot_cus_lib.msg_exe_func = iot_cusapp_cco_msg_exe_func;
g_iot_cus_lib.msg_cancel_func = iot_cusapp_cco_msg_cancel_func;
return ret;
}
void iot_cusapp_cco_deinit()
{
return;
}