Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: 4DGL-uLCD-SE mbed
Diff: src/WifiControl.cpp
- Revision:
- 13:ef68cbcb4e9a
- Parent:
- 12:ef988c7fe8a4
- Child:
- 14:8d31d304eeb3
--- a/src/WifiControl.cpp Mon Oct 19 21:09:22 2015 +0000 +++ b/src/WifiControl.cpp Mon Oct 19 22:25:18 2015 +0000 @@ -12,13 +12,7 @@ strcpy(snd, "AT+CIOBAUD=115200\r\n"); SendCMD(); - - -} - -void WifiControl::wifiGo() -{ DigitalOut reset(p26); reset=0; //hardware reset for 8266 pc->baud(115200); // set what you want here depending on your terminal program speed @@ -28,50 +22,57 @@ timeout=2; getreply(); - esp->baud(115200); // change this to the new ESP8266 baudrate if it is changed at any time. - - //ESPsetbaudrate(); //****************** include this routine to set a different ESP8266 baudrate ****************** - - ESPconfig(); //****************** include Config to set the ESP8266 configuration *********************** - - - - // continuosly get AP list and IP - while(1) { - pc->printf("\n---------- Listing Acces Points ----------\r\n"); + esp->baud(115200); + + + +} + + +void WifiControl::pollAP(char * results){ + + pc->printf("\n---------- Polling APs privately ----------\r\n"); strcpy(snd, "AT+CWLAP\r\n"); SendCMD(); timeout=15; getreply(); - pc->printf(buf); - wait(2); - pc->printf("\n---------- Get IP and MAC ----------\r\n"); + strcpy(results, buf); + + +} + +void WifiControl::getIPMAC() { + + pc->printf("\n---------- Get IP and MAC ----------\r\n"); strcpy(snd, "AT+CIFSR\r\n"); SendCMD(); timeout=10; getreply(); pc->printf(buf); wait(2); - } - } -char WifiControl::pollAP(){ - - char polledAPs; - - pc->printf("\n---------- Polling APs privately ----------\r\n"); - strcpy(snd, "AT+CWLAP\r\n"); +void WifiControl::connect(char * ssid, char * pwd) { //32 byte chars + + pc->printf("\n---------- Connecting to AP ----------\r\n"); + pc->printf("ssid = %s pwd = %s\r\n",ssid,pwd); + strcpy(snd, "AT+CWJAP=\""); + strcat(snd, ssid); + strcat(snd, "\",\""); + strcat(snd, pwd); + strcat(snd, "\"\r\n"); SendCMD(); - timeout=15; + timeout=10; getreply(); pc->printf(buf); - polledAPs = *buf; - return polledAPs; - } + + + + + void WifiControl::ESPsetbaudrate() { strcpy(snd, "AT+CIOBAUD=115200\r\n"); // change the numeric value to the required baudrate @@ -146,19 +147,12 @@ pc->printf(buf); wait(2); - - pc->printf("\n---------- Connecting to AP ----------\r\n"); - pc->printf("ssid = %s pwd = %s\r\n",ssid,pwd); - strcpy(snd, "AT+CWJAP=\""); - strcat(snd, ssid); - strcat(snd, "\",\""); - strcat(snd, pwd); - strcat(snd, "\"\r\n"); - SendCMD(); - timeout=10; - getreply(); - pc->printf(buf); - + + char ssid[32] = "GTOther"; + char pwd[32] = "GeorgeP@1927"; + + connect(ssid, pwd); + wait(5); pc->printf("\n---------- Get IP's ----------\r\n");