2015/09/18

WiFi for everything #3 - HTTP Server

Time did not stop. I keep going with the development of my ESP8266 WiFi module's C library. I have now a very well working own HTTP server layer with lots of capabilities. Let's check out my test application.


The PIC32MX250F128B 32-bit microcontroller is hosting a simple webpage, which can be accessed using a regular internet browser. So there is no need for specific app. Before reaching the content above the user have to enter a username and password pair. This HTTP Basic Authentication was implemented most recently.

Table cells on the page are representing relays connected to the microcontroller, which can be turned on and off by clicking on them. This function is performed "under the hood" using an AJAX request. The response is an XML resource including the actual state of the relays (color codes :D ).

The main feature of my HTTP server implementation is the support of dynamic resources. By this test application the index.html resource is static, because it's content is constant. The XML state resource is dynamic and has parts where text strings will be inserted. These strings are generated at runtime. The mechanism is similar to the Microchip's HTTP2 server solution, but in my realization the resources are handled by the library standalone.

The way I put HTTP resources (files) to the project is using my dotNet app called "HttpContent2WifiServer".


It creates .h header file, which is included to the project. This header contains the file as char array and a structure with important parameters (name, size, number of chunks, properties, positions of the dynamic strings, names of the functions printing dyn. strings, etc.).


Header file below was created from the file states.xml. "~{...}" marks are containing the references to the print functions (Http_Print_xxxxx). These tags are eliminated from the generated array, but their positions are stored (function parameters also).


Header file of a static resource looks a way more simple:


Using my dotNet app makes the development more comfortable and faster.


"TCP Socket Connected" indicator for sockets 0-4



In the next article we will see my first really useful application of this Internet of Things stuff... :)

5 comments:

  1. Hey man great job ,
    I am trying to build a home automation for my home, but i am not an electronic gig so dont know much of it , Could you please help me out in this.
    I would like to control different swtich boards through ESP8266 but i dont know how to connect them .
    If you can help me out on this it would be very helpfull

    Thanks
    Santosh Das

    ReplyDelete
  2. Hi,

    Sorry for late response. After all this I think the easiest and simplest way to program and communicate with these modules is more likely the Arduino environment: https://github.com/esp8266/Arduino

    Best Regards

    ReplyDelete
  3. Making a circuit looks harder than it actually is. We need to learn to attach right wire to right cell. This is very helpful. Thank you for sharing.

    ReplyDelete
  4. Guild hosting is actually a hosting service which will provide services to town that requires gaming. This is certainly not the same as game server hosting services. A sport server is far more focused on hardware and software that can make an activity run. best ark survival server hosting

    ReplyDelete
  5. The primary gadget on your organization is your passage or switch. This gadget gives a nearby page where you can login and design the gadget. All producers have comparative username and passwords.how to access router

    ReplyDelete