I designed the program originally as part of a project for a colleague where a uMite had to respond to a network request from a PC and send a file from an attached SD card. This worked fine on XP but when we came to real world testing he was using Win 7 and it didn't work. Further testing determined that messages from the PC to the uMite were being received and processed but the returned data was being sent but could not be received by Win 7 machine, the broadcast packets were being blocked. Anyway this prompted some improvements to identify the ESP/uMite device and have it use unicast when returning data.
The code I have developed consists of 3 parts. What ever the uMite project the parts are always the same.
1, ESP8266-MCU is the ESP firmware, sends/receives UDP messages between network and attached MCU, in my case a uMite
2, uMite library for ESP communication
3, uMite "Hook" code into the user program running on the uMite.
I have developed a "protocol" that allows messages to be sent to/from ESP/uMites and or PC. The protocol structure allows for commands/data meant for the ESP or the uMite in the ESP/uMite device to be received and acted upon.
Basically the format is IP:Port|from|to|cmd|data however the IP:Port is fairly transparent and handled in the ESPbasic firmware. There are also a selection of commands from the uMite that tell the ESP what to do with the data or are direct commands like time: (gets NTP time from Internet) info: (gets basic system info from ESP, eg IP,Flash,Ram etc)
From the PC end you can Read and Set the time on the uMite, Command the uMite or ESP or Both to reset. These commands could easily be expanded to allow many more ESP specific functions. For a very simple experiment with the ESP firmware loaded and the ESP connected to a terminal (I use CoolTerm as it has a very nice popup screen for sending messages) you can send a commands like info: and time: the ESP should respond with this info. In this way you are emulating an attached MCU. If you then also start up the PC application you should be able to connect to the ESP device you have on your network (if they are in the same domain) and sent commands as well. No answer of course without a MCU attached to the ESP but you will be able to see the commands in the terminal. Baudrate is set at 230400 by the way. You should be also be able to reboot the ESP from the commands list.
[img] [/img]
The uMite uses MMbasic , I suggest you may want to take a look at the the micromite site for more information. http://geoffg.net/micromite.html
I hope this explanation hasn't been to convoluted. For a live example of the functions this project has allowed weather data collected by a uMite/ESP and sent to Weather Underground directly https://www.wunderground.com/personal-weather-station/dashboard?ID=IVICYARR4