0

I have a simple web server going on an Atmel embedded processor. It's a Cortex M4 and it's only running FreeRTOS as an OS; this is not a high powered processor.

I can have it [the Atmel processor] serve up a page by typing in Firefox:

192.168.0.200

This renders a page with drop down boxes and a submit button that enables me to pass data back to the server to control the hardware.

I am using the follwing kind of HTML. Please note, it looks slightly odd because it's in a C string:

"<form> \
<select name=\"group\"> \
  <option value=\"10\">10</option> \
  <option value=\"11\">11</option> \
  <option value=\"12\">12</option> \
  <option value=\"Broadcast\">255</option> \
</select> \
<input type=\"submit\" value=\"Submit\"> \
</form>" 

You can see that, in its address bar, the browser then has something like:

192.168.0.200/?group=4

When the web server on the emebedded processor gets that message in, I can happily parse the line, extract a group number and act on it.

However, I have to send back another page to the browser when I get the

192.168.0.200/?group=4

message into the Atmel processor. Otherwise I get a timeout message. I can happily send the original page back again and it essentially works, but sending the page back resets the values of what the drop down boxes have changed to.

Is there a way of making the browser send a message that the server can parse, but not have to send out the full page again? I guess I'm needing to use something like a POST command, but I don't know how to do that from a web page. I should say that I am experienced in C, but have no HTML knowledge other than what I have learnt in the last few days, so it may be something easy that it completely eluding me from cramming in all this learning this week!

I don't want to/assume I can't use Javascript, because I have such a simple server I need to keep it as simple as possible.

Thanks!

DiBosco
  • 838
  • 8
  • 21

1 Answers1

1

Is there a way of making the browser send a message that the server can parse, but not have to send out the full page again?

Forget about the browser.

Have the server respond with a 204 No Content response instead of a 200 OK response.

If the client is a user agent, it SHOULD NOT change its document view from that which caused the request to be sent. This response is primarily intended to allow input for actions to take place without causing a change to the user agent's active document view, although any new or updated metainformation SHOULD be applied to the document currently in the user agent's active view.


I don't want to/assume I can't use Javascript, because I have such a simple server I need to keep it as simple as possible.

JavaScript runs client side. You don't need the server to do anything complicated to serve JS. You can even embed it in the HTML document.

You could use Ajax to solve your problem instead of a No Content response.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • Mmmm, the no content idea sounds like a splendid one. I will give that a whirl and report back. Thanks! – DiBosco Feb 06 '15 at 10:53