96 lines
3.0 KiB
C
96 lines
3.0 KiB
C
/****************************************************************************
|
|
|
|
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.
|
|
|
|
****************************************************************************/
|
|
|
|
#include "iot_io.h"
|
|
|
|
#include "iot_cli_msg.h"
|
|
#include "iot_cli_tx_rx.h"
|
|
#include "iot_cli_host_interface.h"
|
|
#include "iot_cli_ul_buf.h"
|
|
|
|
extern iot_cli_host_info_t *host_info;
|
|
|
|
void iot_cli_module_send_to_host_with_retry(uint32_t msgid, uint8_t *buffer,
|
|
uint32_t length, uint16_t sn, uint8_t *dst_mac, uint8_t *src_mac)
|
|
{
|
|
(void)dst_mac;
|
|
if (host_info->pfunc_send_ul_package) {
|
|
host_info->pfunc_send_ul_package(
|
|
MODULEID_HOSTINTERFACE, msgid, buffer, length, sn, src_mac);
|
|
}
|
|
}
|
|
|
|
void cli_ul_send_with_retry(uint32_t msgid, uint8_t *buffer,
|
|
uint32_t length, uint8_t *dst_mac)
|
|
{
|
|
uint16_t sn = 0;
|
|
#if PLC_SUPPORT_CCO_ROLE
|
|
sn = cli_ul_buf_add_entry(msgid, buffer, length);
|
|
#endif
|
|
iot_cli_module_send_to_host_with_retry(msgid, buffer, length, sn, dst_mac,
|
|
NULL);
|
|
}
|
|
|
|
void iot_cli_module_send_data_with_retry(uint8_t send_type, uint8_t retry_cnt,
|
|
uint16_t moduleid, uint32_t msgid, uint8_t *src_mac, uint8_t *dest_mac,
|
|
uint8_t *buf, uint32_t len)
|
|
{
|
|
(void)send_type;
|
|
(void)retry_cnt;
|
|
(void)moduleid;
|
|
(void)msgid;
|
|
(void)src_mac;
|
|
(void)dest_mac;
|
|
(void)buf;
|
|
(void)len;
|
|
}
|
|
|
|
void iot_cli_module_send_data(uint8_t send_type, uint8_t retry_cnt,
|
|
uint16_t moduleid, uint32_t msgid, uint8_t *src_mac, uint8_t *dest_mac,
|
|
uint8_t *buf, uint32_t len)
|
|
{
|
|
iot_cli_module_send_data_with_retry(
|
|
send_type, retry_cnt,
|
|
moduleid, msgid, src_mac, dest_mac, buf, len);
|
|
}
|
|
|
|
void iot_cli_host_send_data_plc(uint8_t send_type, uint32_t msgid,
|
|
uint8_t *dest_mac, uint8_t *buf, uint32_t len)
|
|
{
|
|
iot_cli_module_send_data_with_retry(send_type, 0,
|
|
CLI_MODULEID_HOSTINTERFACE, msgid, NULL, dest_mac, buf, len);
|
|
}
|
|
|
|
void iot_cli_plc_recv(void *param, iot_pkt_t *pkt)
|
|
{
|
|
(void)param;
|
|
iot_task_msg_t *t_msg;
|
|
|
|
if ((host_info->host_task_h == NULL)
|
|
|| (pkt == NULL)) {
|
|
iot_printf("Invalid param (%s)\n", __FUNCTION__);
|
|
return;
|
|
}
|
|
|
|
t_msg = iot_cli_create_cli_msg(IOT_CLI_HOST_MSG, pkt);
|
|
|
|
if (t_msg) {
|
|
iot_task_queue_msg(
|
|
host_info->host_task_h, t_msg, IOT_CLI_QUEUE_HOST);
|
|
}
|
|
else if (pkt) {
|
|
iot_pkt_free(pkt);
|
|
}
|
|
} |