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.

cc3200无法使用静态ip连接接入点




// SlNetCfgIpV4Args_t MipV4;
// MipV4.ipV4 = (_u32)SL_IPV4_VAL(10,10,100,138); // _u32 IP address
// MipV4.ipV4Mask = (_u32)SL_IPV4_VAL(255,255,255,0); // _u32 Subnet mask for this STA/P2P
// MipV4.ipV4Gateway = (_u32)SL_IPV4_VAL(10,10,100,254); // _u32 Default gateway address
// MipV4.ipV4DnsServer = (_u32)SL_IPV4_VAL(10,10,100,254); // _u32 DNS server address

// sl_NetCfgSet(SL_IPV4_STA_P2P_CL_STATIC_ENABLE,IPCONFIG_MODE_ENABLE_IPV4,sizeof(SlNetCfgIpV4Args_t),(_u8 *)&ipV4);
// sl_Stop(0);
// sl_Start(NULL,NULL,NULL);

我已经按照提供的函数设置好了, lRetVal = sl_NetCfgSet(SL_IPV4_STA_P2P_CL_DHCP_ENABLE,1,1,&ucVal);也注释掉了,可是不知道为什么还是自动获取ip,以前成功过,奇怪的是最近不知道为什么不行了,热点还是原来的热点没有动,请问是哪里出问题了。。。

  • 静态IP配置

    SlNetCfgIpV4Args_t ipV4;
    ipV4.ipV4 = (_u32)SL_IPV4_VAL(IP地址); // _u32 IP address
    ipV4.ipV4Mask = (_u32)SL_IPV4_VAL(Mask地址); // _u32 Subnet mask for this STA/P2P
    ipV4.ipV4Gateway = (_u32)SL_IPV4_VAL Gateway地址); // _u32 Default gateway address
    ipV4.ipV4DnsServer = (_u32)SL_IPV4_VAL-DNS地址); // _u32 DNS server address
    lRetVal = sl_NetCfgSet(SL_IPV4_STA_P2P_CL_STATIC_ENABLE,IPCONFIG_MODE_ENABLE_IPV4,sizeof(ipV4),(_u8 *)&ipV4);
    ASSERT_ON_ERROR(lRetVal);
    sl_Stop(0);
    sl_Start(NULL,NULL,NULL);

    在这之前又没有打开?

    DHCP功能:

    lRetVal = sl_NetCfgSet(SL_IPV4_STA_P2P_CL_DHCP_ENABLE,1,1,&ucVal); // Enable DHCP client
    ASSERT_ON_ERROR(lRetVal);

  • 对的 我就是这么设置的  不知道为啥不能打开静态ip

    我把ipV4的结构体名字换成了MipV4  因为编译的时候会因为编译器不能分辨原来的ipV4是结构体名字还是结构体里面的元素而报错,所以我改了一下  同时相应的socket.h里面也修改好了

    这是我修改的地方

    #define Net_ipv4                             SL_IPV4_VAL(10,10,100,155)
    #define Net_ipv4Mask                   SL_IPV4_VAL(255,255,255,0)
    #define Net_ipv4Gateway             SL_IPV4_VAL(10,10,100,254)
    #define Net_ipv4DnsServer         SL_IPV4_VAL(10,10,100,254)

    SlNetCfgIpV4Args_t MipV4;

    MipV4.ipV4 = (_u32)Net_ipv4; // _u32 IP address
    MipV4.ipV4Mask = (_u32)Net_ipv4Mask; // _u32 Subnet mask for this STA/P2P
    MipV4.ipV4Gateway = (_u32)Net_ipv4Gateway; // _u32 Default gateway address
    MipV4.ipV4DnsServer = (_u32)Net_ipv4DnsServer; // _u32 DNS server address

    lRetVal = sl_NetCfgSet(SL_IPV4_AP_P2P_GO_STATIC_ENABLE,IPCONFIG_MODE_ENABLE_IPV4,sizeof(SlNetCfgIpV4Args_t),(_u8 *)&MipV4);

    sl_Stop(0);
    sl_Start(NULL,NULL,NULL);
    ASSERT_ON_ERROR(lRetVal);

    socket.h中:

    //ADD
    typedef struct
    {
    _u32 ipV4;
    _u32 ipV4Mask;
    _u32 ipV4Gateway;
    _u32 ipV4DnsServer;
    }SlNetCfgIpV4Args_t;

    typedef union
    {
    SlIpV4AcquiredAsync_t       ipAcquiredV4; /*SL_NETAPP_IPV4_IPACQUIRED_EVENT*/
    // SlIpV6AcquiredAsync_t    ipAcquiredV6; /*SL_NETAPP_IPV6_IPACQUIRED_EVENT*/
    _u32                                     sd; /*SL_SOCKET_TX_FAILED_EVENT*/
    SlIpLeasedAsync_t            ipLeased; /* SL_NETAPP_IP_LEASED_EVENT */
    SlIpReleasedAsync_t        ipReleased; /* SL_NETAPP_IP_RELEASED_EVENT */
    SlNetCfgIpV4Args_t             MipV4; /* Manual IPV4 Configuration */
    } SlNetAppEventData_u;

  • 抱歉 找到原因了  我太粗心了,我用成了 SL_IPV4_AP_P2P_GO_STATIC_ENABLE 而不是SL_IPV4_STA_P2P_CL_STATIC_ENABLE  

    还是谢谢你了