return (btc_transfer_context(&msg, &arg, sizeof(esp_ble_gap_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
+
+esp_err_t esp_ble_gap_stop_scanning(void)
+{
+ btc_msg_t msg;
+ esp_ble_gap_args_t arg;
+
+ msg.sig = BTC_SIG_API_CALL;
+ msg.pid = BTC_PID_GAP_BLE;
+ msg.act = BTC_GAP_BLE_ACT_STOP_SCAN;
+ return (btc_transfer_context(&msg, &arg, sizeof(esp_ble_gap_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+}
+
esp_err_t esp_ble_gap_start_advertising(esp_ble_adv_params_t *adv_params)
{
btc_msg_t msg;
esp_err_t esp_ble_gap_start_scanning(uint32_t duration);
+/*******************************************************************************
+**
+** @function esp_ble_gap_stop_scanning
+**
+** @brief This function call to stop the device scanning the peer device whith advertising on the air
+** @param void
+** @return ESP_OK - success, other - failed
+**
+*******************************************************************************/
+esp_err_t esp_ble_gap_stop_scanning(void);
/*******************************************************************************
**
return BT_STATUS_NOMEM;
}
memcpy(lmsg.arg, arg, arg_len);
- temp = (tBTA_GATTC *)lmsg.arg;
- temp2 = (tBTA_GATTC *)arg;
- LOG_ERROR("###the temp status = %x, if = %x\n####\n",
- temp->reg_oper.status,temp->reg_oper.client_if);
- LOG_ERROR("###the arg status = %x, if = %x\n####\n",
- temp2->reg_oper.status, temp2->reg_oper.client_if);
if (copy_func) {
copy_func(&lmsg, lmsg.arg, arg);
}
}
}
+static void btc_ble_stop_scanning(void)
+{
+ uint8_t duration = 0;
+ BTA_DmBleObserve(false, duration, NULL);
+}
+
static void btc_ble_stop_advertising(void)
{
btc_ble_start_scanning(arg->duration, btc_search_callback);
break;
case BTC_GAP_BLE_ACT_STOP_SCAN:
+ btc_ble_stop_scanning();
break;
case BTC_GAP_BLE_ACT_START_ADV:
btc_ble_start_advertising(&arg->adv_params);
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_GATTC;
msg.act = (uint8_t) event;
+ LOG_ERROR("the gattc event = %x\n",event);
ret = btc_transfer_context(&msg, p_data, sizeof(tBTA_GATTC), btc_gattc_copy_req_data);
if (ret)
{
connet = TRUE;
LOG_ERROR("Connet to the remote device.\n");
+ esp_ble_gap_stop_scanning();
esp_ble_gattc_open(client_if, scan_result->scan_rst.bda, TRUE);
}
}
static void esp_gattc_result_cb(uint32_t event, void *gattc_param)
{
+ uint16_t conidx = 0;
esp_ble_gattc_cb_param_t *gattc_data = (esp_ble_gattc_cb_param_t *)gattc_param;
LOG_ERROR("esp_gattc_result_cb, event = %x\n", event);
switch (event)
LOG_ERROR("status = %x, client_if = %x\n", status, client_if);
break;
case ESP_GATTC_OPEN_EVT:
+ conidx = gattc_data->open.conn_id;
+ LOG_ERROR("conidx = %x, if = %x\n",conidx, gattc_data->open.gatt_if);
+ esp_ble_gattc_search_service(conidx, NULL);
LOG_ERROR("ESP_GATTC_OPEN_EVT\n");
break;
default: