-
Notifications
You must be signed in to change notification settings - Fork 219
Description
Hi!
I'm trying to flash the switch demo on both an ESP32C3 and ESPS3 board, respectively.
I'm running into a situation where, it appears that the demo code fails to handle some information from the Tuya app if the device has been added before and not deleted via the "Delete device and clear data option".
Symptoms:
- on both boards, the setup can consistently trigger the pairing wizard on the app, on both Android and iOS.
- The first pairing will succeed.
- However, if I'm to reflash a new compiled version "tos.py flash" onto the board, it loses the pairing info (which is expected).
- In this state, it still triggers the pairing wizard on the app. But going through the same pairing process will not work. It will hang for a while and present "Failed to add the device".
- It appears that the workaround would be to delete the device and clear data, kill the mobile app, and open it again. In this way, it pairs again.
This behaves differently from a real Tuya device, where, if the device is manually reset, and added back to the same user, it picks up previous pairing info, and it restores the pairing. There's no need to manually clear the pairing info.
It appears that, when it fails to pair, it would receive 4 bluetooth packets from the host, total length at about 993 bytes. It would fail the CRC32 check.
I have tried the info on tuya/tuya-connect-kit-for-mqtt-embedded-c#106 checking on endianness. I can confirm that LITTLE_ENDIAN is set.
I also confirm that the device has bluetooth MTU set to 256 (which is above 247)
At least in one case, this is the CRC32 I got:
expected: 0xcedf, actual: 0xb867
this does not align with the theory that it's an endianness issue.
I suspect forcing Tuya to do a soft AP pairing without bluetooth will work. However, I'm not able to find a no-code product solution on Tuya Developer Platform for this test (also this repo claims that bluetooth pairing is supported).
I have tried changing changing netmgr_conn_set to:
netmgr_conn_set(NETCONN_WIFI, NETCONN_CMD_NETCFG, &(netcfg_args_t){
.type = NETCFG_TUYA_WIFI_AP
});
but it does not disable bluetooth pairing, despite removing the BLUETOOTH constant.
serial:
[01-01 00:00:05 ty D][reset_netcfg.c:62] reset count write 0
[01-01 00:00:05 ty D][tal_kv.c:202] key:rst_cnt, len 1
[01-01 00:00:05 ty D][reset_netcfg.c:69] reset cnt clear!
[01-01 00:00:21 ty I][ble_hs.c:433] ble_hs_timer reset:0
[01-01 00:00:21 ty I][tkl_bluetooth.c:146] BLE_GAP_EVENT_CONNECT(0x00), handle = 0x01, Role(1)
[01-01 00:00:21 ty N][ble_mgr.c:909] Ble Connected
[01-01 00:00:21 ty D][ble_hs_hci_evt.c:152] evt code null:20
[01-01 00:00:21 ty I][ble_hs.c:393] ble_hs_timer_exp:
[01-01 00:00:22 ty D][ble_hs_hci_evt.c:152] evt code null:12
[01-01 00:00:22 ty I][tkl_bluetooth.c:190] mtu update event; conn_handle=0x0001 mtu=256, channel id = 4
[01-01 00:00:22 ty I][tkl_bluetooth.c:216] BLE_GAP_EVENT_SUBSCRIBE
[01-01 00:00:22 ty D][ble_mgr.c:226] ble recv sub_pkg desc:3, no:1, pack_len:49, total_len:49
[01-01 00:00:22 ty N][ble_mgr.c:316] ble sn:4 recv sn 0
[01-01 00:00:22 ty D][ble_mgr.c:942] ble recv req type 0x0000
[01-01 00:00:22 ty D][ble_trsmitr.c:110] ble sub packet lenth set:253
[01-01 00:00:22 ty N][ble_mgr.c:821] ble dev info: state:0, pkg_len:253
[01-01 00:00:22 ty I][tkl_bluetooth.c:200] send notify ok
[01-01 00:00:22 ty D][ble_mgr.c:600] ble resp finish. len:161, rt:0x0
[01-01 00:00:22 ty D][ble_mgr.c:226] ble recv sub_pkg desc:3, no:1, pack_len:129, total_len:129
[01-01 00:00:22 ty N][ble_mgr.c:316] ble sn:5 recv sn 4
[01-01 00:00:22 ty D][ble_mgr.c:942] ble recv req type 0x0001
[01-01 00:00:22 ty N][ble_mgr.c:712] Ble is paired
[01-01 00:00:22 ty I][tkl_bluetooth.c:200] send notify ok
[01-01 00:00:22 ty D][ble_mgr.c:600] ble resp finish. len:33, rt:0x0
[01-01 00:00:22 ty D][ble_mgr.c:729] ble send netstat 0
[01-01 00:00:22 ty I][tkl_bluetooth.c:200] send notify ok
[01-01 00:00:23 ty D][ble_mgr.c:600] ble resp finish. len:33, rt:0x0
[01-01 00:00:23 ty I][ble_hs.c:433] ble_hs_timer reset:0
[01-01 00:00:23 ty D][ble_mgr.c:226] ble recv sub_pkg desc:1, no:1, pack_len:249, total_len:249
[01-01 00:00:23 ty I][ble_hs.c:433] ble_hs_timer reset:0
[01-01 00:00:23 ty D][ble_mgr.c:271] ble receive multi-packet...
[01-01 00:00:23 ty D][ble_mgr.c:226] ble recv sub_pkg desc:2, no:2, pack_len:252, total_len:501
[01-01 00:00:23 ty I][ble_hs.c:433] ble_hs_timer reset:0
[01-01 00:00:23 ty D][ble_mgr.c:271] ble receive multi-packet...
[01-01 00:00:23 ty D][ble_mgr.c:226] ble recv sub_pkg desc:2, no:3, pack_len:252, total_len:753
[01-01 00:00:23 ty D][ble_mgr.c:271] ble receive multi-packet...
[01-01 00:00:23 ty D][ble_mgr.c:226] ble recv sub_pkg desc:3, no:4, pack_len:240, total_len:993
[01-01 00:00:23 ty E][ble_mgr.c:307] ble packet crc err:0xcedf, 0x7ba4
[01-01 00:00:23 ty E][ble_mgr.c:938] tuya_ble_data_proc fail. -2
[01-01 00:00:23 ty I][ble_hs.c:393] ble_hs_timer_exp:
[01-01 00:00:33 ty I][tkl_bluetooth.c:216] BLE_GAP_EVENT_SUBSCRIBE
[01-01 00:00:33 ty N][tkl_bluetooth.c:158] BLE_GAP_EVENT_DISCONNECT(0x213)
[01-01 00:00:33 ty I][ble_gap.c:2248] GAP init: stop adv
[01-01 00:00:33 ty I][ble_hs.c:433] ble_hs_timer reset:0
[01-01 00:00:33 ty E][ble_mgr.c:361] ret:-28683
[01-01 00:00:33 ty N][ble_gap.c:2509] Start Adv
[01-01 00:00:33 ty N][ble_mgr.c:366] ble adv updated 0
[01-01 00:00:33 ty N][ble_mgr.c:923] Ble Disonnected
[01-01 00:00:33 ty I][ble_hs.c:393] ble_hs_timer_exp:
Any insights into the "pairing recovery" please?
(I noticed that the product I picked, 6+2 switch with Wifi+Bluetooth doesn't have an option for PlugPlay Repair. A different test product using 8 power strip, which has the PlugPlay Repair DISABLED, also exhibit this same issue).
Thank you!
===
可以讲中文,如果更方便的话
你好!我发现我在试图运行switch_demo于ESP32C3和ESP32S3并连接Tuya手机端时,遇到以下情况:
- 第一次添加设备可以正常添加
- 重刷固件以后,设备丢失连接(正常情况)
- 此时若再次由手机端连接,会固定产生无法连接产品情况
- 若此时于手机端删除设备及数据,关闭手机app,重开app重新连接则可以正常连接
此现象与正常tuya产品不同:正常tuya产品在手工重置后如上第3步不需要手工删除设备即可重新连接
串口观察到 从手机端收到4个包 合共长度约993字节 并提示CRC32校验错误
CRC32之校验错误expected: 0xcedf, actual: 0xb867与处理器大小端的假设不同 且验证过构建属性正常配置小端(参见https://github.com/tuya/tuya-connect-kit-for-mqtt-embedded-c/issues/106)
此外,尝试修改netmgr_conn_set之参数,删除蓝牙连接内容,但未能生效(观察到设备行为无二致,照样产生如上所述蓝牙连接失败)
目前不能判定是否与Tuya开发者平台上配置之产品规格有关。未能在贵司平台找到纯Wifi之产品配置。
谢谢!