some problem with WiFiClient in arduino enviroment
Posted: Sun Apr 09, 2017 4:47 pm
hi to all, i am working on project that in it i need some file(around 750kb) to my device and i decide to use esp8266 in order to done that.i successfully config arduino and now i can use arduno ide to write program for esp8266.
but i have a problem, when i send my file from my computer to esp8266, i can only find part of that on esp8266; for example when i send a 750kb file i can receive only 5 kb on esp8266 and i do n't know what is problem.
here is my code
and i use below python code to send data to esp:
i am new in esp and i do n't know hove solve this problem,any one can help me ???
but i have a problem, when i send my file from my computer to esp8266, i can only find part of that on esp8266; for example when i send a 750kb file i can receive only 5 kb on esp8266 and i do n't know what is problem.
here is my code
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("Connection closed");
Serial.println("number of items :");
Serial.println(counter);
con.stop();
}
}
and i use below python code to send data to esp:
Code: Select all
import socket
import time
fl = open("2.dat","rb")
data = fl.read()
con = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
con.connect(("192.168.4.1",8888))
con.send(data)
con.close()
fl.close()
i am new in esp and i do n't know hove solve this problem,any one can help me ???