GATT CLIENT接收乱码
GATT CLIENT接收乱码
gatt client,连接ELM327车载OBD芯片,初始化接收乱码。ATZ,ATI等是初始化指令,发送后会首先返回,紧接着是应答值,乱码如下所示,请教一下如何解决?
I (3027) GATTC_DEMO: connect to the remote device.
I (3037) GATTC_DEMO: stop scan successfully
I (3087) GATTC_DEMO: ESP_GATTC_CONNECT_EVT conn_id 0, if 3
I (3087) GATTC_DEMO: REMOTE BDA:
I (3097) GATTC_DEMO: 00 1d a5 68 98 8b
I (3097) GATTC_DEMO: open success
I (3387) GATTC_DEMO: discover service complete conn_id 0
I (3397) GATTC_DEMO: SEARCH RES: conn_id = 0 is primary service 1
I (3397) GATTC_DEMO: start handle 18 end handle 65535 current handle value 18
I (3407) GATTC_DEMO: service found
I (3407) GATTC_DEMO: UUID16: fff0
I (3407) GATTC_DEMO: Get service information from remote device
I (3417) GATTC_DEMO: ESP_GATTC_SEARCH_CMPL_EVT
I (3427) GATTC_DEMO: ESP_GATTC_CFG_MTU_EVT, Status 0, MTU 23, conn_id 0
I (3427) GATTC_DEMO: ESP_GATTC_REG_FOR_NOTIFY_EVT
I (3457) GATTC_DEMO: write char success
I (3467) GATTC_DEMO: ESP_GATTC_NOTIFY_EVT, receive notify value:
� (3467) GATTC_DEMO: atz
I (3557) GATTC_DEMO: update connection params status = 0, min_int = 8, max_int = 16,conn_int = 16,latency = 0, timeout = 300
I (4267) GATTC_DEMO: ESP_GATTC_NOTIFY_EVT, receive notify value:
>LM327 v1.5TTC_DEMO:
I (5447) GATTC_DEMO: write char success
I (5467) GATTC_DEMO: ESP_GATTC_NOTIFY_EVT, receive notify value:
I (5467) GATTC_DEMO: at@1
I (5467) GATTC_DEMO: ���?
I (7447) GATTC_DEMO: write char success
I (7467) GATTC_DEMO: ESP_GATTC_NOTIFY_EVT, receive notify value:
ELM327 v1.5TTC_DEMO: ati
>��7467) GATTC_DEMO:
I (7467) GATTC_DEMO: ESP_GATTC_NOTIFY_EVT, receive notify value:
I (7477) GATTC_DEMO: ��?
I (9447) GATTC_DEMO: write char success
I (9467) GATTC_DEMO: ESP_GATTC_NOTIFY_EVT, receive notify value:
I (9467) GATTC_DEMO: attp
I (9467) GATTC_DEMO: ���?
I (11447) GATTC_DEMO: write char success
I (11467) GATTC_DEMO: ESP_GATTC_NOTIFY_EVT, receive notify value:
I (11467) GATTC_DEMO: 0100
I (11467) GATTC_DEMO: ���?
I (3027) GATTC_DEMO: connect to the remote device.
I (3037) GATTC_DEMO: stop scan successfully
I (3087) GATTC_DEMO: ESP_GATTC_CONNECT_EVT conn_id 0, if 3
I (3087) GATTC_DEMO: REMOTE BDA:
I (3097) GATTC_DEMO: 00 1d a5 68 98 8b
I (3097) GATTC_DEMO: open success
I (3387) GATTC_DEMO: discover service complete conn_id 0
I (3397) GATTC_DEMO: SEARCH RES: conn_id = 0 is primary service 1
I (3397) GATTC_DEMO: start handle 18 end handle 65535 current handle value 18
I (3407) GATTC_DEMO: service found
I (3407) GATTC_DEMO: UUID16: fff0
I (3407) GATTC_DEMO: Get service information from remote device
I (3417) GATTC_DEMO: ESP_GATTC_SEARCH_CMPL_EVT
I (3427) GATTC_DEMO: ESP_GATTC_CFG_MTU_EVT, Status 0, MTU 23, conn_id 0
I (3427) GATTC_DEMO: ESP_GATTC_REG_FOR_NOTIFY_EVT
I (3457) GATTC_DEMO: write char success
I (3467) GATTC_DEMO: ESP_GATTC_NOTIFY_EVT, receive notify value:
� (3467) GATTC_DEMO: atz
I (3557) GATTC_DEMO: update connection params status = 0, min_int = 8, max_int = 16,conn_int = 16,latency = 0, timeout = 300
I (4267) GATTC_DEMO: ESP_GATTC_NOTIFY_EVT, receive notify value:
>LM327 v1.5TTC_DEMO:
I (5447) GATTC_DEMO: write char success
I (5467) GATTC_DEMO: ESP_GATTC_NOTIFY_EVT, receive notify value:
I (5467) GATTC_DEMO: at@1
I (5467) GATTC_DEMO: ���?
I (7447) GATTC_DEMO: write char success
I (7467) GATTC_DEMO: ESP_GATTC_NOTIFY_EVT, receive notify value:
ELM327 v1.5TTC_DEMO: ati
>��7467) GATTC_DEMO:
I (7467) GATTC_DEMO: ESP_GATTC_NOTIFY_EVT, receive notify value:
I (7477) GATTC_DEMO: ��?
I (9447) GATTC_DEMO: write char success
I (9467) GATTC_DEMO: ESP_GATTC_NOTIFY_EVT, receive notify value:
I (9467) GATTC_DEMO: attp
I (9467) GATTC_DEMO: ���?
I (11447) GATTC_DEMO: write char success
I (11467) GATTC_DEMO: ESP_GATTC_NOTIFY_EVT, receive notify value:
I (11467) GATTC_DEMO: 0100
I (11467) GATTC_DEMO: ���?
-
- Posts: 786
- Joined: Wed Nov 14, 2018 8:45 am
Re: GATT CLIENT接收乱码
不是可识别的字符吧,%02x 打印下?
Re: GATT CLIENT接收乱码
因为接收到的根本就是乱码,所以显示不出来,正常应答值应该如下图所示:
I (3507) GATTC_DEMO: Write: atz
I (3537) GATTC_DEMO: Receive:
I (3537) GATTC_DEMO: 61 74 7a 0d fc
I (3647) GATTC_DEMO: update connection params status = 0, min_int = 8, max_int = 16,conn_int = 16,latency = 0, timeout = 300
I (4327) GATTC_DEMO: Receive:
I (4327) GATTC_DEMO: 0d 0d 45 4c 4d 33 32 37 20 76 31 2e 35
I (4347) GATTC_DEMO: Receive:
I (4347) GATTC_DEMO: 0d 0d 3e
I (5507) GATTC_DEMO: Write: at@1
I (5567) GATTC_DEMO: Receive:
I (5567) GATTC_DEMO: 61 74 40 31 00 00 00 00 00 00 00 00 00 ee 08 80
I (5567) GATTC_DEMO: c0 b5 fb 3f
I (7507) GATTC_DEMO: Write: ati
I (7547) GATTC_DEMO: Receive:
I (7547) GATTC_DEMO: 61 74 69 0d 45 4c 4d 33 32 37 20 76 31 2e 35 0d
I (7547) GATTC_DEMO: 0d 3e 80 c0
I (7557) GATTC_DEMO: Receive:
I (7557) GATTC_DEMO: b5 fb 3f
I (9507) GATTC_DEMO: Write: attp
I (9547) GATTC_DEMO: Receive:
I (9547) GATTC_DEMO: 61 74 74 70 00 00 00 00 00 00 00 00 00 ee 08 80
I (9547) GATTC_DEMO: c0 b5 fb 3f
I (11507) GATTC_DEMO: Write: 0100
I (11547) GATTC_DEMO: Receive:
I (11547) GATTC_DEMO: 30 31 30 30 00 00 00 00 00 00 00 00 00 ee 08 80
I (11547) GATTC_DEMO: c0 b5 fb 3f
接收数据误差太大了,不知何故。
对应二进制:
ESP32接收的二进制显示:I (3507) GATTC_DEMO: Write: atz
I (3537) GATTC_DEMO: Receive:
I (3537) GATTC_DEMO: 61 74 7a 0d fc
I (3647) GATTC_DEMO: update connection params status = 0, min_int = 8, max_int = 16,conn_int = 16,latency = 0, timeout = 300
I (4327) GATTC_DEMO: Receive:
I (4327) GATTC_DEMO: 0d 0d 45 4c 4d 33 32 37 20 76 31 2e 35
I (4347) GATTC_DEMO: Receive:
I (4347) GATTC_DEMO: 0d 0d 3e
I (5507) GATTC_DEMO: Write: at@1
I (5567) GATTC_DEMO: Receive:
I (5567) GATTC_DEMO: 61 74 40 31 00 00 00 00 00 00 00 00 00 ee 08 80
I (5567) GATTC_DEMO: c0 b5 fb 3f
I (7507) GATTC_DEMO: Write: ati
I (7547) GATTC_DEMO: Receive:
I (7547) GATTC_DEMO: 61 74 69 0d 45 4c 4d 33 32 37 20 76 31 2e 35 0d
I (7547) GATTC_DEMO: 0d 3e 80 c0
I (7557) GATTC_DEMO: Receive:
I (7557) GATTC_DEMO: b5 fb 3f
I (9507) GATTC_DEMO: Write: attp
I (9547) GATTC_DEMO: Receive:
I (9547) GATTC_DEMO: 61 74 74 70 00 00 00 00 00 00 00 00 00 ee 08 80
I (9547) GATTC_DEMO: c0 b5 fb 3f
I (11507) GATTC_DEMO: Write: 0100
I (11547) GATTC_DEMO: Receive:
I (11547) GATTC_DEMO: 30 31 30 30 00 00 00 00 00 00 00 00 00 ee 08 80
I (11547) GATTC_DEMO: c0 b5 fb 3f
接收数据误差太大了,不知何故。
Re: GATT CLIENT接收乱码
1、看到你图片中发送的指令如“atz ”,后面都多了一个字符,在gatt_client里面可否在写入之前以hex的形式打印出来
2、能否把gatt_client的bin文件、使用的app 及操作方法提供给我们进行复现问题吗
2、能否把gatt_client的bin文件、使用的app 及操作方法提供给我们进行复现问题吗
Re: GATT CLIENT接收乱码
ATZ等指令后是加了回车符0D,ELM327以回车符识别指令是否结束,我用的APP是BLE调试宝,无法识别\r写法,按键回车会当作0A处理,所以手动加了0D,没啥关键作用。
复现的话需要用到ELM327 ObdII行车电脑检测仪器,用于从行车电脑获取水温车速转速故障代码等车辆信息,图片显示的是用手机APP BLE调试宝ble连接ELM327设备手动初始化和ESP32开发板BLE连接elm327设备的初始化过程,同样的设备ESP32接收回传信息一团乱码.
只要手机支持BLE,任何ble调试APP都可以手动输入初始化指令初始ELM327设备,没什么区别。
附上BIN:
复现的话需要用到ELM327 ObdII行车电脑检测仪器,用于从行车电脑获取水温车速转速故障代码等车辆信息,图片显示的是用手机APP BLE调试宝ble连接ELM327设备手动初始化和ESP32开发板BLE连接elm327设备的初始化过程,同样的设备ESP32接收回传信息一团乱码.
只要手机支持BLE,任何ble调试APP都可以手动输入初始化指令初始ELM327设备,没什么区别。
附上BIN:
Re: GATT CLIENT接收乱码
然后又出现了新的问题:
I (3497) GATTC_DEMO: Write: atz
I (3527) GATTC_DEMO: Receive:
� (3537) GATTC_DEMO: atz
I (3597) GATTC_DEMO: update connection params status = 0, min_int = 8, max_int = 16,conn_int = 16,latency = 0, timeout = 300
I (4337) GATTC_DEMO: Receive:
>LM327 v1.5TTC_DEMO:
I (5497) GATTC_DEMO: Write: at@1
I (5537) GATTC_DEMO: Receive:
OBDII to RATTC_DEMO: at@1
I (5547) GATTC_DEMO: S232
I (5547) GATTC_DEMO: Receive:
>t(5547) GATTC_DEMO: Interpreter
I (5557) GATTC_DEMO: Receive:
>0(5557) GATTC_DEMO: tp0
I (7497) GATTC_DEMO: Write: ati
I (7537) GATTC_DEMO: Receive:
ELM327 v1.5TTC_DEMO: ati
>0(7547) GATTC_DEMO:
I (7547) GATTC_DEMO: Receive:
I (7547) GATTC_DEMO: 1
I (7557) GATTC_DEMO: Receive:
41 00 FF FF TC_DEMO: 00
I (7567) GATTC_DEMO: FF F
I (7567) GATTC_DEMO: Receive:
I (7567) GATTC_DEMO: F
I (7657) GATTC_DEMO: Receive:
> (7657) GATTC_DEMO:
I (9497) GATTC_DEMO: Write: attp0
I (9537) GATTC_DEMO: Receive:
>K(9547) GATTC_DEMO: attp0
I (9557) GATTC_DEMO: Receive:
SEARCHING...TC_DEMO: 05
I (9557) GATTC_DEMO:
I (10097) GATTC_DEMO: Receive:
I (10097) GATTC_DEMO: 41 00 FF FF FF F
I (10097) GATTC_DEMO: F
I (10197) GATTC_DEMO: Receive:
> (10197) GATTC_DEMO:
I (11497) GATTC_DEMO: Write: 0100
I (11537) GATTC_DEMO: Receive:
41 00 FF FGATTC_DEMO: 0100
I (11547) GATTC_DEMO: F FF
I (11547) GATTC_DEMO: Receive:
I (11547) GATTC_DEMO: FF
I (11637) GATTC_DEMO: Receive:
> (11637) GATTC_DEMO:
请教如何修改接收中断的超时,让每次接收数据成为一个整体?
I (3497) GATTC_DEMO: Write: atz
I (3527) GATTC_DEMO: Receive:
� (3537) GATTC_DEMO: atz
I (3597) GATTC_DEMO: update connection params status = 0, min_int = 8, max_int = 16,conn_int = 16,latency = 0, timeout = 300
I (4337) GATTC_DEMO: Receive:
>LM327 v1.5TTC_DEMO:
I (5497) GATTC_DEMO: Write: at@1
I (5537) GATTC_DEMO: Receive:
OBDII to RATTC_DEMO: at@1
I (5547) GATTC_DEMO: S232
I (5547) GATTC_DEMO: Receive:
>t(5547) GATTC_DEMO: Interpreter
I (5557) GATTC_DEMO: Receive:
>0(5557) GATTC_DEMO: tp0
I (7497) GATTC_DEMO: Write: ati
I (7537) GATTC_DEMO: Receive:
ELM327 v1.5TTC_DEMO: ati
>0(7547) GATTC_DEMO:
I (7547) GATTC_DEMO: Receive:
I (7547) GATTC_DEMO: 1
I (7557) GATTC_DEMO: Receive:
41 00 FF FF TC_DEMO: 00
I (7567) GATTC_DEMO: FF F
I (7567) GATTC_DEMO: Receive:
I (7567) GATTC_DEMO: F
I (7657) GATTC_DEMO: Receive:
> (7657) GATTC_DEMO:
I (9497) GATTC_DEMO: Write: attp0
I (9537) GATTC_DEMO: Receive:
>K(9547) GATTC_DEMO: attp0
I (9557) GATTC_DEMO: Receive:
SEARCHING...TC_DEMO: 05
I (9557) GATTC_DEMO:
I (10097) GATTC_DEMO: Receive:
I (10097) GATTC_DEMO: 41 00 FF FF FF F
I (10097) GATTC_DEMO: F
I (10197) GATTC_DEMO: Receive:
> (10197) GATTC_DEMO:
I (11497) GATTC_DEMO: Write: 0100
I (11537) GATTC_DEMO: Receive:
41 00 FF FGATTC_DEMO: 0100
I (11547) GATTC_DEMO: F FF
I (11547) GATTC_DEMO: Receive:
I (11547) GATTC_DEMO: FF
I (11637) GATTC_DEMO: Receive:
> (11637) GATTC_DEMO:
请教如何修改接收中断的超时,让每次接收数据成为一个整体?
Re: GATT CLIENT接收乱码
我们 client 接收没有接收超时中断的设置,看你log,应该是你们 server 端发送了多个 notify 的操作,你可以检查下。看你使用 BLE调试宝与我们 client 进行通讯的 log 就很正常
Re: GATT CLIENT接收乱码
大佬,你理解错了,server端就是ELM327 OBDII设备,无论是ESP32还是BLE调试宝APP都是作为client连接ELM327的server进行初始化的操作。
同样是elm327的发送的Notify,BLE调试宝显示就很规范,ESP32就是散装的,所以我以为是ESP32超时设置很小,ESP32会提前返回值。
同样是elm327的发送的Notify,BLE调试宝显示就很规范,ESP32就是散装的,所以我以为是ESP32超时设置很小,ESP32会提前返回值。
Re: GATT CLIENT接收乱码
你再贴个同样 server、同样输入指令的BLE调试宝和我们 esp32 的 log 的对比图吧, 两边都使用hex 的形式输出。 另外,你client MTU值设置为多少?
Who is online
Users browsing this forum: No registered users and 192 guests