by rock » Thu May 27, 2010 6:37 pm
Well, doing a POST *to* the arduino is really a lost cause, and a lot more work than it's worth. There's nothing in the API for *receiving* POST data (although there is for sending). Using links isn't really inelegant, just different. Essentially, you are doing a GET request instead of a POST, and there's nothing at all wrong with doing that. Heck, this forum is using a GET right now (that's the ?key=value&key2=value2 stuff at the end of the URL). It's also a LOT easier to get at the data, because you are parsing the URL that gets sent to your sendPage().
Basically, here is the difference, visually:
GET URL: http://yourWiServer/1
POST URL: http://yourWiServer/
big deal. The problem is, internally, a POST is a lot uglier. A GET has all the info in the URL, so all you have to do is parse the URL variable and get the data you need out of it. To get the same data out of a POST, you have to scan the contents of the entire data blob (including getting past the header data). That's a lot more work, and honestly, I don't think it's worth it.
You don't even need to use buttons or a form at all, just simple links that have the data preloaded would work just fine. The only value using a form has is you can get actual submit buttons displayed on your browser without using CSS to create it. The end result is essentially the same: A URL that has the value you want, ready to be plucked out of the array.
I assume, looking at the referred post, that "not really elegant" means "I'm displaying text links instead of fancy submit buttons". If you create a form as a GET or a POST, it will look the same, including the fancy buttons. Only the URL will be different.
I personally ditched the form altogether and just used text links with a little CSS to make them *look* like buttons.