Merge branch 'bugfix/btdm_bluedroid' into 'master'

Bugfix/btdm bluedroid

Cleanup all the warnings。
Fix GATT CLIENT cannot receive notfiy/indicate from GATT SERVER bug.

Originally, bluetooth have its own master branch(feature/btdm_bluedroid), all the bluetooth sub branch will merge to feature/btdm_bluedroid firstly. If feature/btdm_bluedroid is ready, it will request merge to master. But as Ivan/JG/Jack's requires, all the bluetooth bugfix or feature will request merge to master ASAP.
This MR contains "cleanup warning " and "some bug fix", after, every merge request only contain one thing.

See merge request !286
This commit is contained in:
Jiang Jiang Jian 2016-12-15 16:10:21 +08:00
commit 70d39aa105
30 changed files with 481 additions and 105 deletions

View file

@ -10,10 +10,16 @@ config BT_ENABLED
config BTC_TASK_STACK_SIZE
int "BT event (callback to application) task stack size"
default 2048
default 3072
help
This select btc task stack size
config BLUEDROID_MEM_DEBUG
bool "Bluedroid memory debug"
default no
help
Bluedroid memory debug
#config BT_BTLE
# bool "Enable BTLE"
# depends on BT_ENABLED

View file

@ -340,7 +340,7 @@ esp_gatt_status_t esp_ble_gattc_register_for_notify (esp_gatt_if_t gatt_if,
msg.pid = BTC_PID_GATTC;
msg.act = BTC_GATTC_ACT_REG_FOR_NOTIFY;
arg.reg_for_notify.gatt_if = gatt_if;
memcpy(&arg.reg_for_notify.remote_bda, &server_bda, sizeof(esp_bd_addr_t));
memcpy(arg.reg_for_notify.remote_bda, server_bda, sizeof(esp_bd_addr_t));
memcpy(&arg.reg_for_notify.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
memcpy(&arg.reg_for_notify.char_id, char_id, sizeof(esp_gatt_id_t));
@ -359,7 +359,7 @@ esp_gatt_status_t esp_ble_gattc_unregister_for_notify (esp_gatt_if_t gatt_if,
msg.pid = BTC_PID_GATTC;
msg.act = BTC_GATTC_ACT_UNREG_FOR_NOTIFY;
arg.unreg_for_notify.gatt_if = gatt_if;
memcpy(&arg.unreg_for_notify.remote_bda, &server_bda, sizeof(esp_bd_addr_t));
memcpy(arg.unreg_for_notify.remote_bda, server_bda, sizeof(esp_bd_addr_t));
memcpy(&arg.unreg_for_notify.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
memcpy(&arg.unreg_for_notify.char_id, char_id, sizeof(esp_gatt_id_t));

View file

@ -15,12 +15,14 @@
#ifndef __ESP_BLUFI_API_H__
#define __ESP_BLUFI_API_H__
#include "bt_types.h"
#include "esp_bt_defs.h"
#include "esp_gatt_defs.h"
#include "bta_gatt_api.h"
#include "esp_err.h"
#ifdef __cplusplus
extern "C" {
#endif
#define ESP_BLUFI_RECV_DATA_LEN_MAX (64+1)
#define ESP_BLUFI_EVENT_INIT_FINISH 0
@ -112,6 +114,8 @@ esp_err_t esp_blufi_profile_init(void);
*/
esp_err_t esp_blufi_profile_deinit(void);
#ifdef __cplusplus
}
#endif
#endif /* _ESP_BLUFI_API_ */

View file

@ -18,6 +18,10 @@
#include <stdint.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
/// Status Return Value
typedef enum {
ESP_BT_STATUS_SUCCESS = 0, /* Successful operation. */
@ -99,4 +103,8 @@ typedef enum {
*/
typedef void (* esp_profile_cb_t)(uint32_t event, void *param);
#endif ///__ESP_BT_DEFS_H__
#ifdef __cplusplus
}
#endif
#endif /* __ESP_BT_DEFS_H__ */

View file

@ -15,9 +15,12 @@
#ifndef __ESP_BT_MAIN_H__
#define __ESP_BT_MAIN_H__
#include "btc_main.h"
#include "esp_err.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Enable bluetooth, must after esp_init_bluetooth()
*
@ -54,5 +57,8 @@ esp_err_t esp_init_bluetooth(void);
*/
esp_err_t esp_deinit_bluetooth(void);
#ifdef __cplusplus
}
#endif
#endif /* __ESP_BT_MAIN_H__ */

View file

@ -21,6 +21,10 @@
#include "esp_err.h"
#include "esp_bt_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
/// GAP BLE callback event type
typedef enum {
ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT = 0, /*!< When advertising data set complete, the event comes */
@ -421,4 +425,8 @@ esp_err_t esp_ble_gap_set_device_name(const char *name);
*/
uint8_t *esp_ble_resolve_adv_data(uint8_t *adv_data, uint8_t type, uint8_t *length);
#ifdef __cplusplus
}
#endif
#endif /* __ESP_GAP_BLE_API_H__ */

View file

@ -17,6 +17,107 @@
#include "esp_bt_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
/// GATT INVALID UUID
#define ESP_GATT_ILLEGAL_UUID 0
/**@{
* All "ESP_GATT_UUID_xxx" is attribute types
*/
#define ESP_GATT_UUID_PRI_SERVICE 0x2800
#define ESP_GATT_UUID_SEC_SERVICE 0x2801
#define ESP_GATT_UUID_INCLUDE_SERVICE 0x2802
#define ESP_GATT_UUID_CHAR_DECLARE 0x2803 /* Characteristic Declaration*/
#define ESP_GATT_UUID_CHAR_EXT_PROP 0x2900 /* Characteristic Extended Properties */
#define ESP_GATT_UUID_CHAR_DESCRIPTION 0x2901 /* Characteristic User Description*/
#define ESP_GATT_UUID_CHAR_CLIENT_CONFIG 0x2902 /* Client Characteristic Configuration */
#define ESP_GATT_UUID_CHAR_SRVR_CONFIG 0x2903 /* Server Characteristic Configuration */
#define ESP_GATT_UUID_CHAR_PRESENT_FORMAT 0x2904 /* Characteristic Presentation Format*/
#define ESP_GATT_UUID_CHAR_AGG_FORMAT 0x2905 /* Characteristic Aggregate Format*/
#define ESP_GATT_UUID_CHAR_VALID_RANGE 0x2906 /* Characteristic Valid Range */
#define ESP_GATT_UUID_EXT_RPT_REF_DESCR 0x2907
#define ESP_GATT_UUID_RPT_REF_DESCR 0x2908
/* GAP Profile Attributes */
#define ESP_GATT_UUID_GAP_DEVICE_NAME 0x2A00
#define ESP_GATT_UUID_GAP_ICON 0x2A01
#define ESP_GATT_UUID_GAP_PREF_CONN_PARAM 0x2A04
#define ESP_GATT_UUID_GAP_CENTRAL_ADDR_RESOL 0x2AA6
/* Attribute Profile Attribute UUID */
#define ESP_GATT_UUID_GATT_SRV_CHGD 0x2A05
/* Link ESP_Loss Service */
#define ESP_GATT_UUID_ALERT_LEVEL 0x2A06 /* Alert Level */
#define ESP_GATT_UUID_TX_POWER_LEVEL 0x2A07 /* TX power level */
/* Current Time Service */
#define ESP_GATT_UUID_CURRENT_TIME 0x2A2B /* Current Time */
#define ESP_GATT_UUID_LOCAL_TIME_INFO 0x2A0F /* Local time info */
#define ESP_GATT_UUID_REF_TIME_INFO 0x2A14 /* reference time information */
/* Network availability Profile */
#define ESP_GATT_UUID_NW_STATUS 0x2A18 /* network availability status */
#define ESP_GATT_UUID_NW_TRIGGER 0x2A1A /* Network availability trigger */
/* Phone alert */
#define ESP_GATT_UUID_ALERT_STATUS 0x2A3F /* alert status */
#define ESP_GATT_UUID_RINGER_CP 0x2A40 /* ringer control point */
#define ESP_GATT_UUID_RINGER_SETTING 0x2A41 /* ringer setting */
/* Glucose Service */
#define ESP_GATT_UUID_GM_MEASUREMENT 0x2A18
#define ESP_GATT_UUID_GM_CONTEXT 0x2A34
#define ESP_GATT_UUID_GM_CONTROL_POINT 0x2A52
#define ESP_GATT_UUID_GM_FEATURE 0x2A51
/* device information characteristic */
#define ESP_GATT_UUID_SYSTEM_ID 0x2A23
#define ESP_GATT_UUID_MODEL_NUMBER_STR 0x2A24
#define ESP_GATT_UUID_SERIAL_NUMBER_STR 0x2A25
#define ESP_GATT_UUID_FW_VERSION_STR 0x2A26
#define ESP_GATT_UUID_HW_VERSION_STR 0x2A27
#define ESP_GATT_UUID_SW_VERSION_STR 0x2A28
#define ESP_GATT_UUID_MANU_NAME 0x2A29
#define ESP_GATT_UUID_IEEE_DATA 0x2A2A
#define ESP_GATT_UUID_PNP_ID 0x2A50
/* HID characteristics */
#define ESP_GATT_UUID_HID_INFORMATION 0x2A4A
#define ESP_GATT_UUID_HID_REPORT_MAP 0x2A4B
#define ESP_GATT_UUID_HID_CONTROL_POINT 0x2A4C
#define ESP_GATT_UUID_HID_REPORT 0x2A4D
#define ESP_GATT_UUID_HID_PROTO_MODE 0x2A4E
#define ESP_GATT_UUID_HID_BT_KB_INPUT 0x2A22
#define ESP_GATT_UUID_HID_BT_KB_OUTPUT 0x2A32
#define ESP_GATT_UUID_HID_BT_MOUSE_INPUT 0x2A33
/* Battery Service characteristics */
#define ESP_GATT_UUID_BATTERY_LEVEL 0x2A19
/* Sensor Service */
#define ESP_GATT_UUID_SC_CONTROL_POINT 0x2A55
#define ESP_GATT_UUID_SENSOR_LOCATION 0x2A5D
/* Runners speed and cadence service */
#define ESP_GATT_UUID_RSC_MEASUREMENT 0x2A53
#define ESP_GATT_UUID_RSC_FEATURE 0x2A54
/* Cycling speed and cadence service */
#define ESP_GATT_UUID_CSC_MEASUREMENT 0x2A5B
#define ESP_GATT_UUID_CSC_FEATURE 0x2A5C
/* Scan ESP_Parameter characteristics */
#define ESP_GATT_UUID_SCAN_INT_WINDOW 0x2A4F
#define ESP_GATT_UUID_SCAN_REFRESH 0x2A31
/**
* @}
*/
/// Attribute write data type from the client
typedef enum {
ESP_GATT_PREP_WRITE_CANCEL = 0x00, /*!< Prepare write cancel */
@ -109,15 +210,11 @@ typedef struct {
* @brief Gatt authentication request type
*/
typedef enum {
AUTH_REQ_NO_SCATTERNET, /* Device doesn't support scatternet, it might
support "role switch during connection" for
an incoming connection, when it already has
another connection in master role */
AUTH_REQ_PARTIAL_SCATTERNET, /* Device supports partial scatternet. It can have
simulateous connection in Master and Slave roles
for short period of time */
AUTH_REQ_FULL_SCATTERNET /* Device can have simultaneous connection in master
and slave roles */
ESP_GATT_AUTH_REQ_NONE = 0,
ESP_GATT_AUTH_REQ_NO_MITM = 1, /* unauthenticated encryption */
ESP_GATT_AUTH_REQ_MITM = 2, /* authenticated encryption */
ESP_GATT_AUTH_REQ_SIGNED_NO_MITM = 3,
ESP_GATT_AUTH_REQ_SIGNED_MITM = 4,
} esp_gatt_auth_req_t;
/**
@ -174,4 +271,8 @@ typedef enum {
typedef uint32_t esp_gatt_if_t; /*!< Gatt interface type, different application on GATT client use different gatt_if */
#ifdef __cplusplus
}
#endif
#endif /* __ESP_GATT_DEFS_H__ */

8
components/bt/bluedroid/api/include/esp_gattc_api.h Executable file → Normal file
View file

@ -15,11 +15,14 @@
#ifndef __ESP_GATTC_API_H__
#define __ESP_GATTC_API_H__
#include "bt_types.h"
#include "esp_bt_defs.h"
#include "esp_gatt_defs.h"
#include "esp_err.h"
#ifdef __cplusplus
extern "C" {
#endif
/// GATT Client callback function events
typedef enum {
ESP_GATTC_REG_EVT = 0, /*!< When GATT client is registered, the event comes */
@ -572,5 +575,8 @@ esp_gatt_status_t esp_ble_gattc_unregister_for_notify (esp_gatt_if_t gatt_if,
esp_gatt_srvc_id_t *srvc_id,
esp_gatt_id_t *char_id);
#ifdef __cplusplus
}
#endif
#endif /* __ESP_GATTC_API_H__ */

View file

@ -15,12 +15,14 @@
#ifndef __ESP_GATTS_API_H__
#define __ESP_GATTS_API_H__
#include "bt_types.h"
#include "esp_bt_defs.h"
#include "esp_gatt_defs.h"
#include "bta_gatt_api.h"
#include "esp_err.h"
#ifdef __cplusplus
extern "C" {
#endif
/// GATT Server callback function events
typedef enum {
ESP_GATTS_REG_EVT = 0, /*!< When register application id, the event comes */
@ -458,5 +460,8 @@ esp_err_t esp_ble_gatts_open(esp_gatt_if_t gatt_if, esp_bd_addr_t remote_bda, bo
*/
esp_err_t esp_ble_gatts_close(uint16_t conn_id);
#ifdef __cplusplus
}
#endif
#endif /* __ESP_GATTS_API_H__ */

View file

@ -431,6 +431,10 @@ void bta_dm_disable (tBTA_DM_MSG *p_data)
bta_sys_start_timer(&bta_dm_cb.disable_timer, 0, 5000);
}
#if BLE_PRIVACY_SPT == TRUE
btm_ble_resolving_list_cleanup (); //by TH, because cmn_ble_vsc_cb.max_filter has something mistake as btm_ble_adv_filter_cleanup
#endif
}
/*******************************************************************************

View file

@ -2168,12 +2168,16 @@ void BTA_VendorCleanup (void)
BTM_BleGetVendorCapabilities(&cmn_ble_vsc_cb);
#if (BLE_INCLUDED == TRUE && BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE)
btm_ble_adv_filter_cleanup(); // when BLE_VND_INCLUDED is false, this function will be ignore, so move it out of "if"
#if 0 //by TH, comment out temporarily
if (cmn_ble_vsc_cb.max_filter > 0) {
btm_ble_adv_filter_cleanup();
#if BLE_PRIVACY_SPT == TRUE
btm_ble_resolving_list_cleanup ();
#endif
}
#endif
if (cmn_ble_vsc_cb.tot_scan_results_strg > 0) {
btm_ble_batchscan_cleanup();

View file

@ -598,6 +598,8 @@ void bta_alarm_cb(void *data)
TIMER_LIST_ENT *p_tle = (TIMER_LIST_ENT *)data;
fixed_queue_enqueue(btu_bta_alarm_queue, p_tle);
btu_task_post(SIG_BTU_WORK);
}
void bta_sys_start_timer(TIMER_LIST_ENT *p_tle, UINT16 type, INT32 timeout_ms)

View file

@ -313,25 +313,8 @@ static void btc_ble_set_adv_data(esp_ble_adv_data_t *adv_data,
static void btc_ble_start_advertising (esp_ble_adv_params_t *ble_adv_params)
{
tBTA_DM_DISC disc_mode = 0;
tBTA_DM_CONN conn_mode = 0;
tBLE_BD_ADDR peer_addr;
if (ble_adv_params->adv_type == ADV_TYPE_NONCONN_IND) {
conn_mode = BTA_DM_BLE_NON_CONNECTABLE;
} else {
conn_mode = BTA_DM_BLE_CONNECTABLE;
}
if (ble_adv_params->adv_filter_policy == ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY) {
disc_mode = BTA_DM_BLE_GENERAL_DISCOVERABLE;
} else if (ble_adv_params->adv_filter_policy == ADV_FILTER_ALLOW_SCAN_WLST_CON_ANY
|| ble_adv_params->adv_filter_policy == ADV_FILTER_ALLOW_SCAN_ANY_CON_WLST) {
disc_mode = BTA_DM_BLE_LIMITED_DISCOVERABLE;
} else if (ble_adv_params->adv_filter_policy == ADV_FILTER_ALLOW_SCAN_WLST_CON_WLST) {
disc_mode = BTA_DM_BLE_NON_DISCOVERABLE;
}
if (!BLE_ISVALID_PARAM(ble_adv_params->adv_int_min, BTM_BLE_ADV_INT_MIN, BTM_BLE_ADV_INT_MAX) ||
!BLE_ISVALID_PARAM(ble_adv_params->adv_int_max, BTM_BLE_ADV_INT_MIN, BTM_BLE_ADV_INT_MAX)) {
LOG_ERROR("Invalid advertisting interval parameters.\n");
@ -351,7 +334,6 @@ static void btc_ble_start_advertising (esp_ble_adv_params_t *ble_adv_params)
}
LOG_DEBUG("API_Ble_AppStartAdvertising\n");
///
memcpy(peer_addr.bda, ble_adv_params->peer_addr, ESP_BD_ADDR_LEN);
peer_addr.type = ble_adv_params->peer_addr_type;
BTA_DmSetBleAdvParamsAll(ble_adv_params->adv_int_min,
@ -361,9 +343,6 @@ static void btc_ble_start_advertising (esp_ble_adv_params_t *ble_adv_params)
ble_adv_params->channel_map,
ble_adv_params->adv_filter_policy,
&peer_addr);
/*set connectable,discoverable, pairable and paired only modes of local device*/
BTA_DmSetVisibility(disc_mode, conn_mode, (UINT8)BTA_DM_NON_PAIRABLE, (UINT8)BTA_DM_CONN_ALL);
}

View file

@ -584,7 +584,7 @@ void btc_gattc_cb_handler(btc_msg_t *msg)
case BTA_GATTC_NOTIF_EVT: {
tBTA_GATTC_NOTIFY *notify = &arg->notify;
param.notify.conn_id = notify->conn_id;
memcpy(&param.notify.remote_bda, &notify->bda, sizeof(esp_bd_addr_t));
memcpy(param.notify.remote_bda, notify->bda, sizeof(esp_bd_addr_t));
bta_to_btc_srvc_id(&param.notify.srvc_id, &notify->char_id.srvc_id);
bta_to_btc_gatt_id(&param.notify.char_id, &notify->char_id.char_id);
bta_to_btc_gatt_id(&param.notify.descr_id, &notify->descr_type);
@ -605,7 +605,7 @@ void btc_gattc_cb_handler(btc_msg_t *msg)
param.open.status = open->status;
param.open.conn_id = open->conn_id;
param.open.gatt_if = open->client_if;
memcpy(&param.open.remote_bda, &open->remote_bda, sizeof(esp_bd_addr_t));
memcpy(param.open.remote_bda, open->remote_bda, sizeof(esp_bd_addr_t));
param.open.mtu = open->mtu;
BTC_GATTC_CB_TO_APP(ESP_GATTC_OPEN_EVT, &param);
break;
@ -615,7 +615,7 @@ void btc_gattc_cb_handler(btc_msg_t *msg)
param.close.status = close->status;
param.close.conn_id = close->conn_id;
param.close.gatt_if = close->client_if;
memcpy(&param.close.remote_bda, &close->remote_bda, sizeof(esp_bd_addr_t));
memcpy(param.close.remote_bda, close->remote_bda, sizeof(esp_bd_addr_t));
param.close.reason = close->reason;
BTC_GATTC_CB_TO_APP(ESP_GATTC_CLOSE_EVT, &param);
break;
@ -646,7 +646,7 @@ void btc_gattc_cb_handler(btc_msg_t *msg)
break;
}
case BTA_GATTC_SRVC_CHG_EVT: {
memcpy(&param.srvc_chg.remote_bda, &arg->remote_bda, sizeof(esp_bd_addr_t));
memcpy(param.srvc_chg.remote_bda, arg->remote_bda, sizeof(esp_bd_addr_t));
BTC_GATTC_CB_TO_APP(ESP_GATTC_SRVC_CHG_EVT, &param);
break;
}

View file

@ -20,15 +20,6 @@
#include "allocator.h"
#include "gki_int.h"
#define ALIGN_POOL(pl_size) ( (((pl_size) + 3) / sizeof(UINT32)) * sizeof(UINT32))
#define BUFFER_HDR_SIZE (sizeof(BUFFER_HDR_T)) /* Offset past header */
#define BUFFER_PADDING_SIZE (sizeof(BUFFER_HDR_T) + sizeof(UINT32)) /* Header + Magic Number */
#define MAGIC_NO 0xDDBADDBA
#define BUF_STATUS_FREE 0
#define BUF_STATUS_UNLINKED 1
#define BUF_STATUS_QUEUED 2
/*******************************************************************************
**
** Function gki_init_free_queue
@ -173,7 +164,7 @@ void GKI_init_q (BUFFER_Q *p_q)
/*******************************************************************************
**
** Function GKI_getbuf
** Function GKI_getbuf_func
**
** Description Called by an application to get a free buffer which
** is of size greater or equal to the requested size.
@ -187,7 +178,7 @@ void GKI_init_q (BUFFER_Q *p_q)
** Returns A pointer to the buffer, or NULL if none available
**
*******************************************************************************/
void *GKI_getbuf (UINT16 size)
void *GKI_getbuf_func(UINT16 size)
{
BUFFER_HDR_T *header = osi_malloc(size + BUFFER_HDR_SIZE);
header->status = BUF_STATUS_UNLINKED;
@ -198,10 +189,9 @@ void *GKI_getbuf (UINT16 size)
return header + 1;
}
/*******************************************************************************
**
** Function GKI_getpoolbuf
** Function GKI_getpoolbuf_func
**
** Description Called by an application to get a free buffer from
** a specific buffer pool.
@ -214,9 +204,9 @@ void *GKI_getbuf (UINT16 size)
** Returns A pointer to the buffer, or NULL if none available
**
*******************************************************************************/
void *GKI_getpoolbuf (UINT8 pool_id)
void *GKI_getpoolbuf_func(UINT8 pool_id)
{
return GKI_getbuf(gki_cb.com.pool_size[pool_id]);
return GKI_getbuf_func(gki_cb.com.pool_size[pool_id]);
}
/*******************************************************************************
@ -235,7 +225,6 @@ void GKI_freebuf (void *p_buf)
osi_free((BUFFER_HDR_T *)p_buf - 1);
}
/*******************************************************************************
**
** Function GKI_get_buf_size

View file

@ -21,8 +21,18 @@
#include "bt_target.h"
#include "bt_types.h"
#include "gki_common.h"
#include "gki_int.h"
#include "allocator.h"
//static const char GKI_MODULE[] = "gki_module";
#define ALIGN_POOL(pl_size) ( (((pl_size) + 3) / sizeof(UINT32)) * sizeof(UINT32))
#define BUFFER_HDR_SIZE (sizeof(BUFFER_HDR_T)) /* Offset past header */
#define BUFFER_PADDING_SIZE (sizeof(BUFFER_HDR_T) + sizeof(UINT32)) /* Header + Magic Number */
#define MAGIC_NO 0xDDBADDBA
#define BUF_STATUS_FREE 0
#define BUF_STATUS_UNLINKED 1
#define BUF_STATUS_QUEUED 2
/* Timer list entry callback type
*/
@ -62,14 +72,37 @@ typedef struct {
/* To get and release buffers, change owner and get size
*/
void *GKI_getbuf_func(UINT16);
void *GKI_getpoolbuf_func(UINT8);
void GKI_freebuf(void *);
void *GKI_getbuf (UINT16);
UINT16 GKI_get_buf_size (void *);
void *GKI_getpoolbuf (UINT8);
UINT16 GKI_poolcount (UINT8);
UINT16 GKI_poolfreecount (UINT8);
UINT16 GKI_poolutilization (UINT8);
#ifdef CONFIG_BLUEDROID_MEM_DEBUG
#define GKI_getbuf(_size) \
({ \
BUFFER_HDR_T *header = osi_malloc((_size) + BUFFER_HDR_SIZE); \
header->status = BUF_STATUS_UNLINKED; \
header->p_next = NULL; \
header->Type = 0; \
header->size = (_size); \
(void *)(header + 1); \
})
#define GKI_getpoolbuf(_pool_id) \
({ \
(void *)GKI_getbuf(gki_cb.com.pool_size[(_pool_id)]); \
})
#else
#define GKI_getbuf GKI_getbuf_func
#define GKI_getpoolbuf GKI_getpoolbuf_func
#endif /* CONFIG_BLUEDROID_MEM_DEBUG */
/* User buffer queue management
*/

View file

@ -198,7 +198,7 @@ static void hci_layer_deinit_env(void)
command_waiting_response_t *cmd_wait_q;
if (hci_host_env.command_queue) {
fixed_queue_free(hci_host_env.command_queue, osi_free);
fixed_queue_free(hci_host_env.command_queue, allocator_calloc.free);
}
if (hci_host_env.packet_queue) {
fixed_queue_free(hci_host_env.packet_queue, buffer_allocator->free);
@ -405,8 +405,8 @@ static void restart_comamnd_waiting_response_timer(
timeout = osi_alarm_time_diff(COMMAND_PENDING_TIMEOUT, timeout);
timeout = (timeout <= COMMAND_PENDING_TIMEOUT) ? timeout : COMMAND_PENDING_TIMEOUT;
osi_alarm_set(cmd_wait_q->command_response_timer, timeout);
cmd_wait_q->timer_is_set = true;
osi_alarm_set(cmd_wait_q->command_response_timer, timeout);
}
static void command_timed_out(void *context)
@ -488,6 +488,8 @@ static bool filter_incoming_event(BT_HDR *packet)
return false;
intercepted:
restart_comamnd_waiting_response_timer(&hci_host_env.cmd_waiting_q, false);
/*Tell HCI Host Task to continue TX Pending commands*/
if (hci_host_env.command_credits &&
!fixed_queue_is_empty(hci_host_env.command_queue)) {
@ -495,8 +497,6 @@ intercepted:
}
//ke_event_set(KE_EVENT_HCI_HOST_THREAD);
restart_comamnd_waiting_response_timer(&hci_host_env.cmd_waiting_q, false);
if (wait_entry) {
// If it has a callback, it's responsible for freeing the packet
if (event_code == HCI_COMMAND_STATUS_EVT ||

View file

@ -37,6 +37,7 @@
#include "hash_functions.h"
#include "controller.h"
#include "hci_layer.h"
#include "bta_api.h"
//#include "bluedroid_test.h"
/*
@ -104,6 +105,7 @@ fixed_queue_t *btu_hci_msg_queue;
bluedroid_init_done_cb_t bluedroid_init_done_cb;
extern void osi_mem_dbg_init(void);
/******************************************************************************
**
** Function bte_main_boot_entry
@ -115,6 +117,10 @@ bluedroid_init_done_cb_t bluedroid_init_done_cb;
******************************************************************************/
int bte_main_boot_entry(bluedroid_init_done_cb_t cb)
{
#ifdef CONFIG_BLUEDROID_MEM_DEBUG
osi_mem_dbg_init();
#endif
if (gki_init()) {
LOG_ERROR("%s: Init GKI Module Failure.\n", __func__);
return -1;
@ -163,6 +169,7 @@ void bte_main_shutdown(void)
{
//data_dispatcher_register_default(hci_layer_get_interface()->event_dispatcher, NULL);
hci->set_data_queue(NULL);
fixed_queue_unregister_dequeue(btu_hci_msg_queue);
fixed_queue_free(btu_hci_msg_queue, NULL);
btu_hci_msg_queue = NULL;
@ -174,9 +181,11 @@ void bte_main_shutdown(void)
module_clean_up(get_module(GKI_MODULE));
*/
gki_clean_up();
#if (BLE_INCLUDED == TRUE)
BTA_VendorCleanup();
#endif
bte_main_disable();
gki_clean_up();
}
/******************************************************************************

View file

@ -62,7 +62,7 @@ static void alarm_cb_handler(TimerHandle_t xTimer)
struct alarm_t *alarm;
if (!xTimer) {
LOG_DEBUG("TimerName: NULL\n");
LOG_ERROR("TimerName: NULL\n");
return;
}

View file

@ -24,6 +24,97 @@
extern void *pvPortZalloc(size_t size);
extern void vPortFree(void *pv);
#ifdef CONFIG_BLUEDROID_MEM_DEBUG
#define OSI_MEM_DBG_INFO_MAX 1024
typedef struct {
void *p;
int size;
const char *func;
int line;
} osi_mem_dbg_info_t;
static uint32_t mem_dbg_count = 0;
static uint32_t mem_dbg_count2 = 0;
static osi_mem_dbg_info_t mem_dbg_info[OSI_MEM_DBG_INFO_MAX];
void osi_mem_dbg_init(void)
{
int i;
for (i = 0; i < OSI_MEM_DBG_INFO_MAX; i++) {
mem_dbg_info[i].p = NULL;
mem_dbg_info[i].size = 0;
mem_dbg_info[i].func = NULL;
mem_dbg_info[i].line = 0;
}
mem_dbg_count = 0;
mem_dbg_count2 = 0;
}
void osi_mem_dbg_record(void *p, int size, const char *func, int line)
{
int i;
if (!p || size == 0) {
LOG_ERROR("%s invalid !!\n", __func__);
return;
}
for (i = 0; i < OSI_MEM_DBG_INFO_MAX; i++) {
if (mem_dbg_info[i].p == NULL) {
mem_dbg_info[i].p = p;
mem_dbg_info[i].size = size;
mem_dbg_info[i].func = func;
mem_dbg_info[i].line = line;
mem_dbg_count++;
break;
}
}
if (i >= OSI_MEM_DBG_INFO_MAX) {
LOG_ERROR("%s full %s %d !!\n", __func__, func, line);
}
}
void osi_mem_dbg_clean(void *p, const char *func, int line)
{
int i;
if (!p) {
LOG_ERROR("%s invalid\n", __func__);
return;
}
for (i = 0; i < OSI_MEM_DBG_INFO_MAX; i++) {
if (mem_dbg_info[i].p == p) {
mem_dbg_info[i].p = NULL;
mem_dbg_info[i].size = 0;
mem_dbg_info[i].func = NULL;
mem_dbg_info[i].line = 0;
mem_dbg_count--;
break;
}
}
if (i >= OSI_MEM_DBG_INFO_MAX) {
LOG_ERROR("%s full %s %d !!\n", __func__, func, line);
}
}
void osi_mem_dbg_show(void)
{
int i;
for (i = 0; i < OSI_MEM_DBG_INFO_MAX; i++) {
if (mem_dbg_info[i].p || mem_dbg_info[i].size != 0 ) {
LOG_ERROR("--> p %p, s %d, f %s, l %d\n", mem_dbg_info[i].p, mem_dbg_info[i].size, mem_dbg_info[i].func, mem_dbg_info[i].line);
}
}
LOG_ERROR("--> count %d\n", mem_dbg_count);
}
#endif
char *osi_strdup(const char *str)
{
size_t size = strlen(str) + 1; // + 1 for the null terminator
@ -37,27 +128,46 @@ char *osi_strdup(const char *str)
return new_string;
}
void *osi_malloc(size_t size)
void *osi_malloc_func(size_t size)
{
#ifdef CONFIG_BLUEDROID_MEM_DEBUG
void *p;
p = calloc(1, size);
osi_mem_dbg_record(p, size, __func__, __LINE__);
return p;
#else
return calloc(1, size);
#endif
}
void *osi_calloc(size_t size)
void *osi_calloc_func(size_t size)
{
#ifdef CONFIG_BLUEDROID_MEM_DEBUG
void *p;
p = calloc(1, size);
osi_mem_dbg_record(p, size, __func__, __LINE__);
return p;
#else
return calloc(1, size);
#endif
}
void osi_free(void *ptr)
void osi_free_func(void *ptr)
{
#ifdef CONFIG_BLUEDROID_MEM_DEBUG
osi_mem_dbg_clean(ptr, __func__, __LINE__);
#endif
free(ptr);
}
const allocator_t allocator_malloc = {
osi_malloc,
osi_free
osi_malloc_func,
osi_free_func
};
const allocator_t allocator_calloc = {
osi_calloc,
osi_free
osi_calloc_func,
osi_free_func
};

View file

@ -16,22 +16,13 @@
*
******************************************************************************/
// #define LOG_TAG "bt_osi_future"
// #include <assert.h>
#include "bt_trace.h"
#include "allocator.h"
#include "future.h"
#include "osi.h"
//#include "osi/include/log.h"
#include "osi_arch.h"
struct future_t {
bool ready_can_be_called;
osi_sem_t semaphore; // NULL semaphore means immediate future
void *result;
};
static void future_free(future_t *future);
future_t *future_new(void)
@ -100,7 +91,7 @@ static void future_free(future_t *future)
return;
}
if (!future->semaphore) {
if (future->semaphore) {
osi_sem_free(&future->semaphore);
}

View file

@ -36,8 +36,47 @@ extern const allocator_t allocator_calloc;
char *osi_strdup(const char *str);
void *osi_malloc(size_t size);
void *osi_calloc(size_t size);
void osi_free(void *ptr);
void *osi_malloc_func(size_t size);
void *osi_calloc_func(size_t size);
void osi_free_func(void *ptr);
#ifdef CONFIG_BLUEDROID_MEM_DEBUG
void osi_mem_dbg_init(void);
void osi_mem_dbg_record(void *p, int size, const char *func, int line);
void osi_mem_dbg_clean(void *p, const char *func, int line);
void osi_mem_dbg_show(void);
#define osi_malloc(size) \
({ \
void *p; \
\
p = calloc(1, (size)); \
osi_mem_dbg_record(p, size, __func__, __LINE__); \
(void *)p; \
})
#define osi_calloc(size) \
({ \
void *p; \
\
p = calloc(1, (size)); \
osi_mem_dbg_record(p, size, __func__, __LINE__); \
(void *)p; \
})
#define osi_free(ptr) \
({ \
osi_mem_dbg_clean(ptr, __func__, __LINE__); \
free((ptr)); \
})
#else
#define osi_malloc(size) calloc(1, (size))
#define osi_calloc(size) calloc(1, (size))
#define osi_free(p) free((p))
#endif /* CONFIG_BLUEDROID_MEM_DEBUG */
#endif /* _ALLOCATOR_H_ */

View file

@ -20,7 +20,14 @@
#define __FUTURE_H__
// #pragma once
typedef struct future_t future_t;
#include "osi_arch.h"
struct future {
bool ready_can_be_called;
osi_sem_t semaphore; // NULL semaphore means immediate future
void *result;
};
typedef struct future future_t;
#define FUTURE_SUCCESS ((void *)1)
#define FUTURE_FAIL ((void *)0)

View file

@ -43,18 +43,18 @@ enum {
SIG_BTIF_WORK = 0xff
};
#define HCI_HOST_TASK_STACK_SIZE 1024
#define HCI_HOST_TASK_PRIO (configMAX_PRIORITIES - 3)
#define HCI_HOST_TASK_STACK_SIZE 1500
#define HCI_HOST_TASK_PRIO (configMAX_PRIORITIES - 2)
#define HCI_HOST_TASK_NAME "hciHostT"
#define HCI_HOST_QUEUE_NUM 30
#define HCI_HOST_QUEUE_NUM 40
#define HCI_H4_TASK_STACK_SIZE 1024
#define HCI_H4_TASK_STACK_SIZE 1500
#define HCI_H4_TASK_PRIO (configMAX_PRIORITIES - 3)
#define HCI_H4_TASK_NAME "hciH4T"
#define HCI_H4_QUEUE_NUM 30
#define HCI_H4_QUEUE_NUM 60
#define BTU_TASK_STACK_SIZE 4096
#define BTU_TASK_PRIO (configMAX_PRIORITIES - 1)
#define BTU_TASK_PRIO (configMAX_PRIORITIES - 4)
#define BTU_TASK_NAME "btuT"
#define BTU_QUEUE_NUM 50

View file

@ -64,7 +64,7 @@ static void background_connections_lazy_init()
{
if (!background_connections) {
background_connections = hash_map_new(background_connection_buckets,
hash_function_bdaddr, NULL, osi_free, bdaddr_equality_fn);
hash_function_bdaddr, NULL, allocator_calloc.free, bdaddr_equality_fn);
assert(background_connections);
}
}

View file

@ -1076,6 +1076,14 @@ tBTM_STATUS BTM_BleSetAdvParamsStartAdv(UINT16 adv_int_min, UINT16 adv_int_max,
return BTM_ILLEGAL_VALUE;
}
if(adv_type == BTM_BLE_CONNECT_DIR_EVT){
btm_ble_set_topology_mask(BTM_BLE_STATE_HI_DUTY_DIR_ADV_BIT);
}else if(adv_type == BTM_BLE_CONNECT_LO_DUTY_DIR_EVT){
btm_ble_set_topology_mask(BTM_BLE_STATE_LO_DUTY_DIR_ADV_BIT);
}else if(adv_type == BTM_BLE_CONNECT_LO_DUTY_DIR_EVT){
btm_ble_set_topology_mask(BTM_BLE_STATE_NON_CONN_ADV_BIT);
}
p_cb->adv_interval_min = adv_int_min;
p_cb->adv_interval_max = adv_int_max;
p_cb->adv_chnl_map = chnl_map;

View file

@ -217,9 +217,9 @@ error_exit:;
void BTU_ShutDown(void)
{
btu_task_shut_down();
/*
fixed_queue_free(btu_bta_msg_queue, NULL);
*/
hash_map_free(btu_general_alarm_hash_map);
pthread_mutex_destroy(&btu_general_alarm_lock);
fixed_queue_free(btu_general_alarm_queue, NULL);

View file

@ -378,7 +378,6 @@ void btu_task_start_up(void)
void btu_task_shut_down(void)
{
fixed_queue_unregister_dequeue(btu_hci_msg_queue);
fixed_queue_unregister_dequeue(btu_general_alarm_queue);
fixed_queue_unregister_dequeue(btu_oneshot_alarm_queue);
fixed_queue_unregister_dequeue(btu_l2cap_alarm_queue);

View file

@ -25,7 +25,65 @@ Header Files
Macros
^^^^^^
.. doxygendefine:: ESP_GATT_UUID_PRI_SERVICE
.. doxygendefine:: ESP_GATT_UUID_SEC_SERVICE
.. doxygendefine:: ESP_GATT_UUID_INCLUDE_SERVICE
.. doxygendefine:: ESP_GATT_UUID_CHAR_DECLARE
.. doxygendefine:: ESP_GATT_UUID_CHAR_EXT_PROP
.. doxygendefine:: ESP_GATT_UUID_CHAR_DESCRIPTION
.. doxygendefine:: ESP_GATT_UUID_CHAR_CLIENT_CONFIG
.. doxygendefine:: ESP_GATT_UUID_CHAR_SRVR_CONFIG
.. doxygendefine:: ESP_GATT_UUID_CHAR_PRESENT_FORMAT
.. doxygendefine:: ESP_GATT_UUID_CHAR_AGG_FORMAT
.. doxygendefine:: ESP_GATT_UUID_CHAR_VALID_RANGE
.. doxygendefine:: ESP_GATT_UUID_EXT_RPT_REF_DESCR
.. doxygendefine:: ESP_GATT_UUID_RPT_REF_DESCR
.. doxygendefine:: ESP_GATT_UUID_GAP_DEVICE_NAME
.. doxygendefine:: ESP_GATT_UUID_GAP_ICON
.. doxygendefine:: ESP_GATT_UUID_GAP_PREF_CONN_PARAM
.. doxygendefine:: ESP_GATT_UUID_GAP_CENTRAL_ADDR_RESOL
.. doxygendefine:: ESP_GATT_UUID_GATT_SRV_CHGD
.. doxygendefine:: ESP_GATT_UUID_ALERT_LEVEL
.. doxygendefine:: ESP_GATT_UUID_TX_POWER_LEVEL
.. doxygendefine:: ESP_GATT_UUID_CURRENT_TIME
.. doxygendefine:: ESP_GATT_UUID_LOCAL_TIME_INFO
.. doxygendefine:: ESP_GATT_UUID_REF_TIME_INFO
.. doxygendefine:: ESP_GATT_UUID_NW_STATUS
.. doxygendefine:: ESP_GATT_UUID_NW_TRIGGER
.. doxygendefine:: ESP_GATT_UUID_ALERT_STATUS
.. doxygendefine:: ESP_GATT_UUID_RINGER_CP
.. doxygendefine:: ESP_GATT_UUID_RINGER_SETTING
.. doxygendefine:: ESP_GATT_UUID_GM_MEASUREMENT
.. doxygendefine:: ESP_GATT_UUID_GM_CONTEXT
.. doxygendefine:: ESP_GATT_UUID_GM_CONTROL_POINT
.. doxygendefine:: ESP_GATT_UUID_GM_FEATURE
.. doxygendefine:: ESP_GATT_UUID_SYSTEM_ID
.. doxygendefine:: ESP_GATT_UUID_MODEL_NUMBER_STR
.. doxygendefine:: ESP_GATT_UUID_SERIAL_NUMBER_STR
.. doxygendefine:: ESP_GATT_UUID_FW_VERSION_STR
.. doxygendefine:: ESP_GATT_UUID_HW_VERSION_STR
.. doxygendefine:: ESP_GATT_UUID_SW_VERSION_STR
.. doxygendefine:: ESP_GATT_UUID_MANU_NAME
.. doxygendefine:: ESP_GATT_UUID_IEEE_DATA
.. doxygendefine:: ESP_GATT_UUID_PNP_ID
.. doxygendefine:: ESP_GATT_UUID_HID_INFORMATION
.. doxygendefine:: ESP_GATT_UUID_HID_REPORT_MAP
.. doxygendefine:: ESP_GATT_UUID_HID_CONTROL_POINT
.. doxygendefine:: ESP_GATT_UUID_HID_REPORT
.. doxygendefine:: ESP_GATT_UUID_HID_PROTO_MODE
.. doxygendefine:: ESP_GATT_UUID_HID_BT_KB_INPUT
.. doxygendefine:: ESP_GATT_UUID_HID_BT_KB_OUTPUT
.. doxygendefine:: ESP_GATT_UUID_HID_BT_MOUSE_INPUT
.. doxygendefine:: ESP_GATT_UUID_BATTERY_LEVEL
.. doxygendefine:: ESP_GATT_UUID_SC_CONTROL_POINT
.. doxygendefine:: ESP_GATT_UUID_SENSOR_LOCATION
.. doxygendefine:: ESP_GATT_UUID_RSC_MEASUREMENT
.. doxygendefine:: ESP_GATT_UUID_RSC_FEATURE
.. doxygendefine:: ESP_GATT_UUID_CSC_MEASUREMENT
.. doxygendefine:: ESP_GATT_UUID_CSC_FEATURE
.. doxygendefine:: ESP_GATT_UUID_SCAN_INT_WINDOW
.. doxygendefine:: ESP_GATT_UUID_SCAN_REFRESH
.. doxygendefine:: ESP_GATT_ILLEGAL_UUID
.. doxygendefine:: ESP_GATT_MAX_ATTR_LEN
Type Definitions

View file

@ -165,7 +165,7 @@ static void gatts_event_handler(uint32_t event, void *param)
gl_test.char_handle = p->add_char.attr_handle;
gl_test.descr_uuid.len = ESP_UUID_LEN_16;
gl_test.descr_uuid.uuid.uuid16 = GATT_UUID_CHAR_CLIENT_CONFIG;
gl_test.descr_uuid.uuid.uuid16 = ESP_GATT_UUID_CHAR_CLIENT_CONFIG;
esp_ble_gatts_add_char_descr(gl_test.service_handle, &gl_test.descr_uuid,
ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE);
break;