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.

请教CC3235MODS 官方驱动获得IP地址异常问题

Other Parts Discussed in Thread: CC3235MODS

目前的程序也是这样的,但是还是不行,现象是一样的。

  • 将-ip后面的IP地址去掉,只输入命令wlanconnect -s "myhome network" -t WPA2 -p "password"
    这样得到的IP地址就是一致的
    -ip是重新指定了新的ip地址
  • 好的,我这边让同事测试看看,有及时反馈信息,谢谢。
  • 如果不加-ip的话,静态IP如何设置?
  • 路由器会自动分配,使用CC3235作AP时,可以在程序中设定IP
    具体信息查看手册4.3,4.4,5.3节www.ti.com/.../swru455m.pdf
  • CC3235MODS是STA模式,有些应用场合是在STATIC 下获取IP,有些场合是在DHCP下获取IP地址,目前动态IP地址没问题,静态IP才有问题,STATIC 是如何设置的。
  • 设置静态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了,如果为了兼顾两者的话,这样操作的话,就很不方便了。

  • 不关闭DHCP AP就会自动分配一个IP地址,出现前面所说的地址不一致的情况
  • 好的,非常感谢,我这边也测试了下,我们设置静态IP的时候,虽然跟web的地址不一致,但是在网络中进行ping的时候,能PING通是我们设置的IP地址,而web地址是无法Ping, 也有可能是路由器或是AP那边刷新机制的问题,非常感谢您一直以来的支持。
  • 好的,web地址无法ping可能是DHCP的原因
  • 你的同事(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,也没有发送有关于时间同步的相关指令,帮忙看看,谢谢。

  • 这是另一个问题了,你可以在英文论坛原帖发一个关联贴继续提问