Recieving a binary file over wifi

imtiaz
Posts: 106
Joined: Wed Oct 26, 2016 1:34 am

Recieving a binary file over wifi

Postby imtiaz » Wed Nov 02, 2016 9:13 pm

Hi All,

I would like to receive a binary file over wifi on the esp32 , with the esp32 setup as the host and access point. The binary file will likely need to be stored on the esp32 RAM or flash (depending on size).

Can anyone point me to the right direction on how I can set up a webserver on the esp32 and then receive a binary file. The file will be a binary file used to flash a processor connected to the ESP32 uart.

Any other suggestions / guidance / best practice to achieve the above functionality will be most appreciated.

Code examples with the lwip stack would be great.

Thanks
Imtiaz

imtiaz
Posts: 106
Joined: Wed Oct 26, 2016 1:34 am

Re: Recieving a binary file over wifi

Postby imtiaz » Fri Nov 04, 2016 4:12 am

Hi All,

Does anyone have an example of receiving/decoding a multi-part http post using the esp32?

Thanks
Imtiaz

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Recieving a binary file over wifi

Postby kolban » Fri Nov 04, 2016 5:28 am

If you were writing a pure C application on a Linux/Unix environment and you had access to the sockets API would you be able to achieve your goal?

Within the ESP32 environment, you can safely assume that you have access to all the sockets APIs. What this means is that you can write a C application which creates a socket, binds it to a local port, flags it in listening state and then waits to accept a new client connection. When the client connection arrives, you can read the data through the connection until all received and then close the socket. At this point you will have received the data from the partner.

Prior to setting up the sockets, you will have had to have setup the WiFi connection as either an access point or as a station to a partner access point.

I fully realize that this is far from a fully baked out sample ... but in this post are the "essence" parts to building what you need. What I'd suggest you do is read through this post and make a list of the items you understand and don't understand. Try a google search and read up on those concepts. If you have questions on a specific topic and it isn't answered elsewhere (such as stackexchange) then please feel free to post back here and we can try and assist. There are aspects in this story that are ESP32 specific such as WiFi networking and other aspects that are 100% pure C programming in combination with the sockets API.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

imtiaz
Posts: 106
Joined: Wed Oct 26, 2016 1:34 am

Re: Recieving a binary file over wifi

Postby imtiaz » Mon Nov 07, 2016 1:26 am

Thanks for the reply Kolban. I'll post an update here if/when I manage to get it working.

Jim_ber
Posts: 1
Joined: Fri Oct 13, 2017 9:16 pm

Re: Recieving a binary file over wifi

Postby Jim_ber » Fri Oct 13, 2017 9:18 pm

imtiaz,

I am looking to implement the same functionality. Have you had any luck?

James

imtiaz
Posts: 106
Joined: Wed Oct 26, 2016 1:34 am

Re: Recieving a binary file over wifi

Postby imtiaz » Mon Oct 16, 2017 8:27 pm

Hi James,

Yes this was implemented a while ago. My code is very specific to our application and Im not sure exactly what part you are interested in, however the basic idea is:
1 - start a wifi access point or connect to an existing one
1 - set up a thread that starts a tcp socket server on a specific port and waits for a connection - use a generic tcp socket server example
2 - the code will block and wait for a client to connect
3 - once connected I receive the bytes and write it to a specific partition on the esp32
4 - once the whole file is received - I calculate the md5 hash and compare it to what I was sent before.

I used python as a tcp client to test this out .

Hope this helps
Imtiaz

Who is online

Users browsing this forum: Baidu [Spider], Bing [Bot] and 315 guests