56 lines
1.9 KiB
C
56 lines
1.9 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_cli.h"
|
|
#include "iot_bt_ext_api.h"
|
|
|
|
static void iot_cli_bt_recv(iot_pkt_t *pkt)
|
|
{
|
|
iot_cli_pre_handle_data(iot_pkt_data(pkt), iot_pkt_data_len(pkt),
|
|
COMMUNICATOR_BT);
|
|
iot_pkt_free(pkt);
|
|
}
|
|
|
|
uint32_t iot_cli_bt_communicator_init()
|
|
{
|
|
return iot_bt_ext_rpt_register(IOT_BT_EXT_PORT_USER_VIRTUAL_CLI,
|
|
iot_cli_bt_recv);
|
|
}
|
|
|
|
void iot_cli_bt_communicator_send(iot_pkt_t *pkt)
|
|
{
|
|
iot_bt_ext_send(IOT_BT_EXT_PORT_USER_VIRTUAL_CLI, pkt);
|
|
}
|
|
|
|
iot_pkt_t* iot_cli_bt_create_cli_msg(uint32_t moduleid, uint32_t msgid,
|
|
uint8_t *buffer, uint32_t bufferlen, uint16_t sn)
|
|
{
|
|
iot_pkt_t *data;
|
|
uint32_t datalen = 0;
|
|
uint8_t* data_ptr;
|
|
|
|
data = iot_bt_ext_send_pkt_get(bufferlen + sizeof(cli_msg_hdr_t));
|
|
if (data == NULL) {
|
|
return NULL;
|
|
}
|
|
data_ptr = iot_pkt_data(data);
|
|
cli_add_msg_header(buffer, bufferlen, moduleid, msgid, sn,
|
|
(uint8_t**)&data_ptr, &datalen, NULL);
|
|
if (iot_pkt_set_tail(data, iot_pkt_data(data) + datalen) == NULL) {
|
|
iot_pkt_free(data);
|
|
return NULL;
|
|
}
|
|
return data;
|
|
}
|