118 lines
3.9 KiB
C
Executable File
118 lines
3.9 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_BT_EXT_API_H_
|
|
#define _IOT_BT_EXT_API_H_
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include "iot_pkt_api.h"
|
|
|
|
/* bluetooth mac address length */
|
|
#define IOT_BT_EXT_MAC_ADDR_LEN 6
|
|
|
|
/* bluetooth user port support num, not modify this define */
|
|
#define IOT_BT_EXT_PORT_USER_NUM (IOT_BT_EXT_PORT_USER_END \
|
|
- IOT_BT_EXT_PORT_USER_BASE)
|
|
|
|
/* bluetooth user port define.
|
|
* add new port id before IOT_BT_EXT_PORT_USER_END
|
|
*/
|
|
typedef enum {
|
|
/* bluetooth first user port id */
|
|
IOT_BT_EXT_PORT_USER_BASE = 4,
|
|
/* bluetooth virtual ir port */
|
|
IOT_BT_EXT_PORT_USER_VIRTUAL_IR = IOT_BT_EXT_PORT_USER_BASE,
|
|
/* bluttooth virtual cli port */
|
|
IOT_BT_EXT_PORT_USER_VIRTUAL_CLI,
|
|
/* user port end id */
|
|
IOT_BT_EXT_PORT_USER_END,
|
|
} IOT_BT_EXT_PORT_USER_ID;
|
|
|
|
/* @brief peripheral receive a packet success report function callback
|
|
*
|
|
* @param pkt: recevived pkt. user need to free the pkt.
|
|
* @return: none
|
|
*/
|
|
typedef void (*iot_bt_ext_rpt_func_t)(iot_pkt_t *pkt);
|
|
|
|
/* @brief peripheral receive report register
|
|
*
|
|
* @param port: protocol port id, see IOT_BT_EXT_PORT_XXX
|
|
* @param cb: report callback
|
|
* @return: error code.
|
|
*/
|
|
uint32_t iot_bt_ext_rpt_register(uint8_t port, iot_bt_ext_rpt_func_t cb);
|
|
|
|
/* @brief alloc bt protocol send pkt
|
|
*
|
|
* @param len: send data len
|
|
* @return: alloc pkt ptr
|
|
*/
|
|
iot_pkt_t *iot_bt_ext_send_pkt_get(uint32_t len);
|
|
|
|
/* @brief send bt protocol packet
|
|
*
|
|
* @param port: protocol port id, see IOT_BT_EXT_PORT_XXX
|
|
* @param pkt: send pkt, user need alloc pkt use iot_bt_ext_send_pkt_get
|
|
* api, then call the api to send data, the bt_ext task will
|
|
* free the pkt.
|
|
* @return: none
|
|
*/
|
|
void iot_bt_ext_send(uint8_t port, iot_pkt_t *pkt);
|
|
|
|
/* @brief get bluetooth mac address
|
|
*
|
|
* @param addr: bluetooth mac address pointer. little endian byte order.
|
|
* length = 6bytes.
|
|
* this buffer must be alloc by the caller.
|
|
* @return: error code. see ERR_XXX.
|
|
*/
|
|
uint32_t iot_bt_ext_get_mac_addr(uint8_t *addr);
|
|
|
|
/* @brief set bluetooth mac address
|
|
*
|
|
* @param addr: bluetooth mac address pointer. little endian byte order.
|
|
* length = 6bytes.
|
|
* this buffer must be alloc by the caller.
|
|
* @return: error code. see ERR_XXX.
|
|
*/
|
|
uint32_t iot_bt_ext_set_mac_addr(uint8_t *addr);
|
|
|
|
/* @brief set bluetooth device local name
|
|
*
|
|
* @param name: bluetooth device name pointer. little endian byte order.
|
|
* @param len: device name string length(39byte max)
|
|
*
|
|
* @return: error code. see ERR_XXX.
|
|
*/
|
|
uint32_t iot_bt_ext_set_local_name(uint8_t *name, uint8_t len);
|
|
|
|
/* @brief set bluetooth security pair enable/disable
|
|
*
|
|
* @param is_enable: 0-disable, others-enable
|
|
*
|
|
* @return: error code. see ERR_XXX.
|
|
*/
|
|
uint32_t iot_bt_ext_set_security_pair(uint8_t is_enable);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|