SlideShare uma empresa Scribd logo
Programming with JSR-82 
Soham Sengupta, 
Sr. Lecturer, Dept of IT, 
JIS College of Engineering 
Author, IBM dW, IBM,US 
Community Contributor to Nokia JME Forum 
& SourceForge, 
Formerly, Systems Engineer, TCS
Bluetooth Technology 
 A short distant Wireless Technology 
 79 channels around 2.4 GHz ISM band 
 GFSK 
 Range 10m, 20m, 100m 
 Bluetooth v2.1 speeds up to 3 Mbps 
 IEEE 802.15 standard 
 You’d learn in details about it later 
October 13, 2014 sohamsengupta@yahoo.com 2
JSR-82: what and why 
 JSR stands for Java Specification 
Request 
 JSR-82 is the one for designing API for 
Bluetooth. 
 Presently JSr-82 exists in Java SE and 
ME, both. So, it’s possible to 
programmatically set up and build app 
layer protocol between 2 BT devices. 
October 13, 2014 sohamsengupta@yahoo.com 3
A Look into JSR-82 compliant 
Blucove v2.1 
 javax.bluetooth.DiscoveryAgent; 
 javax.bluetooth.DiscoveryListener; 
 javax.bluetooth.LocalDevice; 
 javax.bluetooth.RemoteDevice; 
 javax.bluetooth.ServiceRecord; 
 javax.bluetooth.UUID; 
 javax.microedition.io.*; 
October 13, 2014 sohamsengupta@yahoo.com 4
Getting Hardware Address of 
a device and its HF name 
 LocalDevice localDevice = 
LocalDevice.getLocalDevice(); 
System.out.println("Address: 
"+localDevice.getBluetoothAddress()); 
System.out.println("Name:”+localDevice 
.getFriendlyName()); 
October 13, 2014 sohamsengupta@yahoo.com 5
Bluetooth Life Cycle in BTSPP 
1. Initialize Bluetooth Stack 
2. Search for devices in range 
3. After device inquiry completes, select a 
device from, say, a UI or console 
4. Search for service, defined by a UUID, on 
the device 
5. If service is available, set up a btspp 
connection 
6. Now apply App. Rules to transfer data/cmd 
October 13, 2014 sohamsengupta@yahoo.com 6
UUID: what and why 
 It’s a 16-bit/32-bit/ 128-bit HEX integer, to 
identify a service uniquely 
 Generally, 128-bit UUIDs are user defined 
and the probability that 2 devices offer the 
same service in a short range is 2^(-2*128). 
 16-bit UUID are occupied by several pre-defined 
App. Services like DUN, OBEX, HSP 
etc. 
October 13, 2014 sohamsengupta@yahoo.com 7
UUID contd. 
 UUID u=new UUID("1103",true); 
 The above u is a 16-bit pre-defined one. 
 It’s for DUN (Dial-up-Network) 
 True is passed to the constructor to 
signify that it’s a short one. 
 false means it’s a 128-bit one. 
October 13, 2014 sohamsengupta@yahoo.com 8
Searching for Devices… 
 LocalDevice localDevice = 
LocalDevice.getLocalDevice(); 
 DiscoveryAgent agent = 
localDevice.getDiscoveryAgent(); 
 agent.startInquiry(DiscoveryAgent.GIAC, 
dscListerner); 
 GIACGeneral Inquiry Access Code 
 dscListerner is an object of DiscoveryListener 
October 13, 2014 sohamsengupta@yahoo.com 9
Interface DiscoveryListener (4 
methods) 
1. public void deviceDiscovered(RemoteDevice 
btDevice, DeviceClass cod) 
2. public void inquiryCompleted(int discType) 
3. public void servicesDiscovered(int transID, 
ServiceRecord[] servRecord) 
4. public void serviceSearchCompleted(int transID, int 
respCode) 
You have to override these four methods as required. 
October 13, 2014 sohamsengupta@yahoo.com 10
Searching for service 
 agent.searchServices(null,uuidSet,remo 
teDevice,bluetoothServiceDiscovery); 
 uuidSet: UUID[] 
 remoteDevice: RemoteDevice 
 bluetoothServiceDiscovery: 
DiscoveryListener 
 null/ int[] defines attribute sets 
October 13, 2014 sohamsengupta@yahoo.com 11
Obtaining Connection 
 Once service is found, 
 StringconnectionURL=servRecord[0].getConn 
ectionURL(0,false); 
 StreamConnection 
conn=(StreamConnection)Connector.open(co 
nnectionURL); 
 DataOutputStream 
dos=conn.openDataOutputStream(); 
 DataInputStream 
dis=conn.openDataInputStream(); 
October 13, 2014 sohamsengupta@yahoo.com 12
Now we can send data/cmd 
 dos.writeUTF(“Hello”); dos.flush(); 
 String x=dis.readUTF(); 
 dos.write(data,0,length); dos.flush(); 
 Now we shall connect to a Mobile 
Device and access the DUN service 
October 13, 2014 sohamsengupta@yahoo.com 13
AT command 
 Commands to Ctrl GSM Modems 
 Mobile phones, too, respond to them 
 The command to dial a Ph. No. is 
ATD 9830740684; (The ; makes it a voice 
call without which it’s a data call). 
October 13, 2014 sohamsengupta@yahoo.com 14

Mais conteúdo relacionado

Semelhante a JSR-82 Bluetooth tutorial

JSR 82 (bluetooth obex)
JSR 82 (bluetooth obex)JSR 82 (bluetooth obex)
JSR 82 (bluetooth obex)
SMIJava
 
How To Analyze Geolocation Data with Hive and Hadoop
How To Analyze Geolocation Data with Hive and HadoopHow To Analyze Geolocation Data with Hive and Hadoop
How To Analyze Geolocation Data with Hive and Hadoop
Hortonworks
 
AODV protocol
AODV protocolAODV protocol
AODV protocol
Raj Sikarwar
 
D03601023026
D03601023026D03601023026
D03601023026
theijes
 
Controlpcviabluetoothenablemobile 091028150632-phpapp01
Controlpcviabluetoothenablemobile 091028150632-phpapp01Controlpcviabluetoothenablemobile 091028150632-phpapp01
Controlpcviabluetoothenablemobile 091028150632-phpapp01
nagapriyanka
 
Control Pc Via Bluetooth Enable Mobile
Control Pc Via Bluetooth Enable MobileControl Pc Via Bluetooth Enable Mobile
Control Pc Via Bluetooth Enable Mobile
Samiul Hoque
 
Controlpcviabluetoothenablemobile 091028150632-phpapp01
Controlpcviabluetoothenablemobile 091028150632-phpapp01Controlpcviabluetoothenablemobile 091028150632-phpapp01
Controlpcviabluetoothenablemobile 091028150632-phpapp01
ramaswamireddy challa
 
WebRTC Introduction & Basics
WebRTC Introduction & BasicsWebRTC Introduction & Basics
WebRTC Introduction & Basics
Muhammad Ali
 
IRJET - Identification and Classification of IoT Devices in Various Appli...
IRJET -  	  Identification and Classification of IoT Devices in Various Appli...IRJET -  	  Identification and Classification of IoT Devices in Various Appli...
IRJET - Identification and Classification of IoT Devices in Various Appli...
IRJET Journal
 
NetSim Technology Library- Manets
NetSim Technology Library- ManetsNetSim Technology Library- Manets
NetSim Technology Library- Manets
Vishal Sharma
 
Automated location tracking_using_bluetooth
Automated location tracking_using_bluetoothAutomated location tracking_using_bluetooth
Automated location tracking_using_bluetooth
abyaz
 
Adhoc mobile wireless network enhancement based on cisco devices
Adhoc mobile wireless network enhancement based on cisco devicesAdhoc mobile wireless network enhancement based on cisco devices
Adhoc mobile wireless network enhancement based on cisco devices
IJCNCJournal
 
Leveraging the strength of OSGi to deliver a convergent IoT Ecosystem - O Log...
Leveraging the strength of OSGi to deliver a convergent IoT Ecosystem - O Log...Leveraging the strength of OSGi to deliver a convergent IoT Ecosystem - O Log...
Leveraging the strength of OSGi to deliver a convergent IoT Ecosystem - O Log...
mfrancis
 
Profile_Prateek
Profile_PrateekProfile_Prateek
Profile_Prateek
Prateek Mathur
 
Security for automation in Internet of Things by using one time password
Security for automation in Internet of Things by using one time passwordSecurity for automation in Internet of Things by using one time password
Security for automation in Internet of Things by using one time password
SHASHANK WANKHADE
 
Connect your Android to the real world with Bluetooth Low Energy
Connect your Android to the real world with Bluetooth Low EnergyConnect your Android to the real world with Bluetooth Low Energy
Connect your Android to the real world with Bluetooth Low Energy
Gabor Paller
 
Android accessories session 2
Android accessories session 2Android accessories session 2
Android accessories session 2
Sathish Raju
 
40120130405021
4012013040502140120130405021
40120130405021
IAEME Publication
 
Topic # 16 of outline Managing Network Services.pptx
Topic # 16 of outline Managing Network Services.pptxTopic # 16 of outline Managing Network Services.pptx
Topic # 16 of outline Managing Network Services.pptx
AyeCS11
 
Ijarcet vol-2-issue-3-933-937
Ijarcet vol-2-issue-3-933-937Ijarcet vol-2-issue-3-933-937
Ijarcet vol-2-issue-3-933-937
Editor IJARCET
 

Semelhante a JSR-82 Bluetooth tutorial (20)

JSR 82 (bluetooth obex)
JSR 82 (bluetooth obex)JSR 82 (bluetooth obex)
JSR 82 (bluetooth obex)
 
How To Analyze Geolocation Data with Hive and Hadoop
How To Analyze Geolocation Data with Hive and HadoopHow To Analyze Geolocation Data with Hive and Hadoop
How To Analyze Geolocation Data with Hive and Hadoop
 
AODV protocol
AODV protocolAODV protocol
AODV protocol
 
D03601023026
D03601023026D03601023026
D03601023026
 
Controlpcviabluetoothenablemobile 091028150632-phpapp01
Controlpcviabluetoothenablemobile 091028150632-phpapp01Controlpcviabluetoothenablemobile 091028150632-phpapp01
Controlpcviabluetoothenablemobile 091028150632-phpapp01
 
Control Pc Via Bluetooth Enable Mobile
Control Pc Via Bluetooth Enable MobileControl Pc Via Bluetooth Enable Mobile
Control Pc Via Bluetooth Enable Mobile
 
Controlpcviabluetoothenablemobile 091028150632-phpapp01
Controlpcviabluetoothenablemobile 091028150632-phpapp01Controlpcviabluetoothenablemobile 091028150632-phpapp01
Controlpcviabluetoothenablemobile 091028150632-phpapp01
 
WebRTC Introduction & Basics
WebRTC Introduction & BasicsWebRTC Introduction & Basics
WebRTC Introduction & Basics
 
IRJET - Identification and Classification of IoT Devices in Various Appli...
IRJET -  	  Identification and Classification of IoT Devices in Various Appli...IRJET -  	  Identification and Classification of IoT Devices in Various Appli...
IRJET - Identification and Classification of IoT Devices in Various Appli...
 
NetSim Technology Library- Manets
NetSim Technology Library- ManetsNetSim Technology Library- Manets
NetSim Technology Library- Manets
 
Automated location tracking_using_bluetooth
Automated location tracking_using_bluetoothAutomated location tracking_using_bluetooth
Automated location tracking_using_bluetooth
 
Adhoc mobile wireless network enhancement based on cisco devices
Adhoc mobile wireless network enhancement based on cisco devicesAdhoc mobile wireless network enhancement based on cisco devices
Adhoc mobile wireless network enhancement based on cisco devices
 
Leveraging the strength of OSGi to deliver a convergent IoT Ecosystem - O Log...
Leveraging the strength of OSGi to deliver a convergent IoT Ecosystem - O Log...Leveraging the strength of OSGi to deliver a convergent IoT Ecosystem - O Log...
Leveraging the strength of OSGi to deliver a convergent IoT Ecosystem - O Log...
 
Profile_Prateek
Profile_PrateekProfile_Prateek
Profile_Prateek
 
Security for automation in Internet of Things by using one time password
Security for automation in Internet of Things by using one time passwordSecurity for automation in Internet of Things by using one time password
Security for automation in Internet of Things by using one time password
 
Connect your Android to the real world with Bluetooth Low Energy
Connect your Android to the real world with Bluetooth Low EnergyConnect your Android to the real world with Bluetooth Low Energy
Connect your Android to the real world with Bluetooth Low Energy
 
Android accessories session 2
Android accessories session 2Android accessories session 2
Android accessories session 2
 
40120130405021
4012013040502140120130405021
40120130405021
 
Topic # 16 of outline Managing Network Services.pptx
Topic # 16 of outline Managing Network Services.pptxTopic # 16 of outline Managing Network Services.pptx
Topic # 16 of outline Managing Network Services.pptx
 
Ijarcet vol-2-issue-3-933-937
Ijarcet vol-2-issue-3-933-937Ijarcet vol-2-issue-3-933-937
Ijarcet vol-2-issue-3-933-937
 

Mais de Soham Sengupta

Spring method-level-secuirty
Spring method-level-secuirtySpring method-level-secuirty
Spring method-level-secuirty
Soham Sengupta
 
Spring security mvc-1
Spring security mvc-1Spring security mvc-1
Spring security mvc-1
Soham Sengupta
 
JavaScript event handling assignment
JavaScript  event handling assignment JavaScript  event handling assignment
JavaScript event handling assignment
Soham Sengupta
 
Networking assignment 2
Networking assignment 2Networking assignment 2
Networking assignment 2
Soham Sengupta
 
Networking assignment 1
Networking assignment 1Networking assignment 1
Networking assignment 1
Soham Sengupta
 
Sohams cryptography basics
Sohams cryptography basicsSohams cryptography basics
Sohams cryptography basics
Soham Sengupta
 
Network programming1
Network programming1Network programming1
Network programming1
Soham Sengupta
 
Xmpp and java
Xmpp and javaXmpp and java
Xmpp and java
Soham Sengupta
 
Core java day2
Core java day2Core java day2
Core java day2
Soham Sengupta
 
Core java day1
Core java day1Core java day1
Core java day1
Soham Sengupta
 
Core java day4
Core java day4Core java day4
Core java day4
Soham Sengupta
 
Core java day5
Core java day5Core java day5
Core java day5
Soham Sengupta
 
Exceptions
ExceptionsExceptions
Exceptions
Soham Sengupta
 
Java.lang.object
Java.lang.objectJava.lang.object
Java.lang.object
Soham Sengupta
 
Jsp1
Jsp1Jsp1
Soham web security
Soham web securitySoham web security
Soham web security
Soham Sengupta
 
Html tables and_javascript
Html tables and_javascriptHtml tables and_javascript
Html tables and_javascript
Soham Sengupta
 
Html javascript
Html javascriptHtml javascript
Html javascript
Soham Sengupta
 
Java script
Java scriptJava script
Java script
Soham Sengupta
 
Sohamsg ajax
Sohamsg ajaxSohamsg ajax
Sohamsg ajax
Soham Sengupta
 

Mais de Soham Sengupta (20)

Spring method-level-secuirty
Spring method-level-secuirtySpring method-level-secuirty
Spring method-level-secuirty
 
Spring security mvc-1
Spring security mvc-1Spring security mvc-1
Spring security mvc-1
 
JavaScript event handling assignment
JavaScript  event handling assignment JavaScript  event handling assignment
JavaScript event handling assignment
 
Networking assignment 2
Networking assignment 2Networking assignment 2
Networking assignment 2
 
Networking assignment 1
Networking assignment 1Networking assignment 1
Networking assignment 1
 
Sohams cryptography basics
Sohams cryptography basicsSohams cryptography basics
Sohams cryptography basics
 
Network programming1
Network programming1Network programming1
Network programming1
 
Xmpp and java
Xmpp and javaXmpp and java
Xmpp and java
 
Core java day2
Core java day2Core java day2
Core java day2
 
Core java day1
Core java day1Core java day1
Core java day1
 
Core java day4
Core java day4Core java day4
Core java day4
 
Core java day5
Core java day5Core java day5
Core java day5
 
Exceptions
ExceptionsExceptions
Exceptions
 
Java.lang.object
Java.lang.objectJava.lang.object
Java.lang.object
 
Jsp1
Jsp1Jsp1
Jsp1
 
Soham web security
Soham web securitySoham web security
Soham web security
 
Html tables and_javascript
Html tables and_javascriptHtml tables and_javascript
Html tables and_javascript
 
Html javascript
Html javascriptHtml javascript
Html javascript
 
Java script
Java scriptJava script
Java script
 
Sohamsg ajax
Sohamsg ajaxSohamsg ajax
Sohamsg ajax
 

Último

Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Tosin Akinosho
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
Project Management Semester Long Project - Acuity
Project Management Semester Long Project - AcuityProject Management Semester Long Project - Acuity
Project Management Semester Long Project - Acuity
jpupo2018
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
DanBrown980551
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
saastr
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Wask
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
Mariano Tinti
 

Último (20)

Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
Project Management Semester Long Project - Acuity
Project Management Semester Long Project - AcuityProject Management Semester Long Project - Acuity
Project Management Semester Long Project - Acuity
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
 

JSR-82 Bluetooth tutorial

  • 1. Programming with JSR-82 Soham Sengupta, Sr. Lecturer, Dept of IT, JIS College of Engineering Author, IBM dW, IBM,US Community Contributor to Nokia JME Forum & SourceForge, Formerly, Systems Engineer, TCS
  • 2. Bluetooth Technology  A short distant Wireless Technology  79 channels around 2.4 GHz ISM band  GFSK  Range 10m, 20m, 100m  Bluetooth v2.1 speeds up to 3 Mbps  IEEE 802.15 standard  You’d learn in details about it later October 13, 2014 sohamsengupta@yahoo.com 2
  • 3. JSR-82: what and why  JSR stands for Java Specification Request  JSR-82 is the one for designing API for Bluetooth.  Presently JSr-82 exists in Java SE and ME, both. So, it’s possible to programmatically set up and build app layer protocol between 2 BT devices. October 13, 2014 sohamsengupta@yahoo.com 3
  • 4. A Look into JSR-82 compliant Blucove v2.1  javax.bluetooth.DiscoveryAgent;  javax.bluetooth.DiscoveryListener;  javax.bluetooth.LocalDevice;  javax.bluetooth.RemoteDevice;  javax.bluetooth.ServiceRecord;  javax.bluetooth.UUID;  javax.microedition.io.*; October 13, 2014 sohamsengupta@yahoo.com 4
  • 5. Getting Hardware Address of a device and its HF name  LocalDevice localDevice = LocalDevice.getLocalDevice(); System.out.println("Address: "+localDevice.getBluetoothAddress()); System.out.println("Name:”+localDevice .getFriendlyName()); October 13, 2014 sohamsengupta@yahoo.com 5
  • 6. Bluetooth Life Cycle in BTSPP 1. Initialize Bluetooth Stack 2. Search for devices in range 3. After device inquiry completes, select a device from, say, a UI or console 4. Search for service, defined by a UUID, on the device 5. If service is available, set up a btspp connection 6. Now apply App. Rules to transfer data/cmd October 13, 2014 sohamsengupta@yahoo.com 6
  • 7. UUID: what and why  It’s a 16-bit/32-bit/ 128-bit HEX integer, to identify a service uniquely  Generally, 128-bit UUIDs are user defined and the probability that 2 devices offer the same service in a short range is 2^(-2*128).  16-bit UUID are occupied by several pre-defined App. Services like DUN, OBEX, HSP etc. October 13, 2014 sohamsengupta@yahoo.com 7
  • 8. UUID contd.  UUID u=new UUID("1103",true);  The above u is a 16-bit pre-defined one.  It’s for DUN (Dial-up-Network)  True is passed to the constructor to signify that it’s a short one.  false means it’s a 128-bit one. October 13, 2014 sohamsengupta@yahoo.com 8
  • 9. Searching for Devices…  LocalDevice localDevice = LocalDevice.getLocalDevice();  DiscoveryAgent agent = localDevice.getDiscoveryAgent();  agent.startInquiry(DiscoveryAgent.GIAC, dscListerner);  GIACGeneral Inquiry Access Code  dscListerner is an object of DiscoveryListener October 13, 2014 sohamsengupta@yahoo.com 9
  • 10. Interface DiscoveryListener (4 methods) 1. public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod) 2. public void inquiryCompleted(int discType) 3. public void servicesDiscovered(int transID, ServiceRecord[] servRecord) 4. public void serviceSearchCompleted(int transID, int respCode) You have to override these four methods as required. October 13, 2014 sohamsengupta@yahoo.com 10
  • 11. Searching for service  agent.searchServices(null,uuidSet,remo teDevice,bluetoothServiceDiscovery);  uuidSet: UUID[]  remoteDevice: RemoteDevice  bluetoothServiceDiscovery: DiscoveryListener  null/ int[] defines attribute sets October 13, 2014 sohamsengupta@yahoo.com 11
  • 12. Obtaining Connection  Once service is found,  StringconnectionURL=servRecord[0].getConn ectionURL(0,false);  StreamConnection conn=(StreamConnection)Connector.open(co nnectionURL);  DataOutputStream dos=conn.openDataOutputStream();  DataInputStream dis=conn.openDataInputStream(); October 13, 2014 sohamsengupta@yahoo.com 12
  • 13. Now we can send data/cmd  dos.writeUTF(“Hello”); dos.flush();  String x=dis.readUTF();  dos.write(data,0,length); dos.flush();  Now we shall connect to a Mobile Device and access the DUN service October 13, 2014 sohamsengupta@yahoo.com 13
  • 14. AT command  Commands to Ctrl GSM Modems  Mobile phones, too, respond to them  The command to dial a Ph. No. is ATD 9830740684; (The ; makes it a voice call without which it’s a data call). October 13, 2014 sohamsengupta@yahoo.com 14