Page 2 of 4

Re: 调用tuya_iot_soc_init_param接口,,返回OPRT_OK,却没有收到回调信息

Posted: 2025年 Apr 25日 18:30
by zszn_ll

rk3126c:/ # ping h6.iot-dns.com
PING h6.iot-dns.com (47.116.185.69) 56(84) bytes of data.
64 bytes from 47.116.185.69: icmp_seq=1 ttl=90 time=31.2 ms
64 bytes from 47.116.185.69: icmp_seq=2 ttl=90 time=30.6 ms
64 bytes from 47.116.185.69: icmp_seq=3 ttl=90 time=42.2 ms
64 bytes from 47.116.185.69: icmp_seq=4 ttl=90 time=34.9 ms
64 bytes from 47.116.185.69: icmp_seq=5 ttl=90 time=31.1 ms
64 bytes from 47.116.185.69: icmp_seq=6 ttl=90 time=34.9 ms
64 bytes from 47.116.185.69: icmp_seq=7 ttl=90 time=35.6 ms
64 bytes from 47.116.185.69: icmp_seq=8 ttl=90 time=62.0 ms
64 bytes from 47.116.185.69: icmp_seq=9 ttl=90 time=32.1 ms
64 bytes from 47.116.185.69: icmp_seq=10 ttl=90 time=30.7 ms
64 bytes from 47.116.185.69: icmp_seq=11 ttl=90 time=40.9 ms
64 bytes from 47.116.185.69: icmp_seq=12 ttl=90 time=30.9 ms
64 bytes from 47.116.185.69: icmp_seq=13 ttl=90 time=33.6 ms
64 bytes from 47.116.185.69: icmp_seq=14 ttl=90 time=47.1 ms
64 bytes from 47.116.185.69: icmp_seq=15 ttl=90 time=32.1 ms
64 bytes from 47.116.185.69: icmp_seq=16 ttl=90 time=37.3 ms
64 bytes from 47.116.185.69: icmp_seq=17 ttl=90 time=52.7 ms

Android设备中可以ping通


Re: 调用tuya_iot_soc_init_param接口,,返回OPRT_OK,却没有收到回调信息

Posted: 2025年 Apr 25日 18:41
by 卢台长

你这个ping出来的IP没问题,但是你日志中获取的IP是有问题的


Re: 调用tuya_iot_soc_init_param接口,,返回OPRT_OK,却没有收到回调信息

Posted: 2025年 Apr 25日 18:50
by zszn_ll

这个tkl_wired_get_gateway方法执行一直报not find gw addr,是否和这个有关系
LOG:

tuya_log.txt
(9.01 KiB) Downloaded 3 times

Re: 调用tuya_iot_soc_init_param接口,,返回OPRT_OK,却没有收到回调信息

Posted: 2025年 Apr 25日 19:33
by 卢台长

发一下 tkl_wired.c


Re: 调用tuya_iot_soc_init_param接口,,返回OPRT_OK,却没有收到回调信息

Posted: 2025年 Apr 28日 13:53
by zszn_ll

tkl_wired:

tkl_wired.zip
(3.55 KiB) Downloaded 1 time

Re: 调用tuya_iot_soc_init_param接口,,返回OPRT_OK,却没有收到回调信息

Posted: 2025年 Apr 28日 14:14
by 卢台长

查询的dns好像有点问题,所以获取的不准,你看看把dns设置下吧


Re: 调用tuya_iot_soc_init_param接口,,返回OPRT_OK,却没有收到回调信息

Posted: 2025年 Apr 28日 15:58
by zszn_ll

它这个是使用tkl_wired.c中tkl_wired_get_ip设置的dns服务器去解析域名吗?我这边设置成阿里云、腾讯云、谷歌的dns服务器解析也是错误的。


Re: 调用tuya_iot_soc_init_param接口,,返回OPRT_OK,却没有收到回调信息

Posted: 2025年 Apr 28日 16:20
by 卢台长

用这个临时试一下,其他客户跑起来没问题


Re: 调用tuya_iot_soc_init_param接口,,返回OPRT_OK,却没有收到回调信息

Posted: 2025年 Apr 28日 16:39
by zszn_ll

Code: Select all

use system dns ip 0.0.0.0 for domain h6.iot-dns.com

这个域名也无法解析

tuya_log.txt
(42.5 KiB) Downloaded 2 times

Re: 调用tuya_iot_soc_init_param接口,,返回OPRT_OK,却没有收到回调信息

Posted: 2025年 Apr 28日 16:51
by zszn_ll

我在tkl_wired.c中加入了如下代码验证解析的ip地址,能够成功解析到ip:101.132.61.178

Code: Select all

#include <stdio.h>
#include <string.h>
#include <netdb.h>
#include <arpa/inet.h>
bool resolveDomainIP() {
    struct addrinfo hints = {0}, *res = NULL;
    memset(&hints, 0, sizeof(hints));
    hints.ai_family = AF_INET; // 仅解析 IPv4
    hints.ai_socktype = SOCK_STREAM;

int dnsResult = getaddrinfo("h6.iot-dns.com", NULL, &hints, &res);
if (dnsResult != 0 || res == NULL) {
    LOGE("解析 h6.iot-dns.com 域名失败: %s", gai_strerror(dnsResult));
    freeaddrinfo(res);
    return false;
}

struct sockaddr_in *addr = (struct sockaddr_in *)res->ai_addr;
char ip[INET_ADDRSTRLEN];
inet_ntop(AF_INET, &(addr->sin_addr), ip, sizeof(ip));
LOGD("h6析 IP 地址: %s", ip);

freeaddrinfo(res);
return true;
}