android-ble

Android 4.4 BLE Scanning lack of stability

青春壹個敷衍的年華 提交于 2019-12-09 18:59:15
问题 Would a Bluetooth LE Jedi know any trick how to get a reliable BLE scanning mode on cheap Android 4.4 devices ? Everything works fine from Android 5 to 6, and most of the Android 4.4 phones... However, on some cheap phones with 4.4 we encounter random issues, some phones do not detect anything, or sometimes just a few beacons among others, depending on environment, daytime, weather, or whatever... It's obviously due to a poor software or hardware on this side, but is there any trick to make

Scanning for BLE devices on Android 8+ in the background

穿精又带淫゛_ 提交于 2019-12-08 19:02:26
I'm using the following method from BLE scanner API on Android 8+ to scan for BLE Beacons startScan(List<ScanFilter> filters, ScanSettings settings, PendingIntent callbackIntent) The problem is that after sometimes I can see Scan Logs but nothing is delivered by the callbackIntent any idea why is this happening? This is the expected behavior on Android 8+. if you need to scan continuously a periodic mechanism is needed in this case. For more information about scanning on different Android versions and different ways. Have a look here 来源: https://stackoverflow.com/questions/52777982/scanning

How will i Split a String that received from a ble device for if else checking and display a value on Textview

帅比萌擦擦* 提交于 2019-12-08 10:25:03
问题 In my Android app I receive data from my ble device as something like 10100201201511 ( it includes date,time and other attributes). I hope I received it as a string, I want to check that value and display it on textview. My Requirement is If (position1=0){ //display yes in Text view }else { // display No in Textview } But I always get errors like Array type expected; found 'Java.lang.String' My current code is: @Override public void onCharacteristicRead(BluetoothGatt gatt,

Scanning for BLE devices on Android 8+ in the background

穿精又带淫゛_ 提交于 2019-12-08 08:36:27
问题 I'm using the following method from BLE scanner API on Android 8+ to scan for BLE Beacons startScan(List<ScanFilter> filters, ScanSettings settings, PendingIntent callbackIntent) The problem is that after sometimes I can see Scan Logs but nothing is delivered by the callbackIntent any idea why is this happening? 回答1: This is the expected behavior on Android 8+. if you need to scan continuously a periodic mechanism is needed in this case. For more information about scanning on different

Reading from a BluetoothGattCharacteristic is failing

允我心安 提交于 2019-12-08 05:57:11
问题 Im trying to read the value stored in a BluetoothGattCharacteristic . The following is my BluetoothGattCallback code, where most of the action takes place: private final BluetoothGattCallback mGattCallback = new BluetoothGattCallback() { @Override public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) { if (newState == BluetoothProfile.STATE_CONNECTED) { Log.i(TAG, "Connected to GATT server."); Log.i(TAG, "Getting services...."); gatt.discoverServices(); } else if

The device GattServer stops advertising after connecting to it

隐身守侯 提交于 2019-12-08 04:39:04
问题 This is the link to the GATT Server sample for Android Things on GitHub: https://github.com/androidthings/sample-bluetooth-le-gattserver Setting up the server on RPi-3 is easy enough. What I do not understand is why the GATT server stops advertising once you have connected to then disconnected from the device (BLE connect). ...gattserver I/GattServerActivity: BluetoothDevice CONNECTED: 67:2F:1A:B4:1F:86 ...gattserver D/BluetoothGattServer: onConnectionUpdated() - Device=67:2F:1A:B4:1F:86

How to correctly use UUID.fromString method?

馋奶兔 提交于 2019-12-06 09:48:31
I am trying to read/write these ble characteristics: Right now, I'm trying to read AA01* I am using this library to do it. Here's my code: private void connectToSensorTag(RxBleDevice rxBleDevice) { rxBleDevice.establishConnection(getApplicationContext(), false) .doOnError(new Action1<Throwable>() { @Override public void call(Throwable throwable) { int i = 0; } }) .flatMap(rxBleConnection -> rxBleConnection.readCharacteristic(UUID.fromString("AA01*"))) .subscribe(new Subscriber<byte[]>() { @Override public void onCompleted() { int i = 0; } @Override public void onError(Throwable e) { int i = 0;

Android BLE startDiscovery() callback is not fired even with Location permissions

人盡茶涼 提交于 2019-12-06 05:19:20
问题 The app is targeted to 22 with minimum version 18 and works as expected on Lollipop. Starting Marshmallow apps need to require 'fine' and 'coarse' permissions for BLE. I've added them but the callback is not fired. AndroidManifest: ... <uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/> <!-- ble --> <uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <uses-permission android:name

Android stops finding BLE devices: onClientRegistered() - status=133 clientIf=0

旧街凉风 提交于 2019-12-05 15:52:52
问题 I am developing an app in which I can both find and configure BLE devices. I am using standard Android BLE API, but recently I've encountered some strange problems. When I turn on my app the BLE scan works OK. I am scanning using: mBluetoothAdapter.startLeScan(mLeScanCallback); // for Kitkat and below and mBluetoothAdapter.getBluetoothLeScanner().startScan(mScanCallback); // for Lollipop and above In the Logcat I am getting following messages (I guess this is important for this issue): D

How to get BluetoothGattCharacteristic value format type?

[亡魂溺海] 提交于 2019-12-05 03:49:29
问题 While developing an application for IOT tried communicating with a BLE peripheral device. Using BLE Lollipop API. Each BluetoothGattService can provide different BluetoothGattCharacteristic, each representing a certain value which can be Read, Write or Notified. Value is communicated in various formats. But there is no way to know which format a particular Characteristic is encoded in. I thought this mKeySize could be a solution but, it is neither accessible nor being used inside