Post topics, source code that relate to the Arduino Platform

User avatar
By akhgari
#60889
martinayotte wrote:Fiest, you are talking about AT command, but you are using an Arduino sketch.
Beware that when you upload Arduino sketch, the AT firmware is gone/erased.

For you code, I don't see any client.available(), so it doesn't check if characters are received.
Check the following code instead :

Code: Select allvoid loop()
{
  // Check if a client has connected
  WiFiClient client = server.available();
  if (client) {
    if (client.available()) { // <--- here is the missing part
      // Read the first line of the request
      String req = client.readStringUntil('\r');
      Serial.println(req);
      client.flush();
      Serial1.println("Client disonnected");
    }
  }
}


Yes! I know. I use terminal and AT commands to check my mobile app. this app have several buttons and when press each buttons on mobile app, send a string on port "8888" that received on terminal
now erase firmware and wish write a skatch to read this string and turn on/off gpio

I use Arduino 1.8.0 downloaded from arduino.org and "http://arduino.esp8266.com/stable/package_esp8266com_index.json"
I compile your code but following error reports

exit status 1
'class ESP8266WebServer' has no member named 'available'
User avatar
By akhgari
#61071 Thanks martinayotte
I changed my code

Code: Select all#include <ESP8266WiFi.h>

const char *ssid = "Test_ESP";
const char *password = "testtest";
unsigned int localPort = 8888;                                 
IPAddress    apIP(192, 168, 56, 1);                           
IPAddress    broadcastIP(255, 255, 255, 255);
WiFiServer server(localPort);

void setup() {
  delay(1000);
  Serial.begin(115200);
  Serial.println();
  Serial.print("Configuring access point...");

  WiFi.mode(WIFI_AP);
  WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));
  WiFi.softAP(ssid, password);
  server.begin();
}


void loop()
{
  // Check if a client has connected
  WiFiClient client = server.available();
  if (client) {
    if (client.available()) { // <--- here is the missing part
      // Read the first line of the request
      String req = client.readStringUntil('\r');
      Serial.println(req);
      client.flush();
      Serial1.println("Client disonnected");
    }
  }
}


I use your code and delete ESP8266WebServer. now it's compile with out any error but nothing show in serial monitor.