Programming of Handheld and Cell phones.


39 views
Uploaded on:
Category: Food / Beverages
Description
supplant the links utilized on cell phones with radio recurrence waves. ... The DiscoveryListener interface permits an application to get gadget revelation ...
Transcripts
Slide 1

Programming of Handheld and Mobile Devices Lecture 20 Bluetooth for MIDlets Rob Pooley rjp@macs.hw.ac.uk Programming Handheld and Mobile gadgets

Slide 2

Wireless Ethernet (IEEE 802.11b) Based upon time-tried Ethernet principles. Works in same unlicensed 2.4GHz band as Bluetooth and HomeRF. Advanced for information transmission up to 100 meters inside office, grounds LANs Waits, retransmits because of obstruction (useful for information, terrible for voice). Remote Ethernet Compatibility Alliance: www.weca.net Programming Handheld and Mobile gadgets

Slide 3

Bluetooth Set of equipment and programming principles indicating how gadgets can convey remotely in unlicensed 2.4GHz band. Enhanced for 30 meters or less, Personal Area Networks (PANs). Based upon expert slave connections in systems of up to eight gadgets, piconets. Bluetooth Special Interest Group landing page at: www.bluetooth.com Java APIs for Bluetooth exertion: java.sun.com/jcp/jsr/jsr_082_bluetooth.html Programming Handheld and Mobile gadgets

Slide 4

What is Bluetooth? The Bluetooth remote innovation was made to take care of a straightforward issue: supplant the links utilized on cell phones with radio recurrence waves. The innovation incorporates a basic minimal effort, low-control, worldwide radio framework for coordination into cell phones. Such gadgets can shape a speedy impromptu secure "piconet" and convey among the associated gadgets. This innovation makes numerous helpful versatile use models on the grounds that the associations can happen while cell phones are being conveyed in pockets and satchels Programming Handheld and Mobile gadgets

Slide 5

Usage model Bluetooth ∗ use model depends on interfacing gadgets together, It is centered around three general classifications: voice/information access focuses, fringe interconnects, and Personal Area Networking (PAN). Programming Handheld and Mobile gadgets

Slide 6

Voice/Data Access Points Voice/information access focuses is one of the key beginning use models and includes associating a processing gadget to an imparting gadget by means of a safe remote connection . For instance, a versatile PC furnished with Bluetooth innovation could connection to a cellular telephone that utilizations Bluetooth innovation to interface with the Internet to get to email. The cell telephone goes about as an individual access point. Far and away superior, the note pad can interface with the Internet while the wireless is being conveyed in a portfolio or handbag. The Bluetooth utilization display likewise imagines open information access focuses later on. Programming Handheld and Mobile gadgets

Slide 7

Peripheral Interconnects fringe interconnects include associating different gadgets together as demonstrated Programming Handheld and Mobile gadgets

Slide 8

Personal Area Networking (PAN ), concentrates on the specially appointed development and breakdown of individual systems. Envision meeting somebody in an airplane terminal and rapidly and safely trading archives by setting up a private piconet. Individual Area Networking Programming Handheld and Mobile gadgets

Slide 9

javax.bluetooth Interfaces  DiscoveryListener L2CAPConnection L2CAPConnectionNotifier ServiceRecord Classes  DataElement DeviceClass DiscoveryAgent LocalDevice RemoteDevice UUID Exceptions  BluetoothConnectionException BluetoothStateException ServiceRegistrationException javax.obex Interfaces  Authenticator ClientSession HeaderSet Operation SessionNotifier Classes  PasswordAuthentication ResponseCodes ServerRequestHandler Bluetooth on MIDlets Programming Handheld and Mobile gadgets

Slide 10

The DiscoveryListener interface permits an application to get gadget revelation and administration disclosure occasions. This interface gives four strategies, two for finding gadgets and two for finding administrations. void deviceDiscovered ( RemoteDevice  btDevice, DeviceClass  cod)           Called when a gadget is found amid an inquiry.  void inquiryCompleted (int discType)           Called when a request is completed.  void servicesDiscovered (int transID, ServiceRecord [] servRecord)           Called when service(s) are found amid an administration search.  void serviceSearchCompleted (int transID, int respCode)           Called when an administration pursuit is finished or was ended as a result of a mistake. DiscoveryListener Programming Handheld and Mobile gadgets

Slide 11

Field Summary static int INQUIRY_COMPLETED           Indicates the ordinary culmination of gadget disclosure. static int INQUIRY_ERROR           Indicates that the request demand neglected to finish typically, yet was not wiped out. static int INQUIRY_TERMINATED           Indicates gadget revelation has been scratched off by the application and did not finish. static int SERVICE_SEARCH_COMPLETED           Indicates the typical finish of administration revelation. static int SERVICE_SEARCH_DEVICE_NOT_REACHABLE           Indicates the administration inquiry couldn\'t be finished in light of the fact that the remote gadget gave to DiscoveryAgent.searchServices() couldn\'t be come to. static int SERVICE_SEARCH_ERROR           Indicates the administration seek ended with a blunder. static int SERVICE_SEARCH_NO_RECORDS           Indicates the administration seek has finished with no administration records found on the gadget. static int SERVICE_SEARCH_TERMINATED           Indicates the administration look has been wiped out by the application and did not finish. Programming Handheld and Mobile gadgets

Slide 12

class DiscoveryAgent The DiscoveryAgent class gives strategies to perform gadget and administration revelation. A nearby gadget must have stand out DiscoveryAgent object. This article must be recovered by a call to getDiscoveryAgent() on the LocalDevice object. Programming Handheld and Mobile gadgets

Slide 13

Device Discovery There are two approaches to find gadgets. Initial, an application may utilize startInquiry() to begin a request to discover gadgets in vicinity to the neighborhood gadget. Found gadgets are returned by means of the deviceDiscovered() strategy for the interface DiscoveryListener. The second way is by means of the retrieveDevices() strategy. This strategy will return gadgets that have been found by means of a past request or gadgets that are delegated pre-known. (Pre-known gadgets are those gadgets that are characterized in the Bluetooth Control Center as gadgets this gadget much of the time contacts.) The retrieveDevices() strategy does not play out a request, but rather gives a fast approach to get a rundown of gadgets that might be in the territory. Programming Handheld and Mobile gadgets

Slide 14

Service Discovery The DiscoveryAgent class additionally typifies the usefulness gave by the administration disclosure application profile. The class gives an interface to an application to look and recover qualities for a specific administration. There are two approaches to hunt down administrations. To hunt down an administration on a solitary gadget, the searchServices() strategy ought to be utilized. On the off chance that you couldn\'t care less which gadget an administration is on, the selectService() strategy does an administration seek on an arrangement of remote gadgets. Programming Handheld and Mobile gadgets

Slide 15

General structure See: http://wireless.klings.org/main.php/Bluetooth/import javax.bluetooth.DiscoveryListener; import javax.microedition.lcdui.Command; import javax.microedition.lcdui.CommandListener; import javax.microedition.lcdui.Displayable; import javax.microedition.midlet.MIDlet; open class yourMidlet amplifies MIDlet actualizes CommandListener, DiscoveryListener { open void startApp() { } open void pauseApp() { } open void destroyApp() { } open void commandAction(Command c, Displayable d) { } open void deviceDiscovered(RemoteDevice remoteDevice, deviceClass) { } open void inquiryCompleted(int param) { } open void serviceSearchCompleted(int param, int param1) { } open void servicesDiscovered(int param, ServiceRecord[] serviceRecord) { } Programming Handheld and Mobile gadgets

Slide 16

Device Discovery To utilize any Bluetooth related strategies you have to get a reference to the LocalDevice object. This is finished with a call to LocalDevice.getLocalDevice(). LocalDevice gives you access to Bluetooth properties for the gadget, for example, Bluetooth address, cordial name and revelation mode. We will utilize LocalDevice to get a DiscoveryAgent. The DiscoveryAgent object gives you access to gadget disclosure and administration look Programming Handheld and Mobile gadgets

Slide 17

import javax.bluetooth.BluetoothStateException; import javax.bluetooth.DeviceClass; import javax.bluetooth.DiscoveryAgent; import javax.bluetooth.DiscoveryListener; import javax.bluetooth.LocalDevice; import javax.bluetooth.RemoteDevice; import javax.bluetooth.ServiceRecord; import javax.microedition.lcdui.Command; import javax.microedition.lcdui.CommandListener; import javax.microedition.lcdui.Displayable; import javax.microedition.midlet.MIDlet; open class yourMIDlet broadens MIDlet actualizes CommandListener, DiscoveryListener { private LocalDevice nearby = invalid; private DiscoveryAgent specialist = invalid; private Vector devicesFound = invalid; open void startApp() {/* Add your MIDlet particular code here. * You likely need to demonstrate the client * an appreciated screen. * The call to doDeviceDiscovery() is * here for the case\'s purpose. You * ought to call doDeviceDiscovery() when * the client effectively requests it. */doDeviceDiscovery(); } private void doDeviceDiscovery() { attempt { neighborhood = LocalDevice.getLocalDevice(); } get (BluetoothStateException bse) {/Error taking care of code here } specialist = local.getDiscoveryAgent(); devicesFound = new Vector(); attempt { if(!agent.startInquiry(DiscoveryAgent.GIAC,this)) {/Inquiry not began, blunder taking care of code here } catch(BluetoothStateException bse) {/Error taking care of code here } Programming Handheld and Mobile gadgets

Slide 18

What happens

Recommended
View more...