Have been having great strides with CC3200 and Energia, but I hit a snag, hoping someone can assist.
I am attempting to use a AP server to display to surrounding available SSIDs and connect to it. Unfortunately as soon as I try to connect to the Wlan using WiFi.Begin it just fails.
I have attached the test code below. When removing the WiFi.BeginNetwork(); the CC3200 connects to the WLan mentioned. But as soon as you introduce the AP it just doesn't connect.
//Include Files
#include <WiFi.h>
#include <WiFiClient.h>
#include <WiFiServer.h>
#include <WString.h>
//stage 1
String security = "WPA";
String ssidconnect = "SSID";
String Passstr = "PASSWORD";
char ssid[50];
char Password[50];
char wifi_name[] = "APtest"; //create mem location, allow to be change in setup
char wifi_password[] = "APPassword"; //create mem location, allow to be change in setup
//Create Wifi server
WiFiServer server(80);
void setup()
{
//Initialize serial and wait for port to open:
Serial.begin(115200);
Serial.println("Serial Terminal Initiated...");
// Initiate Wifi
WiFi.init();
Serial.println("Wifi Initiated...");
// Start WiFi and create a network with wifi_name as the network name
// with wifi_password as the password.
Serial.print("Starting network...");
//WiFi.beginNetwork(wifi_name, wifi_password);
Serial.println("done.");
Serial.println("Starting webserver on port 80");
server.begin(); // start the web server on port 80
Serial.println("Webserver started!");
}
void loop()
{
int keyIndex = 1;
int stringlen = ssidconnect.length() + 1;
ssidconnect.toCharArray(ssid, stringlen);
stringlen = Passstr.length() + 1;
Passstr.toCharArray(Password,stringlen);
Serial.print("Security: ");
Serial.println(security);
if(security == "WEP") {
Serial.println("Connecting to WEP encryption");
// print the network name (SSID);
Serial.println(ssid);
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
WiFi.begin(ssid, keyIndex, Password);
}
else if (security == "WPA") {
Serial.println("Connecting to WPA encryption");
// print the network name (SSID);
Serial.print("SSID: ");
Serial.println(ssid);
Serial.print("Password: ");
Serial.println(Password);
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
WiFi.begin(ssid, Password);
}
else if (security == "None") {
Serial.println("Connecting to NO encryption");
// print the network name (SSID);
Serial.println(ssid);
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
WiFi.begin(ssid);
}
else {
Serial.println("Can't pick up encryption type");
// Couldnt find Encryption type
delay(1);
}
while ( WiFi.status() != WL_CONNECTED) {
// print dots while we wait to connect
Serial.print(".");
delay(300);
}
Serial.println("\nYou're connected to the network");
Serial.println("Waiting for an ip address");
while (WiFi.localIP() == INADDR_NONE) {
// print dots while we wait for an ip addresss
Serial.print(".");
delay(300);
}
Serial.println("\nIP Address obtained");
// continue
}
I'd appreciate any assistance in determining how to stop the AP or just getting the Wlan to run.
Thank you,
Abrie