Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By Medusa
#67518 Hi, I am a use a ESP-12 in AP mode, I am trying to send ascii characters from the console of monitor serie, when the number of these is less than 127 characters I can be received correctly to the other side, but when the number of characters is higher I can not receive anything...

Someone can tell me what is my error?

Is there any restriction on the number of transmitted characters?

Here is my code:

Code: Select all 
//////////////////////
// WiFi Definitions //
//////////////////////
const char WiFiAPPSK[] = "123456";
const int sizeBuffer = 1024;
char tramaRX[sizeBuffer];
boolean newData = false;
int i;

/////////////////////
// Pin Definitions //
/////////////////////
const int LED_PIN = 2; // Thing's onboard, green LED

WiFiServer server(80);

void setup()
{
  initHardware();
  setupWiFi();
  server.begin();
}

void loop()  {
  WiFiClient client = server.available();            // Check if a client has connected
  if (!client) {
    return;
  }
   
 if(Serial.available()) {
    for (i=0; i<sizeBuffer; i++){
        tramaRX[i] = '\0';
    }
   
    i = 0;
    while(Serial.available()  > 0 && newData == false) {

        tramaRX[i] = (char)Serial.read(); // read char from UART

         if (tramaRX[i] == '\r'  ){
              tramaRX[i] = '\0';

              Serial.print("Nro de Caracters: ");
              Serial.println(i);
              i = 0;
              newData = true;
         }
         else{
            i++;
         }
   
    if (newData == true) {


      String s = "HTTP/1.1 200 OK\r\n";
      s += "Content-Type: text/html\r\n\r\n";
      s += "<!DOCTYPE HTML>\r\n<html>\r\n";
     
      s += String(tramaRX);
     
      s += "</html>\n";
      client.print(s);
      delay(100);
      Serial.print(s);
      delay(10);
      i = 0;
      newData = false;
    }
   }
  }
       
  digitalWrite(LED_PIN, LOW);
  delay(100); 
  digitalWrite(LED_PIN, HIGH);
}

void setupWiFi()
{
  WiFi.mode(WIFI_AP);

  // Do a little work to get a unique-ish name. Append the
  // last two bytes of the MAC (HEX'd) to "Thing-":
  uint8_t mac[WL_MAC_ADDR_LENGTH];
  WiFi.softAPmacAddress(mac);
  String macID = String(mac[WL_MAC_ADDR_LENGTH - 2], HEX) +
                 String(mac[WL_MAC_ADDR_LENGTH - 1], HEX);
  macID.toUpperCase();
  String AP_NameString = "DEMO_WIFI_Nro" + macID;

  char AP_NameChar[AP_NameString.length() + 1];
  memset(AP_NameChar, 0, AP_NameString.length() + 1);

  for (int i=0; i<AP_NameString.length(); i++)
    AP_NameChar[i] = AP_NameString.charAt(i);

  WiFi.softAP(AP_NameChar, WiFiAPPSK);
}

void initHardware()
{
  Serial.begin(9600);
  pinMode(LED_PIN, OUTPUT);
  digitalWrite(LED_PIN, HIGH);
}