ESP32蓝牙 华为手机容易断连解决

在长达两年的售后中,收到华为手机连接ESP32蓝牙是最容易断开连接的,一开始小米手机、苹果手机都没问题,就只有华为,一连上就断开,所以我们认为是APP问题,于是我们去找APP的蓝牙底层,每一次的断开连接都是status =8.也看不懂,于是那我就来改ESP32呗。

把ESP32的BLE发射功率调整到最大,

esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_ADV, ESP_PWR_LVL_P9);

然后把超时时间配置大一点、

case ESP_GATTS_CONNECT_EVT:
		ESP_LOGI(GATTS_TABLE_TAG, "ESP_GATTS_CONNECT_EVT, conn_id = %d", param->connect.conn_id);
		esp_log_buffer_hex(GATTS_TABLE_TAG, param->connect.remote_bda, 6);
		esp_ble_conn_update_params_t conn_params = {0};
		memcpy(conn_params.bda, param->connect.remote_bda, sizeof(esp_bd_addr_t));
		/* For the iOS system, please refer to Apple official documents about the BLE connection parameters restrictions. */
		conn_params.latency = 0;

		conn_params.max_int = 0x40; // max_int = 0x20*1.25ms = 40ms
		conn_params.min_int = 0x20; // min_int = 0x10*1.25ms = 20ms
		conn_params.timeout = 1000;	// timeout = 400*10ms = 4000ms
		//start sent the update connection parameters to the peer device.
		esp_ble_gap_update_conn_params(&conn_params);

然后就解决啦,华为P30 PRO P40 MATE40都不会断开连接了!!!!!

  • 3
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值