wireles project

127
Moi University Faculty of Technology Department of Electrical and Communications Engineering Control and Monitoring of Non-computing Devices Over The Internet and The GSM Cellular Network COURSE: ELC 590-Engineering Project II NAME: Makau Thomas Mulei –EC/14/98 SUPERVISORS: Dr. Marcel Odhiambo PhD and Dr. George Kamuncha PhD This report is submitted in partial fulfillment for the award of the degree of Bachelor of Technology in Electrical and Communications Engineering of Moi University PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Upload: wabz-abwao

Post on 17-Oct-2014

111 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Wireles Project

Moi University Faculty of Technology Department of Electrical and Communications Engineering

Control and Monitoring of Non-computing Devices Over The Internet and The GSM Cellular Network

COURSE: ELC 590-Engineering Project II NAME: Makau Thomas Mulei –EC/14/98 SUPERVISORS: Dr. Marcel Odhiambo PhD and Dr. George Kamuncha PhD

This report is submitted in partial fulfillment for the award of the degree of Bachelor of Technology in Electrical and Communications Engineering of

Moi University

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 2: Wireles Project

i

To My Mother, for showing me the right path in life

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 3: Wireles Project

ii

Acknowledgement The completion of this project would have been impossible without the help I received

from very many people.

I would first like to thank my God for the far He has taken me and the favours He has

shown me even though I didn’t deserve some of them.

I would also like to thank Dr. Marcel Odhiambo the head of computer engineering in

Moi University for the invaluable support, correction and Guidance in undertaking this

project. Dr. Kevit Desai the IEEE chairman in East Africa and director of Engineering

at Centurion systems for giving me a platform to express my Ideas. Industrialist Dr.

Manu Chandaria for encouraging me to work harder in life.

The testing of this project would have been hard if I had not got support from fellow

students who were part of the NgeriaNET-The students’ hall of residence Local Area

Network in Hall two: Thank you all for the shared documents, programs and letting me

test my project on the LAN.

I would also like to thank my course mates Guru Kumar Prashant and the senior high priest

of programming Casper Odiko who have been resourceful in this project to bring it into

completion.

I would also like to acknowledge all my lecturers for shaping me for the last five years to

be what I am today.

Lastly and not least, I would like to acknowledge the support I got from my Heartthrob

Rehema for proof reading this report.

-God bless you all.

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 4: Wireles Project

iii

Science, her vision proudly magnified,

By skilled invention, proves all things perceived,

Mere atoms energized but mystified

Recks not whose thought spinning specks conceived.

-Sir George Cockerill in Late Harvest

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 5: Wireles Project

iv

Abstract Remote control and monitoring of unattended non-computing systems provides a real

and tangible economic advantage over the existing onsite systems. This project is about

the feasibility, analysis, design, implementation and testing of a prototype that can

control non computing devices such a motors, lights, boilers and ovens over the Internet

and the GSM mobile network.

The report starts by looking at the feasibility of such a system and its possible application

in industry and then goes to analyze how the system would look like and come up with

the system components.

The design of the system takes place with more attention being paid to how the

individual system components interacts effectively to achieve the global objective of this

project which is to remotely control and monitor non computing devices.

The design after undergoing some computer simulation to ensure that it works as

expected, is implemented and tested.

The test results were very impressive because after fewer modifications than initially

expected, the system worked. The rigorous design considerations that were to improve

system safety, redundancy that also put into consideration the poor prevailing Kenyan

telecommunication infrastructure were also tested to ensure reliability of the system and

the test results showed that the system reliability is very high because even when the

Internet fails (which often happens in Kenya), one is still able to control devices using an

ordinary mobile phone that uses the GSM network.

The report concludes with a comprehensive cost analysis that shows that deployment of

such a system in industry would yield very high return on investment that is above

1000% in less than two years.

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 6: Wireles Project

v

Table of Contents

1 CHAPTER ONE: INTRODUCTION --------------------------------------------------1

1.1 PREAMBLE ----------------------------------------------------------------------------------1 1.1.1 MOTIVATION ------------------------------------------------------------------------------1 1.1.2 PROJECT AIM AND OBJECTIVES---------------------------------------------------------1 1.1.2.1 The local Objectives:------------------------------------------------------------------1 1.1.2.2 The global objectives: ----------------------------------------------------------------1

2 CHAPTER TWO: LITERATURE REVIEW ----------------------------------------3

2.1 WEB-BASED CONTROL -------------------------------------------------------------------3 2.1.1 THE INTERNET ----------------------------------------------------------------------------4 2.1.1.1 Web Servers ----------------------------------------------------------------------------5 2.1.2 RELATIONAL DATABASE SYSTEMS ----------------------------------------------------5 2.1.3 OSI REFERENCE MODEL ----------------------------------------------------------------6 2.1.3.1 Types And Sources Of Network Threats----------------------------------------- 11 2.1.3.2 Protecting a Network Using Firewalls ------------------------------------------- 12 2.2 THE GLOBAL SYSTEM FOR MOBILE COMMUNICATIONS (GSM)----------------15 2.2.1 ARCHITECTURE OF THE GSM NETWORK -------------------------------------------- 15 2.2.2 SHORT MESSAGE SERVICE (SMS) ---------------------------------------------------18 2.3 SOFTWARE DEVELOPMENT ------------------------------------------------------------23 2.3.1 APPLICATION DEVELOPMENT CYCLE -------------------------------------------------23

3 CHAPTER THREE: ANALYSIS -----------------------------------------------------27

3.1 PROBLEM ANALYSIS -------------------------------------------------------------------- 27 3.2 PROJECT CHALLENGES----------------------------------------------------------------- 28 3.3 PROPOSED SOLUTION ------------------------------------------------------------------- 28 3.4 THE CONTROL AND MONITORING SYSTEM ----------------------------------------- 29

4 CHAPTER FOUR: SYSTEM DESIGN --------------------------------------------- 33

4.1 WEB SERVER ----------------------------------------------------------------------------- 33 4.1.1 APACHE WEB SERVER ----------------------------------------------------------------- 33 4.1.2 MICROSOFT INTERNET INFORMATION SERVER (IIS)-------------------------------33 4.1.3 XITAMI WEB SERVER ------------------------------------------------------------------ 34 4.1.4 SCRIPTING -------------------------------------------------------------------------------35 4.1.4.1 How PHP is installed ---------------------------------------------------------------36 4.2 DATABASE SERVER ---------------------------------------------------------------------- 37 4.2.1 MICROSOFT SQL ----------------------------------------------------------------------- 37 4.2.2 ORACLE----------------------------------------------------------------------------------38 4.2.3 MYSQL----------------------------------------------------------------------------------38 4.2.3.1 Installing MySQL ------------------------------------------------------------------- 39

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 7: Wireles Project

vi

4.2.3.2 Creating the database ---------------------------------------------------------------40 4.3 OPEN DATA BASE CONNECTIVITY (ODBC) DATA ACCESS ENGINE ------------ 41 4.4 USER INTERFACE ------------------------------------------------------------------------ 42 4.4.1 DESIGNING THE WEB INTERFACE-----------------------------------------------------43 4.5 SOFTWARE DESIGN---------------------------------------------------------------------- 45 4.6 SOFTWARE CODING --------------------------------------------------------------------- 49 4.6.1 THE SPLASH SCREEN ------------------------------------------------------------------- 50 4.6.2 MOBILE PHONE ACCESS PROGRAM ---------------------------------------------------50 4.6.3 DATABASE ACCESS PROGRAM --------------------------------------------------------51 4.7 REMOTE COMPUTER INTERFACE -----------------------------------------------------52 4.7.1 SERIAL INTERFACE --------------------------------------------------------------------- 52 4.7.2 PARALLEL INTERFACE ----------------------------------------------------------------- 53 4.7.3 PORT ACCESS --------------------------------------------------------------------------- 54 4.8 SWITCHING INTERFACE CIRCUIT -----------------------------------------------------54 4.8.1 CIRCUIT OPERATION ------------------------------------------------------------------- 55 4.8.2 MONITORING CIRCUITS----------------------------------------------------------------56

5 CHAPTER FIVE: TESTS AND RESULTS ---------------------------------------- 59

5.1 CIRCUIT TESTING ------------------------------------------------------------------------ 59 5.1.1 BURN-IN TEST--------------------------------------------------------------------------- 59 5.2 PROGRAM TESTING---------------------------------------------------------------------- 59 5.3 SYSTEM TESTING ------------------------------------------------------------------------ 60 5.3.1 WEB CONTROL -------------------------------------------------------------------------- 61 5.3.2 TEXT MESSAGE (SMS) CONTROL-----------------------------------------------------61 5.3.3 WEB THEN SMS TEXT CONTROL -----------------------------------------------------62

6 CHAPTER SIX: COST ANALYSIS--------------------------------------------------64

6.1 COST ANALYSIS -------------------------------------------------------------------------- 64 6.1.1 SYSTEM LEARNING AND DESIGN ------------------------------------------------------64 6.1.2 RETURN ON INVESTMENT -------------------------------------------------------------65 6.1.3 TO INSTALL OR NOT?------------------------------------------------------------------- 66

7 CHAPTER SEVEN: CONCLUSION AND RECOMMENDATIONS-------- 68

7.1 CONCLUSION ----------------------------------------------------------------------------- 68 7.1.1 SYSTEM LIMITATIONS ------------------------------------------------------------------ 69 7.1.2 PROBLEMS ENCOUNTERED ------------------------------------------------------------69 7.2 RECOMMENDATIONS -------------------------------------------------------------------- 69

8 BIBLIOGRAPHY ------------------------------------------------------------------------ 71

9 APPENDIX---------------------------------------------------------------------------------73

9.1 APPENDIX I -------------------------------------------------------------------------------73 9.2 APPENDIX II ------------------------------------------------------------------------------ 78

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 8: Wireles Project

vii

9.3 APPENDIX II ------------------------------------------------------------------------------ 79 9.4 APPENDIX III ----------------------------------------------------------------------------- 90 9.5 APPENDIX IV ----------------------------------------------------------------------------- 92 9.6 APPENDIX V ------------------------------------------------------------------------------ 94 9.7 APPENDIX VI ----------------------------------------------------------------------------- 97 9.8 APPENDIX VII -------------------------------------------------------------------------- 108 9.9 APPENDIX VIII------------------------------------------------------------------------- 110

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 9: Wireles Project

Chapter One: Introduction

1

1 Chapter One: Introduction

1.1 Preamble The Oxford dictionary defines remote control as control of an apparatus from a distance

by means of signals transmitted from a radio or any other electronic transmission device.

This project is about remotely controlling and monitoring devices over the Internet and

the GSM network. Such devices include domestic appliances, industrial plants, security

systems and unmanned vehicles/robots

1.1.1 Motivation Remote monitoring and control of non-computing unattended systems already provides

real tangible economic advantage in many applications and industry. The continuous

reduction in communications costs and connection options constantly expands the set of

applications for which these tangible operational benefits may be derived [Canuteson

2003].

This project is motivated by an interest in applicability of the Internet communication

infrastructure in industrial and domestic real-time control of non-computing systems.

1.1.2 Project Aim and Objectives The main aim of this project is to remotely control and monitor in real-time, non-

computing devices hence saving on time, money and human resource that are critical

determinant factors of profitability in any industrial or domestic system [Lacy 1994]

1.1.2.1 The local Objectives: q By the end of the project implementation, I should be able to control and

monitor any non-computing devices from a simple web page, accessible from any

Internet connected computer or any Mobile Phone Short Message Text interface

1.1.2.2 The global objectives: q Understand the distributed systems environment, including its architecture and

services.

q Understand the Internet and its protocols

q Review what has already been done in this area and how others have tackled this

problem in the past. Look at technologies like Consumer Electronics Bus

(CEBus), LonWorks technology, SMART HOUSE, X-10, BatiBUS, European

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 10: Wireles Project

Chapter One: Introduction

2

Home System, European Installation Bus, and Japan's Home Bus System [Wacks

1997].

q Look at user interface issues and design a simple and useful GUI, hiding

technical complexities as much as possible.

q Gain a deeper understanding of developing Internet -enabled software.

q Adhere to a low-cost software model.

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 11: Wireles Project

Chapter Two: Literature Review

3

2 Chapter Two: Literature Review

2.1 Web-Based Control

Web-based control refers to the control of systems from a WebPage interface either

from the Internet or a Local Area Network (LAN).

The first philosophy to the whole concept of web-based control arises from the question

“why do users need to control a device through the web?” The answer to this question is

not based on the mere fact that the web exists but rather on the economic implications

of web-based control. In this age of distributed computing, telecommuting and nose

diving telecommunication costs, web based control offers a real and tangible alternative

to onsite control.

The Internet and the World Wide Web have emerged as the primary means of sharing

information between businesses, and company intranets have become the norm in

information exchange within the organization, web-based monitoring and control

therefore avails information on demand to users who might need it.

A web based interface for a control system consists of a web server that that serves

preformatted web pages with data to the user. This data mostly comes from a database

server such as MySQL that in turn is populated by data acquisition software

Fig.2.0: Web Interface components

Web Interface

Web Server

Database Server

Data Acquisition

software

The Internet

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 12: Wireles Project

Chapter Two: Literature Review

4

2.1.1 The Internet

What is the Internet?

The internet is made up of millions of computers linked together around the world in

such a way that information can be sent from any computer to any other 24 hours a day.

These computers can be in homes, schools, universities, government departments, or

businesses small and large. They can be any type of computer and be single personal

computers or workstations on a school or a company network. The Internet is often

described as ‘a network of networks’ because all the smaller networks of organizations

are linked together into the one giant network called the Internet. All computers are

pretty much equal once connected to the Internet, the only difference will be the speed

of the connection.

Sometimes people use the words Internet and World Wide Web (WWW) synonymously

but they are different. The WWW is a component of the Internet that presents

information in a graphical interface. One can think of the WWW as the illustrated

version of the Internet. It began in the late 1980's when physicist Dr. Berners-Lee wrote

a small computer program for his own personal use. This program allowed pages, within

his computer, to be linked together using keywords. It soon became possible to link

documents in different computers, as long as they were connected to the Internet. The

document formatting language used to link documents is called HTML (Hypertext

Markup Language.)

The Web remained primarily text based until 1992. Two events occurred that year that

forever changed the way the Web looked. Marc Andreesen developed a new computer

program called the NCSA Mosaic and gave it away! The NCSA Mosaic was the first Web

browser.

The browser made it easier to access the different Web sites that had started to appear.

Soon Web sites contained more than just text, they also had sound and video files. The

development of the WWW has been the catalyst for the popularity of the Internet and is

also the easiest part of the Internet to use. We now have Internet Chat, Discussion

Groups, Internet Phone capabilities, Video conferencing, News Groups, Interactive

Multimedia, Games and so much more.

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 13: Wireles Project

Chapter Two: Literature Review

5

2.1.1.1 Web Servers A Web server is the caretaker of all the information that travels over the World Wide

Web (WWW) to the Web browsers. A person interested in surfing the WWW would start

up a browser and specify a place to start looking. Most all the information received while

surfing or browsing the Internet comes from a Web server.

A Web server is responsible for managing and delivering the content that an organization

wishes to make available over the WWW. The Web server takes a large repository of

information and makes it easily available to whoever wants to view it. This information

can be in an almost endless number of different shapes, forms, and sizes. The most

popular of which include HTML, text, images, audios, and movies [Segal 1998].

Most users of the WWW never really see a Web server. Their view of the Web is the

browser tool they are using and the information they obtain. The person(s) that

administers the Web server and the people that are responsible for providing the content

for a Web site mostly see the server end of the WWW.

2.1.2 Relational Database Systems Over the years, database management systems have evolved from hierarchical to network

to relational database management systems (RDBMS). A relational database system is an

organized model of subjects and characteristics that have relationships among the

subjects [Dawes 2000]. Examples of RDBMS include, Oracle, MySQL, MSSQL and

Interbase.

A well-designed relational database provides information about a business or process and

is used most widely to store and retrieve information. Some major advantages of

RDBMS are in the way it stores and retrieves information, and in how it maintains data

integrity.

RDBMS structures are easy to understand and to build. These structures are logically

represented using the entity-relationship (ER) model. The ER model includes the

following:

Characteristics of a Relational Database

Relational databases have the following three major characteristics that constitute a well-

defined RDBMS:

Structures: These are objects that store or access data from the database. Tables, views,

and indexes are examples of structures.

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 14: Wireles Project

Chapter Two: Literature Review

6

Operations: These are the actions used to define the structures or manipulate data between

the structures. SELECT statements or CREATE statements are examples of operations

in Oracle and MySQL.

Integrity rules: These govern the kinds of actions allowed on data and the database

structure. Integrity rules protect the data and the structure of the database. The primary

keys and foreign keys are examples of integrity rules in Oracle and MySQL.

2.1.3 OSI Reference Model The Open Systems Interconnection1 (OSI) reference model is a conceptual blueprint of

how communications should take place. It addresses all the processes required for

effective communication and divides these processes into logical groupings called layers.

When a communication system is designed in this manner, it’s known as layered

architecture.

The main advantages of a layered approach to WAN2 design are as follows:

q Dividing the complex network operation into more manageable layers

q Changing one layer without having to change all layers. This allows application

developers to specialize in design and development.

q Defining the standard interface for the “plug-and-play” multivendor integration

The OSI has seven levels on which the different equipment belongs to. These are:

Layer 7: The Application layer provides the software for network services such as file

transfer, remote login, remote execution, e-mail and etc. It provides the interface

between the user programs and the network. “What the user runs”

Layer 6: The Presentation layer converts outbound data from a machine specific format

to an international standard format and vice versa. “Translator”

Layer 5: The Session layer allows the setup and termination of communication path, and

synchronizes the dialog between the two systems. “Terminal emulator”

Layer 4: The Transport layer provides reliable flow of datagrams between the sender and

receiver, and ensures that the data arrives at the correct destination. “Software error

correction”

1 The OSI Reference model was designed by the International Standards Organization (ISO) 2 The Internet can be considered as a Wide Area Network (WAN) covering the whole world

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 15: Wireles Project

Chapter Two: Literature Review

7

Layer 3: The Network layer decides the path that will be taken through the network. It

provides packet addressing which will alert computers on the network as to where to

route the users data. “Addressing schemes”

Layer 2: The Data link layer provides reliable, error free media access for data

transmission. It produces the frame around data. “Hardware error correction”

Layer 1: The Physical layer establishes the actual physical connection (cable) between the

network and the computer equipment. The functions provided at this level include the

type of signaling (what represents a bit 0, what represents a 1), cable length

specifications, and connector size, etc. “Cable”

Application

Presentation

Session

Transport

Network

Data link

Physical

Fig 2.1: The OSI reference model

Internet Protocol (IP) addressing

Internet nodes are uniquely identified by an Internet protocol (IP) address. An Internet

node can be a router, hub, gateway, server or a desktop computer that is connected to

the Internet.

An IP address consists of 32 bits of information. These bits are divided into four

sections, referred to as octets or bytes, each containing 1 byte (8 bits).

One can depict an IP address using one of three methods:

q Dotted-decimal, as in 172.16.30.56

q Binary, as in 10101100.00010000.00011110.00111000

q Hexadecimal, as in 82 39 1E 38

All these examples represent the same IP address. Although hexadecimal is not used

as often as dotted-decimal or binary when IP addressing is discussed.

File, print, database and application services Data encryption, compression and translation services Dialog Control End-to-End Connection Routing Framing Physical topology

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 16: Wireles Project

Chapter Two: Literature Review

8

The 32-bit IP address is a structured or hierarchical address, as opposed to a flat or

nonhierarchical, address. Although either type of addressing scheme could have been

used, the hierarchical variety was chosen for a good reason. The advantage of this

scheme is that it can handle a large number of addresses, namely 4.3 billion (a 32-bit

address space with two possible values for each position—either 0 or 1—gives you 232,

or approximately 4.3 billion).

The disadvantage of this scheme, and the reason it’s not used for IP addressing, relates to

routing. If every address were unique, all routers on the Internet would need to store the

address of each and every machine on the Internet. This would make efficient routing

impossible, even if only a fraction of the possible addresses were used.

The solution to this dilemma is to use a two- or three-level, hierarchical addressing

scheme that is structured by network and host, or network, subnet, and host. This two-

or three-level scheme is comparable to a telephone number. The first section, the area

code, designates a very large area. The second section, the prefix, narrows the scope to a

local calling area. The final segment, the customer number, zooms in on the specific

connection. IP addresses use the same type of layered structure. Rather than all 32 bits

being treated as a unique identifier, as in flat addressing, a part of the address is

designated as the network address, and the other

part is designated as either the subnet and host or just the node address.

Network Addressing

The network address uniquely identifies each network. Every machine on the same

network shares that network address as part of its IP address. In the IP address

172.16.30.56, for example, 172.16 is the network address. The node address is assigned

to, and uniquely identifies, each machine on a network. This part of the address must be

unique because it identifies a particular machine—an individual—as opposed to a

network, which is a group. This number can also be referred to as a host address. In the

sample IP address 72.16.30.56, here, .30.56 is the node address.

The designers of the Internet decided to create classes of networks based on network

size. For the small number of networks possessing a very large number of nodes, they

created the rank Class A network. At the other extreme is the Class C network, which is

reserved for the numerous networks with a small number of nodes. The class distinction

for networks between very large and very small is predictably called the Class B network.

Subdividing an IP address into a network and node address is determined by the class

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 17: Wireles Project

Chapter Two: Literature Review

9

designation of one’s network. The figure below summarizes the three classes of

networks,

Fig 2.2: IP Address class organization

TCP/IP

TCP/IP is a communications protocol used to transfer digital data around the Internet.

TCP and IP were developed by the US Department of Defense (DoD) research project

to connect different networks designed by different vendors into a network of networks

(the "Internet"). TCP/IP is often referred to as the 'Internet protocol'.

As with all communications protocols, TCP/IP is composed of layers:

IP - is responsible for moving packet of data from node to node. IP forwards each

packet based on a four-byte destination address (the IP number). The Internet authorities

assign ranges of numbers to different organizations. The organizations assign groups of

their numbers to departments. IP operates on gateway machines that move data from

department to organization to region and then around the world.

TCP - is responsible for verifying the correct delivery of data from client to server. Data

can be lost in the intermediate network. TCP adds support to detect errors or lost data

and to trigger retransmission until the data is correctly and completely received.

Sockets - is a name given to the package of subroutines that provide access to TCP/IP

on most systems.

Attacks Against The IP

A number of attacks against the IP are possible. Typically, these exploit the fact that the

IP does not perform a robust mechanism for authentication, which is proving that a

packet came from where it claims it did. A packet simply claims to originate from a given

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 18: Wireles Project

Chapter Two: Literature Review

10

address, and there isn't a way to be sure that the host that sent the packet is telling the

truth. This isn't necessarily a weakness, per se, but it is an important point, because it

means that the facility of host authentication has to be provided at a higher layer on the

ISO/OSI Reference Model. Today, applications that require strong host authentication

(such as cryptographic applications) do this at the application layer. Some type of

common attacks are explained as below:

IP Spoofing.

This is where one host claims to have the IP address of another. Since many systems

(such as router access control lists) define which packets may and which packets may not

pass based on the sender's IP address, this is a useful technique to an attacker: he can

send packets to a host, perhaps causing it to take some sort of action.

Additionally, some applications allow login based on the IP address of the person making

the request (such as the Berkeley r-commands)[Morris 1995]. These are both good

examples how trusting untrustable layers can provide security that is at best, weak.

IP Session Hijacking.

This is a relatively sophisticated attack, first described by Steve Bellovin [Bellovin 1989].

This is very dangerous, however, because there are now toolkits available in the market

that allow otherwise unskilled hackers to perpetrate this attack. IP Session Hijacking is an

attack whereby a user's session is taken over, being in the control of the attacker. If the

user was in the middle of email, the attacker is looking at the email, and then can execute

any commands he wishes as the attacked user. The attacked user simply sees his session

dropped, and may simply login again, perhaps not even noticing that the attacker is still

logged in and doing otherwise harmful things.

Replacing standard telnet-type applications with encrypted versions of the same thing can

solve this. In this case, the attacker can still take over the session, but he'll see only

“gibberish” because the session is encrypted. The attacker will not have the needed

cryptographic key(s) to decrypt the data stream that he has taken over the session, and

will, therefore, be unable to do anything with the session.

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 19: Wireles Project

Chapter Two: Literature Review

11

2.1.3.1 Types And Sources Of Network Threats

Denial-of-Service

DoS (Denial-of-Service) attacks are probably the nastiest, and most difficult to address.

These are the nastiest, because they're very easy to launch, difficult (sometimes

impossible) to track, and it isn't easy to refuse the requests of the attacker, without also

refusing legitimate requests for service.

The premise of a DoS attack is simple: send more requests to the machine than it can

handle. There are toolkits available in the market that make this a simple matter of

running a program and telling it which host to blast with requests. The attacker's

program simply makes a connection on some service port, perhaps forging the packet's

header information that says where the packet came from, and then dropping the

connection. If the host is able to answer 20 requests per second, and the attacker is

sending 50 per second, obviously the host will be unable to service all of the attacker's

requests, much less any legitimate requests (hits on the web site running there, for

example).

Such attacks were fairly common in late 1996 and early 1997, but are now becoming less

popular. 3

Some things that can be done to reduce the risk of being stung by a denial of service

attack include:

q Not running the visible-to-the-world servers4 at a level too close to full capacity.

q Using packet filtering to prevent obviously forged packets from entering into

your network address space5.

q Obviously forged packets would include those that claim to come from your own

hosts, addresses reserved for private networks as defined in RFC 1918

[Moskowitz et al 1991], and the loopback network (127.0.0.0).

q Keeping up-to-date on security-related patches for your hosts' operating systems.

Unauthorized Access

“Unauthorized access” is a very high-level term that can refer to a number of different

sorts of attacks. The goal of these attacks is to access some resource that a machine

3 In 1999 a DoS attack brought the Internet to a standstill when an attacker attacked yahoo.com, amazon.com, deutschebank.de and hsbc.com 4 These include mail, HTTP and FTP servers. 5 Ingress (in bound) and Egress (out bound) packet filtering can be applied on Internet gateways

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 20: Wireles Project

Chapter Two: Literature Review

12

should not provide to the attacker. For example, a host might be a web server, and

should provide anyone with requested web pages. However, that host should not provide

command shell access without being sure that the person making such a request is

someone who should get it, such as a local administrator.

Executing Commands Illicitly

It's obviously undesirable for an unknown and untrusted person to be able to execute

commands on server machines. There are two main classifications of the severity of this

problem: normal user access, and administrator access. A normal user can do a number

of things on a system (such as read files, mail them to other people, etc.) that an attacker

should not be able to do. This might, then, be all the access that an attacker needs. On

the other hand, an attacker might wish to make configuration changes to a host (perhaps

changing its IP address, putting a start-up script in place to cause the machine to shut

down every time it's started, or something similar). In this case, the attacker will need to

gain administrator privileges on the host.

Confidentiality Breaches

There is certain information that could be quite damaging if it fell into the hands of a

competitor, an enemy, or the public. In these cases, it's possible that compromise of a

normal user's account on the machine can be enough to cause damage (perhaps in the

form of obtaining information that can be used against the company, etc.)

While many of the perpetrators of these sorts of break-ins are merely thrill-seekers, there

are those who are more malicious.

2.1.3.2 Protecting a Network Using Firewalls In order to provide some level of separation between an organization's Intranet and the

Internet, firewalls have been employed. A firewall is simply a group of components that

collectively form a barrier between two networks.

Types of Firewalls

There are three basic types of firewalls:

Application Gateways: Sometimes known as proxy gateways. These are made up of bastion

hosts that run special software to act as a proxy server. This software runs at the

Application Layer of the ISO/OSI Reference Model, hence the name. Clients behind the

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 21: Wireles Project

Chapter Two: Literature Review

13

firewall must be proxitized (that is, must know how to use the proxy, and be configured

to do so) in order to use Internet services. Traditionally, these have been the most secure,

because they don't allow anything to pass by default, but need to have the programs

written and turned on in order to begin passing traffic. These are also typically the

slowest, because more processes need to be started in order to have a request serviced.

Packet Filtering: Packet filtering is a technique whereby routers have ACLs (Access

Control Lists) turned on. By default, a router will pass all traffic sent to it, and will do so

without any sort of restrictions. Employing ACLs is a method for enforcing security

policy with regard to what sorts of access are allow the outside world to have access to an

internal network, and vice versa.

There are fewer overheads in packet filtering than with an application gateway, because

the feature of access control is performed at a lower ISO/OSI layer (typically, the

transport or session layer). Due to the lower overhead and the fact that packet filtering is

done with routers6, a packet filtering gateway is often much faster than its application

layer peers.

Because they work at a lower level, supporting new applications either comes

automatically, or is a simple matter of allowing a specific packet type to pass through the

gateway.

There are problems with this method, though. Because TCP/IP has absolutely no means

of guaranteeing that the source address is really what it claims to be. As a result, layers of

packet filters have to be used in order to localize the traffic. Its impossible to get all the

way down to the actual host, but with two layers of packet filters, differentiation between

a packet that came from the Internet and one that came from an internal network can be

made.

Hybrid Systems: In an attempt to marry the security of the application layer gateways with

the flexibility and speed of packet filtering, some vendors have created systems that use

the principles of both. In some of these systems, new connections must be authenticated

and approved at the application layer. Once this has been done, the remainder of the

connection is passed down to the session layer, where packet filters watch the connection

to ensure that only packets that are part of an ongoing (already authenticated and

approved) conversation are being passed. Other possibilities include using both packet

6 Which are specialized computers optimized for tasks related to networking

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 22: Wireles Project

Chapter Two: Literature Review

14

filtering and application layer proxies. The benefits here include providing a measure of

protection against servers that provide services to the Internet (such as a public web

server), as well as provide the security of an application layer gateway to the internal

network. Additionally, using this method, an attacker, in order to get to services on the

internal network, will have to break through the access router, the bastion host, and the

core router.

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 23: Wireles Project

Chapter Two: Literature Review

15

2.2 The Global System for Mobile Communications (GSM) GSM belongs to the class of cellular networks, which are used predominantly for public

mass communication. They had an early success with analog systems like the Advance

Mobile Phone System (AMPS) in America, the Nordic Mobile Telephone (NMT) in

Scandinavia, or the C-Netz in Germany. Founded on the digital system GSM (with its

variants for 900 MHz, 1800 MHz, and 1900 MHz)[Gozalvez 2000]

2.2.1 Architecture of the GSM network The GSM technical specifications define the different entities that form the GSM

network by defining their functions and interface requirements.

The GSM network can be divided into four main parts:

1. The Mobile Station (MS).

2. The Base Station Subsystem (BSS).

3. The Network and Switching Subsystem (NSS).

4. The Operation and Support Subsystem (OSS).

Mobile Station

A Mobile Station consists of two main elements:

The mobile equipment or terminal: There are different types of terminals distinguished

principally by their power and application:

q The ‘fixed’ terminals are the ones installed in cars. Their maximum

allowed output power is 20 W.

q The GSM portable terminals can also be installed in vehicles. Their

maximum allowed output power is 8W.

q The handheld terminals (handsets) have experienced the biggest success

thanks to their weight and volume, which are continuously decreasing.

These terminals can emit up to 2 W. The evolution of technologies allows

decreasing the maximum allowed power to 0.8 W.

The Subscriber Identity Module (SIM): The SIM is a smart card that identifies the terminal. By

inserting the SIM card into the terminal, the user can have access to all the subscribed

services. Without the SIM card, the terminal is not operational.

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 24: Wireles Project

Chapter Two: Literature Review

16

The SIM card is protected by a four-digit Personal Identification Number (PIN). In

order to identify the subscriber to the system, the SIM card contains some parameters of

the user such as its International Mobile Equipment Identity (IMEI).

Another advantage of the SIM card is the mobility of the users. In fact, the only element

that personalizes a terminal is the SIM card. Therefore, the user can have access to its

subscribed services in any terminal using its SIM card.

The Base Station Subsystem

The BSS connects the Mobile Station and the NSS. It is in charge of the transmission

and reception. The BSS can be divided into two parts:

The Base Transceiver Station (BTS) or Base Station: The BTS corresponds to the transceivers

and antennas used in each cell of the network. A BTS is usually placed in the center of a

cell. Its transmitting power defines the size of a cell. Each BTS has between one and

sixteen transceivers depending on the density of users in the cell.

The Base Station Controller (BSC): The BSC controls a group of BTS and manages their

radio resources. A BSC is principally in charge of handovers, frequency hopping,

exchange functions and control of the radio frequency power levels of the BTSs.

The Network and Switching Subsystem

Its main role is to manage the communications between the mobile users and other

users, such as mobile users, ISDN users, fixed telephony users, etc. It also includes data

bases needed in order to store information about the subscribers and to manage their

mobility. The different components of the NSS are described below.

The Mobile services Switching Center (MSC):It is the central component of the NSS. The MSC

performs the switching functions of the network. It also provides connection to other

networks.

The Gateway Mobile services Switching Center (GMSC): A gateway is a node interconnecting

two networks. The GMSC is the interface between the mobile cellular network and the

Public Switched Telephone Network. It is in charge of routing calls from the fixed

network towards a GSM user. The GMSC is often implemented in the same machines as

the MSC.

Home Location Register (HLR): The HLR is considered as a very important database that

stores information of the subscribers belonging to the covering area of a MSC. It also

stores the current location of these subscribers and the services to which they have

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 25: Wireles Project

Chapter Two: Literature Review

17

access. The location of the subscriber corresponds to the SS7 address of the Visitor

Location Register (VLR) associated to the terminal.

Visitor Location Register (VLR): The VLR contains information from a subscriber's HLR

necessary in order to provide the subscribed services to visiting users. When a subscriber

enters the covering area of a new MSC, the VLR associated to this MSC will request

information about the new subscriber to its corresponding HLR. The VLR will then have

enough information in order to assure the subscribed services without needing to ask the

HLR each time a communication is established. The VLR is always implemented

together with a MSC; so the area under control of the MSC is also the area under control

of the VLR.

The Authentication Center (AuC): The AuC register is used for security purposes. It

provides the parameters needed for authentication and encryption functions. These

parameters help to verify the user's identity.

The Equipment Identity Register (EIR): The EIR is also used for security purposes. It is a

register containing information about the mobile equipments. More particularly, it

contains a list of all valid terminals. A terminal is identified by its International Mobile

Equipment Identity (IMEI). The EIR allows then to forbid calls from stolen or

unauthorized terminals (e.g, a terminal which does not respect the specifications

concerning the output RF power).

The GSM InterWorking Unit (GIWU): The GIWU corresponds to an interface to various

networks for data communications. During these communications, the transmission of

speech and data can be alternated.

The Operation and Support Subsystem (OSS)

The OSS is connected to the different components of the NSS and to the BSC, in order

to control and monitor the GSM system. It is also in charge of controlling the traffic load

of the BSS.

However, the increasing number of base stations, due to the development of cellular

radio networks, has provoked that some of the maintenance tasks are transferred to the

BTS. This transfer decreases considerably the costs of the maintenance of the system.

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 26: Wireles Project

Chapter Two: Literature Review

18

Mobility Management (MM)

The MM function is in charge of all the aspects related with the mobility of the user,

specially the location management and the authentication and security.

Location management: When a mobile station is powered on, it performs a location update

procedure by indicating its IMSI to the network. The first location update procedure is

called the IMSI attach procedure. The mobile station also performs location updating, in

order to indicate its current location, when it moves to a new Location Area or a

different PLMN. This location-updating message is sent to the new MSC/VLR, which

gives the location information to the subscriber's HLR. If the mobile station is

authorized in the new MSC/VLR, the subscriber's HLR cancels the registration of the

mobile station with the old MSC/VLR. A location updating is also performed

periodically. If after the updating time period, the mobile station has not registered, it is

then deregistered.

When a mobile station is powered off, it performs an IMSI detach procedure in order to

tell the network that it is no longer connected.

Authentication and security: The authentication procedure involves the SIM card and the

Authentication Center. A secret key, stored in the SIM card and the AuC, and a ciphering

algorithm called A3 are used in order to verify the authenticity of the user. The mobile

station and the AuC compute a SRES using the secret key, the algorithm A3 and a

random number generated by the AuC. If the two computed SRES are the same, the

subscriber is authenticated. The different services to which the subscriber has access are

also checked.

Another security procedure is to check the equipment identity. If the IMEI number of

the mobile is authorized in the EIR, the mobile station is allowed to connect the

network.

In order to assure user confidentiality, the user is registered with a Temporary Mobile

Subscriber Identity (TMSI) after its first location update procedure.

2.2.2 Short Message Service (SMS) Short Message Service (SMS) messages are 160 character text messages, sent using a

SDCCH 7(slow speed data channel) from a mobile phone handset to another handset.

7 This means that they can be sent at the same time as a fax or data call, but also means that they can be a little slow because of the limited bandwidth available to carry them.

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 27: Wireles Project

Chapter Two: Literature Review

19

SMS delivery is a store-and-forward system, where the message is sent to a Short

Message Service Center (SMSC), which then forwards them on to the destination mobile

handset.

Short Message Data Structure

A short message is formally known as a Protocol Data Unit (PDU) and comprises two

parts - the header information and the short message text itself (known as the user data).

This short message is sent to the SMS Center that looks at the details on the header and

tries to send the message to the recipient using the type of postal service the sender

specified.

The header contains the following parameters:

SMSC Address: The address of the SMS Center to which the short message is to be sent.

Destination Address: The Destination Address field denotes the final recipient of the short

message. The sender usually specifies this parameter.

Originating Address: The address of the sender of the short message. Usually automatically

appended to the short message itself so that the recipient can identify the sender.

Status Report Request: This parameter allows the short message sender to request

confirmation that the short message has been delivered to its intended recipient.

Service Center Timestamp: In addition to the short message text itself and the Originating

Address, the time and date that the SMS Center received the short message are usually

also automatically appended to outbound short messages from the SMS Center.

Validity Period: Each short message submitted to the SMS Center is assigned a Validity

Period, which sets the maximum time that the short message is retained in the SMS

Center. Failure to successfully deliver the short message within the short message lifetime

causes it to be marked for purge, with no further delivery attempts made. Setting specific

short message Validity Periods is important for many SMS-based applications. Some

SMS Centers can inform software applications as soon as a short message lifetime

expires, allowing alternative, secondary action to be taken.

All short messages have a message lifetime - those short messages that do not have a

specific value when submitted are automatically assigned the default Validity Period for

that mobile network. For example, some mobile network operators set a maximum short

message lifetime of 72 hours (Vodafone, UK) or 24 hours (Safaricom, Kenya), after

which any short messages that haven’t been delivered are deleted [Eberspächer et al

1999].

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 28: Wireles Project

Chapter Two: Literature Review

20

Data Coding Scheme8

The Data Coding Scheme (DCS) parameter is used for several purposes, including the

following:

q Indicate the form in which the short message text (user data) is encoded, be it the

GSM 7-bit default alphabet, 16-bit text or binary.

q Specify short message classes, which tell the mobile phone how to deal with the

short message. For example, the Data Coding Scheme flag is used to indicate

whether to store the short message in the SimCard or memory, send it directly to

the display or to Terminal Equipment attached to the mobile phone.

q Allow a receiving Short Message Entity to display an icon associated with a short

message, such as an email or voice mail icon.

q Indicate that a short message is compressed.

Protocol Identifier (PID)

Another flag that is used for a wide variety of purposes is the Protocol Identifier (PID).

The PID determines how the short message should be handled by the receiving entity or

the SMS Center. Uses of the Protocol Identifier include:

Routing short messages to the correct outbound interface: This is useful when several interfaces

share the same numbering plan (e.g. PSTN fax and voice). Use of the Protocol Identifier

indicates to the SMS Center where to send the short message to maximize the likelihood

that it is successfully delivered to its intended Destination Address.

Routing by Protocol Identifier is, for example, used in the provision of SMS to Fax

services, through which a mobile phone user can send a short message to a fax machine.

The SMS Center recognizes that the Protocol Identifier indicates an SMS to Fax message

and routes the short message to the module within the SMS Center that incorporates fax

outdial, or an SMS to Fax platform resident outside the SMS Center itself.

Indicating that a mobile phone receiving a short message should check to see if a short

message of the same type is currently stored and if so replace it with the new one.

Reply Path

The Reply Path allows a user to indicate to the receiver that a reply to the short message

is requested. When the recipient chooses to reply to a short message, the SMSC Address

8 The Data Coding Scheme values are described in GSM 03.38. How or if they are supported depends on the specific mobile phone. Network support of the DCS parameter also varies- application developers and users have to check with their network operator to see which if any uses of the DCS are allowed.

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 29: Wireles Project

Chapter Two: Literature Review

21

from which the short message came is used instead of the SMSC Address stored on the

SimCard. Additionally, the Originating Address from which the short message came is

automatically used as the Destination Address.

This feature was incorporated to indicate to the SMS Center that the initial sending entity

should be charged for the reply rather than the replying entity. The advantage is that

someone sending a message can receive a reply even if the recipient of the short message

has not got an SMS Center number programmed into his or her SimCard.

Many mobile phones allow a recipient to reply to a short message irrespective of the

setting of the Reply Path parameter in the received short message. In such cases, the SMS

Center and Originating Address translation described above is also applied.

Message Reference

An identifier (1- 255) that is incremented with each short message sent.

Message Length

Indicates the length of the short message in terms of the number of characters and

spaces used.

Reject Duplicates

The Reject Duplicates parameter allows a sender to indicate to the SMS Center that a

short message with the same Message Reference as one already stored in the SMS Center

for the same Destination Address should be discarded and replaced by the new one.

User Data Header Indicator

The User Data Header Indicator allows a sender to indicate that the short message text

itself (the user data) is in a special format of the types defined in GSM 03:40 standard

such as SMS concatenation.

SMS Commands

Some mobile phones allow the sender to send specific instructions to the SMS Center to

carry out operations on previously submitted short messages. For example, different

command types allow the user to inquire about the status of a short message or delete a

short message that is waiting to be delivered.

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 30: Wireles Project

Chapter Two: Literature Review

22

Message Type Indicator

The Message Type Indicator parameter indicates whether a short message is for sending,

receiving, is a status report (confirmation of delivery), or a specific command to the SMS

Center such as an enquiry on a short message. A user does not normally have control

over this parameter from the mobile phone keypad.

Some of these parameters are added by the mobile network entities and some are

accessible by the originator of the short message. A default value for all of these

parameters except the Destination Address is usually built into the application software,

the SMS Center and mobile phone.

Different combinations of these Short Message Data Structure parameters are formed

depending on what SMS-related action is being carried out. For example, the Validity

Period parameter is only set when submitting short messages. Some of the Short

Message Data Structure parameters are optional and some are mandatory9.

The user data plus the other parameters is collectively known as the Protocol Data Unit

(PDU) or SMS-TPDU (SMS-Transport Protocol Data Unit). There are several different

types of PDU, each of which contains different parameter combinations. For example,

the Submit PDU is the format sent by the originating Short Message Entity to send a

short message. The Deliver PDU is the format presented to the receiving message. The

Command PDU is the format sent by the originating SME to request an action on

previously submitted but not yet delivered short messages. The Status Report PDU

indicates the status of a previously submitted short message to the originating SME (for

example, confirming successful delivery to the Destination Address).

9 The presence and order of the parameters for different types of short message transactions are defined within GSM 03:40 standard.

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 31: Wireles Project

Chapter Two: Literature Review

23

2.3 Software Development Software development is an engineering discipline and thus the process of software

development is like other engineering processes. Thus a model of software development

well resembles that of engineering activities. These various software models that available

among them are discussed below.

Waterfall approach

It views software as being made up of stages such as requirements specification, software

design, implementation testing etc. after each stage is designed it is written off and

development proceeds to the next stage.

Explanatory programming

This approach involves development of the system as quickly as possible and then

modifies the system until it performs adequately.

This method is mainly used for artificial intelligence (AI) system development where

users cannot formulate detailed requirements specification and where adequacy rather

than accuracy is the main aim of the system designer.

Prototyping

It is similar to explanatory programming in that the first phase of development involves

the developing a program for user experiment. This is followed by a re-implementation

of software to produce a production quality system.

Formal transformation

This approach involves developing formal specification software and transforming its

specification using correctness- preserving transformations.

System assembly from reusable components

This technique assumes that systems are mostly made of components that already exist.

The system development becomes a process of assembly rather than creation.

Of the models mentioned above it was deemed that the waterfall model would be best

suitable in developing the applications in this project.

2.3.1 Application development cycle A well-designed software application makes the application programming and tuning

much easier. Every application, small or large, passes through the stages of the

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 32: Wireles Project

Chapter Two: Literature Review

24

application development cycle (also known as the system development cycle) described

below:

Analysis

Analysis is the first stage of an application development, and it should enable the

developer to answer the following questions: Why is the application being developed?

Who is going to use it? How will the application benefit the users? What business rules

and needs should be addressed? The complete functionalities of the system should be

determined in requirement analysis. Typically, functional-level managers take care of this

phase.

Design

Design is the most important phase of application development. After the application

requirements are analyzed, the design phase begins. In this phase, the database design is

performed using ER diagrams. The logical database design is converted to physical

structures.

Development

In the development phase, coding is done based on the design; you use the end product

of the design phase of the life cycle as a building block for the development process. The

software design and the designed system requirements provide the basis for the

development of the application.

Testing

The developed application is tested against its objectives to ensure that it is doing what it

is supposed to do. System/integration testing is done on the entire system. Any errors are

corrected, and the application is tested again. Application users do the acceptance testing.

Implementation

Implementation is the final stage in the development cycle. Once the testing is complete,

the application is ready to implement. Errors reported after implementation are fixed by

going back to the appropriate stages. Following all these steps again carries out

enhancements to the application.10 Figure 2.3 shows the application development cycle.

10 This makes the whole process of application development a truly iterative process

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 33: Wireles Project

Chapter Two: Literature Review

25

Fig 2.3: Iterative Application development cycle

Strategy & Analysis Design

Building & Documentation Testing

Implementation

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 34: Wireles Project

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 35: Wireles Project

Chapter Three: Analysis

27

3 Chapter Three: Analysis

3.1 Problem Analysis The project aims to control and monitor non-computing devices remotely over the

Internet and the GSM network.

Non-computing devices can be defined as those which do not posses microprocessors in

them and if they do then these devices are not smart/intelligent but dumb devices [Held

et. al. 1994], such devices include:

q Lighting systems

q Motors

q Industrial boilers

q Security doors and gates

q Ovens

It is very difficult to control non-computing devices using a computer because of the fact

that their underlying modes of operation are different and sometimes incompatible. The

fact that we want to control and monitor these devices remotely makes this problem

even more complicated because of the underlying functional differences of these devices,

although from the feasibility study done, such a project is feasible.

The existing problems can be stated as:

q The current technology for switching devices remotely over a telecommunication

channel is power line carrier communications (PLCC) This technology is not

allowed for commercial use in Kenya by the Communications Commission of

Kenya (CCK) and only Kenya Power and lighting Company is allowed to use it in

their internal operations and communications [CCK 1999].

q Even if PLCC was to be commercialized, the fact that less than 5% of the

country has electricity coverage [UNESCO 1999] would make it difficult for this

technology to catch up, whereas the use of the Internet which is now available

everywhere thanks to technologies such as Very Small Aperture Terminals

(VSAT), terrestrial microwave radio links etc makes the use of the Internet to

control devices cheaper and widely accessible. The recent rise in popularity of

GSM cellular mobile phones makes the concept of Data-over-GSM11

communication widely available.

11 Albeit slow for multimedia data, it is sufficient for some type of data such as short text (SMS)

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 36: Wireles Project

Chapter Three: Analysis

28

q Some devices such as heavy-duty boilers and noisy industrial plants are potential

health hazard to people operating them on site.

q The existing remote switching systems lack the high degree of flexibility availed

by use of web enabled software interface such as that presented on a web page

on the Internet, users of these systems must do their control and monitoring

tasks from a specified terminal and not any other.

3.2 Project Challenges The above problems present major challenges in coming up with a working project.

Some of the major technical challenges to be overcome are:

q Non-computing devices do not all behave in a prescribed manner, they also

posses different functional characteristics e.g. a rotating motor produces back

e.m.f whereas a light bulb does not.

q Computer terminals are digital in nature whereas majority of non-computing

devices are analog.

q The various non computing devices are incompatible among themselves, thus the

way a stepper motor would switch on is not the same way a boiler does hence

device specificity has to be taken into consideration in the analysis and design.

q The observable physical parameters in the many of the controlled devices are

different and a way has to be found to make them compatible to the digital

computer. Such include temperature, speed, light etc.

q The intermittent availability of Internet in Kenya at high speeds

3.3 Proposed solution With the above-mentioned problems and challenges, a solution is to be developed that

will not only overcome them but also meet the systems. The block diagram of the desired

system is as shown in Fig 3.0

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 37: Wireles Project

Chapter Three: Analysis

29

Fig 3.0 System block diagram

3.4 The Control and Monitoring System The system shall be in such a way as to allow the user, through the Internet to control

and monitor devices. Figure 3.1 shows the system block representation

Fig 3.1: System layout

The User Interface

The interface shall be a graphical user interface (GUI) that is web based (in the case of

using the Internet) or a phones Short Message Service (SMS) text interface (in the case of

GSM control). The reason for choosing a web-based interface is its ability to work well in

a distributed environment such as the Internet, platform independence and its ease of

Control Station

The Internet or

the GSM mobile Network

Remote Station

Device 1

Device 2

Device 3

Device n-1

Device n

Devices

User web Interface

Web Server

Database Server

The Internet

Remote PC station

Device Interface Circuit

Mobile Phone

GSM Network

Mobile Phone

handset

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 38: Wireles Project

Chapter Three: Analysis

30

design. The reason for choosing the GSM based interface is it’s high availability and

flexibility12 as compared to the Internet.

The functions of the user interface shall be:

q Present device status information to the user e.g. is the light on? What is the

boiler temperature? etc.

q Present interactive options/ parameters which the user can use to control devices

q Present configuration options and error messages to the user

The Internet The Internet is the main communication and data storage infrastructure on which the

system runs.

Designing a system that runs parallel to the Internet would be uneconomical and

irrational. In this block we have two sub blocks as shown in figure 3.1 namely the Web

server and the database server.

Web server: Process user and database requests through server side scripting,

which as compared to client side scripting is safer, faster and client-platform

independent. The web server also acts as a middleman between the database and

the user because it is responsible for formatting data from the database into

information that can be understood by the user. Another function of the web

server is to provide user authentication to improve security of the system so that

unauthorized persons do not run the system. This is by providing login WebPage

before the user can use/run the system.

Database: A relational database system, its the main system storage of the system

status data. Data read from the device interface software is stored here, data from

the user interface passes through the web browser to the database from which

the application switching software reads it and executes the desired action. The

need for the database arises due to the need to log device activity and act as a

buffer for data in case the latency of the communication paths increases to an

extent that data in transit is lost. The database will also offer and extra layer of

security if need be, this will be by users providing a password before accessing

the data stored.

12 Flexibility because one is able to control a device even while traveling by simply sending a text message to the device

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 39: Wireles Project

Chapter Three: Analysis

31

The GSM Network This is the wireless cellular phone network that is currently provided by Safaricom and

Kencell Communications Ltd. The user of the system can use the GSM network as a

backup of the Internet (incase Internet fails) or when the user is out of reach of an

Internet connected computer. To control say the lights, the user sends a SMS to his

home phone with the message ‘lights on’, to switch them off, he/she sends ‘lights off’.

The system is in such a way that it will only act on the message if it comes from a

particular phone number to prevent malicious interference. This is done by accessing the

phone software by use of the communications port through activeX controls that we are

currently developing. The activeX components will not only be able to read the message

received but also get the International Mobile Equipment Identification (IMEI) number

of the phone that sent the message, this additional feature will enhance security by

preventing phone number spoofing.13

Application switching software This is software that shall be running on the remote computer to which devices are

connected to, its main duty is to interface the switching circuits to the rest of the system

and get data from the mobile phone. It shall be executing commands from the user that

have been stored in a predefined data format in the database. This software shall also

make it possible to perform locally all the services that can be done remotely mainly for

troubleshooting purposes.

The software shall also interpret data from the devices and post it to the database from

which the user interface shall output the device status to the user of the system.14

Device interface This is an electronic circuit that interfaces the devices being monitored and controlled to

the rest of the system. This device shall have a port that connects to the computer

through which data shall flow to and from the circuits. It shall also gather device status

information, digitize it and send it to the rest of the system.

Devices These are the main focus of the system, they are the devices to be monitored and

controlled, and they include any non-computing electrical or electronic device or system

13 This is similar to IP address spoofing used in Denial of Service Attacks (DoS) on Computer networks 14 This is where closed loop feedback comes in to the system.

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 40: Wireles Project

Chapter Three: Analysis

32

such as motors, lights, industrial boilers etc. for demonstration purposes only, we shall

use only two of these devices i.e. an incandescent light bulb and a 12V dc motor.

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 41: Wireles Project

Chapter Four: System Design

33

4 Chapter Four: System Design

4.1 Web server

A Web server is a computer program that serves web pages to users who request them

and runs in background mode (daemon). Other functions of a web server include

formatting information into user readable format. e.g. from a database, a web server can

pick data from a specified field in a table and format it to HTML format that can be

displayed on a web browser. It does this by using a scripting language (such as PHP

which we will use for this project)

Currently, there are several commercial and freeware web servers such as Apache,

Microsoft Internet Information server (IIS), Xitami and Adobe.

4.1.1 Apache Web server Apache is more widely used than all other web servers combined. About 61 % of the

Internet web servers are apache. Apache was designed to work on Linux operating

systems but of recent times, Windows versions have been released. Apache has the

following advantages:

§ Contains a host of configuration options making it easy to customize

§ Can support and handle very many client requests/connections

§ It is open source meaning that one can fully customize it by going into the

software code and modifying its behavior

§ Has extremely good security options

Apaches disadvantages are:

§ Needs powerful server hardware to run it effectively

§ The server configuration options are very many and have to be learned

§ The fact that its open source makes apache vulnerable to malicious changing of

the program code

4.1.2 Microsoft Internet Information Server (IIS)

The IIS is a commercial web server distributed by Microsoft Corporation. It runs on

windows operating system that are built on NT or .NET technology. The advantages of

ISS are:

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 42: Wireles Project

Chapter Four: System Design

34

§ Extremely compatible with windows OS (because they were both developed by

Microsoft Corporation)

§ Can support and handle very many client requests/connections

§ Has a graphical user interface hence user friendly

The disadvantages of IIS are:

§ User license is required to run the server, this means that running IIS is expensive

§ Configuration options are static unlike in Apache where there is 100% freedom

to enter even into the source code

§ IIS has very well know security ‘holes’ making it vulnerable to hacking, this

however can be corrected by installing IIS patches from Microsoft

§ Needs powerful server hardware to run it effectively

§ Can only run in Windows OS unlike Apache that can run on both Windows and

Linux OS

4.1.3 Xitami Web server The Xitami web server is a small but versatile server for small office applications and

intranets. Its advantages are:

§ Can run in an ordinary desktop computer

§ Can handle many user requests though not as many as Apache or IIS

§ Easy to configure through its browser interface.

§ Can run on both Linux and Windows OS

§ It is freeware hence no licenses are required to run it

Disadvantages of Xitami are:

§ Its compact size makes it inefficient in serving very many connections that

demand a lot of data transfer.

We have decided to use the Xitami web server version two release four from iMATRIX

corporation because of its ease of configuration and the light loading it has on the central

processing unit of the computer in which it is running. The web server is installed into

the computer and during the installation the option to enable automatic starting of the

server when the computer is started is enabled. Other installation options done are:

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 43: Wireles Project

Chapter Four: System Design

35

q Username and password to enable web-based configuration, this configuration is

simpler as compared to the text editing done on say the apache web server where

one has to edit long pages of configuration scripts (the httpd.conf file). If one

does not wish to enable web based administration and configuration of the

webserver, the username and password fields are left blank.

q Server performance option which had radio buttons for normal (if we run several

servers), tiny (The server activity will never block another task) or Turbo (for best

performance)

Once the server is installed and running, the following options are set by going to a web

browser and directing it to the address http://127.0.0.1/admin (127.0.0.1 is usually the

default loop back address in Windows/Linux operating systems but can be changed to a

suitable public IP address if the web server is to run on the Internet)

q Click on the configuration hyperlink to view the configuration options

q On the default html page we add index.php because we shall be running a PHP

script that shall be querying the database

q On the server IP address we can chose the IP address assigned to the network

card of the computer running the server.

q On the main html directory space we can fill the path to where the index web

pages and PHP scripts will be stored

q Click save and the restart server for the changes made to take effect

4.1.4 Scripting Scripts are program codes that act on data in a desired manner for example picking user

input and saving it to a database. There are two types of scripting methods namely server

side and client side scripting.

Server side scripting is whereby a script runs on the server and not the client machine

whereas client side scripting, the script is executed on the client machine. Advantages of

server side scripting over client side is:

q It does not consume a lot of bandwidth that would have been used to transfer the

code to the client side in the case of client side scripting this means that web pages

load faster

q The client CPU is freed from the task of script execution that is done at the server

side. This means that pages load faster too.

q Server side scripting is more secure because it is not visible to the client

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 44: Wireles Project

Chapter Four: System Design

36

q Server side scripts can be re-used by several server threads that are serving

different connections.

q Server side scripting is independent of the client platform

q Client side scripting is slow especially when querying databases

Disadvantages of server side scripting are:

q Cannot get local machine parameters such as client side date and time. For

example if you view a date displayed on a web page that was generated by server

side scripting, it would display the server system date and not the client’s system

date. This brings problems especially when we want to time stamp client activity

logs. Client side scripting comes in handy.

Several server side scripting languages exist, they include: PHP, TCL and ASP.

The main advantage of PHP over the rest is:

q PHP is freeware as compared to say ASP for which one has to buy a license from

Microsoft

q It was written with connectivity to databases such as MySQL in mind

q Is easy to learn as compared to ASP, and TCL

q It has more functional capability as compared to the other languages hence runs

more efficiently.

q PHP is platform/server independent i.e. can run in a UNIX/Linux server as well

as a windows server.

4.1.4.1 How PHP is installed

The PHP scripting engine may be downloaded for free from http://www.php.net/ (or

one of its mirrors listed at http://www.php.net/mirrors.php).

When installing we are given a list of web servers that PHP will use and in our case we

select Xitami web server because it is the web server that we are running.

Once it is installed, we make sure that the web server ‘sees’ and is able to use the PHP

scripting engine by making sure that the php.ini file has the following lines in it (php.ini is

found in the windows directory)

magic_quotes_gpc = On <enables use of short PHP tags ‘<? ?>’>

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 45: Wireles Project

Chapter Four: System Design

37

doc_root = <the document root folder of the Xitami Web server> extension_dir = <the PHP install directory> register_globals = On The document root folder is where the WebPages that the server will serve are placed.

The full path of the location is entered here e.g. C:\Webpages.

The PHP install directory is the folder in which we installed the PHP engine e.g.

C:\program files\php

After this is done and saved, we restart the Xitami web server by clicking the back arrow

on the web browser to the server configuration main page and clicking on the ‘restart

server’ button.

4.2 Database Server A database server is a program that can store large amounts of information in an

organized format that is easily accessible from scripting languages like PHP. The database

server’s work is to store data about the status of the devices we are controlling and

monitoring.

There are several types of commercial and freeware database servers in the market today

such as Microsoft SQL, Oracle, and MySQL etc.

4.2.1 Microsoft SQL This is one of the most versatile servers on the market, its ability to allocate separate

CPU threads for each connection makes it fast and efficient.

Advantages of MS SQL are:

q It can handle very many connections at a time

q Issues separate CPU threads per connection making it fast

q Has good security features

Its disadvantages are:

q Can only run in Microsoft NT based operating systems such as windows NT4,

2000, XP

q Needs a license from Microsoft making it expensive

q Needs powerful hardware to run

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 46: Wireles Project

Chapter Four: System Design

38

4.2.2 Oracle Oracle is the most popular enterprise relational database management system (RDMS).

Several versions exist such as Oracle 8i, Oracle 9i etc. It posses similar characteristics to

MS SQL but also includes the following

q It was written with server side scripting in mind

q Has easy to use syntax

Oracle’s disadvantages include the MS SQL disadvantages and the following:

q Its not freeware and a license has to be bought for it to be used

q Runs on Microsoft Windows operating systems and not Linux

4.2.3 MySQL MySQL is a RDBMS that is strikingly similar to Oracle. MySQL has the following

advantages:

q Its freeware meaning its free to download from the Internet as compared to

commercial version of database servers such as Microsoft SQL which requires a

license from Microsoft corporation before being used.

q Its syntax is easy to use and simple to apply e.g. to use a database called project we

simply type use project on the MySQL command prompt

q It is multiplatform i.e. MySQL can be run in Linux or Windows platforms

q MySQL is capable of handling more than one connection simultaneously and

issues a separate CPU threads for each connection hence making it faster.

q No memory leaks. MySQL has been tested with Purify, a commercial memory

leakage detector.

q Full support for several different character sets, including ISO-8859-1 (Latin1),

big5, ujis, and more. For example, the Scandinavian characters ë å and æ are

allowed in table and column names.

MySQL has the following disadvantages

q It is not user friendly because it does not have a graphical user interface but a

command prompt interface.

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 47: Wireles Project

Chapter Four: System Design

39

In this project, MySQL was chosen as the database server to be used because of its wide

availability due to the fact that it’s freeware and open source.

4.2.3.1 Installing MySQL The database server is installed into a computer that has at least 64MB Physical memory.

MySQL database engine can be found by going to http://www.mysql.com (or one of its

mirrors listed at http://www.mysql.com/mirrors.html) and selecting "Register and

download shareware version of MySQL-Win32" in the "Downloads" section under

"Downloads for Windows MySQL related software". After downloading the file, we

unzip it and run the setup.exe program contained therein.

Once installed, MySQL is ready to run (except for a couple of configuration tasks that

are needed to optimize it). Just like the Xitami Web server, MySQL is a server that

should be run in the background so that it may respond to requests for information at

any time. The server program may be found in the "bin" subfolder of the folder where

we installed MySQL. From the MS-DOS Prompt, we can start the server by typing on

the command prompt:

C:\mysql\bin> mysqld To ensure that the server is started whenever Windows starts, we can create a shortcut to

the program and put it in the Startup folder meaning that every time we start windows,

the server shall be running in background mode.

The next step is to set the username and password that shall be used in accessing the

server because if we don’t do this and the server is connected to the Internet, anyone can

access the data stored and make some modifications or worse still delete stored data.

To set a root password for MySQL, we type the following command in the bin directory

of the MySQL installation (including the quotes):

mysqladmin -u root password <new password> Where <new password> is replaced with the password we wish to use and the

username root can be replaced by any other suitable name.

To make sure MySQL has registered this change, we reload its list of authorized users

and passwords:

mysqladmin -u root reload If this command gives an error message saying that access was denied, it means the

password has already taken effect.

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 48: Wireles Project

Chapter Four: System Design

40

4.2.3.2 Creating the database

Once the server is up and running, we create a database in the server. Before this is done

we must login using the credentials we set by typing the following in the command

prompt:

mysql -h 127.0.0.1 -u root -p The ‘-p’ argument will make the server ask for the users password that we shall enter.

Once inside, we can proceed to create the databases which we shall call ‘rock’.

mysql> create database rock; (Every MySQL statement must end with a semi-colon)

Once the database is created we have to tell MySQL that we need to use it, this is done

by typing the line:

mysql> use rock; We then proceed to create a table that shall consist of columns of the items we are

controlling and monitoring, in this case we choose, The Gate, lights, Fridge, and a boiler.

These form part of the possible devices we want to control.

The table (which we call master) is created by typing on the MySQL command prompt as

follows:

mysql> CREATE TABLE master ( -> ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Gate char(3), -> Lights char(3), -> Fan char(3), -> Boiler char(3), ->); The first line says that we want to create a new table called master.

The second line says that we want a column called ID that will contain an integer (INT).

The rest of this line deals with special details for this column. First, this column is not

allowed to be left blank (NOT NULL). Next, if we don't specify any value in particular

when adding a new entry to the table, MySQL should pick a value that is one more than

the highest value in the table so far (AUTO_INCREMENT). Finally, this column is to act

as a unique identifier for entries in this table, so all values in this column must be unique

(PRIMARY KEY).

The third, fourth fifth and sixth line say that we want to create columns called Gate,

Lights, Fan, Boiler that will contain three character long values (char (3)). The last

line closes the whole process by ending with a semi-colon.

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 49: Wireles Project

Chapter Four: System Design

41

To view the contents of the table we have just created we type mysql> DESCRIBE master; The result of this command is displayed in the table below. +----------+---------+------+-----+------------+ | Field | Type | Null | Key | Default | +----------+---------+------+-----+------------+ | ID | int(11) | | PRI | NULL | | Gate | char(3) | | | | | Lights | char(3) | | | | | Fridge | char(3) | | | | | Boiler | char(3) | | | | +----------+---------+------+-----+------------+ 5 rows in set Table 4.0: Command prompt output for the command: Describe master This confirms that the table was created with the properties we defined. These are the

devices that we wish to remotely control, we have entered then into a database so as to

store any information relating to their status (on/off). It is from this database that all

other software modules will get or post information.

The database is now ready for use.

4.3 Open Data Base Connectivity (ODBC) data access engine The ODBC data access engine is used to connect ODBC-aware data access components

to a MySQL server. For MySQL, MyODBC engine is used.

MyODBC is a 32-bit ODBC (2.50) level 0 (with level 1 and level 2 features) driver for

connecting an ODBC-aware application to MySQL. MyODBC works on Windows95,

Windows98, NT, and on most Unix/Linux platforms. The ODBC aware component

used in Delphi programming need to use a DSN entry that is created as follows:

q Open the Control Panel on the Windows machine.

q Double-click the ODBC Data Sources 32 bits icon.

q Click the tab User DSN.

q Click the button Add.

q Select MySQL in the screen Create New Data Source and click the Finish button.

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 50: Wireles Project

Chapter Four: System Design

42

The ODBC set up is filled as follows for this project:

Example of how to fill in the ODBC setup:

Windows DSN name: rock-MySQL Description: ELC 590 Project database MySql Database: rock Server: localhost User: root Password: rock Port: 3306

4.4 User Interface The user interface is defined as the mechanism through which a dialogue between a

computer program and the human is established [Roger 1992]. The user interface should

be easy to use and learn.

We have decided to use two types of user interface:

1. A web-based interface

2. A GSM Mobile phone Short Message Text interface

The web-based interface is set on a web page and displayed on a web browser. The

reasons for this are:

q Web based interface is platform independent (Can execute on any web

browser either in windows, Macintosh or Linux)

q It is extremely flexible in that control and monitoring can be done from any

computer that is online (No need to install any special program interfaces on

the local machine)

q Has a high Input/Output efficiency as compared to resident program-based

interfaces. An interface is I/O efficient when the information can be

supplied or understood by the user with an economy of intellectual effort

[Barstow and Shobe 1998]

q Easier to design and maintain as compared to conventional interfaces

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 51: Wireles Project

Chapter Four: System Design

43

4.4.1 Designing the Web interface The web interface shall consist of the main HTML page and the PHP scripts; the main

page calls the PHP scripts to act on user input. e.g. when a user clicks the ‘lights on’

button, the HTML page calls The PHP scripts responsible for this action to initiate a

connection to the database, update the database, update the user interface and close the

database connection.

Four pages shall characterize the web interface namely:

1. The login page

2. Device control page

3. Device Status page

4. Exception handling pages

The login page is a PHP Script that compares the username and password supplied to

the stored values in the database.

The device control page is the main page from which a user can initiate commands to

switch or control devices, on this page we have push buttons which when clicked will

send commands to carry out the intended action.

The Device history page contains the real-time status of the devices, to ensure that the

displayed status is up-to-date, a refresh rate line is included in the HTML header of the

page set to 2 seconds.

The Exception handling pages are the pages displayed when an error occurs. Such errors

include wrong username and password, failure to connect to the database or page time

out (when device status page refresh fails to occur).

Once a user types the address of the website from which to control devices on the web

browser, he or she must first login to make sure that the user is an authorized user, the

username and password are encrypted by a client side scripting language script into

cipher text which is then transmitted to the user database for comparison.

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 52: Wireles Project

Chapter Four: System Design

44

Mobile Phone Interface The Mobile phone Short Message Text interface is to be used as an alternative to the

web-based interface in the following circumstances:

1. When the Internet is unavailable, SMS can be used to control critical systems

such as industrial boilers

2. When the use is traveling (one can send a text message from a moving vehicle15)

3. When the user is out of reach of an Internet enabled computer.

4. Where it proves that the SMS method is cheaper than Internet access (e.g. in

rural areas where Internet is via dialup trunk call)

At the remote station, an activeX-based software will be running which can access the

phone software through a serial data cable. The activeX is able to do the following:

1. Read the short message string and act on it so that if the received message is

“lights on”, the activeX can update the database whose data is read by the

application switching software to switch the lights on. If the message is “fan on”

the same procedure is carried out to switch on the fan.

2. Query the source phone number and the source phone International Mobile

Equipment Identification number (IMEI); this will prevent the system from

acting on just any received message because malicious people can control your

devices. So the activeX will only update the database if and only if the message

received comes from the expected phone number and handset. The need to

check the IMEI number arises from the fact that people can spoof a phone

number from the free SMS websites from which short message text can be sent.

3. Send a SMS notification to the user that the desire control action has been

performed.

15 Data (text) transmission on SMS does not occur if the user is moving at speeds higher than 120 kph.

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 53: Wireles Project

Chapter Four: System Design

45

4.5 Software Design The software used in this system runs on the remote computer. The software is

responsible for the translation of database information into actions such as switching on

a device. The software pseudo-code is as follows:

Start Login user;

If user is unauthorized then End Else Attempt to connect to database;

If database is not accessible then Alert user; Re-entry;

Else Connect to database; Read database; Select data table;

For column 1 to column n do Read data table; Till end of table;

If column value is ‘ON’ then send activating bit string to port Else Send deactivating bit string to port;

End The above program executes repeatedly so that any changes in the database (which the

user has input) are acted upon.

The other software is the PHP4 script whose main function is to provide for interactive

input on the user interface web page. The PHP4 script has the following pseudo-code:

Start Login user;

If user is unauthorized then Return login error; End

Else Open database connection; Select table in database;

Has user input data to switch on or off devices? If yes

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 54: Wireles Project

Chapter Four: System Design

46

Collect user input; Post user input to database table;

If no Do nothing;

Interface Refresh time out? Yes

Read database table; Format data from database Output formatted data to user interface;

Close database connection; No Do nothing and wait for refresh time out

End The other software is the activeX component that connects to the mobile handset

through the serial communications port (COM 1). The code is written with the

understanding that when a phone sends am SMS, it send it together with the SMS center

number, Phones IMEI and the user data. Its pseudo code is shown below:

Start Connect to phone If connection failed then Alert user Else continue

Read phones’ SMS inbox If Short message received

Check source phone number and IMEI number If source phone number and IMEI number are correct then Update database with message value Send confirmation to user

Else do nothing End The software flowchart for the user input process is as shown in figure 4.0:

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 55: Wireles Project

Chapter Four: System Design

47

Fig 4.0: User input flow chart The software flow chart for device switching is shown in figure 4.1:

START

Challenge user to login

Is user logged

in?

Yes Yes

No Collect data from user

Post data to

database

Close database

connection

Open database

connection

END

Change device status?

No

Third login

attempt?

No

Yes

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 56: Wireles Project

Chapter Four: System Design

48

START

Login User

Is user authorized?

Third login

attempt?

Yes

No

No

Open database

connection

Yes

Read database

Device value is ‘ON’

Yes No Send ‘ON’ bit sequence to

port

Send ‘OFF’ bit sequence to

port

X

END

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 57: Wireles Project

Chapter Four: System Design

49

Fig 4.1: software flow chart for device switching

4.6 Software coding After the software design is complete, the next step is to code the software using a

suitable high level programming language. The suitability of a programming language is

dependent on whether that chosen language can effectively and efficiently carry out the

desired software operation. Effectively in that it can do exactly what is required and

output the desired results, efficiently in that t will do so in as few lines of code as

possible. Borland Delphi 6.0 programming language was chosen as the most suitable

language because of the following reasons:

q Delhi provides the fundamental control-flow constructions required for well-

structured programs, statement grouping, decision-making algorithms, looping

and early loop testing and condition testing.

q Delphi 6 and above can be used to develop programs that can run on both Linux

and Windows platforms.

q Delphi 6 is basically advanced visual Pascal, having a good knowledge of Object

Pascal meant that is much easier to program in Delphi than learn a new language

altogether.

X

Read input pins to get device

status

Update database

Update user

interface

Close database connection

END

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 58: Wireles Project

Chapter Four: System Design

50

q When addressing peripheral devices (which we do in this project), one does not

need to write separate dynamic link libraries (dll) as in other programming

languages such as Visual basic. One can write direct assembly language in Delphi

to access a peripheral device.

The software for this project is divided into several parts for ease of programming

q The splash screen which is shown every time the program is run from a windows

computer

q The Database access and port access program

q The mobile phone access program

4.6.1 The splash screen

The splash screen is an important component in any program. This is because its main

function is to announce the registered name of the program, the owners (e.g. Microsoft).

The splash screen also indicates any acquired or pending patents and the software

version. The splash screen is designed from a simple Delphi form and placing visual

components on the form.

The complete source code for the splash screen is found in appendix V

4.6.2 Mobile phone access program The mobile phone access program is responsible for accessing the mobile phone

software and memory to read any incoming messages and also send messages from the

desktop computer.

This program works in the following way:

q It connects to a phone through a communications port (COM port 1 or COM

port 2) and if it fails to connect it alerts the user

q It constantly reads the phone memory locations for any new incoming message

q If there is a new message, it first makes sure that the message is from the

expected phone number by comparing the senders phone number with the preset

phone number. It can also scan for the IMEI number of the senders phone if the

network operator sends this information with the text message headers. Currently

neither Safaricom nor Kencell sends this information with an SMS. The program

then searches the message string for key words such as lights on, fan on, motor

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 59: Wireles Project

Chapter Four: System Design

51

off, lights off. The program is case insensitive so the ‘LIGHTS ON’ is the same

as ‘Lights on’ or ‘LiGhTS oN’

q Using case of switching in the program flow, it will update the desired

column in the MySQL database so that if the message contains the key words

‘lights on’, the program will update the lights column in the database with the

word ‘ON’ if the key words were ‘lights off’ the it will update the lights column

with the word ‘OFF’ and so on.

q Once the desired device is switched, the phone access program sends back a

confirmation text message (SMS) to the sender confirming that the desired device

has been switched on or off.16

The full program code for the phone access software is found in appendix VI

4.6.3 Database access program This is the main program in the system. It is responsible for getting user input data from

the database and acting on it appropriately so that if a user wished to switch on the fan,

the use information which was saved on the database is read by this program which then

proceeds to output data signals on the parallel port which will activate the device

switching circuits to switch on the fan.

The Data Controls page of the Component palette in the Delphi programming interface

provides a set of data-aware controls that represent data from fields in a database record,

and, if the dataset allows it, enable users to edit that data and post changes back to the

database. By placing data controls onto the forms in our database access application,

were able to build a database application’s User Interface (UI) so that information is

visible and accessible to users and the PHP scripts

Data controls connect to datasets by using a data source. A data source component (

TDataSource) acts as a conduit between the control and a dataset containing data. Each

data-aware control must be associated with a data source component to have data to

display and manipulate. Similarly, all datasets must be associated with a data source

component in order for their data to be displayed and manipulated in data-aware controls

on a form.

16 This is subject to the availability of airtime credit on the remote phone. The confirmation SMS is charged as a normal SMS based on the network provider’s existing tariffs at the time of sending

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 60: Wireles Project

Chapter Four: System Design

52

The complete source code for the database program in Delphi is found in appendix II

and appendix VII for the PHP scripts

4.7 Remote Computer Interface An interface is a boundary between a controlling device and a connected device, which

may or may not include controlling logic such as a transducer, a peripheral or a

microprocessor [Gripps 1981].

An interface will therefore consist of the physical, electrical and logical properties of the

boundary.

Physical properties comprise of the type of interface, shape and number of pins on the

connector. The electrical properties define which electrical signals are used and their

potential level with relation to the ground. Logical properties define the response of the

two devices to electrical signals.

We have two basic types of interfaces namely:

q Serial interface

q Parallel interface

4.7.1 Serial interface In this type of interface, the data bits are transmitted along a single line. The use of a

single line saves the cost of wires especially over long distances. The price paid in this

type of interface is the complexity of the interface in that the sender and receiver must be

accurately synchronized so that the receiver must know when to expect data on the line.

This calls for additional signals. First, the sender must inform the receiver of the

intention to transmit data and the receiver must also send another signal indicating

whether it is ready to receive data or not. In a computer there are serial interfaces

provided, where the external ones are called communications (COM) ports

(Communications Port). A common serial interface is the RS232C with a 25-pin D type

connector. The serial port RS232C standard pin configuration is shown in table 4.1

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 61: Wireles Project

Chapter Four: System Design

53

4.7.2 Parallel Interface In a parallel interface, there are as many data lines as the size of data rate being

transferred so that for transfer of one byte per second then there will be eight data lines

(a data line for each bit). This has the advantage of speed especially over short distances.

In this project we intend to output a three-bit signal (in Parallel) and also receive bit

values from the monitoring circuits hence a parallel port is needed or a parallel to serial

(shift) converter if we are to use the serial port provided by the computer.

The above hurdle can be overcome by making use of the fact that the 25-pin serial port

has two independent channels, which give a total of 8 inputs and seven outputs with the

rest of the signal pins use for timing, grounding and power.

Because of the many output and input pins available in the parallel interface, we shall use

it in the project.

Pin No Signal Type RS232-C Signal Designation Modified Use in This Project

1 Ground Protective Ground 2 Data Data Transmit (Tx) Switching Bit3 out (LSB) 3 Data Data Receive (Rx) Switching Bit2 out 4 Control Request To Send (RTS) Switching Bit1 out (MSB) 5 Control Clear To Send (CTS) Bit Input from Transducer 6 Control Data Set Ready (DSR) Bit Input from Transducer 7 Ground Signal Ground 8 Control Received signal detector (RSD) 9 Reserved for testing 10 Reserved for testing 11 Not Assigned 12 Control Secondary RSD Bit Input from Transducer 13 Control Secondary CTS Bit input from Transducer 14 Data Secondary Tx 15 Timing Transmitted Signal Timing 16 Data Secondary RX 17 Timing Receiver Signal Timing 18 Not Assigned 19 Control Secondary RTS 20 Control Data Terminal ready 21 Control Signal Quality detector 22 Control Ring Indicator 23 Control Data Signal Rate Selector 24 Timing Transmitted signal timing 25 Not Assigned

Table 4.1: Comparison of RS 232 and our modified pin usage table

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 62: Wireles Project

Chapter Four: System Design

54

4.7.3 Port Access Port access is easily achieved in Delphi programming because on simply writes assembly

language directly in the Delphi program module. Unlike in other programming languages

such as visual basic.NET where one has to write separate dynamic link libraries (dll’s) in

another programming language such as C++ or Pascal. This is time consuming because

one has to write a lot of code. In Delphi, less than ten lines of code do the trick as seen

from the appendix II

4.8 Switching Interface Circuit This is the interface circuit between the devices to be switched and the rest of the system.

The circuit is roughly divided into two parts namely:

q Control circuit

q Monitoring circuit

These circuits shall connect to a computer through the parallel port (printer port).

The control circuit should be able to do the following:

q Protect the parallel port from back e.m.f produced by inductive devices such as

motors that we might need to control and electromagnetic relays. This calls for

the use of a power transistor switch and a buffer

q Convert the active low output of the buffer IC to active high outputs, this calls

for the use of inverter IC

q Switch as many devices as possible using the limited number of output pins in

the parallel port. This means that a decoder has to be used.

q Use low voltage output of the parallel port to switch on higher voltage devices

(e.g. A 240V device). This calls for the use of electromagnetic relays.

q Give a stable output to avoid capacitive effects, have a bounce less switching and

this will need a latch such as a JK flip flop.

Upon enquiry in the electrical laboratory, the following devices were available and are to

be used in the control circuit design:

q One 74LS138 3-8 Decoder

q One 74LS244 8 line Buffer

q Two 74LS04 6 line Inverters

q Eight AD149 Power transistors

q Eight 12 to 240 Volts JZC20F Electromagnetic relays

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 63: Wireles Project

Chapter Four: System Design

55

q Two 74LS76 JK Flip Flop

q Clock signal generator (555 timer IC)

q 5V Power supply

q 1 kΩ resistor

q AD 149 NPN Power transistor with metal collector body

4.8.1 Circuit Operation The circuit operation is a follows:

q The 3 to 8 decoder receives three bits in parallel from the parallel port pins 2,3

and 4

q Depending on the bit values, the decoder can switch one of the eight output lines

to low (the decoder being active low)

q The decoder output is passed through a 74LS244 buffer IC to stabilize it and also

isolate the decoder and computer port from the rest of the circuit. Buffering is

important because any fault that might occur in the switching circuit will not

harm the port and decoder.

q The buffer output is then inverted through the 74LS04 inverter IC so as to get an

active high output. This output is used to set a flip flop into active high output

q The active high output is then used to switch a power transistor that in turn

switches an electromechanical relay or enables any other suitable switching

device.

q To switch off the device a similar signal is sent from the twin pin to reset the flip

flop and switch off the device

The relationship between the switching circuit and the rest of the system is as follows:

q In the program, we set that each device be represented by two- three bit binary

number as shown in table 4.2.

DEVICE ON BITS OFF BITS A 001 010 B 011 100 C 101 110 Table 4.2: Device bit combinations

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 64: Wireles Project

Chapter Four: System Design

56

So when the user selects to switch on the device B, 011 is output on the port and the

fourth pin on the decoder is active low, it this that is buffered and inverted to switch on

the transistor which then switches the motor driver IC and the motor runs.

q To switch off the device B, a binary value of 100 is output on the port and this

signal is similarly used as the one above but this time it resets the flip-flop and

the device is shut down.

Electronic workbench software was used to design and simulate the circuit using the

chosen components. After few modifications, the simulation worked as expected.

The circuit in figure 4.2 below shows the switching/control circuit that was simulated

where the device has been represented by a 240Volts incandescent light bulb although it

could be a motor, heater etc.

Fig 4.2: Diagram for the control circuit as viewed in the Electronics workbench simulator. The rest of the devices can be connected in a similar manner as shown by the connection

of a light bulb. The pin-to-pin connection table of the various integrated circuit (IC)

chips is found in the appendix.

4.8.2 Monitoring Circuits The monitoring circuit should be able to monitor the device status by observing one key

parameter of the device and send an electrical signal to a specified pin on the parallel

port. The device monitoring software (which constantly observes this pin) will be able to

Parallel Port

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 65: Wireles Project

Chapter Four: System Design

57

indicate that the monitored device is on or off. If the pin is low (zero volts) then the

device of off whereas if it is high then the device is on.

For demonstration purposes we shall use the following devices and their suitable

transducers in this project:

DEVICE TRANSDUCER 240V Incandescent bulb Light dependent resistor Motor DC Tachometer Water heater Thermistor

Table 4.3: Devices and their suitable transducers In this project, we do not intend to design transducers but shall use commercial off the

shelf (COTS) transducers but because of their varying output, a conditioner to

harmonize their outputs to TTL Level (1 or 0 which correspond to five and zero volts

respectively)

The transducer output will be conditioned by use of a Zener diode working in the

breakdown region. This will ensure that the transducer output is trimmed to 5 volts (TTL

Level) because any over voltage can destroy the port internal buffers. Also in the event of

an under voltage, the same Zener diode can act as a pull-up to increase the voltage to 5

volts.

The graph below shows the operation of a Zener diode as a voltage conditioner/ clipper.

Fig 4.3: Zener Diode input and output waveforms

The conditioner circuit shall be as shown in figure 4.4.

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 66: Wireles Project

Chapter Four: System Design

58

Fig 4.4: Transducer output voltage conditioner

Each transducer shall have its own conditioner diode and its own input pin on the port.

The monitoring software will then be able to tell whether a given device is on or off

depending on the state of the input pin of that device on the port e.g. when the light is

on, the Light dependent resistor will conduct and the light monitoring pin will go ‘high’

(5 volts after conditioning) and the user will then be able to know that the lights have

actually turned on. If the user switches on a given device and does not get a confirmation

that the device has responded to the users command, he will the know that there is a

malfunction e.g. the incandescent light bulb has blown e.t.c.

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 67: Wireles Project

Chapter Five: Tests and Results

59

5 Chapter Five: Tests and Results

5.1 Circuit testing The Electronic workbench program, which is used to design and simulate circuits, was

first used to predict the expected results and behavior of the circuit.

After getting all the desired components from the laboratory, the circuit was then tested

at component level to make sure that the components used worked. The components

were then soldered on the strip board to form the complete control and monitoring

circuit. The lack of some of the components we required in the labs led to some

modifications in the final working circuit.

The complete circuit was then tested by use of function generators, word generators and

oscilloscopes. The word generators and function generators simulates the computer

output and the oscilloscope was able to display the circuit output behavior when an input

from the word generators was registered. The relays that were to switch high voltage

devices by use of the low voltage output from the circuit also worked as expected. The

circuit worked as expected.

5.1.1 Burn-in test A burn in test is simply done by leaving the circuit powered on for over 24 hrs to see if

any of the circuit components give in to fatigue. Fatigue can be caused by over or under

voltage/ current, overheating due to improper connection, poor soldering, hysterisis etc.

The circuit was left powered on for more than 24 hours with constant monitoring of the

temperature of the devices. All the components did not overheat except for the step

down transformer that was quite hot even though the heat did not cause it to

malfunction. The possible reason why it was overheating was because of age. It was

purchased in 1990 and has severally been used in the electrical laboratories for practical

and other projects and in the process lost some efficiency due to mishandling. A solution

to the overheating transformer was to provide a suitable heat sink to dissipate the heat

especially when the circuit is supposed to be on 24 hours a day.

5.2 Program testing The program code, after being written in the Delphi programming interface, was run and

the result was that there were many syntax errors that were corrected by debugging the

program code.

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 68: Wireles Project

Chapter Five: Tests and Results

60

The web interface WebPages and PHP scripts were also loaded to the root directory set

in configuring the web server and accessed from a local web browser by typing

http://localhost on the address bar and the web server was able to server the index page

which contained the login prompt.

The program output to the port was tested by use of light emitting diodes (LED’s) that

lit when an output was registered in the port output pins. The program after several runs

and debugging sessions, ran as expected. For demonstration purposes in this project we

switch on a 240 Volt incandescent light bulb and a small DC fan. The light activation

circuit derives its trigger signals from pin 6 of the parallel port and the DC fan from pin 7

of the parallel port.

5.3 System testing The system is comprised of:

q The interface switching software (phone access, splash screen and database

access programs)

q The Web server

q The Database server

q The Interface circuit

q The Open Data Base Connectivity (ODBC) data access engine

q The switched devices (a light bulb and a DC fan)

Before running the program we have written, the following things were done in the order

in which they are listed:

q The local computer was connected to the halls of residence Local Area Network

(LAN) made up 18 computers in Hall 2

q While the computer is switched off and disconnected from power supply, the

interface circuit is connected to the PC through a parallel port printer cable and

the circuit is then powered

q The mobile phone is connected to the computer COM port (serial port) and

powered, any PIN numbers must be supplied to the phone if required before the

computer is booted

q The Xitami web server must be up and running

q The MySQL database server must be up and running

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 69: Wireles Project

Chapter Five: Tests and Results

61

After this the program was run from the local machine, the program alerted the use that

a phone had been detected at COM port 1 through a message box. The web server that

was running in the local machine was able to serve pages to all the LAN users. The LAN

was used to simulate the Internet environment on which the system is to run.

From any computer on the LAN, we were able to switch on/off the 240-volt light and

DC motor by accessing the user interface WebPage from a web browser and clicking

on/off the device to be switched.

5.3.1 Web control The user first logged in with the correct username and password. An attempt to use the

incorrect username and or password led to the user being denied permission to access

the control page from where the devices are controlled. After login in successfully, the

use selected to switch on the lights that were initially off. And when the user submitted

the information to the web server. After about one second, the lights went on. The use

then switched on the fan and the fan and the light were both on. The use then tried

switching off the lights leaving the fan on and the lights went off as expected leaving the

fan on. The fan was then switched off and now all the devices were off. The web

interface therefore worked without any problems.

5.3.2 Text message (SMS) control The next step was to test the system using the SMS interface control. The text message

setup consisted of the following

q A GSM cellular mobile phone

q Remote GSM cellular mobile phone connected to the remote PC through the

serial port (COM port)

q Software to read local mobile phone memory

q The interface circuit and devices to be switched (This is the same circuit used in

the web-based tests)

A short message text with the text string ‘lights on’ was sent from a phone to the phone

number of the phone connected to the computer. After about two seconds, the sent

message arrived at the recipient phone. The mobile phone access software we wrote was

able to read the received message and switch on the 240 volts bulb. After the bulb went

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 70: Wireles Project

Chapter Five: Tests and Results

62

on, the software sent a confirmation message through the phone connected to the

computer to the phone that originally sent the message. The confirmation message read

‘lights now on’. The software was able to switch on the light bulb because on receiving

the message, it form confirmed that the message came from a valid source and not any

other phone. It was able to do this by comparing the SMS sender number that is found

in the SMS header to the local preset number in the source code. To confirm that the

software only acted on valid SMS messages, we sent a message with the words ‘lights off’

from another unauthorized phone and the light bulb did not go off but when the same

message was sent from a valid phone, the lights went off.

5.3.3 Web then SMS text control A scenario was envisaged where by a user could switch on a device remotely over the

Internet and then loses the Internet connection through an outage. Would the use be

able to switch off the device using a SMS? Tests to simulate such a scenario were done

by login in to the web control interface, switching on the fan that went on as expected. A

message was the sent to the remote phone with the text ‘fan off’. After two seconds, the

message was received and the fan was turned off. This therefore meant that the two

modes of communications could be used to complement each other in cases where one

fails. This has the effect of greatly improving the system redundancy and hence reliability

is improved.

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 71: Wireles Project

Chapter Five: Tests and Results

63

Fig 5.0: The complete system layout

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 72: Wireles Project

Chapter Six: Cost Analysis

64

6 Chapter Six: Cost Analysis

6.1 Cost Analysis The design of any project is incomplete without a comprehensive cost analysis. The cost

analysis of a project can be categorized into two main areas [Lacy 1994]:

q System design and learning

q Return on investment

6.1.1 System learning and design The learning of a system involves the costs incurred while trying to learn it e.g. user

training. Brooks define user friendliness of a system in the following way: That a system

is user friendly if the cost incurred in learning the system is much lower than the benefits

got from using the system [Brooks et al 1994]. The system in this project uses common

user interfaces such as web pages, short message service text (SMS). Majority of users of

our system are already familiar with these interfaces and this means that little or no

training is needed for users to be able to use the system. From Brooks definition, the cost

of learning this system is lower compared to the benefits got.

The system in this project was designed and implemented using freeware (FREE

softWARE). These include:

q PHP Scripting language

q Xitami web server

q MySQL Database Server

q MyODBC connectivity engines

Borland Delphi 6.0 Enterprise edition, which was used in the programming, is not

freeware. The freeware, although free, we had to pay for the cost of downloading them

from the Internet, this cost is dependent on download speeds available at the time of

download.

The use of Commercial Off The Shelf (COTS) systems such as mobile phones also

helped in lowering the overall cost of the system. It would have been very costly to

deign our own mobile phone from scratch.

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 73: Wireles Project

Chapter Six: Cost Analysis

65

6.1.2 Return on Investment For any system to be adopted, it must have a good return on investment. For

demonstration purposes, we will use a two-year return on investment model for a system

that that is controlling a remote critical system such as an oilrig in southern Sudan via

Internet using a VSAT link17. This model is consistent with expected parameters for a

piece of critical remote equipment and uses approximate operational parameters from

the example presented. Following ISO standards, the table for cost analysis is show

below for our system. The currency used is in US dollars (USD):

Cost of Down Time USD/Hour $50 Downtime (without monitoring) Hrs/Year 168 $8,400 Downtime (with monitoring) Hrs/Year 24 $1,200 Cost of Service visit $150 Frequency of Service visit (No monitoring) Days 7 Frequency of Service visit (With monitoring) Days 14 Cost of Service (No monitoring) USD/Year $7,821 Cost of Service (With monitoring) USD/Year $3,910 Installation Cost $1,250 Monthly expense $130 Annual software license& maintenance $0 Cost Saving per year 1 $8,300 Cost Saving per year 2 $9,550 Total cost saving for the two years $17,850 Simple return on investment for the two years 1193.58% Table 6.0: Return on Investment Data for the Web-based/GSM remote monitoring system

The return on investment for the first two years is more than 1000%. The return is very

high because the upfront design and installation expenses are low this in turn produces a

very high return as per percentage of investment.

The next analysis compares the system we have designed with what is there on the

market that is non-web based or mobile phone controlled systems that heavily rely on

onsite control. This system yields a marginal simple return on investment for the first

two years.

17 The war and instability in this region would make remote oilrig monitoring and control a viable option to multinational oil companies as compared to sending staff there. This system would also find wide use in Iraq where insecurity has increased in the last few months

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 74: Wireles Project

Chapter Six: Cost Analysis

66

Cost of Down Time USD/Hour $50 Downtime (without monitoring) Hrs/Year 168 $8,400 Downtime (with monitoring) Hrs/Year 24 $1,200 Cost of Service visit $150 Frequency of Service visit (No monitoring) Days 7 Frequency of Service visit (With monitoring) Days 14 Cost of Service (No monitoring) USD/Year $7,821 Cost of Service (With monitoring) USD/Year $3,910 Installation Cost $7,500 Monthly expense $100 Annual software license& maintenance $2,000 Cost Saving per year 1 $2,410 Cost Saving per year 2 $7,910 Total cost saving for the two years $10,320 Simple return on investment for the two years 35.81% Table 6.1: Return on Investment Data for on-site control and monitoring system

Downtime is a general term used to describe a system that is out of control. In this oilrig

example, it may mean that the pump has stopped, in environmental applications; it could

refer to a process that is out of regulatory compliance. The oilrig example is such that

downtime alone justifies a complete monitoring and control system. In general, the

maintenance visit costs will more frequently dominate. In the case of actual deployment

of the system for example, a saving of 24 hours of downtime per year would yield a

payback of over 1000% during the first year alone.

6.1.3 To install or not? The decision of whether to install the system or not in any industrial setting can be

clouded in uncertainty of whether the system will make any cost saving or improve

productivity; we have simplified decision-making by the following steps:

q Compute the monthly cost savings if this system is implemented.

q Compute the monthly cost for the remote monitoring system.

q Subtract the monthly cost of the remote monitoring system fro the monthly

savings

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 75: Wireles Project

Chapter Six: Cost Analysis

67

q If the result is negative, do not proceed with installing the system.

q If the result is positive, compare the installation costs with the incremental cost

savings, the simplest method is to simply compare the savings over the first two

years to the upfront cost required. A slightly more advanced financial model can

discount the cost savings with an appropriate cost of capital for an organization.

The overall results in most cases would yield a positive result meaning that the cost

savings of deploying such a system in an industrial setting is very high.

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 76: Wireles Project

Chapter Seven: Conclusion and Recommendations

68

7 Chapter Seven: Conclusion and Recommendations

7.1 Conclusion Having designed implemented and tested the system; the local and global objectives were

all met as intended at the beginning of this project.

The project if implemented as desired could be applied in a variety of situations such as:

q Remote control of machines in a manufacturing setting the advantage of which is

lower operational costs due to improved efficiency, less human capital etc

q Operation of equipment and devices found in polluted environments such as

noise-polluted power plants could be controlled from far, nuclear power plants

could be controlled from far. Dusty mines and grinders, boilers, high-speed

machines could all be controlled from far.

q Control and monitoring of Oilrigs in war prone zones: it is worth noting that

most countries where there is oil, war is very common and insecurity to oilrig

staff is real.

q Telecommuting (working from home)

q Control of domestic appliances from a centralized place (the home PC or mobile

phone) could revolutionize lifestyles (On your way from work you could switch

on the water heating system in your house from your mobile phone right from

the middle of a traffic jam so that once you arrive in your house you take a hot

refreshing shower)

The recently concluded computer exposition by Technology Students’ Association (TSA)

also helped in the further refining and testing the system, during the exposition, the

system ran for two days being tested by the exposition guests.18 Questions were asked

that lead to further improvement of the system such as the general look of the web

interface.

The system performance was as expected although in a real-life setting where the system

works over the real Internet as opposed to a Local Area Network would introduce speed

bottlenecks, latency and these mean that the device response would not be as fast as

when the system is on a LAN.

18 The project also emerged as the best project in the exposition

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 77: Wireles Project

Chapter Seven: Conclusion and Recommendations

69

7.1.1 System limitations q The system cannot be used to control devices in real time especially in regions

where Internet bandwidth is a problem such as Kenya this is because of the time

delays present.

q Even if the system was real-time, its response is not instantaneous and cannot

therefore be used in high precision or high speed response systems such as

control of fast moving remote unmanned vehicles

q Due to the finite number of output pins (eight in number), not many devices can

be remotely controlled by this system.

q It can only be used in regions with Internet access and or GSM cellular network.

A VSAT solution would overcome the Internet connectivity problem whereas

the use of satellite phone would also overcome the problem of GSM coverage. A

good example of a worldwide satellite phone is Thuraya ™ satellite phones

7.1.2 Problems encountered The project was more challenging than we initially anticipated. Although we managed to

implement the project, the lack of circuit components in the lab led to a lot of

modifications in the circuit.

The lack of two public IP addresses (one for the web server and the other for the

database server) meant that the system could not be tested on the Internet per se but had

to be tested on a Local Area Network (LAN). The LAN in the electrical laboratory was

also malfunctioning and the test had to be done in the LAN found in the halls of

residence.

The program coding was also done in Delphi 6.0 that requires at least 128 MB RAM,

333Mhz CPU. We did it in a 64MB RAM, 233Mhz CPU making compiling the code

somehow slower.

Port access in the newer Windows NT based computers was a problem. In windows XP,

one has to be logged in with administrator privileges to be able to access any port-

connected device in this project.

7.2 Recommendations The project, although implemented and working as expected, can do with several

improvements such as:

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 78: Wireles Project

Chapter Seven: Conclusion and Recommendations

70

q Use of multiple cascaded demultiplexers to switch more devices using the finite

number of output pins.

q The use CMOS based components as opposed to TTL based would make the

response time of the circuit faster especially for speed critical switching.

q The cost of the whole project would be much lower if the system is mass-

produced.

q The Use of Programmable Logic Controllers (PLCs) would eliminate the need

for having a dedicated personal computer at the remote end.

All in all the project worked as expected and was great success to see that we achieved

95% of our objectives.

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 79: Wireles Project

Bibliography

71

8 Bibliography [Bellovin 1991] S.M. Bellovin, Security Problems in the TCP/IP Protocol Suite.

Computer Communication Review, Vol. 19, No. 2, April 1991. pp. 32-48

[Canuteson 2003] Canuteson, E. “Wireless Web-Native monitoring and Control”,

IEE Journal of Computing and Control Engineering, August/September 2003, pp. 22-23.

[Carney 1999] Carney, D. “Requirements and COTS-Based Systems: A Thorny

Question Indeed,” http://interactive.sei.cmu.edu/news@sei/columns/the_cots_spot/cots-spot.htm

[CCK 1999] http://www.cck.go.ke/ Policy and Regulations WebPages.

[Dawes 2000] Dawes C, Thomas B. (2000) OCP: Oracle8i™ DBA SQL and

PL/SQL Study Guide Sybex Inc. Alameda [Eberspächer 1999] Jörg Eberspächer, Hans-Jörg Vögel, Christian Bettstetter (1999)

GSM switching, services, and protocols.—2nd ed.John Willey and Sons, New York

[Gozalvez 2000] Gozalvez, J. S (2000) An Overview of the GSM System, John-Willey

and Sons, New York [Held et. al. 1994] Held, C. et al. (1994), An introduction to Embedded Systems, McGraw-

Hill, New York. [Lacy 1994] Lacy, A. J. (1994), Systems Engineering Management, McGraw-Hill,

New York [Morris 1995] R.T. Morris, (1995.) A Weakness in the 4.2BSD Unix TCP/IP

Software, Computing Science Technical Report No. 117, AT&T Bell Laboratories, Murray Hill, New Jersey.

[Moskowitz 1991 ] R. Moskowitz, Y. Rekhter, , D. Karrenberg, G. de Groot, E. Lear,

‘Address Allocation for Private Internets.’ RFC 1918. [Segal 1998] Segal B, (1998) A Short History of Internet Protocols at CERN, World

Wide Web Consortium, Atlanta. [Theraja & Theraja] Theraja, B.L, Theraja A.K, (1999) A Textbook of Electrical

Technology, S. Gupta & sons publishers, New Delhi [UUNET 2004] http://www.uunet.co.ke Newsletter WebPage.

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 80: Wireles Project

Bibliography

72

[Wacks 1997] Wacks, K. (1997), Home Automation and Utility Customer Services, Aspen publishers, Cambridge Massachusetts

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 81: Wireles Project

Appendix

73

9 Appendix

9.1 Appendix I The program interfaces

The main login and control page as viewed from a web browser on the LAN/Internet

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 82: Wireles Project

Appendix

74

The Program Splash screen

The Database login prompt

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 83: Wireles Project

Appendix

75

The exception-handling page

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 84: Wireles Project

Appendix

76

The Remote PC interface which has access to the www. The panel on the right shows the device status; currently the gate is open as indicated by the light green icon. This interface also read the phone memory in the background.

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 85: Wireles Project

Appendix

77

The web based device History page

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 86: Wireles Project

Appendix

78

9.2 Appendix II The main Initialization program that calls the other units program Rock; uses Forms, Mainfrm in 'Mainfrm.pas' {RockForm}, DMfrm in 'DMfrm.pas' {DM: TDataModule}, Aboutfrm in 'Aboutfrm.pas' {AboutForm}, UnitD in 'UnitD.pas' {PhoneForm}; PassDlg in 'PassDlg.pas' {PasswordDlg} ; {$R *.RES} Var Splash : TAboutForm; begin Application.Initialize; Splash:=TAboutForm.Create(Nil); Splash.OKBtn.Visible :=False; Splash.Show; Splash.Update ; Application.Title:='Remote Web-Based Control Interface'; Application.CreateForm(TRockForm, RockForm); Application.CreateForm(TPasswordDlg, PasswordDlg); Application.CreateForm(TDM, DM); Application.CreateForm(TAboutForm, AboutForm); Splash.Hide; Splash.Free; Application.Run; end.

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 87: Wireles Project

Appendix

79

9.3 Appendix II The Main Database and port access unit unit Mainfrm; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, Db, ADODB, ExtCtrls, DBCtrls, Grids, DBGrids, Menus, ComCtrls, OleCtrls, SHDocVw, ImgList, StdCtrls, Buttons, AgentObjects_TLB; type TRockForm = class(TForm) Timer1: TTimer; MainMenu1: TMainMenu; File1: TMenuItem; Open1: TMenuItem; N1: TMenuItem; Exit1: TMenuItem; PageMan: TPageControl; DataSheet: TTabSheet; BrowserSheet: TTabSheet; ToolBar: TPanel; DBGrid1: TDBGrid; ImageList1: TImageList; SBar: TStatusBar; SpeedButton1: TSpeedButton; Help1: TMenuItem; About1: TMenuItem; View1: TMenuItem; Data1: TMenuItem; Browser1: TMenuItem; PBar2: TProgressBar; Panel3: TPanel; GroupBox2: TGroupBox; Panel1: TPanel; SpeedButton2: TSpeedButton; SpeedButton3: TSpeedButton; Label1: TLabel; URLCombo: TComboBox; Panel4: TPanel; Browser: TWebBrowser; DBNavigator1: TDBNavigator; Agent1: TAgent;

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 88: Wireles Project

Appendix

80

Timer2: TTimer; SpeedButton4: TSpeedButton; GroupBox1: TGroupBox; DeviceList: TTreeView; StatusPanel: TPanel; Splitter1: TSplitter; SpeedButton5: TSpeedButton; PhoneModule1: TMenuItem; Edit1: TEdit; procedure Timer1Timer(Sender: TObject); procedure Exit1Click(Sender: TObject); procedure BrowserSheetShow(Sender: TObject); procedure FormActivate(Sender: TObject); procedure SpeedButton1Click(Sender: TObject); procedure About1Click(Sender: TObject); procedure Data1Click(Sender: TObject); procedure Browser1Click(Sender: TObject); procedure SpeedButton2Click(Sender: TObject); procedure SpeedButton3Click(Sender: TObject); procedure URLComboKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure URLComboClick(Sender: TObject); procedure Agent1DblClick(Sender: TObject; const CharacterID: WideString; Button, Shift, x, y: Smallint); procedure FormCreate(Sender: TObject); procedure Timer2Timer(Sender: TObject); procedure SpeedButton4Click(Sender: TObject); procedure PhoneModule1Click(Sender: TObject); procedure Edit1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); private { Private declarations } Function CheckUpdate:Boolean; Procedure WritePort(PortNo:Word;Data:Byte); Function ReadPort(PortNo:Word):Word; Procedure Delay(Ms: Real); public { Public declarations } GateOpen : Boolean; Procedure UpdateDevs; Procedure UpdateList; Procedure PhoneUpdate(InMsg,Source : String); Procedure DOQry(Qry : String);

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 89: Wireles Project

Appendix

81

end; Const LPT1:Word = $378; Const FData: Array [0..3] Of Byte = (1,2,4,8); Const RData: Array [0..3] Of Byte = (2,1,8,4); Const ComArray : Array [1..4] Of String = ('LIGHTS ON','LIGHTS OFF','FAN ON','FAN OFF'); var RockForm: TRockForm; PortStatus : Word; Genie: IAgentCtlCharacter ; implementation uses DMfrm, Aboutfrm, UnitD; {$R *.DFM} Procedure TRockForm.DoIntro; Begin End; Procedure TRockForm.Delay(Ms:Real); Var Time1,CurrTime: Double; Del : Real; Begin Time1:=Now; //CurrTime:=Time1; Del := Ms/(24*60*60*1000); //Label1->Caption = FloatToStr(Del); Repeat CurrTime:=Now; Application.ProcessMessages; Until ( CurrTime >= Time1+Del); End;

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 90: Wireles Project

Appendix

82

Procedure TRockForm.UpdateDevs; Var I : Integer; PortData: Integer; Begin For I:= 0 To DM.RockQry.RecordCount Do Begin PortData:=0; If DM.RockQry.Fields[3].AsString = 'On' Then PortData:=(PortData Or 16); If DM.RockQry.Fields[6].AsString = 'On' Then PortData:=(PortData Or 32); SendData(LPT1,16) WritePort(LPT1,PortData); End; Function TRockForm.ReadPort(PortNo:Word):Word; Var PortStat : Word; Begin PortStat:=PortNo+1; Asm Mov Dx,PortStat In Ax,Dx Mov PortStatus,Ax End ; Result:=PortStatus; End; Procedure TRockForm.WritePort(PortNo:Word;Data:Byte); Begin Asm Mov Dx, PortNo Mov Al, Data Out Dx, Al End

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 91: Wireles Project

Appendix

83

End; Procedure TRockForm.UpdateList; Var I :Integer; Begin If DM.RockQry.RecordCount > 0 Then Begin DM.RockQry.Last ; For I:= 1 To 8 Do Begin If DM.RockQry.Fields[I].AsString = 'On' Then Begin DeviceList.Items[I-1].ImageIndex := 1; DeviceList.Items[I-1].SelectedIndex := 1; End Else Begin DeviceList.Items[I-1].ImageIndex := 0; DeviceList.Items[I-1].SelectedIndex := 0; End; End; DeviceList.Refresh ; DeviceList.Update ; DeviceList.Invalidate; End; End; Function TRockForm.CheckUpdate:Boolean; Var Cnt1,Cnt2:Integer; Begin

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 92: Wireles Project

Appendix

84

Cnt1:=DM.SnoopTable.Recordset.RecordCount ; DM.SnoopTable.Close; DM.SnoopTable.Open; Cnt2:=DM.SnoopTable.Recordset.RecordCount ; Result:= (Cnt2 <> Cnt1); End; procedure TRockForm.Timer1Timer(Sender: TObject); begin If RockForm.Visible Then If CheckUpdate Then Try DM.RockQry.Close; DM.RockQry.Open; UpdateList; UpDateDevs; Except ShowMessage('Data Refresh Error. Please Troubleshoot Extensions.'); End; end; procedure TRockForm.Exit1Click(Sender: TObject); begin Close; end; procedure TRockForm.BrowserSheetShow(Sender: TObject); begin Browser.Navigate('Http://localhost/ '); end; Procedure TRockForm.PhoneUpdate(InMsg,Source : String); Var Devs : Array [1..8] Of String; I: Integer; Index : Integer; Flag : Boolean; Begin InMsg:= UpperCase(Trim(InMsg)); If InMsg=ComArray[1] Then

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 93: Wireles Project

Appendix

85

Begin Index:=3; Flag:=True; End Else If InMsg=ComArray[2] Then Begin Index:=3; Flag:=False; End Else If InMsg=ComArray[3] Then Begin Index:=6; Flag:=True; End Else If InMsg=ComArray[4] Then Begin Index:=6; Flag:=False; End Else Begin ShowMessage('Invalid Command : ' + InMsg); Exit; End; DM.RockQry.Last; For I:=1 To 8 Do Begin Devs[I]:= DM.RockQry.Fields[I].AsString; End; If Flag Then Devs[Index] := 'On' Else Devs[Index] := 'Off'; With DM.TempTable Do Begin Open; Insert; For I:=1 To 8 Do Fields[I].AsString := Devs[I]; Fields[9].AsDateTime:=Now; Post;

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 94: Wireles Project

Appendix

86

End; DOQry(Qry); SBar.SimpleText :='Phone Update . . .'; PhoneForm.SendTextE.Text := InMsg; PhoneForm.SendToE.Text := Source; PhoneForm.SendMsgBtnClick(Self); End; Procedure TRockForm.DOQry(Qry : String); Var TempQry: TStringlist; Begin With DM.RockQry Do Begin TempQry := TStringList.Create ; TempQry.Assign(SQL); SQL.Clear; SQL.Add(Qry); Close; ShowMessage(SQL.Commatext); ExecSQL; Close; SQL := TempQry; Open; End; End; procedure TRockForm.SpeedButton1Click(Sender: TObject); Var TempQry: TStringlist; begin TempQry := TStringList.Create ; TempQry.Assign(DM.RockQry.SQL); DM.RockQry.SQL.Clear; DM.RockQry.SQL.Add('Delete From master'); DM.RockQry.Close;

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 95: Wireles Project

Appendix

87

DM.RockQry.ExecSQL; DM.RockQry.Close; DM.RockQry.SQL := TempQry; DM.RockQry.Open; end; procedure TRockForm.About1Click(Sender: TObject); begin AboutForm.ShowModal; end; procedure TRockForm.Data1Click(Sender: TObject); begin PageMan.ActivePage:=DataSheet; end; procedure TRockForm.Browser1Click(Sender: TObject); begin PageMan.ActivePage:=BrowserSheet; end; procedure TRockForm.SpeedButton2Click(Sender: TObject); begin Try Browser.GoBack Except End; end; procedure TRockForm.SpeedButton3Click(Sender: TObject); begin Try Browser.GoForward Except End; end; procedure TRockForm.URLComboKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin Case Key Of VK_RETURN: Begin URLCombo.Items.Add(URLCOmbo.Text);

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 96: Wireles Project

Appendix

88

Browser.Navigate(URLCombo.Text); End; End; end; procedure TRockForm.URLComboClick(Sender: TObject); begin Browser.Navigate(URLCombo.Text); end; procedure TRockForm.FormCreate(Sender: TObject); begin PageMan.ActivePage := BrowserSheet; end; procedure TRockForm.Timer2Timer(Sender: TObject); begin StatusPanel.Caption := Format('Status : %d',[ReadPort(LPT1)]); end; procedure TRockForm.SpeedButton4Click(Sender: TObject); begin PhoneUpDate(Edit1.Text,'+254721460438'); end; procedure TRockForm.PhoneModule1Click(Sender: TObject); begin PhoneModule1.Checked := Not PhoneModule1.Checked; PhoneForm.Visible:= PhoneModule1.Checked ; end; procedure TRockForm.Edit1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 97: Wireles Project

Appendix

89

Case Key Of VK_Return : PhoneUpDate(Edit1.Text,'+254721460438'); End; end; end.

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 98: Wireles Project

Appendix

90

9.4 Appendix III The minor Database access unit unit DMfrm; interface uses Windows, Messages, Db, ADODB, Classes,SysUtils, Graphics, Controls, Forms, Dialogs ; type TDM = class(TDataModule) RockSource: TDataSource; Rock: TADOConnection; SnoopTable: TADOTable; RockQry: TADOQuery; procedure RockSourceDataChange(Sender: TObject; Field: TField); procedure DataModuleCreate(Sender: TObject); procedure RockWillConnect(Connection: TADOConnection; var ConnectionString, UserID, Password: WideString; var ConnectOptions: TConnectOption; var EventStatus: TEventStatus); procedure RockAfterConnect(Sender: TObject); procedure RockQryAfterOpen(DataSet: TDataSet); private { Private declarations } public { Public declarations } end; var DM: TDM; implementation uses Mainfrm, PassDlg; {$R *.DFM} procedure TDM.RockSourceDataChange(Sender: TObject; Field: TField); begin RockForm.UpdateList; RockForm.UpdateDevs;

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 99: Wireles Project

Appendix

91

end; procedure TDM.DataModuleCreate(Sender: TObject); begin Rock.Open ; end; procedure TDM.RockWillConnect(Connection: TADOConnection; var ConnectionString, UserID, Password: WideString; var ConnectOptions: TConnectOption; var EventStatus: TEventStatus); begin UserID:=''; Password:=''; If PasswordDlg.ShowModal=mrOK Then Begin UserID:=PasswordDlg.UserName.Text; Password:=PasswordDlg.Password.Text; End Else Begin ShowMessage('Database Login Aborted !'); Abort; End; end; procedure TDM.RockAfterConnect(Sender: TObject); begin SnoopTable.Open ; RockQry.Open ; RockForm.Timer1.Enabled:=True; end; procedure TDM.RockQryAfterOpen(DataSet: TDataSet); begin end.

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 100: Wireles Project

Appendix

92

9.5 Appendix IV The login prompt source code unit PassDlg; interface uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls, Buttons, ExtCtrls,Dialogs,Registry; type TPasswordDlg = class(TForm) GroupBox1: TGroupBox; Label2: TLabel; Password: TEdit; Label1: TLabel; BitBtn1: TBitBtn; BitBtn2: TBitBtn; Panel1: TPanel; Label3: TLabel; Label4: TLabel; UserName: TEdit; Role: TEdit; procedure FormActivate(Sender: TObject); procedure UserNameChange(Sender: TObject); private { Private declarations } public Procedure GetLastUser; Procedure LoadUsers; { Public declarations } end; Const RegKey : AnsiString = '%\windows\system 32\; var PasswordDlg: TPasswordDlg; Reg:TRegistry; Vals: TStringlist; implementation {$R *.DFM} Procedure TPasswordDlg.GetLastUser; Begin

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 101: Wireles Project

Appendix

93

Reg:=TRegistry.Create ; Try Reg.RootKey:=HKEY_LOCAL_MACHINE; // Section to look for within the registry Reg.OpenKey(RegKey,True); UserName.Text := Reg.ReadString('LastUser'); Role.Text := Reg.ReadString('LastRole'); Finally Reg.CloseKey ; Reg.Free ; End; End; procedure TPasswordDlg.FormActivate(Sender: TObject); Begin GetLastUser; UserName.Text :='root'; Password.Text:=''; Password.SetFocus; End; Procedure TPasswordDlg.UserNameChange(Sender: TObject); Begin If Trim(UserName.Text) = 'SYSDBA' Then Role.Enabled := False Else Role.Enabled := True; End; End.

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 102: Wireles Project

Appendix

94

9.6 Appendix V The splash screen source code unit Aboutfrm; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls, Buttons,Shellapi, Menus,shlobj, jpeg,Registry; type TAboutForm = class(TForm) Panel1: TPanel; OKBtn: TBitBtn; Label1: TLabel; Label3: TLabel; Label8: TLabel; Timer1: TTimer; AppTitle: TLabel; Label2: TLabel; UserLabel: TLabel; CompLabel: TLabel; Label5: TLabel; Bevel1: TBevel; Image1: TImage; Label4: TLabel; Label10: TLabel; Image2: TImage; BugProof: TLabel; Mail: TLabel; procedure Timer1Timer(Sender: TObject); procedure FormActivate(Sender: TObject); procedure BugProofClick(Sender: TObject); procedure MailClick(Sender: TObject); private { Private declarations } public { Public declarations } Procedure Delay(Ms:Integer); end;

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 103: Wireles Project

Appendix

95

Var AboutForm: TAboutForm; Reg:TRegistry; Implementation {$R *.DFM} Procedure TAboutForm.Delay (Ms:Integer); Begin Timer1.Tag:=0; Timer1.Enabled :=True; Repeat Application.ProcessMessages; Until Timer1.Tag >= Ms; Timer1.Enabled :=False; End; procedure TAboutForm.Timer1Timer(Sender: TObject); begin Timer1.Tag := Timer1.Tag +Timer1.Interval ; end; procedure TAboutForm.FormActivate(Sender: TObject); Var I,J: Integer; Tempo:AnsiString; Begin Tempo:=AppTitle.Caption ; AppTitle.Caption :=''; J:=Length(Tempo); For I:=1 To J Do Begin AppTitle.Caption :=AppTitle.Caption + String(Tempo[I]); ShowMessage(AppLabel.Caption); Application.ProcessMessages; Delay(50); End; end; procedure TAboutForm.BugProofClick(Sender: TObject); begin ShellExecute(Handle,'Open','mailto:[email protected]',Nil,Nil,SW_SHOWMAXIMIZED);

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 104: Wireles Project

Appendix

96

end; procedure TAboutForm.MailClick(Sender: TObject); begin ShellExecute(Handle,'Open','mailto:[email protected]',Nil,Nil,SW_SHOWMAXIMIZED); end; end.

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 105: Wireles Project

Appendix

97

9.7 Appendix VI Phone access source code unit UnitD; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, Jpeg, ExtDlgs, Buttons, Spin, ComCtrls, ExtCtrls, Grids, SMSComp, StdCtrls, Menus, FileCtrl; type TPhoneForm = class(TForm) StBar: TStatusBar; GBox1: TGroupBox; PhoneML: TLabel; PhoneMCB: TComboBox; PortL: TLabel; PortE: TSpinEdit; ConnTypeL: TLabel; ConnTCB: TComboBox; ConnBtn: TButton; DisConnBtn: TButton; GBox2: TGroupBox; GetInbox_Btn: TButton; MsgNumCB: TComboBox; TotalL: TLabel; TotalMsgL: TLabel; BusyL: TLabel; BusyMsgL: TLabel; CurMsgL: TLabel; TextL: TLabel; MsgTextL: TLabel; TimeL: TLabel; MsgTimeL: TLabel; FromL: TLabel; MsgFromL: TLabel; PictureL: TLabel; Image1: TImage; NoPictureL: TLabel; Bevel1: TBevel; DelMsg_Btn: TButton; ReadMsg_Btn: TButton; GBox3: TGroupBox;

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 106: Wireles Project

Appendix

98

SendToL: TLabel; SendTextL: TLabel; SendValidL: TLabel; NRepChB: TCheckBox; UnicodeChB: TCheckBox; SendMsgBtn: TButton; SendToE: TEdit; SendTextE: TEdit; SendValidE: TSpinEdit; GBox4: TGroupBox; MsgGrid: TStringGrid; OPD1: TOpenPictureDialog; Picture_Btn: TSpeedButton; Bevel2: TBevel; Label3: TLabel; Label4: TLabel; Label6: TLabel; Label7: TLabel; Label1: TLabel; Label2: TLabel; Label5: TLabel; Button7: TButton; Label8: TLabel; SPD: TSavePictureDialog; SpeedButton1: TSpeedButton; SendSendL: TLabel; MSGTypeCB: TComboBox; SendSMSCL: TLabel; SendSMSCE: TEdit; SendMCCL: TLabel; SendMNCL: TLabel; MCCE: TSpinEdit; MNCE: TSpinEdit; procedure FormCreate(Sender: TObject); procedure ConnBtnClick(Sender: TObject); procedure DisConnBtnClick(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure SMSRepReceived(Index: Integer; Time: TDateTime; Send: String; Delivery:integer); procedure SMSMSGReceived(Index: Integer; Time: TDateTime;Text, Send: String; Pict: TBitmap); procedure ReadMsg_BtnClick(Sender: TObject); procedure DelMsg_BtnClick(Sender: TObject); procedure GetInbox_BtnClick(Sender: TObject); procedure SendMsgBtnClick(Sender: TObject); procedure Button7Click(Sender: TObject);

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 107: Wireles Project

Appendix

99

procedure ConnTCBChange(Sender: TObject); procedure PortEChange(Sender: TObject); procedure MsgNumCBChange(Sender: TObject); procedure PhoneMCBChange(Sender: TObject); procedure ConnState(st: boolean); procedure Clear1Click(Sender: TObject); procedure MsgGridClick(Sender: TObject); procedure LoadMessage(location : integer); procedure Image1DblClick(Sender: TObject); procedure Picture_BtnClick(Sender: TObject); procedure SpeedButton1Click(Sender: TObject); procedure MSGTypeCBChange(Sender: TObject); private { Private declarations } public { Public declarations } end; var PhoneForm: TPhoneForm; SMS1: TOxygenSMS; FldNum: integer; Numbers: TStringList; SendPic : TBitmap; BMPPath : string; implementation uses Mainfrm; {$R *.DFM} procedure TPhoneForm.LoadMessage(location : integer); var IsMsg: WordBool; Time: TDateTime; Text, Send : string; Deliv: integer; Pict : TBitmap; begin if SMS1.ReadSMSMessage(Location, isMsg, Time, Text, Send, Deliv, Pict) then begin MsgTimeL.caption := DateTimeToStr(Time); if isMsg then MsgTextL.caption := Text else MsgTextL.caption := IntTostr(Deliv); MsgFromL.caption := send;

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 108: Wireles Project

Appendix

100

if Pict <> nil then Image1.Picture.Assign(Pict) else Image1.visible := false; end else begin MsgTimeL.caption := ''; MsgTextL.caption := ''; MsgFromL.caption := ''; Image1.visible := false; ShowMessage('Slot is empty'); end; end; procedure TPhoneForm.ConnState(st: boolean); begin PhoneMCB.Enabled := not st; PortE.enabled := not st; ConnTCB.Enabled := not st; end; procedure TPhoneForm.FormCreate(Sender: TObject); begin SMS1 := TOxygenSMS.create(self); with SMS1 do begin top := 10; left := 10; //ComNumber := 2; ComNumber := StrToInt(PortE.text); Model := 0; ConnectionMode := 0; OnSMSReportReceived := SMSRepReceived; OnSMSMessageReceived := SMSMsgReceived; AutoDeleteMessages := False; AutoDeleteReports := False; Try ConnBtnClick(Self); Except End; end; Numbers := TStringList.Create; PhoneMCB.ItemIndex := 0; // ConnTCB.ItemIndex := 0; with MsgGrid do begin

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 109: Wireles Project

Appendix

101

Cells[0,0] := 'Type'; Cells[1,0] := 'Location'; Cells[2,0] := 'From'; Cells[3,0] := 'Time'; Cells[4,0] := 'Text'; Cells[5,0] := 'Picture'; end; ConnState(false); SendPic := nil; BMPPath := ExtractFileDir(Application.ExeName)+ '\bmp\'; if not DirectoryExists(BMPPath) then CreateDir(BMPPath); end; procedure TPhoneForm.ConnBtnClick(Sender: TObject); begin SMS1.Close; if SMS1.Open = true then begin StBar.Panels[0].text := 'Connected'; StBar.Panels[1].text := 'Phone type: ' + sms1.PhoneType; StBar.Panels[2].text := 'IMEI: ' + SMS1.Imei; // ConnState(true); end else ShowMessage('FAILED'); end; procedure TPhoneForm.DisConnBtnClick(Sender: TObject); begin SMS1.Close; StBar.Panels[0].text := 'Not Connected'; StBar.Panels[1].text := 'Phone type: none'; StBar.Panels[2].text := 'IMEI:'; // ConnState(false); end; procedure TPhoneForm.FormClose(Sender: TObject; var Action: TCloseAction); begin SMS1.Close; SMS1.Free; Numbers.Free; RemoveDir(BMPPath); end;

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 110: Wireles Project

Appendix

102

procedure TPhoneForm.SMSRepReceived(Index: Integer; Time: TDateTime; Send: String; Delivery: integer); begin with MsgGrid do begin Cells[0,RowCount-1] := 'REP'; Cells[1,RowCount-1] := IntToStr(Index); Cells[2,RowCount-1] := Send; Cells[3,RowCount-1] := DateTimeToStr(Time); Cells[4,RowCount-1] := IntToStr(Delivery); RowCount := RowCount + 1; MsgNumCB.Items.Add(IntTostr(Index)); BusyMsgL.Caption := IntToStr(MsgNumCB.Items.count); end; StBar.Panels[3].text := 'Report arrived'; end; procedure TPhoneForm.SMSMSGReceived(Index: Integer; Time: TDateTime; Text, Send: String; Pict: TBitMap); begin with MsgGrid do begin Cells[0,RowCount-1] := 'MSG'; Cells[1,RowCount-1] := IntToStr(Index); Cells[2,RowCount-1] := Send; Cells[3,RowCount-1] := DateTimeToStr(Time); Cells[4,RowCount-1] := Text; If Pos('Balance',Text)<>0 Then Begin RockForm.PhoneUpdate(Text,Send); End Else Begin RockForm.PhoneUpdate(False,3); End; if Pict <> nil then begin Cells[5,RowCount-1] := 'Picture'; Pict.SaveToFile(BMPPath + IntToStr(RowCount-1)+ '.bmp'); end; RowCount := RowCount + 1; if Index <> 0 then

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 111: Wireles Project

Appendix

103

begin MsgNumCB.Items.Add(IntTostr(Index)); BusyMsgL.Caption := IntToStr(MsgNumCB.Items.count); end end; StBar.Panels[3].text := 'Message arrived'; end; procedure TPhoneForm.ReadMsg_BtnClick(Sender: TObject); begin LoadMessage(StrToInt(MsgNumCB.text)); end; procedure TPhoneForm.DelMsg_BtnClick(Sender: TObject); var s : string; i : integer; begin try if SMS1.DeleteSMSMessage(StrToInt(MsgNumCB.text)) then begin MsgNumCB.Items.Delete(MsgNumCB.ItemIndex); StBar.Panels[3].text := 'Message deleted'; s := BusyMsgL.Caption; i := StrToInt(s); if i > 0 then begin Dec(i); s := IntToStr(i); BusyMsgL.Caption := s; end; MsgNumCB.text := ''; end else StBar.Panels[3].text := 'Message NOT deleted'; except end; end; procedure TPhoneForm.GetInbox_BtnClick(Sender: TObject); var count, busy : integer; Locations : string; begin GetInbox_Btn.Enabled := false; SMS1.GetInboxInfo(Count, Busy, Locations); TotalMsgL.Caption := IntToStr(Count); BusyMsgL.Caption := IntToStr(Busy); MsgNumCB.Clear;

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 112: Wireles Project

Appendix

104

MsgNumCB.Items.CommaText := Locations; if MsgNumCB.Items.Count > 0 then begin MsgNumCB.ItemIndex := 0; MsgNumCBChange(Self); end; GetInbox_Btn.Enabled := true; end; procedure TPhoneForm.SendMsgBtnClick(Sender: TObject); var Res : boolean; begin if SendSMSCE.text <> '' then SMS1.SetSMSCNumber(SendSMSCE.text); StBar.Panels[3].text := 'Sending message...'; Case MsgTypeCB.ItemIndex of 0: Res := sms1.SendSMSMessage(SendToE.text, SendtextE.text, StrToInt(SendValidE.text), NRepChB.Checked, UnicodeChB.Checked, nil); 1: Res := sms1.SendUnicodeSMSMessage(SendToE.text, SendtextE.text, StrToInt(SendValidE.text), NRepChB.Checked, nil); 2: Res := sms1.SendSMSMessage(SendToE.text, SendtextE.text, StrToInt(SendValidE.text), NRepChB.Checked, UnicodeChB.Checked, SendPic); 3: if sms1.CheckRTTTL(SendtextE.text) = 0 then Res := sms1.SendRingtone(SendToE.text, SendtextE.text, StrToInt(SendValidE.text), NRepChB.Checked) else Res := false; 4: Res := sms1.SendOperatorLogo(SendToE.text, MCCE.Value, MNCE.Value, StrToInt(SendValidE.text), NRepChB.Checked, SendPic); 5: Res := sms1.SendCLILogo(SendToE.text, StrToInt(SendValidE.text), NRepChB.Checked, SendPic); 6: Res := sms1.SendFlashMessage(SendToE.text, SendTextE.text, StrToInt(SendValidE.text),NRepChB.checked); Else Res := false; end; if Res then StBar.Panels[3].text := 'Message sent' else StBar.Panels[3].text := 'Message NOT sent'; end; procedure TPhoneForm.Button7Click(Sender: TObject); begin

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 113: Wireles Project

Appendix

105

if SMS1.CheckConnection then begin Label1.Caption := 'State: ' + IntToStr(SMS1.State); Label2.Caption := 'SMSC: ' + SMS1.getsmscnumber; Label3.Caption := 'Signal: ' + IntToStr(SMS1.SignalLevel); Label4.Caption := 'Battery: ' + IntToStr(SMS1.BatteryLevel); Label5.Caption := 'HardWare: ' + SMS1.HW; Label6.Caption := 'Software: ' + SMS1.SW; Label7.Caption := 'SWDate: ' + SMS1.SWDate; StBar.Panels[0].text := 'Connected'; end else StBar.Panels[0].text := 'Not Connected'; end; procedure TPhoneForm.ConnTCBChange(Sender: TObject); begin SMS1.ConnectionMode := ConnTCB.ItemIndex; end; procedure TPhoneForm.PortEChange(Sender: TObject); begin SMS1.ComNumber := StrToInt(PortE.text); end; procedure TPhoneForm.MsgNumCBChange(Sender: TObject); begin if MsgNumCB.text <> '' then LoadMessage(StrToInt(MsgNumCB.text)); end; procedure TPhoneForm.PhoneMCBChange(Sender: TObject); begin // SMS1.Model := PhoneMCB.ItemIndex; end; procedure TPhoneForm.Clear1Click(Sender: TObject); begin

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 114: Wireles Project

Appendix

106

SendPic := nil; Picture_btn.Glyph.Assign(nil); end; procedure TPhoneForm.MsgGridClick(Sender: TObject); begin with MsgGrid do if Row <> RowCount-1 then case StrToInt(Cells[1, Row]) of 0: begin MsgFromL.caption := Cells[2, Row]; MsgTimeL.caption := Cells[3, Row]; MsgTextL.caption := Cells[4, Row]; try Image1.Picture.LoadFromFile(BMPPath + IntToStr(Row) + '.bmp'); Image1.visible := true; except Image1.visible := false; end; end; else begin MsgNumCB.itemindex := MsgNumCB.Items.IndexOf(Cells[1, Row]); LoadMessage(StrToInt(Cells[1, Row])); Image1.visible := false; end; end; end; procedure TPhoneForm.Image1DblClick(Sender: TObject); begin if SPD.Execute then Image1.Picture.SaveToFile(SPD.filename); end; procedure TPhoneForm.Picture_BtnClick(Sender: TObject); begin if OPD1.Execute then begin Picture_btn.Caption := ''; Picture_btn.Glyph.LoadFromFile(OPD1.FileName); SendPic := Picture_btn.Glyph; SendPic.width := 72; SendPic.height := 28; SendPic.height := 14;

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 115: Wireles Project

Appendix

107

end; end; procedure TPhoneForm.SpeedButton1Click(Sender: TObject); begin SendPic := nil; Picture_btn.Glyph.Assign(nil); Picture_btn.Caption := 'No picture' end; procedure TPhoneForm.MSGTypeCBChange(Sender: TObject); begin if MSGTypeCB.ItemIndex = 4 then begin MCCE.Enabled := true; MNCE.Enabled := true; end else begin MCCE.Enabled := false; MNCE.Enabled := false; end; end; end.

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 116: Wireles Project

Appendix

108

9.8 Appendix VII PHP scripts

1. Database connection PHP Script <? function db_connect($UserName,$Password) { $dbcon = @mysql_connect('localhost', $UserName, $Password); if (!$dbcon) return false; if (! @mysql_select_db("rock") ) return false; return $dbcon; } ?>

2. PHP script to get data from database to web browser <?php require_once("dbcon.php"); $dbcnx = db_connect('php','phpman'); if (!$dbcnx) { echo( "<P>Unable to connect to the " . "database server at this time.</P>" ); exit(); } $ourqry="SELECT * FROM Master"; $Result =mysql_query($ourqry); $rowcnt=mysql_num_rows($Result); $fldcnt=mysql_num_fields($Result); printf("<center><h3>Device History </h3></center>"); echo "<table border=1 align='center'>"; for ($k=0 ;$k < $fldcnt; $k++) {

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 117: Wireles Project

Appendix

109

printf("<th> %s </th>",mysql_fieldname($Result,$k)); } for ($i=0; $i < $rowcnt ;$i++) { if($i % 2) { $RowCol='#ccccdd'; } else{ $RowCol='#ddcccc'; } printf("<tr bgcolor=$RowCol>"); $Dat=mysql_fetch_row($Result); for ($j=0; $j < $fldcnt; $j++) { printf(" <td> %s </td>",$Dat[$j]); } printf("</tr>"); } echo "</table>"; ?>

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 118: Wireles Project

Appendix

110

9.9 Appendix VIII 1. Banner page HTML code

<html> <head> <title>ELC 590 Project Banner</title> <link rel="stylesheet" type="text/css" href="./css/main.css"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body > <table align=center width=100%> <tr> <td><image src="./images/moilogo.gif" width=80 height=80 name='logo1'>&nbsp;&nbsp;</td> <td><center><font color=green size=5 ><b>MOI UNIVERSITY</font><br> <FONT color=red SIZE=4 >Faculty of Technology </FONT><BR> <font color=navy size=4>Department of Electrical and Communications Engineering</b></font> </center> </td> <td><image src="./images/moilogo.gif" width=80 height=80 name='logo2'></td> </tr> </table> </body> </html>

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 119: Wireles Project

Appendix

111

2. Database modification and exception handling page HTML and PHP code <html> <head> <title>ELC 590 Project Exception page</title> <link rel="stylesheet" type="text/css" href="./css/main.css"> </head> <body> <?php require_once("dbcon.php"); $dbcnx = db_connect($User,$Passwd); // login with username "guest" and password "mypass" to local serve if (!$dbcnx) { echo( "<P Class=Shout>Unable to connect to the " . "database server at this time.<BR><BR> Please Check That : <ul> <li>The Database Server Is Up & Running. <li>Your Username and Password are Properly Spelt. <li>Your CAPSLOCK is set Correctly. <li>Your Keyboard is Working :-) </ul></P>" ); exit(); } @$upquery= sprintf("INSERT INTO Master (Gate,Heater,Lights,TV,Fridge,Fan,Music,Alarm) Values ( '%s','%s','%s','%s','%s','%s','%s','%s')",$Gate? 'On':'Off',$Heater? 'On':'Off',$Lights? 'On':'Off', $TV? 'On':'Off',$Fridge? 'On':'Off',$Fan? 'On':'Off',$Music? 'On':'Off',$Alarm? 'On':'Off'); //printf($upquery); if (mysql_query($upquery)) { printf("<center><p class=info> Update Was Successful. <p> Click <A href='showdata.php'>Here </A> to view Records</center>");

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 120: Wireles Project

Appendix

112

} else { printf("Update Failure!!!"); } ?> </body> </html>

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 121: Wireles Project

Appendix

113

3. Index page HTML code <html> <head> <title>ELC 590:Engineering Project II</title> </head> <frameset rows="25%,*" frameborder="no" noresize > <frame src="banner.php" name="banner" scrolling="NO" > <frameset cols="20%,*" noresize> <frame src="toc.htm" noresize> <frame src="rock.php" name="main" noresize > </frameset </frameset> <noframes> <p class=shout> This Page Contains Frames Which Cannot Be Viewed By This Browser. </noframes> </html>

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 122: Wireles Project

Appendix

114

4. The main login and Control page HTML code <HTML> <HEAD> <META NAME="AUTHOR" Content="Tom Makau and Kumar Prashant"> <TITLE>ELC 590: FINAL YEAR PROJECT</TITLE> <link rel="stylesheet" type="text/css" href="./css/main.css"> </HEAD> <BODY> <h3 align=center>Remote Web-native Control <br>(R.W.C.C.)</h3> <FORM METHOD="POST" ACTION="dolog.php"> <Center> Username: <INPUT type='text' size='15%' name='User'> <br> Password: <INPUT type='Password' name='Passwd' size="15%" > <p> <h4> Device Options</h4> <TABLE BORDER=1 align="center"> <TR><TD> Gate<INPUT type='checkbox' name='Gate' > </TD> <TD> Heater<INPUT type='checkbox' name='Heater' > </TD> <TD> Lights<INPUT type='checkbox' name='Lights'> </TD> <TD> TV<INPUT type='checkbox' name='TV'> </TD> <TD> Fridge<INPUT type='checkbox' name='Fridge'></TD> <TD> Fan<INPUT type='checkbox' name='Fan'> </TD> <TD> Music<INPUT type='checkbox' name='Music' ></TD> <TD> Alarm<INPUT type='checkbox' name='Alarm' ></TD></TR> </TABLE> <p> <INPUT type="Reset" Value="Reset"> <INPUT type="Submit" Value="Submit"> </Center> </FORM> </BODY> </HTML>

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 123: Wireles Project

Appendix

115

5. The Cascade Style Sheet referred to by all the WebPages and PHP scripts .note { font-weight: bold; font-size: 75%; font-style: italic; color: navy; } .info { font-weight: bold; font-size: 80%; color: rgb(102,102,102); } .shout { font-weight: bold; color: red; } input { ; } a { } a:hover { font-style: italic; } a:link { } a:visited

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 124: Wireles Project

Appendix

116

{ color: rgb(51,102,204); } a:active { color: rgb(255,153,0); } th { color: navy; } td { text-align:right; font-size: 13; } table { color: brown; table-border-color-light: black; table-border-color-dark:black; } body { font-size: 14; font-family: Times; background-color: #ffffcc; color: #666633; } h1 { font-family: arial, color: rgb(153,153,51); } h2 { font-size: 18pt; color: rgb(204,153,0); } h3

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 125: Wireles Project

Appendix

117

{ font-size: 14pt; font-family: Times; color: rgb(0,102,153); } h4 { font-family: Times New Roman, Times; color: rgb(255,153,0); } h5 { font-family: Times New Roman, Times; color: rgb(153,153,0); } h6 { font-family: Times New Roman, Times; color: rgb(51,102,204); }

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 126: Wireles Project

Appendix

118

6. Jscript code that runs the status bar text var SysStr = "ELC 590:Final Year Project 2004 :" var StatStr = "(C)Tom Makau and Prashnat Kumar. All Rights Reserved. EMail: [email protected], [email protected] "; defaultStatus = StatStr; var DeptStr = "Department Of Electrical And Communications Engineering. "; var FactStr = "Faculty of Technology."; var UniStr = "Moi University."; var MyArray= new array(SysStr,DeptStr,FactStr,UniStr,StatStr); var CharInd = 1; var ArrInd = 0; function Init() { setInterval("Animate()",50); } function Animate() { defaultStatus = MyArray[ArrInd].substr(0,CharInd) ; if (CharInd++ >MyArray[ArrInd].length) { CharInd = 1; if (ArrInd++ > 3 ) ArrInd = 0 ; } } function fade(orb,stat) { if(stat==1) { orb.bgColor="ffeeaa"; } else { orb.bgColor="#ffffcc"; } }

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 127: Wireles Project

Appendix

119

74LS 138 Pins 74LS244 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 A X X V

A T T U

B X X V

B T U T

C V X V O’ V X

C T U T

(Table is continued here…)

74LS04 Pins 74LS76 Pins OUTPUT 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 A V O O P Pin 15 high = A is On A U K P’ K Pin 15 low = A is Off B O V O P Pin 11 high = B is On B U K P’ K Pin 11 low = B is Off C V O’ O’ Q Pin 15’ high=C is on C U’ K’ Q’ K’ Pin 15’ low =C is off

Table 3.0 Pin connection table for the control circuit

PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com