Files
kunlun/app/smart_grid_extend/inc/iot_cusapp.h
2024-09-28 14:24:04 +08:00

143 lines
4.5 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_CUSAPP_H_
#define _IOT_CUSAPP_H_
#include "iot_task_api.h"
#include "iot_plc_api.h"
#include "iot_uart_api.h"
#include "iot_ipc_api.h"
#ifdef __cplusplus
extern "C" {
#endif
/** Message type defination: */
#define IOT_CUSAPP_MT_UART 1 /** message from uart. */
#define IOT_CUSAPP_MT_SG 2 /** message from sg-app. */
#define IOT_CUSAPP_MT_WL 3 /** message from wrieless device. */
#define IOT_CUSAPP_MT_SOCKET 4 /** message from socket */
#define IOT_CUSAPP_MT_PLC 5 /** message from plc */
/* Message type defination id definition */
#define IOT_CUSAPP_ID_MSG_PLC 1 /* message delivered from PLC */
/* enable socket to cctt at CUSAPP */
#define IOT_CUSAPP_SOCKET_TO_CCTT_ENABLE 0
/* local port on CCO */
#define IOT_CUSAPP_SOCKET_LOCAL_PORT 55555
/* remote port on cctt */
#define IOT_CUSAPP_SOCKET_REMOTE_PORT 55555
/* cctt's ip */
#define IOT_CUSAPP_SOCKET_REMOTE_IP "10.100.0.2"
enum _iot_cusapp_data_process_path_
{
CUSAPP_PT_PLC = 0,
CUSAPP_PT_WIERLESS = 1,
CUSAPP_PT_MAX
};
/** uart data process handle */
typedef void (*iot_cusapp_uart_data_handle)(iot_pkt_t *p_pkt, uint32_t arg);
/** cusapp message */
typedef struct _iot_cusapp_msg {
/* iot task message */
iot_task_msg_t task_msg;
/* pointer to message data */
void *data;
/* another data field */
uint32_t data2;
} iot_cusapp_msg_t;
/*
* function callback to handle msg executing case
* @msg: pointer to message to be executed
*/
typedef void (*iot_sg_ext_msg_execute_func_t)(iot_cusapp_msg_t *msg);
/*
* function callback to handle msg canceling case
* @msg: pointer to message to be canceled
*/
typedef void (*iot_sg_ext_msg_cancel_func_t)(iot_cusapp_msg_t *msg);
/* Entity of cusapp. */
typedef struct _iot_cusapp {
iot_task_config_t task_cfg;
iot_uart_h uart_h;
iot_task_h task_h;
iot_ipc_h ipc_h;
iot_plc_app_h app_handle;
uint8_t role;
uint32_t module_type;
int32_t socket_h;
iot_sg_ext_msg_execute_func_t msg_exe_func;
iot_sg_ext_msg_cancel_func_t msg_cancel_func;
iot_cusapp_uart_data_handle path[CUSAPP_PT_MAX];
} iot_cusapp_t;
/**
* @brief iot_cusapp_uart_send() - Send data to uart port.
* @param p_pkt: packet for sending to uart port, the packet shall be release.
* @return: ERR_OK - send successfully.
* ERR_FAIL - send failed.
*/
uint32_t iot_cusapp_uart_send(iot_pkt_t *p_pkt);
/**
* @brief iot_cusapp_uart_data_path_get() - Select data path to the target.
* @return: the path. reference to enum _iot_cusapp_data_process_path_.
*/
uint32_t iot_cusapp_data_path_get(void);
/**
* @brief iot_cusapp_cmd_uart_config() - uart config function.
* @param p_data: argument for configration.
*/
uint32_t iot_cusapp_cmd_uart_config(void *p_data);
/**
* @brief iot_cusapp_send_msdu_to_sg() - send msdu data to sg.
* @param pkt: data for send to sg.
*/
void iot_cusapp_send_msdu_to_sg(iot_pkt_t *pkt);
/**
* @brief iot_cusapp_cmd_msdu_enable() - enable msdu handle.
* @param enable: if enable msud handle.
*/
void iot_cusapp_cmd_msdu_enable(uint8_t enable);
/**
* @brief iot_cusapp_send_msdu_to_plc() - send plc msdu data.
* @param msg_type: msdu msg type, see IOT_SG_EXT_CUS_TYPE_XXX.
* @param dest_mac: sta mac addr, big - endian.
* @param pro: msg priority, valid value is 0-3.
* @param retry_cnt: msg retry count, see IOT_SG_EXT_CUS_XXX.
* @param len: send msdu data length.
* @param data: send msdu data.
*/
void iot_cusapp_send_msdu_to_plc(uint8_t msg_type, uint8_t* dest_mac,
uint8_t pro, uint8_t retry_cnt, uint16_t len, uint8_t *data);
#ifdef __cplusplus
}
#endif
#endif /* _IOT_CUSAPP_H_ */