component/bt: squash the branch of the early commit

component/bt: Added the set static random address callback to the bt project.

component/bt: fixed the set static random address error.
pull/639/merge
Yulong 2017-05-19 05:23:00 -04:00
rodzic 972d1d9242
commit e30459b0de
5 zmienionych plików z 42 dodań i 9 usunięć

Wyświetl plik

@ -30,6 +30,7 @@ typedef enum {
ESP_BT_STATUS_BUSY = 3, ESP_BT_STATUS_BUSY = 3,
ESP_BT_STATUS_NO_RESOURCES = 4, ESP_BT_STATUS_NO_RESOURCES = 4,
ESP_BT_STATUS_WRONG_MODE = 5, ESP_BT_STATUS_WRONG_MODE = 5,
ESP_BT_STATUS_INVALID_STATIC_RAND_ADDR = 6,
} esp_bt_status_t; } esp_bt_status_t;

Wyświetl plik

@ -87,6 +87,7 @@ typedef enum {
ESP_GAP_BLE_NC_REQ_EVT, /* Numeric Comparison request event */ ESP_GAP_BLE_NC_REQ_EVT, /* Numeric Comparison request event */
ESP_GAP_BLE_ADV_STOP_COMPLETE_EVT, /*!< When stop adv complete, the event comes */ ESP_GAP_BLE_ADV_STOP_COMPLETE_EVT, /*!< When stop adv complete, the event comes */
ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT, /*!< When stop scan complete, the event comes */ ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT, /*!< When stop scan complete, the event comes */
ESP_GAP_BLE_SET_STATIC_RAND_ADDR_EVT, /*!< When set the static rand address complete, the event comes */
} esp_gap_ble_cb_event_t; } esp_gap_ble_cb_event_t;
/// Advertising data maximum length /// Advertising data maximum length
@ -485,6 +486,12 @@ typedef union {
struct ble_adv_stop_cmpl_evt_param { struct ble_adv_stop_cmpl_evt_param {
esp_bt_status_t status; /*!< Indicate adv stop operation success status */ esp_bt_status_t status; /*!< Indicate adv stop operation success status */
} adv_stop_cmpl; /*!< Event parameter of ESP_GAP_BLE_ADV_STOP_COMPLETE_EVT */ } adv_stop_cmpl; /*!< Event parameter of ESP_GAP_BLE_ADV_STOP_COMPLETE_EVT */
/**
* @brief ESP_GAP_BLE_SET_STATIC_RAND_ADDR_EVT
*/
struct ble_set_rand_cmpl_evt_param {
esp_bt_status_t status; /*!< Indicate set static rand address operation success status */
} set_rand_addr_cmpl; /*!< Event parameter of ESP_GAP_BLE_SET_STATIC_RAND_ADDR_EVT */
} esp_ble_gap_cb_param_t; } esp_ble_gap_cb_param_t;
/** /**

Wyświetl plik

@ -634,10 +634,32 @@ static void btc_ble_set_pkt_data_len(BD_ADDR remote_device, uint16_t tx_data_len
static void btc_ble_set_rand_addr (BD_ADDR rand_addr) static void btc_ble_set_rand_addr (BD_ADDR rand_addr)
{ {
esp_ble_gap_cb_param_t param;
bt_status_t ret;
btc_msg_t msg;
param.set_rand_addr_cmpl.status = ESP_BT_STATUS_SUCCESS;
if (rand_addr != NULL) { if (rand_addr != NULL) {
if((rand_addr[BD_ADDR_LEN - 1] & BT_STATIC_RAND_ADDR_MASK)
== BT_STATIC_RAND_ADDR_MASK) {
BTA_DmSetRandAddress(rand_addr); BTA_DmSetRandAddress(rand_addr);
} else { } else {
LOG_ERROR("Invalid randrom address.\n"); param.set_rand_addr_cmpl.status = ESP_BT_STATUS_INVALID_STATIC_RAND_ADDR;
LOG_ERROR("Invalid randrom address, the high bit should be 0x11xx");
}
} else {
param.set_rand_addr_cmpl.status = ESP_BT_STATUS_INVALID_STATIC_RAND_ADDR;
LOG_ERROR("Invalid randrom addressm, the address value is NULL");
}
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_GAP_BLE;
msg.act = ESP_GAP_BLE_SET_STATIC_RAND_ADDR_EVT;
ret = btc_transfer_context(&msg, &param,
sizeof(esp_ble_gap_cb_param_t), NULL);
if (ret != BT_STATUS_SUCCESS) {
LOG_ERROR("%s btc_transfer_context failed\n", __func__);
} }
} }
@ -709,6 +731,8 @@ void btc_gap_ble_cb_handler(btc_msg_t *msg)
case ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT: case ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT:
btc_gap_ble_cb_to_app(ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT, param); btc_gap_ble_cb_to_app(ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT, param);
break; break;
case ESP_GAP_BLE_SET_STATIC_RAND_ADDR_EVT:
btc_gap_ble_cb_to_app(ESP_GAP_BLE_SET_STATIC_RAND_ADDR_EVT, param);
default: default:
break; break;

Wyświetl plik

@ -87,7 +87,7 @@ typedef enum {
BT_STATUS_UNHANDLED, BT_STATUS_UNHANDLED,
BT_STATUS_AUTH_FAILURE, BT_STATUS_AUTH_FAILURE,
BT_STATUS_RMT_DEV_DOWN, BT_STATUS_RMT_DEV_DOWN,
BT_STATUS_AUTH_REJECTED BT_STATUS_AUTH_REJECTED,
} bt_status_t; } bt_status_t;
#ifndef CPU_LITTLE_ENDIAN #ifndef CPU_LITTLE_ENDIAN

Wyświetl plik

@ -58,6 +58,7 @@ typedef bool BOOLEAN;
*/ */
#define BT_EVT_MASK 0xFF00 #define BT_EVT_MASK 0xFF00
#define BT_SUB_EVT_MASK 0x00FF #define BT_SUB_EVT_MASK 0x00FF
#define BT_STATIC_RAND_ADDR_MASK 0xC0
/* To Bluetooth Upper Layers */ /* To Bluetooth Upper Layers */
/************************************/ /************************************/
#define BT_EVT_TO_BTU_L2C_EVT 0x0900 /* L2CAP event */ #define BT_EVT_TO_BTU_L2C_EVT 0x0900 /* L2CAP event */