• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps bluetooth socket(almost there)

DR doggy

Newbie
I am trying to access my firefly serial bluetooth dongle with android phone, i have also tried to connect to laptop usb bt, with no sucess, so far i have gotten manifest proper, and am able to detect pair,

also i should mention connecting dongle to laptop installs spp driver if we need to be aware of that..



[HIGH]





BluetoothAdapter bluetooth = BluetoothAdapter.getDefaultAdapter();
if(bluetooth != null)
{
// Continue with bluetooth setup.
String status;
if (bluetooth.isEnabled()) {
// Enabled. Work with Bluetooth.
String mydeviceaddress = bluetooth.getAddress();
String mydevicename = bluetooth.getName();
int state = bluetooth.getState();
status = mydevicename + " : " + mydeviceaddress + " : " + state;
Set<BluetoothDevice> pairedDevices = bluetooth.getBondedDevices();

String address = "E4:EC:10:BD:E1:3C";
bluetooth.cancelDiscovery();
BluetoothDevice device1 = bluetooth.getRemoteDevice(address);
try {

String UUID_STRING = "00001101-0000-1000-8000-00805F9B34FB";

UUID uuid = UUID.fromString(UUID_STRING);
socket = device1.createRfcommSocketToServiceRecord(BluetoothSerialUuid);


// get adapter
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();

// get remote device
BluetoothDevice btDevice = adapter.getRemoteDevice(address);

socket = btDevice.createInsecureRfcommSocketToServiceRecord(BluetoothSerialUuid);


// Toast.makeText(this,"2"+socket.toString(), Toast.LENGTH_LONG).show();
socket.connect();
// Toast.makeText(this,"3", Toast.LENGTH_LONG).show();




} catch (IOException e) {
// Toast.makeText(this,"ee"+e, Toast.LENGTH_LONG).show();
// TODO Auto-generated catch block
e.printStackTrace();
}



Toast.makeText(this,"ok", Toast.LENGTH_LONG).show();



}
else
{
status = "Bluetooth is not Enabled.";
}
}
else
{
// Disabled. Do something else.
}






[/HIGH]




toast "3" never shows though indicating that the failure is on the:
connect();
other toasts are showing proper data, as far as i can see, indicating that i am getting proper mac & socket, also i have tried with proper uuid,
im not sure how to decode errorlog yet, but error says:


04-02 10:24:08.357: W/System.err(1939): java.io.IOException: [JSR82] connect: Connection is not created (failed or aborted).
04-02 10:24:08.358: W/System.err(1939): at android.bluetooth.BluetoothSocket.connect(BluetoothSocket.java:395)
04-02 10:24:08.358: W/System.err(1939): at ........



i can feel it i am very close
 
Back
Top Bottom