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
Recieving a binary file over wifi
Re: Recieving a binary file over wifi
Hi All,
Does anyone have an example of receiving/decoding a multi-part http post using the esp32?
Thanks
Imtiaz
Does anyone have an example of receiving/decoding a multi-part http post using the esp32?
Thanks
Imtiaz
Re: Recieving a binary file over wifi
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.
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
Re: Recieving a binary file over wifi
Thanks for the reply Kolban. I'll post an update here if/when I manage to get it working.
Re: Recieving a binary file over wifi
imtiaz,
I am looking to implement the same functionality. Have you had any luck?
James
I am looking to implement the same functionality. Have you had any luck?
James
Re: Recieving a binary file over wifi
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
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: No registered users and 224 guests