Bluetooth Smart (4.0) / GATT support in Android 4.0?

前端 未结 6 498
陌清茗
陌清茗 2021-01-30 14:29

I\'m trying to find way to work with Bluetooth 4.0 (AKA Bluetooth Smart) devices using modern Android smartphones, namely - HTC One V.

As I understood, there is some iss

6条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-30 14:50

    After some research I can only say this:

    • Motorola has sided with Broadcom to develop a proprietary API. It would seem it is extremely limited since it states there's support for existing profiles only. Check it out here.

    • Samsung fails to provide any information regarding its BLE API, which I can verify exists and is called samsung.bluetoothle. I actually decompiled some apps from Google Play that use the SGSIII's BLE capabilities and found a couple of methods that do not exist in Android's native BT API, and they're names clearly state they're BLE related. I've tried using them through java reflection and am currently working out the possibility of developing a library. But tests I've run so far have had shakey results at best. There is also a thread on Samsung's developer forum, I would suggest making some pressure here if you're interested.

    • Google has made almost no remarks in this aspect. There's a thread regarding this issues in the Galaxy Nexus, which you should star, with a lot of people complaining. The closest thing to an answer from Google can be found here.

    [UPDATE]

    Samsung has also modified a couple of Android's classes, more especifically:

    • BluetoothAdapter
    • BluetoothDevice

    [UPDATE]

    Since I've put this issue aside for a while due to lack of support from both Google and Samsung I'll post what I've learned so far:

    BluetoothAdapter new methods:

    public boolean android.bluetooth.BluetoothAdapter.leTestEnd()
    public boolean android.bluetooth.BluetoothAdapter.setAvStreaming(boolean)
    public boolean android.bluetooth.BluetoothAdapter.setScanLE(boolean)
    public void android.bluetooth.BluetoothAdapter.setScoPathChange(int)
    public boolean android.bluetooth.BluetoothAdapter.startLeDiscovery()
    

    To use them do the following:

    BluetoothAdapter ba = new BluetoothAdapter();
    Method starteLeDiscoveryMethod = null;
    starteLeDiscoveryMethod = ba.class.getMethod("startLeDiscovery");
    starteLeDiscoveryMethod.invoke(ba);
    

    NOTE: This method in particular works somewhat like the regular startDiscovery() method but, at least for me, it discovers the BLE device 2 out of 5 times. And remember, this is only for the SGSIII. I haven't gotten around to extracting the new methods in BluetoothDevice but when I do, I'll post them here.

提交回复
热议问题