Page 1 of 2

【已解决】[SDK开发]运行demo程序无法连接到涂鸦云

Posted: 2024年 Mar 20日 17:31
by huangwenxi

我使用的SDK版本是sdk_6.1.1-beta.83,开发方式选择的是SDK独立开发方式。按照文档,使用extract_standalone_sdk.sh脚本提取出来sdk的库文件和头文件之后,在software/sdk_6.1.1-beta.83目录下执行make命令,会生成demo可执行文件。我将demo文件以及修改过pid/uuid/authkey配置的tuya_device_cfg.json拷贝到运行环境的同一个目录下,并期望使用./demo -c ./ -m 2 -t AYD8z6FqmP1xxx 的方式运行demo程序并连接到涂鸦云平台,可是等了一会后,没有在涂鸦智能app上看到对应的设备连接。以下是程序的部分运行日志。

日志:
WIFI[0] Get IP:
[01-01 00:00:47 ty E][tuya_svc_lan.c:1069] sendto Fail: len:258 ret:-1,errno:-18 port:6667
[01-01 00:00:47 ty D][svc_netcfg_qrcode.c:127] start config
[01-01 00:00:47 ty D][tuya_svc_mqtt_direct.c:264] start direct mqtt
[01-01 00:00:47 ty D][uni_network.c:312] set_dns_cache_priority:1
[01-01 00:00:47 ty D][simplekv.c:1248] delete key:tls_ca_cnt isFuzzy:0
[01-01 00:00:47 ty D][simplekv.c:1254] cnt:5 delete bit arr len:1
[01-01 00:00:47 ty D][simplekv.c:1287] key:tls_ca_cnt not find
[01-01 00:00:47 ty D][simplekv.c:1248] delete key:tls_ca isFuzzy:1
[01-01 00:00:47 ty D][simplekv.c:1254] cnt:5 delete bit arr len:1
[01-01 00:00:47 ty D][simplekv.c:1287] key:tls_ca not find
[01-01 00:00:47 ty D][simplekv.c:1128] read key:tls_ca_cnt isFuzzy:0 skipCnt:0
[01-01 00:00:47 ty D][simplekv.c:1156] no key find
[01-01 00:00:47 ty D][simplekv.c:1198] __read_kv_raw fail. -3
[01-01 00:00:47 ty D][simplekv.c:1236] __read_kv_with_decode fail. -3
[01-01 00:00:47 ty D][tuya_cert_manager.c:463] load tls_ca_cnt fail. no ca in local db
[01-01 00:00:47 ty D][iot_httpc.c:1367] http_iot_dns_get_cloud_url start
[01-01 00:00:47 ty D][iot_httpc.c:1412] http_dns region , send: {"env":"pro","config":[{"key":"httpUrl","need_ca":false},{"key":"mqttUrl","need_ca":false},{"key":"httpsPSKUrl","need_ca":false},{"key":"mqttsPSK3Url","need_ca":false},{"key":"httpsStdUrl","need_ca":true},{"key":"mqttsStdUrl","need_ca":true},{"key":"ghostUrl","need_ca":true}]}
[01-01 00:00:47 ty D][tuya_register_center.c:434] rcs.urlx:h6.iot-dns.com
[01-01 00:00:47 ty D][iot_httpc.c:1416] get url config:https://h6.iot-dns.com/v1/url_config
sh: iwconfig: not found
ifconfig: ens33: error fetching interface information: Device not found
sh: iwconfig: not found
ifconfig: ens33: error fetching interface information: Device not found
WIFI[0] Get IP:
[01-01 00:00:48 ty D][httpc.c:620] Connect: h6.iot-dns.com Port: 443 -->>
[01-01 00:00:48 ty D][uni_network.c:230] unw_gethostbyname h6.iot-dns.com, prio 1
gethostbyname_r error: NULL
[01-01 00:00:48 ty E][uni_network.c:253] fail to gethostbyname -100

[01-01 00:00:48 ty D][uni_network.c:285] lower_dns_cache_priority:0
[01-01 00:00:48 ty E][tcp_transporter.c:41] DNS parser host h6.iot-dns.com failed -5
[01-01 00:00:48 ty E][tls_transporter.c:53] tcp transporter connect failed,ret:-0x7102
[01-01 00:00:48 ty D][httpc.c:622] Connect: h6.iot-dns.com Port: 443 --<< ,r:-28930
[01-01 00:00:48 ty D][tls_transporter.c:93] tls transporter close socket fd:-1
[01-01 00:00:48 ty D][tls_transporter.c:98] tls transporter already closed
[01-01 00:00:48 ty D][tuya_tls.c:907] tuya_tls_connect_destroy.
[01-01 00:00:48 ty E][http_inf.c:59] Open session failed: https://h6.iot-dns.com/v1/url_config (-28930)
[01-01 00:00:48 ty E][iot_httpc.c:1425] fail to get cloud url -2050
[01-01 00:00:48 ty D][uni_network.c:312] set_dns_cache_priority:1
[01-01 00:00:48 ty E][tuya_svc_mqtt_direct.c:270] ret:-2050
[01-01 00:00:48 ty E][svc_netcfg_qrcode.c:130] ret:-2050
[01-01 00:00:48 ty E][svc_netcfg_qrcode.c:144] start config failed
ifconfig: ens33: error fetching interface information: Device not found
ifconfig: ens33: error fetching interface information: Device not found
WIFI[0] Get IP:
sh: iwconfig: not found
ifconfig: ens33: error fetching interface information: Device not found
ifconfig: ens33: error fetching interface information: Device not found
WIFI[0] Get IP:
name_list NULL
sh: iwconfig: not found
ifconfig: ens33: error fetching interface information: Device not found
ifconfig: ens33: error fetching interface information: Device not found
WIFI[0] Get IP:
[01-01 00:00:48 ty E][tuya_svc_lan.c:1069] sendto Fail: len:258 ret:-1,errno:-18 port:6667
sh: iwconfig: not found
ifconfig: ens33: error fetching interface information: Device not found
ifconfig: ens33: error fetching interface information: Device not found
WIFI[0] Get IP:
sh: iwconfig: not found
ifconfig: ens33: error fetching interface information: Device not found
ifconfig: ens33: error fetching interface information: Device not found
WIFI[0] Get IP:
name_list NULL
sh: iwconfig: not found
ifconfig: ens33: error fetching interface information: Device not found
ifconfig: ens33: error fetching interface information: Device not found
WIFI[0] Get IP:
[01-01 00:00:49 ty E][tuya_svc_lan.c:1069] sendto Fail: len:258 ret:-1,errno:-18 port:6667
sh: iwconfig: not found
ifconfig: ens33: error fetching interface information: Device not found
ifconfig: ens33: error fetching interface information: Device not found
WIFI[0] Get IP:
sh: iwconfig: not found
ifconfig: ens33: error fetching interface information: Device not found
ifconfig: ens33: error fetching interface information: Device not found
WIFI[0] Get IP:
name_list NULL
sh: iwconfig: not found
ifconfig: ens33: error fetching interface information: Device not found
ifconfig: ens33: error fetching interface information: Device not found
WIFI[0] Get IP:
[01-01 00:00:50 ty E][tuya_svc_lan.c:1069] sendto Fail: len:258 ret:-1,errno:-18 port:6667
sh: iwconfig: not found
ifconfig: ens33: error fetching interface information: Device not found
ifconfig: ens33: error fetching interface information: Device not found
WIFI[0] Get IP:
sh: iwconfig: not found
ifconfig: ens33: error fetching interface information: Device not found
C[signal_handle, 59] get signal(2) name(demo)


Re: [SDK开发]运行demo程序无法连接到涂鸦云

Posted: 2024年 Mar 20日 20:19
by huangwenxi

设备是通过有线网络连接到互联网的。


Re: [SDK开发]运行demo程序无法连接到涂鸦云

Posted: 2024年 Mar 20日 20:28
by 郭老庄

tkl_wifi.c需要适配。例如,日志中调用tkl_wifi_get_ip,没有获取到设备ip


Re: [SDK开发]运行demo程序无法连接到涂鸦云

Posted: 2024年 Mar 21日 09:12
by huangwenxi

请问,我可以先用有线网络来测试demo连接到涂鸦云的功能吗?


Re: [SDK开发]运行demo程序无法连接到涂鸦云

Posted: 2024年 Mar 21日 09:39
by 郭老庄

可以的,配网模式设置为PARING_MODE_WIRED。连接模式设置为TUYA_IPC_LINK_WIRE。然后适配tkl_wired.c。
demo运行的命令改为:./output/platform_tuyaos-ipc/firmware/tuyaos_demo_ipc -c ./apps/tuyaos_demo_ipc/ -m 3 -t xxxxxxxxxx


Re: [SDK开发]运行demo程序无法连接到涂鸦云

Posted: 2024年 Mar 22日 15:25
by huangwenxi

配网模式的设置不需要再改代码了吧?因为在启动程序的时候,会通过-m参数传递该配置。


Re: [SDK开发]运行demo程序无法连接到涂鸦云

Posted: 2024年 Mar 22日 15:33
by 郭老庄
huangwenxi 2024年 Mar 22日 15:25

配网模式的设置不需要再改代码了吧?因为在启动程序的时候,会通过-m参数传递该配置。

可以不改配网模式的代码


Re: [SDK开发]运行demo程序无法连接到涂鸦云

Posted: 2024年 Mar 22日 15:35
by huangwenxi

问题:修改为有线的连接方式来运行demo程序但是无法连接到涂鸦云并出现段错误的问题

详细描述:
我将连接模式改为TUYA_IPC_LINK_WIRE,并适配了tkl_wired.c中获取gw的接口后,重新编译并使用./output/platform_tuyaos-ipc/firmware/tuyaos_demo_ipc -c ./apps/tuyaos_demo_ipc/ -m 3 -t xxxxxxxxxx的方式去运行demo程序

问题日志:
[01-01 00:00:00 ty N][tuya_svc_netmgr_linkage.c:270] default linkage[1] is set
[01-01 00:00:00 ty D][svc_netcfg_qrcode.c:99] stop config
[01-01 00:00:00 ty D][svc_netcfg_qrcode.c:127] start config
[01-01 00:00:00 ty D][tuya_svc_mqtt_direct.c:264] start direct mqtt
[01-01 00:00:00 ty D][uni_network.c:312] set_dns_cache_priority:1
[01-01 00:00:00 ty D][simplekv.c:1248] delete key:tls_ca_cnt isFuzzy:0
[01-01 00:00:00 ty D][simplekv.c:1254] cnt:5 delete bit arr len:1
[01-01 00:00:00 ty D][simplekv.c:1287] key:tls_ca_cnt not find
[01-01 00:00:00 ty D][simplekv.c:1248] delete key:tls_ca isFuzzy:1
[01-01 00:00:00 ty D][simplekv.c:1254] cnt:5 delete bit arr len:1
[01-01 00:00:00 ty D][simplekv.c:1287] key:tls_ca not find
[01-01 00:00:00 ty D][simplekv.c:1128] read key:tls_ca_cnt isFuzzy:0 skipCnt:0
[01-01 00:00:00 ty D][simplekv.c:1156] no key find
[01-01 00:00:00 ty D][simplekv.c:1198] __read_kv_raw fail. -3
[01-01 00:00:00 ty D][simplekv.c:1236] __read_kv_with_decode fail. -3
[01-01 00:00:00 ty D][tuya_cert_manager.c:463] load tls_ca_cnt fail. no ca in local db
[01-01 00:00:00 ty D][iot_httpc.c:1367] http_iot_dns_get_cloud_url start
[01-01 00:00:00 ty D][iot_httpc.c:1412] http_dns region , send: {"env":"pro","config":[{"key":"httpUrl","need_ca":false},{"key":"mqttUrl","need_ca":false},{"key":"httpsPSKUrl","need_ca":false},{"key":"mqttsPSK3Url","need_ca":false},{"key":"httpsStdUrl","need_ca":true},{"key":"mqttsStdUrl","need_ca":true},{"key":"ghostUrl","need_ca":true}]}
[01-01 00:00:00 ty D][tuya_register_center.c:434] rcs.urlx:h6.iot-dns.com
[01-01 00:00:00 ty D][iot_httpc.c:1416] get url config:https://h6.iot-dns.com/v1/url_config
tkl_wired_get_ip 317: ifname=eth0
[01-01 00:00:00 ty D][httpc.c:620] Connect: h6.iot-dns.com Port: 443 -->>
[01-01 00:00:00 ty D][uni_network.c:230] unw_gethostbyname h6.iot-dns.com, prio 1
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
[01-01 00:00:01 ty N][tuya_svc_lan.c:713] Not actived, use linkage addr[172.16.6.60][ac10063c]
[01-01 00:00:01 ty D][tuya_lan_sock.c:331] reg post queue 7
[01-01 00:00:01 ty D][tuya_lan_sock.c:331] reg post queue 8
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
[01-01 00:00:02 ty D][tuya_lan_sock.c:127] reg lan sock 7,read:0x64d09
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
[01-01 00:00:03 ty D][tuya_lan_sock.c:127] reg lan sock 8,read:0x670e1
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
tkl_wired_get_ip 317: ifname=eth0
gethostbyname_r error: NULL
[01-01 00:00:20 ty E][uni_network.c:253] fail to gethostbyname -100

[01-01 00:00:20 ty D][uni_network.c:285] lower_dns_cache_priority:0
[01-01 00:00:20 ty E][tcp_transporter.c:41] DNS parser host h6.iot-dns.com failed -5
[01-01 00:00:20 ty E][tls_transporter.c:53] tcp transporter connect failed,ret:-0x7102
[01-01 00:00:20 ty D][httpc.c:622] Connect: h6.iot-dns.com Port: 443 --<< ,r:-28930
[01-01 00:00:20 ty D][tls_transporter.c:93] tls transporter close socket fd:-1
[01-01 00:00:20 ty D][tls_transporter.c:98] tls transporter already closed
[01-01 00:00:20 ty D][tuya_tls.c:907] tuya_tls_connect_destroy.
[01-01 00:00:20 ty E][http_inf.c:59] Open session failed: https://h6.iot-dns.com/v1/url_config (-28930)
[01-01 00:00:20 ty E][iot_httpc.c:1425] fail to get cloud url -2050
[01-01 00:00:20 ty D][uni_network.c:312] set_dns_cache_priority:1
[01-01 00:00:20 ty E][tuya_svc_mqtt_direct.c:270] ret:-2050
[01-01 00:00:20 ty E][svc_netcfg_qrcode.c:130] ret:-2050
[01-01 00:00:20 ty E][svc_netcfg_qrcode.c:144] start config failed
Segmentation fault


Re: 【求助】[SDK开发]运行demo程序无法连接到涂鸦云

Posted: 2024年 Mar 22日 18:01
by huangwenxi

上面这个问题我找到了,是因为没有正确配置网关和DNS的地址导致的问题,我对这两个问题进行了修正,不会再出现上面的报错了,不过还是连接不上涂鸦云,报错的日志如下:

[01-01 00:01:33 ty N][tuya_svc_mqtt_client.c:836] connect to mqtt broker mqtts://m6.tuyacn.com:8886 port 8886
tkl_wired_get_ip 317: ifname=eth0
[01-01 00:01:33 ty N][tuya_svc_mqtt_client.c:846] mqtt client ip:172.16.6.60
[01-01 00:01:33 ty D][uni_network.c:230] unw_gethostbyname m6.tuyacn.com, prio 1
[01-01 00:01:33 ty D][uni_network.c:258] use system dns ip 121.5.96.27 for domain m6.tuyacn.com

[01-01 00:01:33 ty D][uni_network.c:185] cache dns [m6.tuyacn.com]<->[121.5.96.27]
[01-01 00:01:33 ty D][tcp_transporter.c:79] bind ip:ac10063c port:41978 ok
[01-01 00:01:33 ty D][tuya_tls.c:945] MAX SECURITY_LEVEL:1, TUYA SECURITY_LEVEL:1, mode:1
[01-01 00:01:33 ty D][tuya_tls.c:954] TUYA_TLS Begin Connect m6.tuyacn.com:8886
[01-01 00:01:33 ty D][tuya_tls.c:714] mbedtls authmode: MBEDTLS_SSL_VERIFY_REQUIRED
[01-01 00:01:33 ty D][tuya_tls.c:727] load tuya cert.
[01-01 00:01:33 ty D][tuya_cert_manager.c:213] p_url:m6.tuyacn.com:8886, rcs.urlx:h6.iot-dns.com
[01-01 00:01:33 ty D][tuya_cert_manager.c:236] tuya public url
[01-01 00:01:33 ty D][tuya_cert_manager.c:1099] parse crt <0> len <540> ret <0>
[01-01 00:01:33 ty D][tuya_tls.c:1036] socket fd is set. set to inner send/recv to handshake
[01-01 00:01:33 ty D][tuya_tls.c:687] mbedtls_cert_pkey_free.
[01-01 00:01:33 ty D][tuya_tls.c:1098] handshake finish for m6.tuyacn.com. set send/recv to user set
[01-01 00:01:33 ty D][tuya_tls.c:1104] TUYA_TLS Success Connect m6.tuyacn.com:8886 Suit:TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256
[01-01 00:01:33 ty N][tuya_svc_mqtt_client.c:883] setup mqtt transporter success
[01-01 00:01:33 ty N][tuya_svc_mqtt_client.c:177] [mqtts://m6.tuyacn.com:8886] mqtt state change 1 -> 2
[01-01 00:01:33 ty N][tuya_svc_mqtt_client.c:908] send mqtt connect success
[01-01 00:01:33 ty N][tuya_svc_mqtt_client.c:177] [mqtts://m6.tuyacn.com:8886] mqtt state change 2 -> 3
[01-01 00:01:33 ty E][tuya_svc_mqtt_client.c:928] host[mqtts://m6.tuyacn.com:8886] mqtt connect resp err:5
[01-01 00:01:33 ty D][tuya_svc_mqtt_direct.c:132] mqtt connect deny:12
[01-01 00:01:33 ty N][tuya_svc_mqtt_client.c:665] mqtt close
[01-01 00:01:33 ty D][tls_transporter.c:93] tls transporter close socket fd:9
[01-01 00:01:33 ty D][tcp_transporter.c:177] tcp transporter close socket fd:9
[01-01 00:01:33 ty D][tls_transporter.c:101] tls transporter close tls handler:0x72c0b0
[01-01 00:01:33 ty D][tuya_tls.c:1180] TUYA_TLS Disconnect ENTER
[01-01 00:01:33 ty D][tuya_tls.c:1205] TUYA_TLS Disconnect Success
[01-01 00:01:33 ty D][tuya_tls.c:907] tuya_tls_connect_destroy.
[01-01 00:01:33 ty N][tuya_svc_mqtt_client.c:177] [mqtts://m6.tuyacn.com:8886] mqtt state change 3 -> 1
[01-01 00:01:33 ty D][tuya_svc_mqtt_direct.c:124] mqtt disconnected
[01-01 00:01:33 ty D][tuya_svc_mqtt_client.c:717] mqtt fail_cnt:12, sleeptime:3390 ms


Re: 【求助】[SDK开发]运行demo程序无法连接到涂鸦云

Posted: 2024年 Mar 22日 18:21
by 郭老庄

这是短码配网的报错,不影响最终激活上线。有完整的日志吗?