Wednesday, 15 July 2015

java - Android/ArduinoBT Connection -



java - Android/ArduinoBT Connection -

i'm trying connect samsung galaxy tab arduinobt bluetooth.

my code :

public void run() { if (adapter == null) { return; } device = adapter.getremotedevice(macaddress); seek { socket = device.createrfcommsockettoservicerecord(uuid.fromstring("00001101-0000-1000-8000-00805f9b34fb")); socket.connect(); } grab (exception e) { e.printstacktrace(); } }

when launch application, i've window : http://i.stack.imgur.com/tlc3x.png

i write password : 0000

and in eclipse, can see :

02-05 19:14:36.828: v/bluetoothsocket.cpp(4952): connectnative 02-05 19:14:41.296: v/bluetoothsocket.cpp(4952): ...connect(52, rfcomm) = 111 (errno 111) 02-05 19:14:41.296: w/system.err(4952): java.io.ioexception: connection refused 02-05 19:14:41.296: w/system.err(4952): @ android.bluetooth.bluetoothsocket.connectnative(native method) 02-05 19:14:41.296: w/system.err(4952): @ android.bluetooth.bluetoothsocket.connect(bluetoothsocket.java:236) 02-05 19:14:41.296: w/system.err(4952): @ iut.robot.bluetooththread.run(bluetooththread.java:38)

i don't understand, when used application : https://play.google.com/store/apps/details?id=mobi.dzs.android.bluetoothspp&hl=fr it's worked perfectly.

your bluetooth code looks fine.

here few suggestions might resolve problem:

pair arduinobt, bluetooth settings, before launch application.

make sure there one app connected arduinobt (restart bluetooth in tablet disconnect current connections)

make sure bluetooth mac address in right format i.e. xx:xx:xx:xx:xx:xx

check android app has required permissions android.permission.bluetooth, can add together android.permission.bluetooth_admin not required case

edit:

if correctly paired aurdionobt , entered pin during pairing process, can seek connect insecure rfcomm

socket = device.createinsecurerfcommsockettoservicerecord(uuid.fromstring("00001101-0000-1000-8000-00805f9b34fb"));

java android bluetooth

No comments:

Post a Comment