<ul><li>JSR 82 </li></ul>
Introduction <ul><li>JSR 82 is an optional package </li></ul><ul><li>The current available version is 1.1 </li></ul><ul><l...
Check Bluetooth API <ul><li>To determine if the optional API is available and which version is  installed you have to call...
Bluetooth Stack <ul><li>Host Controller Interface (HCI) –  this is the lowest layer of the Bluetooth Host stack. It interf...
Bluetooth Profiles <ul><li>To ensure interoperability and consistency between devices, Bluetooth profiles define vendor-ne...
Bluetooth Profiles <ul><li>Service Discover Application Profile (SDAP) – describes a specific application and usage of SDP...
Bluetooth Devices and Network <ul><li>Bluetooth devices use a unique IEEE 802  48-bit address. </li></ul><ul><li>When two ...
Bluetooth API- Organization <ul><li>Bluetooth API and Java ME platform </li></ul><ul><li>At the bottom of the stack are ha...
Bluetooth/OBEX API- Packages Packages Name Description javax.bluetooth.*; Core Bluetooth API, such as Discovery, L2CAP, an...
JSR 82-enable MIDlet <ul><li>All interfaces and classes available to a JSR-82-enabled MIDlet are shown below: </li></ul>
Bluetooth API & GCF
Using Bluetooth API
Bluetooth Client & Server
Initializing the Bluetooth Application(Client) ... private  LocalDevice  localDevice ; // local Bluetooth Manager  private...
Discover Bluetooth Enable Device(Client) <ul><li>public class MyBT implements DiscoveryListener { </li></ul><ul><li>public...
Get BT Services(Client) <ul><li>public class MyBT implements DiscoveryListener{ </li></ul><ul><li>private final UUID[] uui...
Example(Client) <ul><li>public class MyBT implements DiscoveryListener , Runnable{ </li></ul><ul><li>private final UUID[] ...
Bluetooth(Server) <ul><li>public class MyBTServer implements DiscoveryListener , Runnable{ </li></ul><ul><li>private Strin...
<ul><li>Thank You </li></ul>
Upcoming SlideShare
Loading in...5
×

JSR 82 (bluetooth obex)

2,446
-1

Published on

JSR 82 (bluetooth obex)

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
2,446
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
52
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

JSR 82 (bluetooth obex)

  1. 1. <ul><li>JSR 82 </li></ul>
  2. 2. Introduction <ul><li>JSR 82 is an optional package </li></ul><ul><li>The current available version is 1.1 </li></ul><ul><li>JSR 82 provides two optional API’s </li></ul><ul><li>Bluetooth API </li></ul><ul><li> Object Exchange (OBEX) API </li></ul><ul><li>The Bluetooth is a low-cost, short-range radio technology intended to replace data cables connecting electronic devices. </li></ul><ul><li>Bluetooth technology consists radio technology, the software stack, and profiles. </li></ul>
  3. 3. Check Bluetooth API <ul><li>To determine if the optional API is available and which version is installed you have to call: </li></ul><ul><li>String currentVersion = </li></ul><ul><li>System.getProperty(“bluetooth.api.version”) </li></ul><ul><li>or </li></ul><ul><li>String currentVersion = </li></ul><ul><li>javax.bluetooth.LocalDevice.getProperty(&quot;bluetooth.api.version&quot;); </li></ul><ul><li>If the API is available a string with the version will be returned </li></ul><ul><li>If the API is not available a null value is returned </li></ul><ul><li>Currently only version “1.1” has been defined </li></ul>
  4. 4. Bluetooth Stack <ul><li>Host Controller Interface (HCI) – this is the lowest layer of the Bluetooth Host stack. It interfaces directly with the host controller hardware. </li></ul><ul><li>Logical Link Control and Adaptation Layer (L2CAP) – this layer handles packet segmentation and reassembly (SAR), protocol multiplexing, and provides quality of service information. </li></ul><ul><li>Service Discovery Protocols (SDP) – as the name implies, applications use this layer to discover Bluetooth services that are available. </li></ul><ul><li>RFCOMM – this layer provides serial behavior over Bluetooth, similar to using a standard serial (COM) port. </li></ul><ul><li>Object Exchange Protocol – originally defined by the Infrared Data Association (IrDA), this protocol enables the exchange of objects such as vCard and vCalendar synchronization data. </li></ul>
  5. 5. Bluetooth Profiles <ul><li>To ensure interoperability and consistency between devices, Bluetooth profiles define vendor-neutral device capabilities. </li></ul><ul><li>A profile describes specific functions and features that use Bluetooth as its transport mechanism </li></ul><ul><li>Profiles supply information that makes certain that Bluetooth devices that claim these capabilities can exchange data with devices. </li></ul><ul><li>The Bluetooth Standard profile are given below: </li></ul><ul><ul><li>Generic Access Profile (GAP) – defines the use of the low-layers of the Bluetooth protocol stack, including device management functionality. All Bluetooth implementations implement the GAP. </li></ul></ul>
  6. 6. Bluetooth Profiles <ul><li>Service Discover Application Profile (SDAP) – describes a specific application and usage of SDP, the availability and user interface aspects of service discovery, and the use of the L2CAP and low-layer for service discovery. </li></ul><ul><li>Serial Port Profile (SPP) – defines the RFCOMM, L2CAP, SDP, and low-layer layer interoperability requirements and capabilities, for serial cable emulation. </li></ul><ul><li>Dial-up Networking Profile (DUNP) – defines the interoperability requirements for GAP and SPP, and dialing and control capabilities that allows a device to serve as a dial-up device. </li></ul><ul><li>Generic Object Exchange Profile (GOEP) – defines the OBEX, SPP, and GAP interoperability requirements, and OBEX capabilities for file transfers, object push, and synchronization. </li></ul><ul><li>Object Push Profile (OPP) – defines the user interface requirements, use of OBEX and SDP, and the object push feature to push vCard, vCalendar, vNote, and vMessage content formats. </li></ul><ul><li>File Transfer Profile (FTP) – defines the user interface requirements, and the interoperability and use of GOEP, OBEX, and SDP. </li></ul><ul><li>Synchronization Profile (SP) – defines the user interface requirements, and the interoperability and use of GOEP, OBEX and SDP, as well as IrMC synchronization requirements. </li></ul>
  7. 7. Bluetooth Devices and Network <ul><li>Bluetooth devices use a unique IEEE 802 48-bit address. </li></ul><ul><li>When two or more Bluetooth devices connect, they form Piconet </li></ul><ul><li>Bluetooth supports one data channel and a maximum of three voice channels. </li></ul><ul><li>Data exchanged at a rate of approximately 720 kilobits per second & range for device 10 meters(theoretical range 100) </li></ul>
  8. 8. Bluetooth API- Organization <ul><li>Bluetooth API and Java ME platform </li></ul><ul><li>At the bottom of the stack are hardware,OS,Bluetooth Stack, followed by configuration, profile, and optional package(in this case JSR 82) </li></ul>
  9. 9. Bluetooth/OBEX API- Packages Packages Name Description javax.bluetooth.*; Core Bluetooth API, such as Discovery, L2CAP, and device and data interfaces and classes. javax.obex.*; Core Object Exchange (OBEX) APIs. Support is optional.
  10. 10. JSR 82-enable MIDlet <ul><li>All interfaces and classes available to a JSR-82-enabled MIDlet are shown below: </li></ul>
  11. 11. Bluetooth API & GCF
  12. 12. Using Bluetooth API
  13. 13. Bluetooth Client & Server
  14. 14. Initializing the Bluetooth Application(Client) ... private LocalDevice localDevice ; // local Bluetooth Manager private DiscoveryAgent discoveryAgent ; // discovery agent ... /** * Initialize */ public void btInit() throws BluetoothStateException { localDevice = null; discoveryAgent = null; // Retrieve the local device to get to the Bluetooth Manager localDevice = LocalDevice.getLocalDevice(); // Retrieve the discoveryAgent to start inquiry discoveryAgent = localDevice.getDiscoveryAgent(); // Servers set the discoverable mode to GIAC discoveryAgent .startInquiry(DiscoveryAgent.GIAC, this); } ...
  15. 15. Discover Bluetooth Enable Device(Client) <ul><li>public class MyBT implements DiscoveryListener { </li></ul><ul><li>public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod) { </li></ul><ul><li>//Retrieve bt enable devices </li></ul><ul><li>} </li></ul><ul><li>public void inquiryCompleted(int inquiryID) { </li></ul><ul><li>//Get inquiry completed notification </li></ul><ul><li>} </li></ul><ul><li>public void servicesDiscovered(int transID, ServiceRecord[] servRecord) { </li></ul><ul><li>//Retrieve the found devices services </li></ul><ul><li>} </li></ul><ul><li>public void serviceSearchCompleted(int transID, int respCode) { </li></ul><ul><li>//Get services search completed notification </li></ul><ul><li>} </li></ul><ul><li>} </li></ul>
  16. 16. Get BT Services(Client) <ul><li>public class MyBT implements DiscoveryListener{ </li></ul><ul><li>private final UUID[] uuidset = {new UUID(0x1105)}; </li></ul><ul><li>private void getServices(int index){ </li></ul><ul><li>RemoteDevice remoteDevice = (RemoteDevice) btRemoteDevice.elementAt(index); </li></ul><ul><li>… </li></ul><ul><li>… </li></ul><ul><li>discoveryAgent.searchServices(null, uuidset, remoteDevice, this); </li></ul><ul><li>} </li></ul><ul><li> public void servicesDiscovered(int transID, ServiceRecord[] servRecord) { </li></ul><ul><li>//Bt URL found </li></ul><ul><li>} </li></ul><ul><li> public void serviceSearchCompleted(int transID, int respCode){ </li></ul><ul><li>//open connection </li></ul><ul><li>} </li></ul><ul><li>} </li></ul>
  17. 17. Example(Client) <ul><li>public class MyBT implements DiscoveryListener , Runnable{ </li></ul><ul><li>private final UUID[] uuidset = {new UUID(0x1105)}; </li></ul><ul><li>//bt url found </li></ul><ul><li>private String btURL = “btgoep://002109D7F9D:9; authenticate=false;encrypt=false;master=false”; </li></ul><ul><li>… public void run() { InputStream inputStream = null; byte[] data=null; StringBuffer str = new StringBuffer(); try { int i = 0; </li></ul><ul><li>inputStream = getClass().getResourceAsStream(&quot;/icon.png&quot;); while ((i = inputStream.read()) != -1) { str.append((char) i); } data = str.toString().getBytes(); </li></ul><ul><li>//throw exception here Connection conn = Connector.open(btURL); </li></ul><ul><li>ClientSession clientSession = (ClientSession)conn; HeaderSet header = clientSession.createHeaderSet(); header.setHeader(HeaderSet.NAME,&quot;test.png&quot;); header.setHeader(HeaderSet.TYPE,&quot;image/png&quot;); </li></ul>header.setHeader(HeaderSet.LENGTH,new Long(data.length)); HeaderSet headerset = clientSession.connect(header); Operation operation = clientSession.put(header); OutputStream outStream = operation.openDataOutputStream(); outStream.write(data); outStream.close(); operation.close(); clientSession.disconnect(null); conn.close(); } catch (Exception ex) { ex.printStackTrace(); } } }
  18. 18. Bluetooth(Server) <ul><li>public class MyBTServer implements DiscoveryListener , Runnable{ </li></ul><ul><li>private String btURL = “btgoep://002109D7F9D:9; authenticate=false;encrypt=false;master=false”; </li></ul><ul><li>… public void run() { </li></ul><ul><li>try{ </li></ul><ul><li>String ServiceURL =&quot;btgoep://002109D7F9D:9;authenticate=false;encrypt=false;master=false&quot;; </li></ul><ul><li>// create a server connection </li></ul><ul><li>StreamConnectionNotifier notifier = (StreamConnectionNotifier) Connector.open(ServiceURL); </li></ul><ul><li>// accept client connections </li></ul><ul><li>StreamConnection connection = notifier.acceptAndOpen(); </li></ul><ul><li>// prepare to send/receive data </li></ul><ul><li>String msg = &quot;hello there, client&quot;; </li></ul><ul><li>OutputStream os = connection.openOutputStream(); </li></ul><ul><li>// send data to the client </li></ul><ul><li>os.write(msg.getBytes()); </li></ul><ul><li>//close connection </li></ul><ul><li>connection.close(); </li></ul><ul><li>}catch(Exception ex){ </li></ul><ul><li>} </li></ul><ul><li>} </li></ul><ul><li>} </li></ul>
  19. 19. <ul><li>Thank You </li></ul>
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×