Chat freely about anything...

User avatar
By nikan110
#64769 hi to all, i am working on a project that in it i need to send some file over wifi from my computer to my micro and i decide to use esp8266 in order to done that. i use below code for my esp8266 to recive file and redirect it to uart port :
Code: Select all#include <ESP8266WiFi.h>

uint8_t data = 0;

WiFiServer server(8888);
int counter = 0;
void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);

  WiFi.softAP("akbar","akbar11041");

  server.begin();
 
}

void loop() {
   // put your main code here, to run repeatedly:
   WiFiClient con = server.available();
   if(con)
   {
      Serial.println("new connection");
      counter = 0;
      while(con.connected())
      {
        if(con.available())
        {
          counter += con.read(&data,1);
         
          Serial.print(data);
          Serial.println();
        }
      }
      Serial.println("Connection closed");
      Serial.println("number of items :");
      Serial.println(counter);
      con.stop();
   }
}

and use below python code for sending file :
Code: Select allimport socket
import time



fl = open("3.dat","rb")
data = fl.read()
con = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
con.connect(("192.168.4.1",8888))
print(con.send(data))
fl.close()

but i have a problem, as you can see i send every byte that i receive to Serial port, but for example when i sent a file that has 768000 byte i only receive 5000 byte of that file in esp and also in uart.
now can any one help me to solve that, it offend me for tow day.