component/bt: Added the set static random address callback to the bt project.
component/bt: fixed the set static random address error.
/// Status Return Value
typedef enum {
- ESP_BT_STATUS_SUCCESS = 0, /* Successful operation. */
- ESP_BT_STATUS_FAILURE = 1, /* Generic failure. */
- ESP_BT_STATUS_PENDING = 2, /* API cannot be completed right now */
- ESP_BT_STATUS_BUSY = 3,
- ESP_BT_STATUS_NO_RESOURCES = 4,
- ESP_BT_STATUS_WRONG_MODE = 5,
+ ESP_BT_STATUS_SUCCESS = 0, /* Successful operation. */
+ ESP_BT_STATUS_FAILURE = 1, /* Generic failure. */
+ ESP_BT_STATUS_PENDING = 2, /* API cannot be completed right now */
+ ESP_BT_STATUS_BUSY = 3,
+ ESP_BT_STATUS_NO_RESOURCES = 4,
+ ESP_BT_STATUS_WRONG_MODE = 5,
+ ESP_BT_STATUS_INVALID_STATIC_RAND_ADDR = 6,
} esp_bt_status_t;
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_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;
/// Advertising data maximum length
struct ble_adv_stop_cmpl_evt_param {
esp_bt_status_t status; /*!< Indicate adv stop operation success status */
} 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;
/**
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) {
- BTA_DmSetRandAddress(rand_addr);
+ if((rand_addr[BD_ADDR_LEN - 1] & BT_STATIC_RAND_ADDR_MASK)
+ == BT_STATIC_RAND_ADDR_MASK) {
+ BTA_DmSetRandAddress(rand_addr);
+ } else {
+ 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 {
- LOG_ERROR("Invalid randrom address.\n");
+ 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, ¶m,
+ sizeof(esp_ble_gap_cb_param_t), NULL);
+
+ if (ret != BT_STATUS_SUCCESS) {
+ LOG_ERROR("%s btc_transfer_context failed\n", __func__);
}
}
case ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT:
btc_gap_ble_cb_to_app(ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT, param);
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:
break;
BT_STATUS_UNHANDLED,
BT_STATUS_AUTH_FAILURE,
BT_STATUS_RMT_DEV_DOWN,
- BT_STATUS_AUTH_REJECTED
+ BT_STATUS_AUTH_REJECTED,
} bt_status_t;
#ifndef CPU_LITTLE_ENDIAN
*/
#define BT_EVT_MASK 0xFF00
#define BT_SUB_EVT_MASK 0x00FF
+#define BT_STATIC_RAND_ADDR_MASK 0xC0
/* To Bluetooth Upper Layers */
/************************************/
#define BT_EVT_TO_BTU_L2C_EVT 0x0900 /* L2CAP event */