1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-30 16:24:09 +03:00

Bugfix and fix compilation erro with new-extensions branch

This commit is contained in:
mlafauci
2011-05-18 08:39:47 +02:00
parent 8d1761f009
commit 4f7e2f1201
12 changed files with 144 additions and 29 deletions

View File

@ -10,6 +10,7 @@
*/
#include <WiFi.h>
#include <IPAddress.h>
#define _PRINT_
byte mac[6] = { 0 };
IPAddress ip;
@ -103,11 +104,13 @@ int startWiFiWpa()
{
Serial.println("\nSetup WiFi Wpa...");
//strcpy(ssid, "AndroidAP9647");
//strcpy(ssid, "AndroidAP3551");
strcpy(ssid, "Cariddi");
Serial.print("SSID: ");
Serial.println(ssid);
const char *pass = "1234567890";
status = WiFi.begin(ssid, pass);
//status = WiFi.begin(ssid);
if ( status != WL_CONNECTED)
{
Serial.println("Connection Failed");
@ -146,9 +149,12 @@ void setup()
void execCmd(char* buf)
{
#ifdef _PRINT_
Serial.print("\nExecuting command: ");
Serial.println(buf);
server.write(buf);
#endif
//server.write(buf);
server.print(buf);
}
@ -166,12 +172,18 @@ void loop()
}
static byte idx = 0;
int c = 0;
while (client.available())
do
{
dataBuf[idx] = client.read();
c = client.read();
if (c!=-1)
{
dataBuf[idx] = c;
#ifdef _PRINT_
if (idx == 0) Serial.print("Client chatting...: ");
Serial.print(dataBuf[idx]);
#endif
if ((dataBuf[idx] == 0xa)/*||(dataBuf[idx] == 0xd)*/)
{
dataBuf[idx+1]=0;
@ -181,7 +193,8 @@ void loop()
}else{
++idx;
}
}
}
}while (c!=-1);
}
}
}

View File

@ -114,12 +114,12 @@ void setup()
{
Serial.begin(9600);
Serial.println("*** Start WiFi example ***");
WiFi.begin();
//scanNetworks();
delay(3000);
int _status = startWiFi();
//int _status = startWiFi();
/*
if ( _status == WL_CONNECTED)
{
Serial.println("Wifi Connected!");
@ -129,17 +129,53 @@ void setup()
printCurrNet();
scanNetworks();
/*
Serial.println("Starting server...");
server.begin();
delay(1000);
*/
}
*/
}
void loop()
{
static boolean free = false;
// if (free) Serial.println(WiFi.test(),10);
if (free) WiFi.test();
byte c = Serial.read();
if (c!=255)
{
switch (c)
{
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
{
int i = 0;
for (;i<(c-0x30);++i)
{
int num = WiFi.test();
//Serial.println(num,10);
}
break;
}
case 'c':
free = true;
break;
case 's':
free = false;
break;
}
}
/*
Client client = server.available();
static uint8_t count = 0;
Serial.println("Retry connect...");
status = WiFi.begin(ssid);