Shop OBEX P1 Docs P2 Docs Learn Events
Loading a different web page depending on a i/o port state — Parallax Forums

Loading a different web page depending on a i/o port state

dhenningerdhenninger Posts: 2
edited 2014-08-28 03:35 in Accessories
I would like to load one web page if a specific i/o port is "High" and a different web page if that i/o port is "low"

Could anyone help me with code to accomplish this??


Thank you

Comments

  • Mike GMike G Posts: 2,702
    edited 2014-08-24 16:13
    The attached project load one of two pages depending on the state of the Spinneret's user button on pin 23. You must configure the Spinneret to work on your local network. See the source code comments.

    Spinneret source code can be found on the code repo.
  • dhenningerdhenninger Posts: 2
    edited 2014-08-26 20:32
    Ok, i was able to get that loaded and working nicely. Before i was using Httpserv to be able to access html files on the microSD card. Is there a way to modify the code you developed to load a html file from the SD card?
  • Mike GMike G Posts: 2,702
    edited 2014-08-28 03:35
    You can find web server code on the repo. Like HttpServer it reads the HTTP header to determine which page to load.

    It should be straight forward to modify either code bases to read pin state similar to the attached code.

    Take a look at WebServer_W5100_RTC or WebSErver_W5100 in the code repo and find the method PRI RenderDynamic(id). You'll see a filter for "pinstate.xml" and an associated method, PRI BuildPinStateXml(strpin, strvalue) | pin, value, state, dir . This method sets and reads the state of a pin as requested by an HTTP GET and returns XML.
    http://192.168.1.120:5000/pinstate.xml?led=23&value=1
    

    Of course you'll need to use the DHCP assigned IP which can be found by opening the Parallax Serial Terminal right after loading the web server code.

    Anyway, take a look at the code and see if that sparks any ideas.
Sign In or Register to comment.