adriancretu / beacons-android

Android BLE advertising library
Apache License 2.0
115 stars 33 forks source link

Android 8 support #3

Open guillaumelachaud opened 6 years ago

guillaumelachaud commented 6 years ago

I am trying to use the library to broadcast a Beacon from my Google Pixel XL running Android 8.1. I am facing two issues:

Logcat excerpt:


01-02 11:10:00.182 1326-1794/? W/bt_btif: bta_gattc_conn_cback() - cif=3 connected=0 conn_id=3 reason=0x0100
01-02 11:10:00.182 1326-1794/? W/bt_btif: bta_gattc_conn_cback() - cif=4 connected=0 conn_id=4 reason=0x0100
01-02 11:10:00.182 1326-1794/? W/bt_btif: bta_gattc_conn_cback() - cif=6 connected=0 conn_id=6 reason=0x0100
01-02 11:10:00.183 1326-1794/? W/bt_btif: bta_gattc_conn_cback() - cif=7 connected=0 conn_id=7 reason=0x0100
01-02 11:10:00.183 1326-1794/? W/bt_btif: bta_gattc_conn_cback() - cif=8 connected=0 conn_id=8 reason=0x0100
01-02 11:10:00.185 2153-2673/? D/BluetoothGattServer: onServerConnectionState() - status=0 serverIf=5 device=E0:49:D9:C3:F7:C9
01-02 11:10:00.187 7708-7720/? D/BluetoothGatt: onClientConnectionState() - status=133 clientIf=8 device=E0:49:D9:C3:F7:C9
01-02 11:10:00.204 7708-7852/? D/BluetoothGatt: cancelOpen() - device: E0:49:D9:C3:F7:C9
01-02 11:10:00.207 1326-1794/? E/bt_btif: No such connection need to be cancelled
01-02 11:10:00.208 1326-1794/? E/bt_stack: [ERROR:bta_gattc_utils.cc(509)] bta_gattc_mark_bg_conn unable to find the bg connection mask for: e0:49:d9:c3:f7:c9
01-02 11:10:00.218 7708-7852/? D/BluetoothGatt: close()
01-02 11:10:00.218 7708-7852/? D/BluetoothGatt: unregisterApp() - mClientIf=8
01-02 11:10:00.219 7708-7961/? D/BluetoothGatt: connect() - device: D6:11:68:96:F7:7D, auto: false
01-02 11:10:00.219 7708-7961/? D/BluetoothGatt: registerApp()
01-02 11:10:00.220 7708-7961/? D/BluetoothGatt: registerApp() - UUID=8441d0b4-251f-4c79-b1f0-7a5cd3306cc6
01-02 11:10:00.224 1326-1794/? I/bt_stack: [INFO:gatt_api.cc(1004)] GATT_Register
01-02 11:10:00.225 1326-1794/? I/bt_stack: [INFO:gatt_api.cc(1027)] allocated gatt_if=8
01-02 11:10:00.231 7708-7720/? D/BluetoothGatt: onClientRegistered() - status=0 clientIf=8
01-02 11:10:00.236 1326-1794/? I/bt_stack: [INFO:gatt_api.cc(1168)] GATT_Connectgatt_if=8 d6:11:68:96:f7:7d
01-02 11:10:01.951 887-1560/? I/WifiService: releaseMulticastLock uid=10156
01-02 11:10:02.525 7708-7708/? D/BluetoothManager: getConnectedDevices
01-02 11:10:02.531 2519-2519/? I/BgTaskExecutorImpl: Starting EXCLUSIVE background task send_pending_events_to_clearcut.
01-02 11:10:02.554 2519-2519/? W/SearchService: Abort, client detached.
01-02 11:10:02.555 2519-11929/? I/EventLogSendingHelper: Sending log events.
01-02 11:10:02.590 2153-5407/? I/Places: ?: PlacesBleScanner stop()
01-02 11:10:02.591 2153-2153/? I/BeaconBle: Places requested to stop scan
01-02 11:10:02.597 2153-2153/? I/BeaconBle: Scan canceled successfully.
01-02 11:10:02.606 2153-5407/? I/PlaceInferenceEngine: [anon] Changed inference mode: 105
01-02 11:10:04.564 887-2347/? I/ActivityManager: Killing 9150:com.facebook.katana/u0a296 (adj 906): empty #17```
adriancretu commented 6 years ago

The library is not yet updated to allow the notification for the service on 8.0. So, even though you get back the relevant events there is no actual BLE transmission started. Interesting. Does Beacon Toy behave the same when trying to start a beacon?

guillaumelachaud commented 6 years ago

I just tried Beacon Toy and yes, it does behave the same. Note that I also tried Beacon Simulator (https://play.google.com/store/apps/details?id=net.alea.beaconsimulator) and had the same results.

adriancretu commented 6 years ago

Are you sure the S8 can detect other beacons? The only API updates in Oreo relate to Bluetooth 5.0 support for extended advertising (up to 251 bytes using data channel multiplexing).

guillaumelachaud commented 6 years ago

I don't have physical beacons to try with unfortunately. If you have any ideas on how I can make sure the problem isn't with the S8, I'll be more then happy to try them.

On Tue, Jan 2, 2018, 20:13 Adrian Crețu notifications@github.com wrote:

Are you sure the S8 can detect other beacons? The only API updates in Oreo relate to Bluetooth 5.0 support for extended advertising (up to 251 bytes using data channel multiplexing).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/uriio/beacons-android/issues/3#issuecomment-354924367, or mute the thread https://github.com/notifications/unsubscribe-auth/AB-tcaoQ9mt6oEQYeq17pksuczwKQMsuks5tGuJTgaJpZM4RQ2VT .

guillaumelachaud commented 6 years ago

And it does detect beacons created from an other S8 so this is why I am suspecting the pixel to be the problem.

On Tue, Jan 2, 2018, 20:15 Guillaume LACHAUD guillaume.lachaud@gmail.com wrote:

I don't have physical beacons to try with unfortunately. If you have any ideas on how I can make sure the problem isn't with the S8, I'll be more then happy to try them.

On Tue, Jan 2, 2018, 20:13 Adrian Crețu notifications@github.com wrote:

Are you sure the S8 can detect other beacons? The only API updates in Oreo relate to Bluetooth 5.0 support for extended advertising (up to 251 bytes using data channel multiplexing).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/uriio/beacons-android/issues/3#issuecomment-354924367, or mute the thread https://github.com/notifications/unsubscribe-auth/AB-tcaoQ9mt6oEQYeq17pksuczwKQMsuks5tGuJTgaJpZM4RQ2VT .

adriancretu commented 6 years ago

That logcat is suspiciously referencing BLE GATT connections. Usually a BLE chip will not advertise while there is an active GATT connection in progress. Do you have accessories that are connecting to your Pixel somehow?

guillaumelachaud commented 6 years ago

I don't think so. The Bluetooth icon isn't showing as "connected", my headphones are off, I tried rebooting my device,...

On Tue, Jan 2, 2018, 20:22 Adrian Crețu notifications@github.com wrote:

That logcat is suspiciously referencing BLE GATT connections. Usually a BLE chip will not advertise while there is an active GATT connection in progress. Do you have accessories that are connecting to your Pixel somehow?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/uriio/beacons-android/issues/3#issuecomment-354925187, or mute the thread https://github.com/notifications/unsubscribe-auth/AB-tcTyN3chGzCqdhIKyaEL01fubf-Ljks5tGuRWgaJpZM4RQ2VT .

adriancretu commented 6 years ago

AOSP Oreo 8.1r1 on a Nexus 6 behaves as expected, beacons can be created and even the service works correctly, waking up at the correct time in case of refreshable beacons such as EID.

I'll release shortly a new library version that compiles against the latest SDK, so that the notification works without the app crashing when targeting API 26 or later. But that doesn't fix your issue, which is likely an app on the Pixel that is interfering with the BLE stack.