arduino - esp8266 hangs after 4th client is created -


i using mit app inventor send data esp8266 , depending upon performing application on arduino-uno. new esp8266 development

here happens creating 80 port web-server.after sending string data esp8266. , among "fan on","fan off","light on" or "light off".

if sending data 1 one delay.it creates client , closes client,which fine.

but when send 2 or more data string simultaneously,it create client 0,1,2,3 respectively not closing every connection.and after esp8266 hangs , not respond new connection.

here code

      #include <softwareserial.h>       #define timeout 1000 // ms       #define led 5       #define motor 9       softwareserial myserial(7, 6); // rx, tx        void setup()       {         pinmode(8,output);         pinmode(motor,output);         pinmode(led, output);         //pinmode(button, input);         serial.begin(38400);         digitalwrite(8,high);         myserial.begin(38400);         delay(2000);         serial.println("start setup");         sendcommand("at+rst", "ready");         delay(5000);         sendcommand("at+cwmode=1", "ok");         sendcommand("at+cifsr", "ok");         sendcommand("at+cipmux=1", "ok");         sendcommand("at+cipserver=1,80", "ok");         serial.println("start end");       }        void loop() {          string incomingstring = "";         boolean stringready = false;          while (myserial.available())          {             if(myserial.find("+ipd,"))         {         delay(500);         int connectionid = myserial.read()-48;         incomingstring = myserial.readstring();         serial.println(connectionid);         stringready = true;         if (stringready)          {           serial.println("received string: " + incomingstring);            if (incomingstring.indexof("fan on") != -1) {             digitalwrite(motor,high);           }            if (incomingstring.indexof("fan off") != -1) {            digitalwrite(motor,low);           }           if (incomingstring.indexof("light on") != -1) {             digitalwrite(led, high);           }           if (incomingstring.indexof("light off") != -1) {             digitalwrite(led, low);           }         }          sendcommand("at+cipclose=5","ok");         /*switch( connectionid )         {           case 0 :              sendcommand("at+cipclose=0","ok");             break;           case 1 :              sendcommand("at+cipclose=1","ok");             break;           case 2 :             sendcommand("at+cipclose=2","ok");             break;           case 3 :              sendcommand("at+cipclose=3","ok");             break;           case 4 :              sendcommand("at+cipclose=4","ok");             break;           default:            sendcommand("at+cipclose=5","ok");             break;         }*/         }         }       }        boolean sendcommand(string cmd, string ack) {         myserial.println(cmd); // send "at+" command module         if (!echofind(ack)) // timed out waiting ack string           return true; // ack blank or ack found       }        boolean echofind(string keyword) {         byte current_char = 0;         byte keyword_length = keyword.length();         long deadline = millis() + timeout;         while (millis() < deadline) {           if (myserial.available())           {             char ch = myserial.read();             serial.write(ch);             if (ch == keyword[current_char])               if (++current_char == keyword_length)               {                 serial.println();                 return true;               }           }         }         return false; // timed out       } 

this app developed in mit app inventor


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -