This program opens a socket and wait connection through Wi-Fi. When the socket is connected, print out received characters to LCD.
Diff: main.cpp
- Revision:
- 2:f5754fb90f07
- Parent:
- 1:e87727c8979d
--- a/main.cpp Sun Jun 03 12:24:13 2012 +0000 +++ b/main.cpp Wed Oct 24 10:16:52 2012 +0000 @@ -1,6 +1,9 @@ #include "mbed.h" #include "LcdScreen.h" +static void setLeds(int data); +#include "WifiTerminalMode.h" + DigitalOut myled1(LED1); DigitalOut myled2(LED2); DigitalOut myled3(LED3); @@ -13,30 +16,32 @@ myled4 = (data & 1); } -#include "wifi.h" - int main() { int i = 0; unsigned char *p; LcdScreen *ls = new LcdScreen(); + WifiTerminalMode *terminal = new WifiTerminalMode(); - wifiReset(); - wifiSerialInit(); - wifiPortSetup(); + // 1st time set up parameters + ls->print("setting parameters\r\n"); + terminal->reset(); + terminal->serialInit(); + terminal->portSetup(); setLeds(1); - wifiReset(); + // 2nd time do connect + ls->print("connecting\r\n"); + terminal->reset(); setLeds(2); - wifiSerialInit(); + terminal->serialInit(); setLeds(3); - p = wifiGetAddr(); + p = terminal->getAddr(); ls->print(p); ls->print((const unsigned char *)"\r\n"); setLeds(8); - wifiReadBlock(); while (true) { setLeds(8 | i); i ^= 1; - p = wifiReadLine(); + p = terminal->readLine(); ls->print(p); } }