/**************************************************************************** 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. ****************************************************************************/ /* os_ship header files */ #include "os_task_api.h" #include "os_event_api.h" #include "os_timer_api.h" #include "os_utils_api.h" /* iot common header files */ #include "iot_plc_api.h" #include "iot_module_api.h" #include "iot_queue_api.h" #include "iot_config_api.h" #include "iot_plc_msg_api.h" #include "iot_board_api.h" #include "iot_mem_pool_api.h" #include "iot_config_api.h" #include "iot_app_api.h" #include "iot_errno_api.h" #include "iot_io_api.h" #include "iot_dbglog_api.h" #include "iot_uart_api.h" #include "iot_utils_api.h" #include "iot_ckb.h" #if (IOT_STA_CONTROL_MODE == 1) static iot_ckb_task_data_t *ckb_task_data; static uint32_t iot_ckb_task_init() { uint32_t ret = ERR_OK; iot_task_config_t task_cfg; iot_cus_printf("Initializing ckb task start\n"); ckb_task_data = os_mem_malloc(IOT_APP_CKB_MID, sizeof(*ckb_task_data)); if (!ckb_task_data) { ret = ERR_NOMEM; goto error_1; } os_mem_set(ckb_task_data, 0, sizeof(iot_ckb_task_data_t)); ckb_task_data->link_id = IOT_CKB_TASK_LIKE_ID; ckb_task_data->dev_role = IOT_PLC_DEV_ROLE_INVALID; ckb_task_data->band_id = PLC_LIB_FREQ_BAND_1; task_cfg.stack_size = 0; task_cfg.task_prio = IOT_CKB_TASK_PRIO; task_cfg.msg_size = sizeof(iot_ckb_task_msg_t); task_cfg.msg_cnt = IOT_CKB_TASK_POOL_SIZE; task_cfg.queue_cnt = IOT_CKB_TASK_QUEUE_MAX_PRIO; task_cfg.queue_cfg[IOT_CKB_TASK_QUEUE_HP].quota = 0; task_cfg.msg_exe_func = NULL; task_cfg.msg_cancel_func = NULL; ckb_task_data->task_handle = iot_task_create(IOT_APP_CKB_MID, &task_cfg); if (ckb_task_data->task_handle == NULL) { ret = ERR_FAIL; goto error_2; } ckb_task_data->info_pool.remain_cnt = IOT_CKB_POOL_NUM; goto success; error_2: os_mem_free(ckb_task_data); ckb_task_data = NULL; error_1: success: iot_cus_printf("Initializing ckb task done, ret: %lu\n", ret); return ret; } /* * app_entry: entry for sta_conn_less app * @return: * ERR_PENDING - if application want to delay the plc network formation. * otherwise - plc network formation will be started automatically. */ uint32_t app_ckb_entry() { uint32_t ret = ERR_PENDING; /* if the firmware is release version(0), disabel log printing, if not, * enable the log printing */ if (iot_version_type() == 1) { iot_cus_print_config(true); } else { iot_cus_print_config(false); } if (iot_ckb_task_init()) { return ERR_OK; } return ret; } #endif /* IOT_STA_CONTROL_MODE==1 */