【已解决】[Tuya OS SDK] 初次适配TuyaOS V:6.1.0 蓝牙配网问题

IPC/NVR/可视门铃等具备多媒体能力的设备,扫地机/AGV等机器人设备


郭老庄
Posts: 135

zq. 2024年 Feb 28日 10:16

另外网站上提到的建议5和建议6怎么实现呢?
我记得老版本sdk在配网失败后,一定要重启设备才行,现在6.x的sdk能够通过哪些方式重置进入配网阶段吗?
再者通过蓝牙的方式怎么告知app配网失败了呢?

这个是sdk和手机APP的逻辑,你不用关心。不过当前公版app还没有上这个功能,暂时无法体验。
新版APP除了可以重新进入配网阶段,还可以感知wifi密码错误,扫描wifi列表等功能。因此建议你先把这些功能做起来:

  1. 配网过程中支持扫描wifi列表,涉及API:tkl_wifi_scan_ap
  2. 设备连接ap时需感知wifi密码错误的事件,涉及API:tkl_gen_station_get_status,密码错误时返回WSS_PASSWD_WRONG

Tags:
zq.
Posts: 71

Re: [Tuya OS SDK] 初次适配TuyaOS V:6.1.0 蓝牙配网问题

(1)app大概啥时候能出来,我这边对接完,等有app出来才能验证效果
(2) 上面剩余的疑问帮忙解答下,挺重要,谢谢。 :shock:

郭老庄
Posts: 135

Re: [Tuya OS SDK] 初次适配TuyaOS V:6.1.0 蓝牙配网问题

  1. app预计4月底发布
  2. 崩溃的问题,你可以先不调用tuya_ble_set_startup_attr(TUYA_BLE_ABILITY_NETCFG); 等你想stack deinit的时候,调tuya_ble_set_serv_switch(0);试试
  3. sdk里默认mtu是247
  4. 有些api demo调用,但sdk没调是正常的,demo主要起验证的作用
zq.
Posts: 71

Re: [Tuya OS SDK] 初次适配TuyaOS V:6.1.0 蓝牙配网问题

3.sdk会不会受设备上报的TKL_BLE_GATT_EVT_MTU_RSP带的mtu修正内部的mtu 247的值,影响调用notify的最大len。
还是说不受影响,需要设备端做发送数据大小的可靠性保护。

郭老庄
Posts: 135

Re: [Tuya OS SDK] 初次适配TuyaOS V:6.1.0 蓝牙配网问题

sdk会受设备上报的TKL_BLE_GATT_EVT_MTU_RSP带的mtu修正内部的mtu 247的值,影响调用notify的最大len

zq.
Posts: 71

Re: [Tuya OS SDK] 初次适配TuyaOS V:6.1.0 蓝牙配网问题

郭老庄 2024年 Feb 28日 14:00
  1. app预计4月底发布
  2. 崩溃的问题,你可以先不调用tuya_ble_set_startup_attr(TUYA_BLE_ABILITY_NETCFG); 等你想stack deinit的时候,调tuya_ble_set_serv_switch(0);试试
  3. sdk里默认mtu是247
  4. 有些api demo调用,但sdk没调是正常的,demo主要起验证的作用

2实测在不调用tuya_ble_set_startup_attr(TUYA_BLE_ABILITY_NETCFG)前提下,在__on_status_online函数中执行tuya_ble_set_serv_switch(0);,还是会挂死。

[02-28 20:01:17 ty I][ty_sdk_status_callback.c:58] online: network status MQTT connected
执行语句tuya_ble_set_serv_switch(0)
[02-28 20:01:17 ty D][tuya_ipc_sdk_info.c:330] ipc sdk info: mqstat change to :1
[02-28 20:01:17 ty N][tuya_wifi_status.c:168] cur stat:7 0x4f96f0 -->>
[02-28 20:01:17 ty N][tuya_wifi_status.c:171] wifi netstat changed to:7 -->>
[02-28 20:01:17 ty N][tuya_wifi_status.c:175] report wifi netstat[7] to callback -->>
[02-28 20:01:17 ty D][tuya_iot_base_api.c:298] wired netstat changed to:2 -->>
[02-28 20:01:17 ty D][tuya_iot_base_api.c:300] wired netstat changed to:2 <<--
[02-28 20:01:17 ty N][tuya_ble_svc.c:1580] BT Serv closing...
[02-28 20:01:17 ty D][tuya_ble_svc.c:1349] ble monitor delete
tkl_ble_stack_deinit 47 role 3
[02-28 20:01:17 ty D][simplekv.c:1128] read key:em_sys_env isFuzzy:0 skipCnt:0
[02-28 20:01:17 ty D][simplekv.c:1156] no key find
[02-28 20:01:17 ty D][simplekv.c:1198] __read_kv_raw fail. -3
[02-28 20:01:17 ty D][simplekv.c:1236] __read_kv_with_decode fail. -3
[02-28 20:01:17 ty E][svc_online_log_db.c:25] ret:-6
[02-28 20:01:17 ty D][tuya_svc_online_log.c:154] load env fail. maybe not exist.
[02-28 20:01:17 ty D][tuya_svc_online_log.c:159] update property:{"value":"{\"embed_sys_env\":\"T31_uclibc\"}"}
[02-28 20:01:17 ty D][iot_httpc.c:963] Post Data: {"value":"{\"embed_sys_env\":\"T31_uclibc\"}","t":1709121677}
[02-28 20:01:17 ty D][iot_httpc.c:975] Post URL: https://a6.tuyacn.com/d.json?a=tuya.dev ... 2b283c4a39
[02-28 20:01:17 ty D][simplekv.c:1128] read key:ap_info_v2 isFuzzy:0 skipCnt:0
[02-28 20:01:17 ty D][simplekv.c:1156] no key find
[02-28 20:01:17 ty D][simplekv.c:1198] __read_kv_raw fail. -3
[02-28 20:01:17 ty D][simplekv.c:1236] __read_kv_with_decode fail. -3
[02-28 20:01:17 ty E][tuya_wifi_connect.c:80] ap_info_v2 read fail:-6
[02-28 20:01:17 ty E][tuya_wifi_connect.c:131] ws_db_connect_ap_info_read fail:-6
[02-28 20:01:17 ty E][tuya_wifi_connect.c:48] para null
[02-28 20:01:17 ty E][tuya_wifi_connect.c:134] ws_db_connect_ap_info_v2_write fail:-2
[02-28 20:01:17 ty D][httpc.c:620] Connect: a6.tuyacn.com Port: 443 -->>
[02-28 20:01:17 ty D][uni_network.c:230] unw_gethostbyname a6.tuyacn.com, prio 1
[02-28 20:01:17 ty D][uni_network.c:246] use dynamic dns ip:81.69.183.170 for domain:a6.tuyacn.com
[02-28 20:01:17 ty D][tcp_transporter.c:79] bind ip:c0a864a0 port:0 ok
[02-28 20:01:17 ty D][tuya_tls.c:945] MAX SECURITY_LEVEL:1, TUYA SECURITY_LEVEL:1, mode:1
[02-28 20:01:17 ty D][tuya_tls.c:954] TUYA_TLS Begin Connect a6.tuyacn.com:443
[02-28 20:01:17 ty D][tuya_tls.c:714] mbedtls authmode: MBEDTLS_SSL_VERIFY_REQUIRED
[02-28 20:01:17 ty D][tuya_tls.c:727] load tuya cert.
[02-28 20:01:17 ty D][tuya_cert_manager.c:213] p_url:a6.tuyacn.com, rcs.urlx:h6-ay.iot-dns.com
[02-28 20:01:17 ty D][tuya_cert_manager.c:236] tuya public url
[02-28 20:01:17 ty D][tuya_cert_manager.c:1099] parse crt <0> len <540> ret <0>
[02-28 20:01:17 ty D][tuya_tls.c:1036] socket fd is set. set to inner send/recv to handshake
[02-28 20:01:17 ty D][pps_tuya_ipc_sdk_6.c:645] tuya_ipc_sdk_mqtt_online_proc is start run

[02-28 20:01:17 ty D][tuya_ipc_sdk_info.c:130] ipc get service time 1709121677 28800
[02-28 20:01:17 ty D][tuya_ipc_sdk_info.c:161] got service time 1709121677 28800
[12:02:04.049 ERR pps_tuya_ipc_sdk_6.c:660] TUYA_IPC_Media_Stream_Init
[02-28 20:01:17 ty D][simplekv.c:1128] read key:media_log_info isFuzzy:0 skipCnt:0
[02-28 20:01:17 ty D][simplekv.c:1156] no key find
[02-28 20:01:17 ty D][simplekv.c:1198] __read_kv_raw fail. -3
[02-28 20:01:17 ty D][simplekv.c:1236] __read_kv_with_decode fail. -3
[02-28 20:01:17 ty E][tuya_imm_service_log.c:490] read media_log_info fails, ret[-6]
[02-28 20:01:17 ty D][tuya_imm_service_log.c:502] LOAD log server: level[2],server[/av/moto/log]
[02-28 20:01:17 ty I][tuya_imm_service_log.c:338] use mqtt uploader
[02-28 20:01:17 ty I][tuya_imm_service_log.c:372] init uploader[0] OK.
[02-28 20:01:17 ty D][tuya_ipc_mqtt_subscribe.c:84] __mqtt_subscribe_init
[02-28 20:01:17 ty D][tuya_imm_service_log.c:614] send mqtt msg to topic[/av/moto/log/d/6ce3bfcf6309b01e00xfvp][{"header":{"from":"6ce3bfcf6309b01e00xfvp","type":"getLogToken","tid":"00ec354b89c7e1d951fc3dc4fe457852"}}]
[02-28 20:01:17 ty D][mqc_app.c:891] Send MQTT Msg.P:312 N:47552 Q:0
[02-28 20:01:17 ty D][tuya_svc_mqtt_client.c:427] packet id: 3
[02-28 20:01:17 ty I][tuya_imm_service_log.c:674] init ok
[02-28 20:01:17 ty D][tuya_ring_buffer.c:767] ch0st0tr9 open with type 1
[02-28 20:01:17 ty D][tuya_ring_buffer.c:767] ch0st0tr0 open with type 1
[02-28 20:01:17 ty D][tuya_ring_buffer.c:767] ch0st0tr1 open with type 1
[02-28 20:01:17 ty D][mqc_app.c:336] Rev MQTT:{"protocol":312,"pv":"2.3","t":1709121677,"data":{"header":{"type":"setLogToken","to":"6ce3bfcf6309b01e00xfvp","tid":"00ec354b89c7e1d951fc3dc4fe457852"},"msg":{"mode":"log","log":{"level":2,"size":1024,"interval":60,"topic":"/av/moto/log","api":"thing.m.rtc.log","tcp":{"domain":"wework-2-cn.stream.iot-11.com","address":"1.117.192.37","port":9092,"key":"6e9d446e4a2d2cdc"}}}}}
[02-28 20:01:17 ty D][tuya_ipc_mqtt_subscribe.c:213] recv mq: protocol 312
[02-28 20:01:17 ty D][simplekv.c:1128] read key:media_log_info isFuzzy:0 skipCnt:0
[02-28 20:01:17 ty D][simplekv.c:1156] no key find
[02-28 20:01:17 ty D][simplekv.c:1198] __read_kv_raw fail. -3
[02-28 20:01:17 ty D][simplekv.c:1236] __read_kv_with_decode fail. -3
[02-28 20:01:17 ty D][simplekv.c:369] write key:media_log_info And Value Len:96
[02-28 20:01:17 ty D][simplekv.c:401] 4 valid is false AND size old 420 >= new 96
[02-28 20:01:17 ty D][simplekv.c:415] find 4 available space
[02-28 20:01:17 ty D][simplekv.c:452] reuse available space 30092
[02-28 20:01:17 ty D][simplekv.c:207] update crc 3238666639
[02-28 20:01:17 ty D][tuya_ipc_media_stream.c:65] P2P API Version: 244.3.4.120

[02-28 20:01:17 ty D][tuya_ipc_media_stream.c:397] gw actived
tuya liteos uv
[02-28 20:01:17 ty D][simplekv.c:356] write head to normal file success
[02-28 20:01:17 ty D][simplekv.c:492] write success
[02-28 20:01:17 ty D][tuya_imm_service_log.c:596] Set log server:[/av/moto/log]
[02-28 20:01:17 ty D][simplekv.c:1128] read key:tuya_seed isFuzzy:0 skipCnt:0
[02-28 20:01:17 ty D][simplekv.c:1159] find key:0 tuya_seed
[02-28 20:01:17 ty D][simplekv.c:1185] key:tuya_seed find value.Len:80
[02-28 20:01:17 ty D][simplekv.c:1128] read key:tuya_seed isFuzzy:0 skipCnt:0
[02-28 20:01:17 ty D][simplekv.c:1159] find key:0 tuya_seed
[02-28 20:01:17 ty D][simplekv.c:1185] key:tuya_seed find value.Len:80
[02-28 20:01:17 ty D][simplekv.c:369] write key:tuya_seed And Value Len:80
[02-28 20:01:17 ty D][simplekv.c:387] 0 key same AND size old 148 >= new 80
[02-28 20:01:17 ty D][simplekv.c:415] find 0 available space
[02-28 20:01:17 ty D][simplekv.c:452] reuse available space 28700
[02-28 20:01:17 ty D][simplekv.c:207] update crc 2751757715
*status 0
[02-28 20:01:18 ty D][tuya_lan_sock.c:149] unreg lan sock 31 and close it
[02-28 20:01:18 ty D][simplekv.c:356] write head to normal file success
[02-28 20:01:18 ty D][simplekv.c:492] write success
[02-28 20:01:18 ty D][simplekv.c:1128] read key:tuya_seed isFuzzy:0 skipCnt:0
[02-28 20:01:18 ty D][simplekv.c:1159] find key:0 tuya_seed
[02-28 20:01:18 ty D][simplekv.c:1185] key:tuya_seed find value.Len:80
[02-28 20:01:18 ty D][simplekv.c:1128] read key:tuya_seed isFuzzy:0 skipCnt:0
[02-28 20:01:18 ty D][simplekv.c:1159] find key:0 tuya_seed
[02-28 20:01:18 ty D][simplekv.c:1185] key:tuya_seed find value.Len:80
[02-28 20:01:18 ty D][simplekv.c:1128] read key:tuya_seed isFuzzy:0 skipCnt:0
[02-28 20:01:18 ty D][simplekv.c:1159] find key:0 tuya_seed
[02-28 20:01:18 ty D][simplekv.c:1185] key:tuya_seed find value.Len:80
[02-28 20:01:18 ty D][simplekv.c:369] write key:tuya_seed And Value Len:80
[02-28 20:01:18 ty D][simplekv.c:387] 0 key same AND size old 148 >= new 80
[02-28 20:01:18 ty D][simplekv.c:415] find 0 available space
[02-28 20:01:18 ty D][simplekv.c:452] reuse available space 28700
[02-28 20:01:18 ty D][simplekv.c:207] update crc 1681751062
[02-28 20:01:18 ty D][tuya_ble_svc.c:888] rev ble event 14
[02-28 20:01:18 ty D][tuya_ble_svc.c:849] Dev Rev BT Package
[02-28 20:01:18 ty D][tuya_ble_svc.c:97] bt_rev_raw 36 <0x68405c00>
00 21 46 05 34 48 43 4e 4d 54 31 47 33 4d 4d 4e 4f 46 44 44 cc 24 0f f7 e1 07 ce 2a 3a ab 90 23 28 bb c0 1f

[02-28 20:01:18 ty D][tuya_ble_data_handler.c:139] recive sub_pkg desc:3, no:1, pack_len:33, total_len:33
[02-28 20:01:18 ty D][tuya_ble_svc.c:97] ble rev data 33 <0x1088794>
05 34 48 43 4e 4d 54 31 47 33 4d 4d 4e 4f 46 44 44 cc 24 0f f7 e1 07 ce 2a 3a ab 90 23 28 bb c0 1f

这里就挂了

Attachments
AC8357E8-35EA-4fc7-9F4D-0DC331403355.png
郭老庄
Posts: 135

Re: [Tuya OS SDK] 初次适配TuyaOS V:6.1.0 蓝牙配网问题

对比你发的两份日志,每次都是收到蓝牙数据后崩溃了
因为蓝牙协议栈已经销毁了,我们的蓝牙数据的处理函数也全部置为NULL。理论上协议栈销毁后不会再收到蓝牙数据了,此时若收到数据,就可能崩溃

zq.
Posts: 71

Re: [Tuya OS SDK] 初次适配TuyaOS V:6.1.0 蓝牙配网问题

我现在deinit空实现,你意思是我一定需要将deinit正确实现?保证在deinit后不能往你们那边write数据是吗?我试一下,但是按理说你们内部也需要加点保护措施。

zq.
Posts: 71

Re: [Tuya OS SDK] 初次适配TuyaOS V:6.1.0 蓝牙配网问题

实测可以了,deinit不写目前看不会挂,尝试了tuya_ble_set_serv_switch(0)以及tuya_ble_set_startup_attr(TUYA_BLE_ABILITY_NETCFG)两种改法,都没挂。

Post Reply