Hardware Reference
In-Depth Information
If you call this script from a browser, you'll
get the HTML version. If you want to get the
“processing” or “arduino” responses, you'll
need to send a custom HTTP request. Try calling it from
your terminal program, as follows.
As you can see, this is a powerful feature. To use it, all you
need to do is add one line to your HTTP requests from Pro-
cessing or the microcontroller (see Chapter 3). Just add an
extra print statement to send the user agent, and you're all
set. In Processing or Arduino, the HTTP request would now
look like this:
First, connect to the server as you did before:
// Send the HTTP GET request:
String requestString = " /~yourAccount/ip_geocoder.php ";
client.write("GET " + requestString + " HTTP/1.0\r\n");
client.write("HOST: example.com \r\n");
client.write("USER-AGENT: processing\r\n\r\n");
telnet example.com 80
Then send the following (press Enter one extra time
after you type that last line):
Using the user agent variable like this can simplify your
development a great deal. This is because it means that
you can easily use a browser or the command line to
debug programs that you're writing for any type of client.
GET /~yourAccount/ip_geocoder.php HTTP/1.1
HOST: example.com
USER-AGENT: arduino
You should get a response like this:
Mail Environment Variables
Email affords a more flexible relationship between objects
than you get with IP addresses, because it gives you the
ability to structure complex conversations. An object can
communicate not only who it is (the from: address), but to
whom it would like you to reply (using the reply-to: field),
and whom you should include in the conversation ( cc: and
bcc: fields). All of that information can be communicated
without even using the subject or body of the message.
PHP gives you simple tools to do the parsing. Because so
many devices communicate via email (mobile phone text
messaging can interface with email as well), it expands the
range of possible devices you can add to a system.
HTTP/1.1 200 OK
Date: Thu, 21 Jun 2007 14:44:11 GMT
Server: Apache/2.0.52 (Red Hat)
Content-Length: 38
Connection: close
Content-Type: text/html; charset=UTF-8
<40.6698,-73.9438,UNITED STATES (US)>
If you change the user agent from arduino to processing ,
you'll get:
HTTP/1.1 200 OK
Date: Thu, 21 Jun 2007 14:44:21 GMT
Server: Apache/2.0.52 (Red Hat)
Content-Length: 64
Connection: close
Content-Type: text/html; charset=UTF-8
Like HTTP, email protocols have environment variables
that you can take advantage of as well. If you've ever
viewed the full headers of an email in your favorite mail
client, you've seen some of these. To look at mail in more
depth, you can use PHP's IMAP mail functions. Internet
Message Access Protocol is a mail protocol that lets you
get mail from a server from multiple clients. The mail
stays on the server until a client tells the server to delete
a particular message. This allows you to use multiple mail
clients for the same account, and keep mail coordinated
across them.
Latitude:40.6698
Longitude:-73.9438
Country:UNITED STATES (US)
 
Search WWH ::




Custom Search