コード例 #1
0
ファイル: WiFi.cpp プロジェクト: ArduCAM/Energia
void WiFiClass::config(IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet)
{
    if (!_initialized) {
        init();
    }

    //
    // Set the local_IP indicating that the network
    // is configured for static IP.
    //
    local_IP = local_ip;

    //
    //get current configuration
    //
    SlNetCfgIpV4Args_t config = {0};
    unsigned char len = sizeof(SlNetCfgIpV4Args_t);
    sl_NetCfgGet(SL_IPV4_STA_P2P_CL_GET_INFO, NULL, &len, (unsigned char*)&config);
    
    //
    //Assign new ip address and new dns server to current config
    //and use netcfgset to set the new configuration in memory
    //
    config.ipV4 = sl_Ntohl((uint32_t)local_ip);
    config.ipV4DnsServer = sl_Ntohl((uint32_t)dns_server);
    config.ipV4Gateway = sl_Ntohl((uint32_t)gateway);
    config.ipV4Mask = sl_Ntohl((uint32_t)subnet);
    sl_NetCfgSet(SL_IPV4_STA_P2P_CL_STATIC_ENABLE, 1, sizeof(SlNetCfgIpV4Args_t), (unsigned char*)&config);
    
}
コード例 #2
0
ファイル: WiFi.cpp プロジェクト: Ryan1014/Energia
void WiFiClass::config(IPAddress local_ip)
{
    if (!_initialized) {
        init();
    }

    //
    // Set the local_IP indicating that the network
    // is configured for static IP.
    //
    local_IP = local_ip;

    //
    //get current configuration
    //
    _NetCfgIpV4Args_t config = {0};
    unsigned char len = sizeof(_NetCfgIpV4Args_t);
    sl_NetCfgGet(SL_IPV4_STA_P2P_CL_GET_INFO, NULL, &len, (unsigned char*)&config);
    
    //
    //Assign new ip address to current config
    //and use netcfgset to set the new configuration in memory
    //
    config.ipV4 = sl_Ntohl((uint32_t)local_ip);
    sl_NetCfgSet(SL_IPV4_STA_P2P_CL_STATIC_ENABLE, 1, sizeof(_NetCfgIpV4Args_t), (unsigned char*)&config);
}