Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remote Bluetooth

I'm trying to understand the work client-server bluetooth. Where android is client. PC is server.

I found code. This worked an samsung galaxy 10.1 (android 3.2), but does not work an samsung galaxy s(android 2.3.3) ans htc wildfire s(android 2.2).

MY_UUID = UUID.fromString("04c6093b-0000-1000-8000-00805f9b34fb");

    04-25 18:32:37.023: D/BluetoothCommandService(13665): setState() 1 -> 2
04-25 18:32:37.033: I/BluetoothCommandService(13665): BEGIN mConnectThread
04-25 18:32:37.063: E/BluetoothService.cpp(102): stopDiscoveryNative: D-Bus error in StopDiscovery: org.bluez.Error.Failed (Invalid discovery session)
04-25 18:32:37.103: E/BluetoothCommandService(13665): Unable to start Service Discovery
04-25 18:32:37.103: E/BluetoothCommandService(13665): java.io.IOException: Unable to start Service Discovery
04-25 18:32:37.103: E/BluetoothCommandService(13665):   at android.bluetooth.BluetoothSocket$SdpHelper.doSdp(BluetoothSocket.java:367)
04-25 18:32:37.103: E/BluetoothCommandService(13665):   at android.bluetooth.BluetoothSocket.connect(BluetoothSocket.java:201)
04-25 18:32:37.103: E/BluetoothCommandService(13665):   at com.luugiathuy.apps.remotebluetooth.BluetoothCommandService$ConnectThread.run(BluetoothCommandService.java:258)
04-25 18:32:37.103: D/BluetoothCommandService(13665): setState() 2 -> 1
like image 720
alezhka Avatar asked Apr 25 '12 12:04

alezhka


1 Answers

Your device fails for service discovery (i think so) .

  1. I have read about BT issues with numerous Samsung devices and HTC devices but those where specifically for L2CAP/HID profile. Soln: you could use SPP or RFCOMM if you are using L2CAP

  2. If you are using one of the above mentioned in solution then try using with standard UUID

SPP 00001101-0000-1000-8000-00805F9B34FB

RFCOMM 00000003-0000-1000-8000-00805F9B34FB

Edit

Alternatively you may try using reflection to get your socket connection something like the below method

private static BluetoothSocket createBluetoothSocket(
        int type, int fd, boolean auth, boolean encrypt, String address, int port){
    try {
        Constructor<BluetoothSocket> constructor = BluetoothSocket.class.getDeclaredConstructor(
                int.class, int.class,boolean.class,boolean.class,String.class, int.class);
        constructor.setAccessible(true);
        BluetoothSocket clientSocket = (BluetoothSocket) 
            constructor.newInstance(type,fd,auth,encrypt,address,port);
        return clientSocket;
    }catch (Exception e) { return null; }
}
like image 198
Its not blank Avatar answered Sep 30 '22 23:09

Its not blank