mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
component bt:Added the profile task to the bt project
This commit is contained in:
parent
57f8128718
commit
c377650cdd
@ -48,7 +48,7 @@ void bt_prf_sys_init(void)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bt_prf_sys_event(BT_HDR *p_msg)
|
||||
void bt_prf_sys_event(prf_hdr_evt_t *p_msg)
|
||||
{
|
||||
UINT8 id;
|
||||
BOOLEAN freebuf = TRUE;
|
||||
|
@ -38,7 +38,7 @@
|
||||
//ke_event_clear(KE_EVENT_BTU_TASK_THREAD);
|
||||
|
||||
TaskEvt_t *e;
|
||||
for (;;) {
|
||||
for (;;) {
|
||||
if (pdTRUE == xQueueReceive(xProfileQueue, &e, (portTickType)portMAX_DELAY)) {
|
||||
|
||||
if (e->sig == SIG_BTU_WORK) {
|
||||
@ -68,10 +68,10 @@
|
||||
}
|
||||
|
||||
void bt_profile_msg_ready(fixed_queue_t *queue) {
|
||||
BT_HDR *p_msg;
|
||||
prf_hdr_evt_t *p_msg;
|
||||
|
||||
while (!fixed_queue_is_empty(queue)) {
|
||||
p_msg = (BT_HDR *)fixed_queue_dequeue(queue);
|
||||
p_msg = (prf_hdr_evt_t *)fixed_queue_dequeue(queue);
|
||||
if(p_msg != NULL)
|
||||
{
|
||||
bt_prf_sys_event(p_msg);
|
||||
|
@ -16,6 +16,7 @@
|
||||
#define _PROFILE_SYS_H__
|
||||
|
||||
#include "bt_types.h"
|
||||
#include "prf_defs.h"
|
||||
|
||||
enum
|
||||
{
|
||||
@ -38,7 +39,7 @@ typedef UINT8 tBT_PRF_SYS_CONN_STATUS;
|
||||
/* disable function type */
|
||||
typedef void (tBT_PRF_SYS_DISABLE)(void);
|
||||
/* event handler function type */
|
||||
typedef BOOLEAN (tBT_PRF_SYS_EVT_HDLR)(BT_HDR *p_msg);
|
||||
typedef BOOLEAN (tBT_PRF_SYS_EVT_HDLR)(prf_hdr_evt_t *p_msg);
|
||||
|
||||
/* conn callback for role / low power manager*/
|
||||
typedef void (tBT_PRF_SYS_CONN_CBACK)(tBT_PRF_SYS_CONN_STATUS status,
|
||||
@ -73,14 +74,14 @@ extern tBT_PRF_SYS_CB bt_prf_sys_cb;
|
||||
|
||||
extern void bt_prf_sys_init(void);
|
||||
extern void bt_prf_sys_free(void);
|
||||
extern void bt_prf_sys_event(BT_HDR *p_msg);
|
||||
extern void bt_prf_sys_event(prf_hdr_evt_t *p_msg);
|
||||
|
||||
extern void bt_prf_sys_register(UINT8 id, const tBT_PRF_SYS_REG *p_reg);
|
||||
extern void bt_prf_sys_deregister(UINT8 id);
|
||||
extern BOOLEAN bt_prf_sys_is_register(UINT8 id);
|
||||
extern void bt_prf_sys_register(uint8_t id, const tBT_PRF_SYS_REG *p_reg);
|
||||
extern void bt_prf_sys_deregister(uint8_t id);
|
||||
extern BOOLEAN bt_prf_sys_is_register(uint8_t id);
|
||||
|
||||
extern void bt_prf_sys_idle(UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
|
||||
extern void bt_prf_sys_busy(UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
|
||||
extern void bt_prf_sys_idle(uint8_t id, uint8_t app_id, BD_ADDR peer_addr);
|
||||
extern void bt_prf_sys_busy(uint8_t id, uint8_t app_id, BD_ADDR peer_addr);
|
||||
|
||||
|
||||
#endif ///_PROFILE_SYS_H__
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include "bta_api.h"
|
||||
#include "bta_gatt_api.h"
|
||||
#include "bta_gatts_int.h"
|
||||
#include "bt_app_api.h"
|
||||
#include "button_pro.h"
|
||||
|
||||
#include "prf_defs.h"
|
||||
|
@ -36,6 +36,16 @@
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/* Define the header of each buffer used in the profile stack.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t event;
|
||||
uint16_t len;
|
||||
uint8_t data[];
|
||||
} prf_hdr_evt_t;
|
||||
|
||||
|
||||
/// Characteristic Value Descriptor
|
||||
typedef struct
|
||||
{
|
||||
|
@ -1194,6 +1194,41 @@ void esp_ble_gatts_close(uint16_t conn_id)
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_prf_app_register
|
||||
**
|
||||
** @brief This function is called to register application callbacks
|
||||
** with BTA GATTS module.
|
||||
**
|
||||
** @param[in] p_app_uuid - applicaiton UUID
|
||||
** @param[in] p_cback - pointer to the application callback function.
|
||||
**
|
||||
** @return None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_prf_app_register(uint8_t prf_id, void *p_cback)
|
||||
{
|
||||
//tBTA_GATTS_API_REG *p_buf;
|
||||
|
||||
/* register with BTA system manager */
|
||||
if (bt_prf_sys_is_register(PRF_ID_SYS) == FALSE)
|
||||
{
|
||||
bt_prf_sys_register(PRF_ID_SYS, NULL);
|
||||
}
|
||||
|
||||
// if ((p_buf = (tBTA_GATTS_API_REG *) GKI_getbuf(sizeof(tBTA_GATTS_API_REG))) != NULL)
|
||||
// {
|
||||
// p_buf->hdr.event = BTA_GATTS_API_REG_EVT;
|
||||
|
||||
// if (p_app_uuid != NULL)
|
||||
// memcpy(&p_buf->app_uuid, p_app_uuid, sizeof(tBT_UUID));
|
||||
// p_buf->p_cback = p_cback;
|
||||
|
||||
// bta_sys_sendmsg(p_buf);
|
||||
// }
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -68,13 +68,13 @@ static void bt_app_task_handler(void *arg)
|
||||
fixed_queue_process(bt_app_general_alarm_queue);
|
||||
}
|
||||
#if (BUT_PROFILE_CFG)
|
||||
else if(e->sig == BUTTON_PRESS_EVT){
|
||||
LOG_ERROR("button_press_event come in,button_value=%x\n",e->par);
|
||||
button_msg[1] = e->par;
|
||||
button_msg_notify(2,button_msg);
|
||||
// else if(e->sig == BUTTON_PRESS_EVT){
|
||||
// LOG_ERROR("button_press_event come in,button_value=%x\n",e->par);
|
||||
// button_msg[1] = e->par;
|
||||
// button_msg_notify(2,button_msg);
|
||||
|
||||
|
||||
}
|
||||
//}
|
||||
#endif ///BUT_PROFILE_CFG
|
||||
|
||||
}
|
||||
|
@ -41,7 +41,7 @@
|
||||
#include "button_pro.h"
|
||||
#include "app_button_int.h"
|
||||
|
||||
static const tBTA_SYS_REG bta_gatts_reg =
|
||||
static const tBT_PRF_SYS_REG bta_gatts_reg =
|
||||
{
|
||||
ble_but_prf_hdl_event,
|
||||
ble_but_prf_disable
|
||||
@ -59,7 +59,7 @@ static const tBTA_SYS_REG bta_gatts_reg =
|
||||
** Returns BOOLEAN
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN ble_but_prf_hdl_event(BT_HDR *msg_data)
|
||||
BOOLEAN ble_but_prf_hdl_event(prf_hdr_evt_t *msg_data)
|
||||
{
|
||||
UINT16 connid = 0;
|
||||
switch(msg_data->event)
|
||||
@ -112,7 +112,7 @@ void ble_but_prf_disable(void)
|
||||
|
||||
if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
|
||||
{
|
||||
p_buf->event = BTA_GATTS_API_DISABLE_EVT;
|
||||
p_buf->event = BLE_BUT_DISABLE_IND_EVT;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
bta_sys_deregister(PRF_ID_BUT_LE);
|
||||
|
@ -119,7 +119,7 @@ typedef union
|
||||
|
||||
|
||||
|
||||
BOOLEAN ble_but_prf_hdl_event(BT_HDR *msg_data);
|
||||
BOOLEAN ble_but_prf_hdl_event(prf_hdr_evt_t *msg_data);
|
||||
|
||||
void ble_but_prf_disable(void);
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include "bt_types.h"
|
||||
#include "bt_app_defs.h"
|
||||
#include "bta_gatt_api.h"
|
||||
|
||||
#include "bt_prf_sys.h"
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
@ -895,7 +895,7 @@ void esp_ble_gatts_cancel_conn (esp_gatts_if_t server_if, BD_ADDR remote_bda, BO
|
||||
**
|
||||
** @function esp_ble_gatts_close
|
||||
**
|
||||
** @param[in] Close a connection a remote device.
|
||||
** @brief Close a connection a remote device.
|
||||
**
|
||||
** @param[in] conn_id: connectino ID to be closed.
|
||||
**
|
||||
@ -904,3 +904,21 @@ void esp_ble_gatts_cancel_conn (esp_gatts_if_t server_if, BD_ADDR remote_bda, BO
|
||||
*******************************************************************************/
|
||||
void esp_ble_gatts_close(uint16_t conn_id);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_prf_app_register
|
||||
**
|
||||
** @brief This function is called to register application callbacks
|
||||
** with BTA GATTS module.
|
||||
**
|
||||
** @param[in] prf_id - the profile identification
|
||||
** @param[in] p_cback - pointer to the application callback function.
|
||||
**
|
||||
** @return None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void esp_prf_app_register(uint8_t prf_id, void *p_cback);
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user