ESP32-S3 如果是要蓝牙和手机app通讯的,应该用哪一个例程?

122722629@qq.com
Posts: 20
Joined: Wed Feb 16, 2022 7:01 am

ESP32-S3 如果是要蓝牙和手机app通讯的,应该用哪一个例程?

Postby 122722629@qq.com » Thu Mar 31, 2022 5:55 am

有很多例程,不知道用哪一个好,谢谢了
微信截图_20220331135450.png
微信截图_20220331135450.png (60.19 KiB) Viewed 3500 times

122722629@qq.com
Posts: 20
Joined: Wed Feb 16, 2022 7:01 am

Re: ESP32-S3 如果是要蓝牙和手机app通讯的,应该用哪一个例程?

Postby 122722629@qq.com » Thu Mar 31, 2022 7:18 am

试了一下gatt_server_service_table例程

虽然,可以收发数据,但是发送(手机端读取)只能是固定的

static const uint8_t char_value[4] = {0x11, 0x22, 0x33, 0x44};

如果需要可以手机正常收发通讯的,应该用哪个例程?

898791901@qq.com
Posts: 4
Joined: Wed Jan 12, 2022 1:24 am

Re: ESP32-S3 如果是要蓝牙和手机app通讯的,应该用哪一个例程?

Postby 898791901@qq.com » Thu Mar 31, 2022 8:24 am

gatt_client

122722629@qq.com
Posts: 20
Joined: Wed Feb 16, 2022 7:01 am

Re: ESP32-S3 如果是要蓝牙和手机app通讯的,应该用哪一个例程?

Postby 122722629@qq.com » Thu Mar 31, 2022 9:09 am

while(true)
{
if( gatts_info.bEnable )
{
i++ ;
buf[0] = i >> 24 ;
buf[1] = i >> 16 ;
buf[2] = i >> 8 ;
buf[3] = i ;
esp_err_t t = esp_ble_gatts_send_indicate(gatts_info.gatts_if , gatts_info.conn_id, gatts_info.attr_handle ,
sizeof(buf), buf, false);

ESP_LOGI(GATTS_TABLE_TAG,"send %d ,ret %d",i,t);
}
vTaskDelay(500);
}


已经可以发数据了,通过这个函数发数据。

Who is online

Users browsing this forum: No registered users and 39 guests