- Tue Feb 23, 2016 1:21 pm
#41745
martinayotte wrote:Yes ! WifiClient is derived from Client, and Client is derived from Stream, and Stream is derived from Print.
In the mean time that your ESPs arrive, you can start writing the server python code, it can easily be manually tested with simple telnet tool.
Hi martinayotte;
thanks again for your help!
Meanwhile, my ESP-01s arrived and I got it working - in principle.... but here is where I am stuck right now:
In my ESP/Arduino code, I gather data in packets of an array of 10 values. These 10 values I want to send from the ESP (as client) to a TCP server (via python, as you suggested earlier)
This is the code snippet on the ESP side:
Code: Select all // This will send the data to the server
for(int x = 0;x < loopmaxcount; x++) { // send batch of timestamps server
client.print(timestamp[x]);
// client.println();
}
The problem: On the server side, I only get one entry (the last one).
Here is the python server snippet:
Code: Select all def handle(self):
# self.request is the TCP socket connected to the client
self.data = self.request.recv(1024)
print "{} wrote:".format(self.client_address[0])
print self.data
file = open("newfile.txt", "a")
file.write(self.data)
file.close()
# just send back an ok
self.request.sendall('ok')
Both in the generated file newfile.txt as well as the on screen output, only the last of the 10 values per packet is shown.
What am I doing wrong?
I think, the problem lies on the ESP code side, as when I try with a mini python client to send 2 strings to the python server, this works and both are received and listed....
Can you - or anyone else give me some hints?