* * ======== setStationMode ======== * Sets the SimpleLink Wi-Fi in station mode and enables DHCP client */ void setStationMode(void) { int response; #ifdef dhcp unsigned char param; //Used with DHCP config #endif mode = sl_Start(0, 0, 0); if (mode < 0) { System_abort("Could not initialize SimpleLink Wi-Fi"); } /* Change network processor to station mode */ if (mode != ROLE_STA) //if not in STA mode { sl_WlanSetMode(ROLE_STA); //Set Mode /* Restart network processor */ sl_Stop(0xFF); //Stop processor mode = sl_Start(0, 0, 0); //Restart and get Mode if (mode != ROLE_STA) //if not STA Abort { System_abort("Failed to set SimpleLink Wi-Fi to Station mode"); } sl_Stop(0XFF); //Stop processor } sl_WlanDisconnect(); response = sl_WlanPolicySet(SL_POLICY_CONNECTION,SL_CONNECTION_POLICY(1,0,0,0,0),NULL,0); if(response < 0) { System_abort("Could not set policy"); } response = sl_WlanProfileDel(0xFF); if(response < 0) { System_abort("Could not delete profiles"); } /* Enable DHCP client */ param = 1; response = sl_NetCfgSet(SL_IPV4_STA_P2P_CL_DHCP_ENABLE, 1, 1, ¶m); //Config WiFi as station with dynamic IP address if(response < 0) { System_abort("Could not enable DHCP client"); } sl_Stop(10); /* Set connection variables to initial values */ deviceConnected = false; ipAcquired = false; }