capke
capke

Reputation: 21

Detect iBeacons on android-things devices (Raspberry Pi 3)

Is it possible to detect iBeacons on android-things devices (Raspberry Pi 3)?

I try to subscribe to Bluetooth Low Energy (BLE) beacon messages with the Nearby Messages API. My app subscribes to ibeacon messages in the foreground, but the registered iBeacons will not detected.

Everythings works fine, but at starting I get this message:

E/BluetoothAdapter: Bluetooth binder is null

Does anybody has experience with the iBeacon detection on Android-things devices (Raspberry Pi 3)?

Upvotes: 0

Views: 692

Answers (3)

shalafi
shalafi

Reputation: 3996

Update: Since the release of Android Things developer preview 3, Bluetooth and BLE are now available.

Bluetooth is disabled in the current version of Android things, it is expected to be included in the near future.

Upvotes: 1

Blundell
Blundell

Reputation: 76496

According to the release notes: https://developer.android.com/things/preview/releases.html

Known issues

  • Bluetooth APIs are currently disabled.

Upvotes: 0

davidgyoung
davidgyoung

Reputation: 64941

I suspect you are having trouble scanning for BLE devices on the Raspberry Pi 3 using Nearby. It may be an issue with Android's driver interface to the onboard Bluetooth LE chip.

Nearby is a hard API to troubleshoot as it is high level and opaque. I would try using low level scanning APIs to see if you can get better error messaging. You could try running my super simple BLE packet counter app. It does a scan like this and simply logs a count of results:

private BluetoothAdapter mBluetoothAdapter;
private boolean mScanning;
private Handler mHandler;
private long mAdvertisementCount = 0;
private BluetoothAdapter.LeScanCallback mLeScanCallback =
        new BluetoothAdapter.LeScanCallback() {
            @Override
            public void onLeScan(final BluetoothDevice device, int rssi,
                                 byte[] scanRecord) {
                mAdvertisementCount++;
                Log.d(TAG, ""+mAdvertisementCount);
            }
        };

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    final BluetoothManager bluetoothManager =
            (BluetoothManager) getSystemService(this.BLUETOOTH_SERVICE);
    mBluetoothAdapter = bluetoothManager.getAdapter();
}

@Override
protected void onResume() {
    super.onResume();
    mBluetoothAdapter.startLeScan(mLeScanCallback);
}

protected void onPause() {
    super.onPause();
    mBluetoothAdapter.stopLeScan(mLeScanCallback);
}

If you run this code you can see if you get any low-level errors in the logs, and if the counter increases in the presence of a beacon.

Upvotes: 0

Related Questions