Wireless Access Methods and Schemes
In telecommunications and computer networks, a channel access method or multiple access method allows several terminals connected to the same multi-point transmission medium to transmit over it and to share its capacity. Examples of shared physical media are wireless networks, bus networks, ring networks, hub networks and half-duplex point-to-point links.
A channel-access scheme is based on a multiplexing method, that allows several data streams or signals to share the same communication channel or physical medium. Multiplexing is in this context provided by the physical layer. Note that multiplexing also may be used in full-duplex point-to-point communication between nodes in a switched network, which should not be considered as multiple access.
A channel-access scheme is also based on a multiple access protocol and control mechanism, also known as media access control
(MAC). This protocol deals with issues such as addressing, assigning
multiplex channels to different users, and avoiding collisions. The
MAC-layer is a sub-layer in Layer 2 (Data Link Layer) of the OSI model and a component of the Link Layer of the TCP/IP model. There are two kind of physical switching techniques available to transfer data via these wireless access method schemes.
Circuit switching(Analog Method)
Circuit switching is a methodology of implementing a telecommunications network in which two network nodes establish a dedicated communications channel (circuit) through the network before the nodes may communicate. The circuit guarantees the full bandwidth of the channel and remains connected for the duration of the communication session. The circuit functions as if the nodes were physically connected as with an electrical circuit.The defining example of a circuit-switched network is the early analog telephone network. When a call is made from one telephone to another, switches within the telephone exchanges create a continuous wire circuit between the two telephones, for as long as the call lasts.
Packet switching(Digital Method)
Packet switching is a digital networking communications method that groups all transmitted data – regardless of content, type, or structure – into suitably sized blocks, called packets. Packet switching features delivery of variable-bit-rate data streams (sequences of packets) over a shared network which allocates transmission resources as needed using statistical multiplexing or dynamic bandwidth allocation techniques. When traversing network adapters, switches, routers, and other network nodes, packets are buffered and queued, resulting in variable delay and throughput depending on the network's capacity and the traffic load on the network.
1G
Frequency Division Multiple Access (FDMA)
The frequency-division multiple access (FDMA) channel-access scheme is based on the frequency-division multiplexing (FDM) scheme, which provides different frequency bands to different data-streams. In the FDMA case, the data streams are allocated to different nodes or devices. An example of FDMA systems were the first-generation (1G) cell-phone systems, where each phone call was assigned to a specific uplink frequency channel, and another downlink frequency channel. Each message signal (each phone call) is modulated on a specific carrier frequency.
2G
2G is a digital wireless access method used by basic cellular
telephones. The name comes from the term "second generation," and
indicates that 2G is an upgrade from the outdated analog connection
method. Prior to the introduction of 2G wireless in the early 1990s,
cellphones were not digital. The radio signal of a first-generation
analog phone could be easily intercepted by anybody listening on the
same frequency. 2G digital signals are much more secure and have
significantly better sound quality. This type of wireless signal is not
designed to transfer large amounts of data, and is best suited for
standard voice calls and simple text messages. In order to allow many
different phones to share the same frequencies, CDMA and GSM standards
were developed. In basic terms, CDMA and GSM signals are sent using a
variety of digital languages, or "codes." Some of the cell phones in an
area utilize one code, while other phones communicate with a completely
different code. This prevents 2G phones from "interrupting" each other.
As of the date of publication, the 2G format is still used by many basic
cell phones, although it is slowly being replaced by newer technology.
Time division multiple access (TDMA)
The time division multiple access (TDMA) channel access scheme is based on the time-division multiplexing (TDM) scheme, which provides different time-slots to different data-streams (in the TDMA case to different transmitters) in a cyclically repetitive frame structure. For example, node 1 may use time slot 1, node 2 time slot 2, etc. until the last transmitter. Then it starts all over again, in a repetitive pattern, until a connection is ended and that slot becomes free or assigned to another node. An advanced form is Dynamic TDMA (DTDMA), where a scheduling may give different timesometimes but some times node 1 may use time slot 1 in first frame and use another time slot in next frame.
Code division multiple access (CDMA)
The code division multiple access (CDMA) scheme is based on spread spectrum, meaning that a wider radio spectrum in Hertz is used than the data rate of each of the transferred bit streams, and several message signals are transferred simultaneously over the same carrier frequency, utilizing different spreading codes. The wide bandwidth makes it possible to send with a very poor signal-to-noise ratio of much less than 1 (less than 0 dB) according to the Shannon-Heartly formula, meaning that the transmission power can be reduced to a level below the level of the noise and co-channel interference (cross talk) from other message signals sharing the same frequency.
GSM
GSM (Global System for Mobile Communications, originally Groupe Spécial Mobile), is a standard set developed by the European Telecommunications Standards Institute (ETSI) to describe protocols for second generation (2G) digital cellular networks used by mobile phones. It became the de facto global standard for mobile communications with over 80% market share. The GSM standard was developed as a replacement for first generation (1G) analog cellular networks, and originally described a digital, circuit-switched network optimized for full duplex voice telephony. This was expanded over time to include data communications, first by circuit-switched transport, then packet data transport via GPRS (General Packet Radio Services) and EDGE (Enhanced Data rates for GSM Evolution or EGPRS).
3G
3G or "third generation" wireless access is designed to transfer data at a faster rate than the older 2G system. This speed upgrade occurred in several steps. In the year 2000, cell phone companies began to implement General Packet Radio Service, or "GPRS." This was the beginning of 3G service, and allowed wireless data speeds of up to 114 kbps. Enhanced Data Rates for Global Evolution, also called "EDGE," was implemented in 2003. This improved the transfer rate for 3G devices to 384 kbps. Several other upgrades have since raised the rate of 3G wireless to over 1 Mbps in many developed countries. These speeds allow smartphones, including the BlackBerry and iPhone, to browse the Web and send multimedia messages. 3G can also be used to wirelessly connect tablet computers and laptops to the Internet.General Packet Radio Service
General packet radio service (GPRS) is a packet oriented mobile data service on the 2G and 3G cellular communication system's global system for mobile communications (GSM). GPRS was originally standardized by European Telecommunications Standards Institute (ETSI) in response to the earlier CDPD and i-mode packet-switched cellular technologies. It is now maintained by the 3rd Generation Partnership Project (3GPP).
GPRS usage is typically charged based on volume of data transferred, contrasting with circuit switched data, which is usually billed per minute of connection time. Usage above the bundle cap is either charged per megabyte or disallowed
Enhanced Data Rates for GSM Evolution
Enhanced Data rates for GSM Evolution (EDGE) (also known as Enhanced GPRS (EGPRS), or IMT Single Carrier (IMT-SC), or Enhanced Data rates for Global Evolution) is a digital mobile phone technology that allows improved data transmission rates as a backward-compatible extension of GSM. EDGE is considered a pre-3G radio technology and is part of ITU's 3G definition.[1] EDGE was deployed on GSM networks beginning in 2003 – initially by Cingular (now AT&T) in the United States.
4G
4G is the "fourth generation" of mobile wireless technology. According
to the International Telecommunication Union, a network is considered
4G if it operates at 100 Mbps or faster. This is more than 25 times
faster than the previous 3G format. 4G wireless networks are fast enough
to replace traditional cable-based broadband Internet connections, and
can be used by both home computer and mobile smartphone users. 4G is
significantly different from 3G -- it's not just an "upgraded" version
of the older technology. A 4G network uses orthogonal frequency division
multiplexing, or "OFDM." This means that the signal is split into
several distinct sub-signals with slightly different frequencies. 4G was
first launched in the United States in 2008. Large cities were the
first to receive fourth-generation service. Major U.S. carriers plan to
extend the wireless coverage -- meaning that 4G speeds eventually will
be available throughout most of the country.
Orthogonal frequency-division multiplexing
Orthogonal frequency-division multiplexing (OFDM) is a method of encoding digital data on multiple carrier frequencies. OFDM has developed into a popular scheme for wideband digital communication, whether wireless or over copper wires, used in applications such as digital television and audio broadcasting, DSL broadband internet access, wireless networks, and 4G mobile communications.
OFDM is essentially identical to coded OFDM (COFDM) and discrete multi-tone modulation (DMT), and is a frequency-division multiplexing (FDM) scheme used as a digital multi-carrier modulation method. The word "coded" comes from the use of forward error correction (FEC).[1] A large number of closely spaced orthogonal sub-carrier signals are used to carry data[1] on several parallel data streams or channels. Each sub-carrier is modulated with a conventional modulation scheme (such as quadrature amplitude modulation or phase-shift keying) at a low symbol rate, maintaining total data rates similar to conventional single-carrier modulation schemes in the same bandwidth.
Wi-Fi
Wi-Fi is a type of wireless signal designed for local networks. A
Wireless Local Area Network, or "WLAN," typically covers an office
building or a home and does not extend beyond a relatively short range. A
Wi-Fi wireless network allows a group of users to share files and
connect to the Internet without a hard-wired network cable. There are
several varieties of Wi-Fi, each defined by the Institute of Electrical
and Electronics
Engineers (IEEE). The 802.11b Wi-Fi format operates on a radio
frequency of 2.4 GHz and has a maximum speed of 11 Mbps. 802.11g was
released in 2003 and increased the maximum Wi-Fi speed to 54 Mbps. In
2009, the 802.11n wireless standard was announced -- it significantly
upgraded the rate, to 600 Mbps. Wi-Fi networks can be used to connect
PCs, smartphones, and tablet computers to the Internet; they typically
have a range of several hundred feet.
Bluetooth
Bluetooth is a wireless networking technology intended for small,
personal networks. A short-range Bluetooth network is sometimes called a
Personal Area Network, "PAN," or "piconet." While cell phone and Wi-Fi
networks provide connectivity for many simultaneous users, a Bluetooth
connection is typically used by only one user. Small Bluetooth radios
are integrated in many electronic devices, ranging from music players to
smartphones and printers. Wireless Bluetooth can replace the tangle of
cords that these devices traditionally require. For example, a
Bluetooth-enabled smartphone can be controlled by a wireless keyboard
while also connecting to the user's headset for incoming calls.
Bluetooth devices must be "paired" or linked before use -- this prevents
unauthorized people from connecting to the personal network.
Wireless Application Protocol
Wireless Application Protocol (WAP) is the worldwide standard for providing Internet communications and advanced services on digital mobile devices, such as handheld phones, pagers, and other wireless devices. This protocol is an open, global specification that enables users of these digital devices to securely access and interact with Internet, intranet, and extranet applications and services.
Many phones and PDAs currently have multimedia capabilities that include:
- Retrieving e-mail
- Accessing data from company databases
- Executing stock trading
- Paying bills
- Making travel reservations
- Online requests for maps and driving directions
- Running other exciting applications
The WAP Forum was founded in June 1997, by Ericsson, Motorola, Nokia, and Phone.com. It has drafted a global wireless specification for all wireless networks. The forum contributed to various industry groups, such as wireless service providers, handset manufacturers, infrastructure providers, and software developers. WAP version 2 brings together open Internet standards and mobile networking as it adds optimized support for TCP and HTTP, Extended Hypertext Markup Language (XHTML), and Transport Layer Security.
The WAP environment
wireless devices lack the traditional desktop GUI like the Web browser. Other fundamental
limitations for handheld, wireless devices include:
- Less powerful CPUs
- Less memory
- Restricted power consumption
- Smaller displays
- Different input devices (for example, phone keypad and voice input)
Wireless data networks present many communications challenges compared to wired networks. For example, the wireless communication environment is constrained because wireless links have:
- Less bandwidth
- More latency
- Less connection stability
- Less predictable availability
As a result, protocols that provide wireless applicability must be tolerant of these types of problems
Key elements of the WAP specifications
WAP defines an open standard architecture and a set of protocols to implement wireless Internet access.
- Definition of the WAP programming model
- The Extended Hypertext Markup Language Mobile Profile (XHTMLMP).
- The Wireless Markup Language (WML).
- A lightweight protocol stack
- A framework for wireless telephony
WAP Architecture
The WAP architecture illustrated in Figure
- The WAP client (the handheld device or WAP terminal)
- The application server
This programming model is the Web programming model with some extensions and enhancements to match the characteristics of the wireless clients. This programming model adds two enhancements to the Web programming model:
- Push
- Wireless Telephony Support (WTA)
Feature and performance-enhancing proxies
The WAP model recommends the use of proxies to optimize the connection between the wireless clients and the Web
A variety of functions are then provided by the WAP proxy, including:
Protocol gateway
Translates requests from a wireless protocol stack (for example, the WAP 1.x stack—WSP, WTP, WTLS, and WDP) to the WWW protocols (HTTP and TCP/IP). Also can perform DNS lookups for the URLs requested by the client.
Content encoders and decoders
Translates WAP content for better utilization of the underlying link, reducing the bandwidth use by different compression techniques.
User Agent Profile Manager
Used mainly to communicate the client’s device capabilities and personal preferences to the server
applications.
Caching proxy
Caching frequently accessed resources, a caching proxy can improve network utilization
Overall Architecture
Wireless Application Protocol
Here's what happens when you access a Web site using a WAP-enabled device:- You turn on the device and open the minibrowser.
- The device sends out a radio signal, searching for service.
- A connection is made with your service provider.
- You select a Web site that you wish to view.
- A request is sent to a gateway server using WAP.
- The gateway server retrieves the information via HTTP from the Web site.
- The gateway server encodes the HTTP data as WML.
- The WML-encoded data is sent to your device.
- You see the wireless Internet version of the Web page you selected.
What happens between the gateway and the client relies on features of different parts of the WAP protocol stack. Let's take a look at each part of the stack:
- WAE - The Wireless Application Environment holds the tools that wireless Internet content developers use. These include WML and WMLScript, which is a scripting language used in conjunction with WML. It functions much like Javascript.
- WSP - The Wireless Session Protocol determines whether a session between the device and the network will be connection-oriented or connectionless.
What this is basically talking about is whether or not the device needs
to talk back and forth with the network during a session. In a
connection-oriented session, data is passed both ways between the device
and the network; WSP then sends the packet to the Wireless Transaction
Protocol layer (see below). If the session is connectionless, commonly
used when information is being broadcast or streamed from the network to the device, then WSP redirects the packet to the Wireless
Datagram Protocol layer.
- WTP - The Wireless Transaction Protocol acts like a traffic cop, keeping the data flowing in a logical and smooth manner. It also determines how to classify each transaction request: Reliable two-way Reliable one-way Unreliable one-way The WSP and WTP layers correspond to Hypertext Transfer Protocol (HTTP) in the TCP/IP protocol suite.
- WTLS - Wireless Transport Layer Security provides many of the same security features found in the Transport Layer Security (TLS) part of TCP/IP. It checks data integrity, provides encryption and performs client and server authentication.
- WDP - The Wireless Datagram Protocol works in conjunction with the network carrier layer (see below). WDP makes it easy to adapt WAP to a variety of bearers because all that needs to change is the information maintained at this level.
- Network carriers - Also called bearers, these can be any of the existing technologies that wireless providers use, as long as information is provided at the WDP level to interface WAP with the bearer.
Once the information is received by the WAP client, it is passed to the minibrowser.
This is a tiny application built into the wireless device that provides
the interface between the user and the wireless Internet.
Wireless(WAP) Application Development
Wireless Markup Language
WAP uses Wireless Markup Language (WML), which includes the Handheld Device Markup Language (HDML) developed by Phone.com.
WML can also trace its roots to eXtensible Markup Language
(XML). A markup language is a way of adding information to your content
that tells the device receiving the content what to do with it. The
best known markup language is Hypertext Markup Language (HTML). Unlike HTML, WML is considered a meta language. Basically, this means that in addition to providing predefined tags, WML lets you design your own markup language components. WAP also allows the use of standard Internet protocols such as UDP, IP and XML.
There are three main reasons why wireless Internet needs the Wireless Application Protocol:
- Transfer speed
- Size and readability
- Navigation
Most cell phones and Web-enabled PDAs have data transfer rates of 14.4 Kbps or less. Compare this to a typical 56 Kbps modem, a cable modem or a DSL
connection. Most Web pages today are full of graphics that would take
an unbearably long time to download at 14.4 Kbps. Wireless Internet
content is typically text-based in order to solve this problem.
The relatively small size of the LCD on a cell phone or PDA presents another challenge. Most Web pages are designed for a resolution of 640x480 pixels, which is fine if you are reading on a desktop or a laptop. The page simply does not fit on a wireless device's display,
which might be 150x150 pixels. Also, the majority of wireless devices
use monochrome screens. Pages are harder to read when font and
background colors become similar shades of gray.
WML (Wireless Markup Language) is the new web language for
making sites on mobile phones. Over the past few months new WAP
(Wireless Applications Protocol) phones have become extremely popular
and many large websites have created special ‘mobile’ versions of their
site. Many people predict that, over the next few years, WAP sites will
become extremely popular and e-commerce over mobile phones will be widly
available.
To create a WAP site you don’t need a WAP enabled phone. You can get a
WAP simulator for a PC. This is a piece of software which will give you a
WAP phone on your desktop. You can then type in the URLs of WAP sites
and then view them on your PC. You can get a very good free WAP
simulator from YourWAP.com
WAP sites are not like standard web sites at all. As an example, you are looking at part of the Gowansnet web site.
As you can see, sites written in WML are monochrome, very limited and
there is very little screen space. Because of this you must be very
careful when you are designing a WAP site as it is nothing like a web
site.
Just read on to learn how to create a WAP site using WML. It is a great
advantage if you know HTML as WML is a lot like it (in fact WML is just a
variant of XML, another web language). Let’s get straight into how to create a site. Note, a working knowledge
of HTML is useful and you should really have either a WAP phone or a WAP
simulator to view your site.
Unfortunately WML cannot be run on all web hosts. For WML content to be
run, a web host must make some changes to the configuration of their web
server. If your host cannot do this for you, you can try WAPHosts.net. They can provide you with a server that will support WML.
Valid WML Elements
WML predefines a set of elements that can be combined together to create a WML document. These elements include can be broken down into two groups: the Deck/Card elements and the Event elements.Deck/Card Elements
| wml | card | template | head | access | meta |
Event Elements
| do | ontimer | onenterforward | onenterbackward | onpick | onevent | postfield |
Tasks
| go | prev | refresh | noop |
Variables
| setvar |
User input
| input | select | option | optgroup | fieldset |
Anchors, Images, and Timers
| a | anchor | img | timer |
Text Formatting
| br | p | table | tr | td |
Each of these elements is entered into the document using the following syntax:
<element> element value </element>
If an element has no data between it (as is often the case with formatting elements such as
<br>), you can save space by entering one tag appended with a \ character (for instance, <br/>).
Using Variables
Because multiple cards can be contained within one deck, some mechanism needs to be in place to hold data as the user traverses from card to card. This mechanism is provided via WML variables. Variables can be created and set using several different methods. For instance:- Using the
<setvar>element as a result of the user executing some task. The<setvar>element can be used to set a variable’s state within the following elements: go, prev, and refresh. The following element would create a variable named x with a value of 123:<setvar name="x" value="123"/>
- Variables are also set through any input element (input, select,
option, etc.). A variable is automatically created that corresponds with
the name attribute of an input element. For instance, the following
element would create a variable named x:
<select name="x" title="X Value:">
Although we haven’t discussed WMLScript yet, it is important to note
that WML and WMLScript within a document share the same variables.
Declaring A WML Document
When you are creating a WML document all you need is notepad, just like for HTML. The first thing you should enter is:
<?xml version="1.0"?><!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"><wml>
this tells the phone that it is interpreting a WML document and which WML standards it is using.
Cards
Instead of having pages, WAP sites have cards. These are what is
displayed on the screen at any one time, just like a page. More than one
card can be inserted in each WML document. To declare a card, insert
the following:
<card id="index" title="My WAP Site" newcontext="true">
This will make a card with the ID index (used for linking) and will display the text:
My WAP Site
at the top of the screen.
Closing Tags
Unlike with HTML, it is extremely important to close WML tags. If you
do not, a page will certainly not work. You must close both the
<card> and <wml> tags:
</card>
</wml>
</wml>
Now I am going to show you how to insert text and how to format it.
The <p> Tag
Just like in HTML the <p> tag is used to show where a paragraph
begins and ends. Unlike HTML though, all text on a WML page must be
inside these tags. You are not allowed to nest these tags either. One
important thing to remember about WML is that, unlike HTML where a page
will still display even if there is bad code, a WAP phone will just
reject a page if there is code it doesn’t understand.
As with HTML you use the tags as follows:
<p>
information
</p>
Aligning Text
Aligning text in WML is nearly exactly the same as in HTML, except
you can’t use the center tag. All aligning must be done using the
following <p> tags:
Center:<p align="center">Right:<p align="right">
The <br/> Tag
In WML (as mentioned earlier) all tags must be closed. This causes
problems when using old HTML tags (like <br>) which have no
closing tag. To get around this, some tags have had a / put on the end
e.g.
<br/>
This, like in HTML will make a line break.
Text
In WML there is actually no font tag (as you can only display text in the phone's default font in black). To show text all you need to do is put it in between the <p> and </p> tags. Here is an example of a full WML document:<?xml version="1.0"?><!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="index" title="My WAP Site" newcontext="true"></wml>
<p align="center">
Welcome to my new WAP site. You can view this on your mobile phone anywhere in the world!<br/>
It is amazing!
</p>
</card>
Hyperlinks + Images
Now I will show you how you can make this better by adding extra
parts, linking to them (and other sites) and how to add images to your
site.
More Cards
WAP sites have cards instead of pages. They are really the same as
pages except that they can all be written in one file. To add another
card, all you need to do is put in another <card> tag with a
different ID to the others. For example:
<card title="About Me" id="about">
information
</card>
would be added below the first card but before the </wml> tag.
Linking
There are three ways to link to another WAP site, file or card. Just
like in HTML these can either be the full path to a file or a relative
link.
To link to a WAP site you use the following:
<a href="http://gowansnet.waphosts.net/">Gowansnet</a>
in your text. To link to another file on your site you would use:
<a href="links.wml">My Links</a>
and to link to another card in the same page you use:
<a href="#about">About Me</a>
Images
Unfortunately, because WAP phones only have monochrome screens,
images do not work very well on WML pages. They also use their own image
format: WBMP. When you are creating an image to use on your site you
will need to make it small (mobile phone screens are about 100x50
pixels).
The easiest way to get an image into the WBMP format is to create it
as a GIF or JPG (it can be in colour if you want) and then visit this
site to convert it into a monochrome (black and white) WBMP image which
you can then include on your site.
Images in WML are inserted using the <img> tag, just like in HTML:
<img src="logo.wbmp" alt="Logo" />
Again, you can see that a / has been added at the end as the
<img> tag has no closing tag. It is very important that you also
include the alt text as it will be displayed while the image is being
downloaded.
Example Site
Below is the sample WML code for a small WAP site. It has two cards, an image, and a link to an external site:<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="index" title="My WAP Site" newcontext="true">
<p align="center">
Welcome to my new WAP site. You can view this on your mobile phone anywhere in the world!<br/>
<img src="logo.wbmp" src="Logo" />
</p>
<p>
Here are some links:<br/>
<a href="#about">About Me</a><br/>
<a href="http://gowansnet.waphosts.net/">Gowansnet</a>
</p>
</card>
<card id="about" title="About Me">
<p>Here is some informatio about me. You can't write too much in here, though as there is not much space<br/>
You can scroll down the screen, of course.
</p>
<p align="center">
<a href="#index">Back</a>
</p>
</card>
</wml>
Creating A WML Deck
In this example, we’ll
start by creating a WML deck that allows us to first select a username
from a list, enter in a password, then have our selections repeated back
to us. This will illustrate the basic handling of user input, events,
and variables all within one deck using multiple cards.
<?xml version='1.0'?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"> <wml> <card id="Login" title="Login"> <do type="accept" label="Password"> <go href="#Password"/> </do> <p> UserName: <select name="name" title="Name:"> <option value="John Doe">John Doe</option> <option value="Paul Smith">Paul Smith</option> <option value="Joe Dean">Joe Dean</option> <option value="Bill Todd">Bill Todd</option> </select> </p> </card> <card id="Password" title="Password:"> <do type="accept" label="Results"> <go href="#Results"/> </do> <p> Password: <input type="text" name="password"/> </p> </card> <card id="Results" title="Results:"> <p> You entered:<br/> Name: $(name)<br/> Password: $(password)<br/> </p> </card> </wml>
element to be analyzed.If you are familiar with the anchor tag (
) in HTML, you know that it specifies an href attribute that tells the browser where to link to if this anchor is selected. The WML
element’s "href" attribute works in the same manner. As with HTML, to
link to another card in the document, you simply prepend a # symbol
before it. For example, to link to the Results card, we define the
following element:
<go href="#Results"/>
This Results card makes use of variables by retrieving and displaying
the contents of the name and password variables. Recall that variables
are substituted into a card or deck by using the following syntax:
$(variable_name)
Calling A Server Script
Without
the ability to perform server transactions, WML would only serve to
provide a standardized way to display text on a client. Adding in the
ability to dynamically connect to remote servers opens up every WAP
device to the world of Internet messaging, enterprise data, and
e-commerce. WAP devices interact with these data sources through a WAP
gateway as mentioned in our WAP Overview tutorial. This gateway must
interface with a carrier such as CDMA, GSM, or GPRS.
WMLExample2.wml
<?xml version='1.0'?> <DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"> <wml> <card id="Order" title="Query Inventory"> <p> <select name="Items" title="Items"> <option value="Books">Books</option> <option value="Music">Music</option> <option value="Video">Video</option> <option value="Software">Software</option> </select> </p> <do type="accept" label="Query"> <go href="http://127.0.0.1/WML/Inventory.asp" method="post"> <postfield name="Items" value="$(Items)"/> </go> </do> </card> </wml>
Listing 3 - Inventory.asp
<% Dim Body If Request.Form("Items") = "Books" Then Body = "You selected Books!" ElseIf Request.Form("Items") = "Video" Then Body = "You selected Video!" ElseIf Request.Form("Items") = "Software" Then Body = "You selected Software!" ElseIf Request.Form("Items") = "Music" Then Body = "You selected Music!" End If Response.ContentType = "text/vnd.wap.wml"%> <?xml version='1.0'?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"> <wml> <card> <p> <%Response.write(Body)%> </p> </card> </wml>
.wml text/vnd.wap.wml
.wmls text/vnd.wap.wmlscript
If you’d like to use Wireless Bitmap images (the image format supported by WAP), also add:
.wbmp image/vnd.wap.wbmp
Adding Client-Side Logic To WAP Using WMLScript
WMLScript is the WAP
corollary to the JavaScript scripting language that was popularized by
Netscape Communications. Standardization efforts by Netscape helped
produce the ECMAScript standard, a standard that WMLScript was based on.
WMLScript syntax is based
on the ECMAScript programming language. Unlike ECMAScript, however, the
WMLScript specification also defines a bytecode and interpreter
reference architecture for optimal utilization of current narrowband
communications channels and handheld device memory requirements.
- The smallest unit of execution in WMLScript is a statement and each statement must end with a semicolon (;).
- WMLScript is case-sensitive.
- Comments can either be single-line (beginning with //) or multi-line (bracketed by /* and */). This syntax is identical to both C++ and Java.
- A literal character string is defined as any sequence of zero or more characters enclosed within double ("") or single (‘) quotes.
- Boolean literal values correspond to true and false.
- New variables are declared using the var keyword (i.e.
var x;)
Data Types
WMLScript is a weakly typed language. This means that no type-checking is done at compile- or run-time and no variable types are explicitly declared. Internally, the following data types are supported:Boolean
Integer
Floating-point
String
Invalid
The programmer does not need to specify the type of any variable;
WMLScript will automatically attempt to convert between the different
types as needed. One other point to note is that WMLScript is not
object-oriented (such as Java or C++). Therefore, it is impossible to
create your own user-defined data types programmatically.Operators
WMLScript supports a variety of operators that support value assignment operations, arithmetic operations, logical operations, string operations, comparison operations, and array operations. For more information on the wide variety of WMLScript operators, see the WMLScript specification.Flow Control Statements
The operators and expressions supported by WMLScript are virtually identical to those of the JavaScript programming language so we will not discuss them here. Java does support a number of control statements for handling branching within programs. These include the if-else, for loop, while loop, break, and continue statements.Functions
Related WMLScript statements can be executed together as a unit known as a function. A function declaration has the following syntax: extern function identifier(FormatParameterList) Block ;The
extern keyword is optional and is used to specify a
function that can be called from outside the current compilation unit in
which the function is defined. A sample WMLScript function declaration
looks like this:
function RunTime(distance, speed)
{
var time = distance / speed;
return time;
}; The above example simply takes two input variables,
distance and speed, and uses them to calculate a time variable. The return keyword is then used to return a value.When calling a function included with one of the WMLScript standard libraries (see below), the library name must be included with the function call. For example, to call the String library’s
length() function, use the following syntax:
var a = String.length("1234567890");
The WMLScript Standard Libraries
While WMLScript does not support the creation of new objects via
object-oriented programming, it does provide six "pre-built" libraries
that aid in the handling of many common tasks. These libraries (with a
brief description of each) include:
- Lang - This library contains a set of functions that are closely related to the WMLScript language core. Included in this library are functions for data type manipulation, absolute value calculations, and random number generation.
- Float - The Float library is optional and is only supported on those clients who have floating-point capabilities. Typical functions provided by this library include sqrt(), round(), and pow().
- String - The String library contains a set of functions for performing string operations. Some of the functions included in this library are length(), charAt(), find(), replace(), and trim().
- URL - This library contains a set of functions for handling both absolute URLs and relative URLs. Typical functions include getPath(), getReferer(), and getHost().
- WMLBrowser - This library contains functions by which WMLScript can access the associated WML context. These functions must not have any side effects and must return invalid in cases where the system does not support WMLBrowser and where the interpreter is not invoked by the WML Browser. Commonly used functions in this library include go(), prev(), next(), getCurrentCard(), and refresh().
- Dialogs - This library contains a set of typical user interface functions including prompt(), confirm(), and alert().
Example: Validating User Input Via WMLScript
In the following example,
we will build a simple WML card that asks the user to input a social
security number (an identification number used by the U.S. Social
Security Administration). We will then use WMLScript to verify that the
user’s input was formatted correctly. Following this verification, we’ll
alert the user via WMLScript to let them know whether their number was
accepted or not. This example, though simple, represents a typical usage
of WMLScript on a client.
Listing 1 - WMLScriptExample.wml
<?xml version='1.0'?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"> <wml> <card id="SSN" title="SSN:"> <do type="accept" label="Results"> <go href="WMLScriptExample.wmls#validateSSN($(SSN))"/> </do> <p> Enter SSN: <input type="text" name="SSN"/> </p> </card> <card id="Results" title="Results:"> <p> You entered:<br/> SSN: $(SSN)<br/> </p> </card> </wml>
Listing 2 - WMLScriptExample.wmls
extern function validateSSN(SSN) { if (String.length(SSN) != 9) { WMLBrowser.setVar("SSN", "Error: String must be 9 digits long."); } WMLBrowser.go("WMLScriptExample.wml#Results"); };













No comments:
Post a Comment