143 lines
		
	
	
		
			4.6 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			143 lines
		
	
	
		
			4.6 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
| /****************************************************************************
 | |
| 
 | |
| 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.
 | |
| 
 | |
| ****************************************************************************/
 | |
| 
 | |
| #ifndef IOT_CLI_HOST_INTERFACE_H
 | |
| #define IOT_CLI_HOST_INTERFACE_H
 | |
| 
 | |
| /* os shim includes */
 | |
| #include "os_types.h"
 | |
| #include "os_task.h"
 | |
| #include "os_event.h"
 | |
| #include "os_timer_api.h"
 | |
| 
 | |
| #include "iot_task.h"
 | |
| #include "iot_utils.h"
 | |
| #include "iot_queue.h"
 | |
| #include "iot_ipc_api.h"
 | |
| #include "iot_uart_h.h"
 | |
| 
 | |
| #include "iot_cli_module_config.h"
 | |
| #include "iot_cli.h"
 | |
| #include "iot_cli_msg.h"
 | |
| #include "iot_cli_common.h"
 | |
| 
 | |
| #ifdef __cplusplus
 | |
| extern "C" {
 | |
| #endif
 | |
| 
 | |
| #pragma pack(push)  /* save the pack status */
 | |
| #pragma pack(1)     /* 1 byte align */
 | |
| 
 | |
| typedef void(*HOST_SEND_PACKAGE_EVENT_CB) (uint32_t moduleid,
 | |
|     uint32_t msgid, uint8_t *buffer, uint32_t length, uint16_t sn,
 | |
|     uint8_t *src_mac);
 | |
| 
 | |
| /* module id */
 | |
| #define MODULEID_HOSTINTERFACE                      (2)
 | |
| /* request id */
 | |
| #define CLI_HOST_USE_API_BY_PLCM                    (1)
 | |
| 
 | |
| typedef struct _iot_cli_host_info_t {
 | |
|     /* link id used for sending msdu */
 | |
|     uint8_t                link_id;
 | |
|     /* handle of task for this app */
 | |
|     os_task_h              host_task_h;
 | |
|     /* send ul package callback*/
 | |
|     HOST_SEND_PACKAGE_EVENT_CB pfunc_send_ul_package;
 | |
|     /* mac address of local device */
 | |
|     uint8_t                mac_addr[IOT_MAC_ADDR_LEN];
 | |
|     /* plc_mgr_state */
 | |
|     uint8_t                host_app_state;
 | |
|     /* plc mgr live flag */
 | |
|     uint8_t                host_app_live;
 | |
|     /* live query timer */
 | |
|     timer_id_t             live_timer;
 | |
|     /* log timer */
 | |
|     timer_id_t             log_timer;
 | |
|     /* is ready flag */
 | |
|     /* bit7: ctrl proto connect flag */
 | |
|     uint8_t                is_ready;
 | |
|     /* hplc link load, value: 0 - 100 */
 | |
|     uint8_t                link_load;
 | |
| } iot_cli_host_info_t;
 | |
| 
 | |
| typedef void(*CLI_MSG_HANDLER)(uint8_t *buffer, uint32_t len, uint8_t *src_mac);
 | |
| typedef struct _CLI_MSG_ENTRY
 | |
| {
 | |
|     cli_moduleid_t      module_id;
 | |
|     uint32_t            msg_id;
 | |
|     CLI_MSG_HANDLER     pFun;
 | |
| }*PCLI_MSG_ENTRY, CLI_MSG_ENTRY;
 | |
| 
 | |
| uint8_t iot_cli_host_interface_init(HOST_SEND_PACKAGE_EVENT_CB cb,
 | |
|     iot_task_h task_h);
 | |
| void iot_cli_host_interface_deinit();
 | |
| 
 | |
| uint8_t iot_cli_host_interface_handle_msg(
 | |
|     cli_moduleid_t moduleid, uint32_t msgid, iot_cli_msg_t *msg);
 | |
| uint8_t iot_cli_host_interface_handle_task_msg(
 | |
|     iot_cli_msg_t *cli_msg, uint16_t id);
 | |
| uint8_t iot_cli_host_interface_cancel_task_msg(
 | |
|     iot_cli_msg_t *cli_msg, uint16_t id);
 | |
| void iot_cli_host_interface_init_uart(
 | |
|     commnucator_t * com, uint8_t interface_type);
 | |
| uint8_t cli_execute_msg_entry(
 | |
|     cli_moduleid_t moduleid, uint32_t msgid,
 | |
|     CLI_MSG_ENTRY *msg_entry, iot_cli_msg_t *msg);
 | |
| 
 | |
| // for cli module interface
 | |
| void iot_cli_module_init_uart(
 | |
|     commnucator_t * com, uint8_t interface_type);
 | |
| uint8_t iot_cli_proto_module_init();
 | |
| void iot_cli_proto_module_deinit();
 | |
| uint8_t iot_cli_module_handle_msg(
 | |
|     cli_moduleid_t moduleid, uint32_t msgid, iot_cli_msg_t *msg);
 | |
| uint8_t iot_cli_module_handle_task_msg(
 | |
|     iot_cli_msg_t *cli_msg, uint16_t id);
 | |
| uint8_t iot_cli_module_cancel_task_msg(
 | |
|     iot_cli_msg_t *cli_msg, uint16_t id);
 | |
| 
 | |
| /**
 | |
|  * @brief iot_cli_host_is_ctrl_connected - check is ctrl connected
 | |
|  * @retval: 1 - is ctrl connected, 0 - is not.
 | |
|  */
 | |
| uint8_t iot_cli_host_is_ctrl_connected();
 | |
| /**
 | |
|  * @brief iot_cli_host_set_ctrl_connected - set ctrl connect
 | |
|  * @param enable: 1 - set ctrl connected flag, 0 - clean ctrl connected
 | |
|  *                flag.
 | |
|  */
 | |
| void iot_cli_host_set_ctrl_connected(uint8_t setting);
 | |
| 
 | |
| 
 | |
| /**
 | |
|  * @brief iot_cli_host_is_join_connected - check is join connected
 | |
|  * @retval: 1 - is join connected, 0 - is not.
 | |
|  */
 | |
| uint8_t iot_cli_host_is_join_connected();
 | |
| /**
 | |
|  * @brief iot_cli_host_set_join_connected - set join connect
 | |
|  * @param enable: 1 - set join connected flag, 0 - clean join connected
 | |
|  *                flag.
 | |
|  */
 | |
| void iot_cli_host_set_join_connected(uint8_t setting);
 | |
| 
 | |
| #pragma pack(pop)   /* restore the pack status */
 | |
| 
 | |
| #ifdef __cplusplus
 | |
| }
 | |
| #endif
 | |
| 
 | |
| #endif /* IOT_CLI_HOST_INTERFACE_H */ |