Hardware Reference
In-Depth Information
which is five or four fewer than “ $status ”. So, calculate
the difference before you send the HTTP header. The
total is 20 or 21 characters shorter than the original file,
depending on the relay status, which you can determine
by calling checkThermostat() . You can change the
sendFile() to adjust for this right before it sends the OK
header, like this:
When you're changing the contents of a file dynamically
before you serve it, you have to make adjustments like this
all the time. So, it's good to know a few methods for doing
it. On a server with plenty of memory, you might simply
put the whole file in an array and get the size of the array.
One of the valuable things you learn when working on
microcontrollers with limited memory is how to do work-
arounds like this.
if (checkThermostat()) {
mySize = mySize - 21;
}
else {
mySize = mySize - 20;
}
// send an OK header:
sendHttpHeader(thisClient, 200, mySize, fileType);
I'll admit it: I went for the hack solution first.
X
HTML5 and Other Mobile
Web Approaches
There's currently a lot of excitement among mobile appli-
cation developers around HTML5, the next version of the
HyperText Markup Language standard. HTML5 aims to
make HTML able to support a greater amount of interac-
tion and control over how web pages look and behave.
In fact, what makes HTML5 interesting is not just the
markup language itself, but the possibilities it offers when
combined with JavaScript and CSS3, the Cascading Style
Sheets standard.
and send and retrieve data to locations other than the
browser—whether the data is on the user's hard drive or a
remote server.
Previously, applications running within a web browser
had very limited access to the hardware of the computer
on which they were running. Operating system manufac-
turers felt that it was unsafe to allow an application that
you downloaded from the Internet to access your hard
drive, camera, microphone, or other computer hardware.
Hackers might do evil things! Of course, now that nearly
every application is downloaded from the Internet, that
thinking seems dated. You could still download a program
that does malicious things—but, by now, most people
have a sense of what makes an online source more or less
trustworthy, whether that source is delivering a web page
or an application that's native to your operating system.
At the same time, more of the data we need to access
lives online today, whether on a social media site or a web
data storage service like Google Docs or Dropbox. There's
no need for a browser to access your hard drive if your
files are online.
So, how do HTML5, JavaScript, and CSS3 work together?
Roughly, you could say that HTML gives you nouns, CSS
gives you adjectives and adverbs, and JavaScript gives
you the verbs to put them into action. HTML describes the
basic page structure and the elements within it: forms,
input elements, blocks of text, and so forth. CSS primarily
describes the characteristics of the visual elements:
the colors, fonts, spacing, etc. The scripting language
JavaScript allows you to make connections between the
elements of a page, between pages in a browser, and
between the browser and remote servers. The grammar
analogy isn't perfect, but the point is that the three tools
give you a wide range of means to present information,
listen to user input, generate interactive responses,
The blurring of the distinction between browser security
and general security is good news if you like to build
physical interfaces. HTML5 and JavaScript include
methods to access some of the hardware of your
 
Search WWH ::




Custom Search