#define SSID "Mywifi"
#define PASSWORD "Password"
#include "uartWIFI.h"
#include <SoftwareSerial.h>
WIFI wifi;
extern int chlID; //client id(0-4)
int led = 12;
void setup()
{
pinMode(led,OUTPUT);
digitalWrite(led,0);
wifi.begin();
bool b = wifi.Initialize(STA, SSID, PASSWORD);
delay(3000); //หน่วงเวลาให้เครื่องเชื่อมกับ wifi
wifi.confMux(1);
if(wifi.confServer(1,8080)){
digitalWrite(led,HIGH);
}
else
{
digitalWrite(led,HIGH);
delay(1000);
digitalWrite(led,LOW);
delay(1000);
}
if(!b)
{
DebugSerial.println("Init error");
}
delay(8000); //make sure the module can have enough time to get an IP address
String ipstring = wifi.showIP();
DebugSerial.print
("My IP address:");
DebugSerial.println(ipstring); //show the ip address of module
String wifimode = wifi.showMode();
DebugSerial.println(wifimode); //show the name of current wifi access port
}
void loop()
{
char buf[100];
int iLen = wifi.ReceiveMessage(buf);
if(iLen > 0)
{
wifi.Send(chlID,"Hello 1 ");
wifi.Send(chlID,"Hello 2");
}
}