目前的程序也是这样的,但是还是不行,现象是一样的。
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
设置静态IP就是之前的两种方式,通过-ip或者在程序中设置:
• Static – In this mode the IPv4 address of the device is preconfigured. Example: _i16 Status; SlNetCfgIpV4Args_t ipV4; ipV4.Ip = (_u32)SL_IPV4_VAL(10,1,1,201); // _u32 IP address ipV4.IpMask = (_u32)SL_IPV4_VAL(255,255,255,0); // _u32 Subnet mask for this STA/P2P ipV4.IpGateway = (_u32)SL_IPV4_VAL(10,1,1,1); // _u32 Default gateway address ipV4.IpDnsServer = (_u32)SL_IPV4_VAL(8,8,8,8); // _u32 DNS server address Status = sl_NetCfgSet(SL_NETCFG_IPV4_STA_ADDR_MODE,SL_NETCFG_ADDR_STATIC,sizeof(ipV4),(_u8*)&ipV4); if( Status ) { // error }
至于AP上显示的IP地址和设定不一致的情况,设置静态IP时需要在AP端关闭DHCP,否则AP会自动分配给Station一个IP地址
int32_t AppWIFISetIpAddrAllocMode(uint8_t mode)
{
int32_t status = -1;
SlNetCfgIpV4Args_t ipV4;
switch (mode)
{
case STATIC_IP:
charArrToIPVal(&ipV4.Ip, ParaRO.Item.SrcIPAddr);
charArrToIPVal(&ipV4.IpMask, ParaRO.Item.MaskIPAddr);
charArrToIPVal(&ipV4.IpGateway, ParaRO.Item.GatewayIPAddr);
ipV4.IpMask = (unsigned long) (SL_IPV4_VAL(255, 255, 255, 0));
ipV4.IpDnsServer = ipV4.IpGateway;
status = sl_NetCfgSet(SL_NETCFG_IPV4_STA_ADDR_MODE,
SL_NETCFG_ADDR_STATIC, sizeof(SlNetCfgIpV4Args_t),
(uint8_t *) &ipV4);
status = sl_Stop(SL_STOP_TIMEOUT);
status = sl_Start(0, 0, 0);
break;
case DHCP_FAST_RENEW_NO_ACK:
status = sl_NetCfgSet(SL_NETCFG_IPV4_STA_ADDR_MODE, SL_NETCFG_ADDR_DHCP,
0, 0);
// Enable the "fast renew feature" + "NO wait"
status = sl_NetCfgSet(SL_NETCFG_IPV4_STA_ADDR_MODE,
SL_NETCFG_ADDR_ENABLE_FAST_RENEW, 0, 0);
status = sl_NetCfgSet(SL_NETCFG_IPV4_STA_ADDR_MODE,
SL_NETCFG_ADDR_FAST_RENEW_MODE_NO_WAIT_ACK, 0, 0);
// status = sl_Stop(SL_STOP_TIMEOUT); //modified by Pyz 2020.12.12
// status = sl_Start(0, 0, 0);
break;
}
return (status);
}
目前程序时这样操作的,那么设置上时没问题了,但是如果您说设置静态IP的时候,需要把AP关掉的话才行,这个应用就有些问题了。 我们在实际应用中,有些设备是需要设置成固定IP,有些设备时动态获取就OK了,如果为了兼顾两者的话,这样操作的话,就很不方便了。
你的同事(Michael)回复如下:
UDP port 123 is generally used for Network Time Protocol, in order to fetch the current date and time from an internet server to ensure that the CC3235 has the correct time in its settings. This accurate time is important for many reasons such as to verify the validity date of security certificates, and to provide low-power timing services.
That being said, fetching the time on the CC3235 is not automatic - you need to use application code to open a socket to a NTP time server to fetch the time, then update the system clock. Is the customer's power measurement example modified at all? Also, what power management use case are they using?
我接着回复:
I just chose low-power routines to modify, and did not pay attention to the time synchronization aspect, and did not deliberately modify it, all are the default settings.
We only involved TCP sockets in the use process, and never used the UDP protocol.
你的同事(Michael)接着回复:
Thank you for clarifying your code, and knowing that the power_measurement testing you perform only uses TCP makes things clearer.
后面就无法在帖子后面回复了,我查询了程序,没有使用到UDP,也没有发送有关于时间同步的相关指令,帮忙看看,谢谢。