问题
I have a dual-mode (BR/EDR + BLE) device running a GATT server. The address is public and same for BLE and BD/EDR.
When I call connectGatt on Galaxy S7 with Android 6.0.1 (API level 23) and set the transport parameter as "TRANSPORT_LE" the phone still tries to establish connection over BD/EDR. It looks like the problem is related to the public address of the BLE because if I set it to private the connection is done over BLE, as expected.
This problem was observed only on Galaxy S7, on other phones (i.e Nexus 6P) the connection is always correctly done over BLE.
Is this an Android bug or am I missing something?
回答1:
Bluetooth 4.0 specification states that if both devices support Classic and LEW then connection must be done over Classic. And Android stacks tend to follow this. Make you other device non-connectable and not in visible in inquiry and it should work fine
回答2:
GATT is not transport specific and it is a framework implemented on top of attribute protocol(ATT). Its possible to access GATT over BR/EDR if the peripheral device is a dual mode device and supports GATT over BR/EDR. Bluetooth 4.X core specifications doesn't mandate access of connection bearer over GATT. Some android phones try using GATT over BR/EDR and applications can not control it. I also observed GATT over BR/EDR in Lenovo TAB 2 A8-50F.
回答3:
An old question, but not answered...
You might have wrong FLAGS on the Advertising packet on the GATT device. Additionally the EIR (Extended Inquiry Response) packet transmitted by the Classic part of your implementation.
There is a flag "BR/EDR NOT SUPPORTED" that might help you in both of these cases.
This problem is common on the CSR chipsets, due to the default setup in the ADK code provided by CSR. Is there any chance you are using a CSR chip? your problem might not be on the android device?
来源:https://stackoverflow.com/questions/40127107/connectgatt-on-samsung-galaxy-s7-creates-connection-over-bluetooth-classic-inste