BLE距离问题
-
- Posts: 36
- Joined: Thu Jun 29, 2017 7:20 am
Re: BLE距离问题
for(i=0; i<ESP_BLE_PWR_TYPE_DEFAULT; i++){
ret = esp_ble_tx_power_set(i,ESP_PWR_LVL_P7);
if (ret) {
ESP_LOGE(GATTC_TAG, "%s set ble tx power failed: %s\n", __func__, esp_err_to_name(ret));
return;
}else{
ESP_LOGE(GATTC_TAG, "%s set ble tx power success\n", __func__);
}
}
程序中加入以上代码后,测试距离,没有什么变化啊!!
ret = esp_ble_tx_power_set(i,ESP_PWR_LVL_P7);
if (ret) {
ESP_LOGE(GATTC_TAG, "%s set ble tx power failed: %s\n", __func__, esp_err_to_name(ret));
return;
}else{
ESP_LOGE(GATTC_TAG, "%s set ble tx power success\n", __func__);
}
}
程序中加入以上代码后,测试距离,没有什么变化啊!!
-
- Posts: 36
- Joined: Thu Jun 29, 2017 7:20 am
Re: BLE距离问题
Hi,nick.yao wrote: ↑Thu Nov 28, 2019 10:55 amfor(i=0; i<ESP_BLE_PWR_TYPE_DEFAULT; i++){
ret = esp_ble_tx_power_set(i,ESP_PWR_LVL_P7);
if (ret) {
ESP_LOGE(GATTC_TAG, "%s set ble tx power failed: %s\n", __func__, esp_err_to_name(ret));
return;
}else{
ESP_LOGE(GATTC_TAG, "%s set ble tx power success\n", __func__);
}
}
程序中加入以上代码后,测试距离,没有什么变化啊!!
对于连接的情况, 需要连接成功后去设置才会生效. 你是连接后才去设置吗?
设置后, 你看下手机端收到的 RSSI 是否变大了? 一些软件会显示收到的 BLE 包的 RSSI.
Thanks,
Island
Re: BLE距离问题
在gattc_profile_event_handler的ESP_GATTC_CONNECT_EVT中将代码改写成:
case ESP_GATTC_CONNECT_EVT:
ESP_LOGI(GATTC_TAG, "ESP_GATTC_CONNECT_EVT: conn_id=%d, gatt_if = %d", spp_conn_id, gattc_if);
ESP_LOGI(GATTC_TAG, "REMOTE BDA:");
esp_log_buffer_hex(GATTC_TAG, gl_profile_tab[PROFILE_APP_ID].remote_bda, sizeof(esp_bd_addr_t));
spp_gattc_if = gattc_if;
is_connect = true;
spp_conn_id = p_data->connect.conn_id;
memcpy(gl_profile_tab[PROFILE_APP_ID].remote_bda, p_data->connect.remote_bda, sizeof(esp_bd_addr_t));
for(i=0; i<ESP_BLE_PWR_TYPE_ADV; i++){
ret = esp_ble_tx_power_set(i,ESP_PWR_LVL_P7);
if (ret) {
ESP_LOGE(GATTC_TAG, "%s set ble tx power failed: %s\n", __func__, esp_err_to_name(ret));
return;
}else{
ESP_LOGE(GATTC_TAG, "%s set ble tx power success-------------------------------------------------", __func__);
}
}
esp_ble_gattc_search_service(spp_gattc_if, spp_conn_id, &spp_service_uuid);
break;
经测试距离有所增加,从8米增加至10米,再远就不行了。
case ESP_GATTC_CONNECT_EVT:
ESP_LOGI(GATTC_TAG, "ESP_GATTC_CONNECT_EVT: conn_id=%d, gatt_if = %d", spp_conn_id, gattc_if);
ESP_LOGI(GATTC_TAG, "REMOTE BDA:");
esp_log_buffer_hex(GATTC_TAG, gl_profile_tab[PROFILE_APP_ID].remote_bda, sizeof(esp_bd_addr_t));
spp_gattc_if = gattc_if;
is_connect = true;
spp_conn_id = p_data->connect.conn_id;
memcpy(gl_profile_tab[PROFILE_APP_ID].remote_bda, p_data->connect.remote_bda, sizeof(esp_bd_addr_t));
for(i=0; i<ESP_BLE_PWR_TYPE_ADV; i++){
ret = esp_ble_tx_power_set(i,ESP_PWR_LVL_P7);
if (ret) {
ESP_LOGE(GATTC_TAG, "%s set ble tx power failed: %s\n", __func__, esp_err_to_name(ret));
return;
}else{
ESP_LOGE(GATTC_TAG, "%s set ble tx power success-------------------------------------------------", __func__);
}
}
esp_ble_gattc_search_service(spp_gattc_if, spp_conn_id, &spp_service_uuid);
break;
经测试距离有所增加,从8米增加至10米,再远就不行了。
Who is online
Users browsing this forum: No registered users and 59 guests