Word - RIT - Department of Computer Engineering

lifeguardknowledgeInternet και Εφαρμογές Web

30 Ιουλ 2012 (πριν από 5 χρόνια και 3 μήνες)

347 εμφανίσεις




Home Automation

A

means of electronically controlling common household devices.


Independent Research o
f

High Risk Items

Central Interface Connectivity

By:
Mark Hogan



Tom Booth

(tpb7463@rit.edu)

Interference with existing household components

Martin Corraine

(
mac1190@rit.edu
)

Wireless communication of Xbee® modules

Mark Hogan

(
mdh2654@rit.edu
)



Central Interface Connectivity











Computer Engineering Design Projects I

0306
-
654
-
01

Instructor: Dr. Roy Czernikowski

Date of
Submission: 3/31/10


Page
2


Table of Contents

Topic of Investigation

................................
................................
................................
....

3

Xbee
®
to P
C Connection

................................
................................
...............................

3

Controlling the Xbee
®
via Software

................................
................................
..............

4

Web Interface

................................
................................
................................
.................

4

Media Center Control from the Web

................................
................................
..............

4

Xbee
®
from the Web

................................
................................
................................
.....

5

Pricing and Availability

................................
................................
................................
..

5

Performance

................................
................................
................................
....................

5

Testing

................................
................................
................................
............................

6

Appendix

................................
................................
................................
........................

7

1)

Xbee Java API Library Summary

................................
................................
...........

7

2)

XBMC HTTP API Library Summary of Commands that Modify Settings

..........

9



























Page
3






Topic of Investigation

This investigation will look into how
the central interface will control/monitor
the Xbee
®

modules, provide a web interface to the user and control the media center.
This includes how the user’s actions on the web interface will correlate to send/receive
c
ommands with the Xbee
®

coordinator module

and how the user’s action
s

will control
the media center
.




Xbee
®

to PC Connection

One Xbee
®

module with an Xbee
®

Explorer USB module will be attached to
the central interface computer running Ubuntu with a USB ca
ble. Although an Xbee
®

Explorer USB module is not required for communication between the PC and Xbee
®
,
the alternative would be to use a serial cable. The necessity of a serial port on a PC
would limit the options the user has when choosing a central int
erface PC as serial
ports are less common on modern computers.


The Xbee
®

module attached to the Xbee
®

Explorer USB module will be
flashed and configured as a coordinator module. This will allow the module to
communicate with the other Xbee
®

modules
that
are
attached to sensors, outlets and
lights.

A diagram showing the communication between the Xbee
®

coordinator
module and the PC is shown in
Figure
1
.











Figure
1
: Xbee
®

to PC Connectivity Diagram




USB


Page
4


Controlling the Xbee
®

via Software

To control the Xbee
®

coordinator module, t
he PC that is connected via the

Xbee
®

Explorer USB module
will

communicate with the Xbee
®

module via

an open
source Java API library developed by Andrew Rapp. This API library allows
for
advanced
communication from the coordinator Xbee
®

module to remote Xbee
®

modules
.

The API library will communicate using packets
which will be verified for
integrity to maintain security.
The advantage

of using the Java API library is that it
has already been tested and thus allows for low risk communication handling between
the PC and Xbee
®

modules.

Also, using Java allows portab
ility for cross
-
platform use
in the event that the user would like to run the central interface on a non
-
linux
machine.



Web

Interface


As described in the project proposal, the user will control the entire system via
a web interfa
ce. The

web interface
w
ill be run using Apache2 on an Ubuntu machine.
The website itself
will be built using HTML, CSS, and PHP scripts to allow flexibility
and functionality for the user. Using strictly HTML, CSS and PHP
provides a simple
interface which
will allow users with
out the ability to load java applets and flash
applications to control the central interface effectively.




Media Center Control

from the Web

As described in the project proposal, the web interface will communicate with
the XBMC HTTP API library. This will be accomplished using PHP scripts triggered
by the user’s actions on the website. For example, if the user clicks on the “Music”
button, th
e user will be presented with a list of the current music on the XBMC media
center. This will be accomplished through a PHP script which will be executed when
the user clicks on the “Music” button. The PHP script will use an HTTP request to get
the
curre
nt music from the media center. After receiving the list of music available on
the media center, the PHP script will format the list in an HTML table visible to user.

In the event that the media center is not currently on and the user would like to
turn t
he media center on, the user will click on the “Turn On” button on the media
center page. To handle this request, the PHP script will send a Wake On LAN packet
to the media center PC requesting that the media center startup.



Page
5


Xbee
®

from the Web


In order
to control the Xbee
®

coordinator module via the web interface, a PHP
to Java bridge must be used. The PHP to Java bridge allows Java objects to be created
and modified via PHP code. To provide this Java bridge, IBM’s WebSphere sMash
CLI will be used. We
bSphere sMash is free, open source, and available for Linux,
Windows and MacOS a
llowing for cross
-
platform operability.

When the user clicks
on a button to turn off a light in the web interface, a PHP script will be called which
will then call the Java API library

using the PHP to Java bridge

to control the

Xbee
®

coordinator module and request that the remote Xbee
®

module

turn off the desired
light.



Pricing and Availability


Each software component used in the central interface is free, and currently
available for download. The central interface computer itself does not need to be very
powerful and should only need to
meet the minimum requirements for Ubuntu and
Java

and have 1 USB port
. A computer that meets these requirements can be bought
for roughly $100.



Performance


Performance of communications within the central interface will be highly
dependent on the host
machine. Assuming that the Xbee
®

module is the limiting
factor, the maximum bandwidth will be 250 Kbps. This should result in negligible
communication delays between the time that the user presses the button on the web
interface and a light turns on or o
ff. However, the internet connection to the web
interface could also cause significant, unexpected delays.


Alternatives


Instead of using the Xbee USB Explorer module, a serial connection could be
used to interface the Xbee module with the central interf
ace machine. However, due
to the fact that the current PC market is moving away from the inclusion of serial ports
with modern PCs, the USB
Explorer module will be used to allow widespread use in
the current market.


Page
6



Rather than use a fancy, complicated f
lash web interface, HTML, PHP, and
CSS were chosen for simplicity, compatibility and cheap development costs. If a flash
interface was used, fewer web browsers would actually be able to control the interface,
the development would be more difficult and th
e cost of tools to develop a flash
interface would be more substantial.



Testing


Preliminary testing of the central interface has already begun. Ubuntu 10.04
has been installed on the proposed central interface computer along with XBMC,
Apache2 and PHP. The default apache webpage indicates that the machine can
properly serve HTML web
pages. A simple php line of code was used to verify that
PHP is working correctly (<?php phpinfo( );?>). XBMC was installed and verified to
play videos, music and photos correctly.

Further t
esting of the central interface will be done in stages working

from the
bottom up. First, communication between the Xbee
®

coordinator module and the Java
API library will be verified through a simple send/receive operation. Next,
communication between PHP and the Java API library through IBM’s PHP to Java
Bridge wi
ll be verified through simple instantiation of classes and function calls.
Finally, the interface will be tested from the web interface down to the Xbee
®

coordinator module by pressing an HTML button that triggers a PHP script which will
cause the Java AP
I library to communicate with the Xbee
®

coordinator module
.
These tests are simple and will be conducted after the Xbee
®

modules are ordered and
received which should be at the start of May 2010.


In addition, XBMC media center communication will be teste
d by
sending/receiving simple HTTP API requests such as getting the currently playing
song/video. Also, Wake On LAN packets will be sent to the XBMC machine from the
web interface to test startup functionality.

This functionality will be tested by the en
d
of April 2010.




Page
7


Appendix

1)


Xbee Java API Library Summary


(
http://code.google.com/p/xbee
-
api/wiki/DevelopersGuide
)


Transmit Packets

Class

Description

Series

API ID Enum

AtCommand

For executing/querying
AT commands a local
XBee

Both

ApiId.AT_COMMAND

ZNetRemoteAtRequest

For executing/querying
AT commands on a
remote XBee. Although
this is na
med ZNet, it
works now with Series 1
XBees (10C8 firmware
and later)

Both

ApiId.ZNET_REMOTE_AT_REQUEST

TxRequest16

For sending data to a
remote XBee, via a 16
-
bit Address

Series 1

ApiId.TX_REQUEST_16

TxReque
st64

For sending data to a
remote Series 1 XBee,
via a 64
-
bit Address

Series 1

ApiId.TX_REQUEST_64

ZNetTxRequest

For sending data to a
remote Series 2 XBee

Series 2

ApiId.ZNET_TX_REQUEST


Receive Packets

Class

Description

Series

API ID Enum

AtCommandResponse

Sent in response to an
AtCommand and indicates
if the command was
successful. If the command
was a query, it will contain
the configuration value

Both

ApiId.AT_RESPONSE

ModemStatusResponse

Sent by the local XBee on
certains events, such as
Association, Disassociation

Both

ApiId.MODEM_STATUS_RESPONSE

ZNetRemoteAtResponse

Sent in response to a
ZNetRemoteAtRequest

Both
(requires
10C8
ApiId.Z
NET_REMOTE_AT_RESPONSE


Page
8


firmware
for
Series 1)

TxStatusResponse

Sent after a TxRequest16
or TxRequest64 packet.
Indicates if transmission
was successful

Series 1

ApiId.TX_STATUS_RESPONSE

RxResponse16

Received on the remote
radio after a TxRequest16
packet is sent

Series 1

ApiId.RX_16_RESPONSE

RxResponse64

Received on the remote
radio after a TxRequest64
packet is sent

Series 1

ApiId.RX_64_RESPONSE

RxResponseIoSample

Sent by a remote XBee,
configured to send I/O
Samples. Not
e:
getSourceAddress() returns
either a XBeeAddress16 or
XBeeAddress64 depending
on if the packet is
configured for 16 or 64 bit
addressing

Series 1

Either

ApiId.RX_16_IO_RESPONSE

or

ApiId.RX_64_IO_RESPONSE

(depending
on 16 or 64 bit address configuration)

ZNetTxStatusResponse

Sent after a
ZNetTxRequest packet.
Indicates if transmission
was successful

Series 2

ApiId.ZNET_TX_STATUS_RESPONSE

ZNetRxResponse

Received on the remote
radio after a
ZNetTxRequest packet is
sent

Series 2

ApiId.ZNET_RX_RESPONSE

ZNetExplicitRxResponse

Received on the remote
radio a
ZNetExplicitTxRequest
packet is sent

Series 2

ApiId.ZNET_EXPLICIT_RX_RESPONSE

ZN
etRxIoSampleResponse

Sent by a remote XBee,
configured to send I/O
Samples

Series 2

ApiId.ZNET_IO_SAMPLE_RESPONSE





Page
9


2)

XBMC HTTP

API Library Summary

of Commands

that Modify Settings



(
http://wiki.xbmc.org/index.php?title=Web_Server_HTTP_API#A_Note_about_Pl
aylists
)


Command

Information

AddToPlayList(media;[playlist];[mask];[recursive])

Adds a file or folder (
media

is either a file or a
folder) to the current playlist or the playlist
specified by

playlist
. To specify a file mask
use

mask

e.g. .mp3|.wma.

If

recursive

= "1" and

media

is a folder then all
appropriate media within subfolders
beneath

media

will be added otherwise only
media within the folder

media

will be added.
Default behaviour is to be recursive.

mask

can
now also be set to one of the following values
(including

the square brackets) [music], [video],
[pictures], [files] in which case XBMC's current
set of file extensions for the type specified will be
used as the mask.

AddToPlayListFromDB(type;statement)

Adds a set of items to the playlist using an SQL
statement
. The

type

parameter is one of the
following: [songs], [movies], [episodes] or
[musicvideos]. The

statement

is an SQL condition
after the WHERE clause.

AddToSlideshow(media;[mask];[recursive])

Adds a file or folder (
media

is either a file or a
folder) to
the slideshow playlist. To specify a file
mask use

mask

e.g. .jpg|.bmp

If

recursive

= "1" and

media

is a folder then all
appropriate media within subfolders
beneath

media

will be added otherwise only
media within the folder

media

will be added.
Default
behaviour is to be recursive.

mask

can
now also be set to one of the following values
(including the square brackets) [music], [video],
[pictures], [files] in which case XBMC's current

Page
10


set of file extensions for the type specified will be
used as the mask.

(Note it only makes much sense
for this command to use a value of

[pictures]
.

ClearPlayList([playlist])

Clears the current playlist or the playlist specified
by

playlist
.

ClearSlideshow

Clears the slideshow playlist.

Mute

Toggles the sound on/off.

RemoveFromPlaylist(item,[playlist])

Removes media from the current playlist or from
playlist

playlist
.

item

can be either an integer
specifying the position in the playlist of the item
to be removed or the complete path (including
filename) of the media to

be removed. It is not
possible to remove the media if it is currently
being played.

SeekPercentage

Sets the playing position of the currently playing
media as a percentage of the media’s length.

SeekPercentageRelative

Adds/Subtracts the current percenta
ge on to the
current postion in the song

SetCurrentPlaylist(playlist)

Sets the current playlist to

playlist
.

SetGUISetting(type; name; value)

Sets the value of GUI setting name to
value.

Type

specifies whether the setting is of
type integer (0), boolean

(1) or float (2) which
must be set correctly or could cause a crash. For a
full list of setting names see GUISettings.cpp.

SetPlaylistSong(position)

Sets the media at playlist position

position

to be
the next item to be played. The example sets the
posit
ion to the 6th song in the playlist

SetPlaySpeed(speed)

Sets the playing speed to the integer

speed
.

SlideshowSelect(filename)

Sets the slideshow playlist position by specifying
the file name of the next image to show.

SetVolume

Sets the volume as a
percentage of the maximum
possible.

SetLogLevel

Sets XBMC's log level

SetAutoGetPictureThumbs

If set to True then media thumbnails will be
automatically created when required. (Default:
True.)