11

What I'm doing now is trying to scan for both BLE and classic bluetooth devices at the same time. As far as I could see I can discover both by using:

BluetoothAdapter.getDefaultAdapter().startDiscovery() and receiving intents via previously registered BroadcastReceiver. It works fine and I can distinguish between classic and LE devices but I have some valuable data in advertising packet and I have no idea how to get it from incoming Intent. Appreciate any ideas.

bgplaya
  • 1,105
  • 15
  • 27
  • This has already been answered here: http://stackoverflow.com/a/22315225/1214974 – Janus Varmarken Aug 25 '15 at 16:34
  • onLeScan this is for BLE devices, but I need to get this `scanRecord` (advertisement packet) from classic device. – bgplaya Aug 25 '15 at 19:49
  • Sorry, I thought only BLE allowed bundling advertisement data. What is in the packet? – Janus Varmarken Aug 25 '15 at 21:10
  • Where did you hear this? There is some device specific data (color,model, etc.), the issue actually is in getting this advertisement data for BLE device but scanning like for classic using `startDiscovery()` and receiving result in `BroadcastReceiver` – bgplaya Aug 26 '15 at 06:27
  • I didn't hear it from somewhere/someone, I just never used bundling of extra advertisement data in Bluetooth Classic. I added an answer that may help you get some of the information you need. Hope it helps. – Janus Varmarken Aug 26 '15 at 07:24

1 Answers1

3

I am not sure if this will allow you to get all the information you need, but it should allow you to get at least some of it.

When you receive the ACTION_FOUND Intent, that Intent has an extra field identified by BluetoothDevice.EXTRA_DEVICE. This extra contains an instance of BluetoothDevice that represents the remote device. The BluetoothDevice instance will allow you to get some information about the device such as its name and type.

Moreover, the ACTION_FOUND Intent also has an extra field identified by BluetoothDevice.EXTRA_CLASS which contains a BluetoothClass instance that also provides some more information about the remote device such as the class of the device.

See the class documentation for BluetoothDevice and BluetoothClass.

Janus Varmarken
  • 2,306
  • 3
  • 20
  • 42
  • 1
    Yeah, I know that but unfortunately there is no extra in `Intent` for raw bytes that I need and also neither `BluetoothDevice` or `BluetoothClass` doesn't provide that too. – bgplaya Aug 26 '15 at 11:04