Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jan 28 2019 15:36

    dariuszseweryn on dagger

    Improved DeviceComponent and De… (compare)

  • Jan 28 2019 15:21

    dariuszseweryn on dagger

    Improved ClientComponent and Cl… Improved DeviceComponent and De… (compare)

  • Jan 28 2019 15:10

    dariuszseweryn on dagger

    Merged DeviceModuleBinder with … (compare)

  • Jan 28 2019 15:09

    dariuszseweryn on dagger

    Merged ClientModuleBinder with … (compare)

  • Jan 24 2019 15:01
    Steppschuh closed #536
  • Jan 23 2019 19:14
    dariuszseweryn edited #534
  • Jan 22 2019 11:55
    Steppschuh opened #536
  • Jan 20 2019 22:46
    lukaszkalnik opened #535
  • Jan 20 2019 19:53
    mohank1288 opened #534
  • Jan 20 2019 13:14
    lukaszkalnik edited #528
  • Jan 19 2019 22:33
    lukaszkalnik edited #528
  • Jan 19 2019 22:32
    lukaszkalnik edited #528
  • Jan 19 2019 22:32
    lukaszkalnik synchronize #528
  • Jan 19 2019 15:39
    lukaszkalnik closed #531
  • Jan 19 2019 15:39
    lukaszkalnik synchronize #528
  • Jan 18 2019 17:27

    dariuszseweryn on dagger

    Improved DeviceComponent and De… (compare)

  • Jan 18 2019 17:22

    dariuszseweryn on dagger

    Improved ClientComponent and Cl… (compare)

  • Jan 18 2019 17:21

    dariuszseweryn on dagger

    Bumped dagger version to 2.21 (compare)

  • Jan 18 2019 16:23
    dariuszseweryn closed #510
  • Jan 18 2019 16:21

    dariuszseweryn on master

    Added sample application in kot… (compare)

Nguyễn Trung Nghĩa
@trungnghi4
I have used ReplayingShare, could that be the problem that caused GATT 133 error?
Dariusz Seweryn
@dariuszseweryn
Unlikely
Nguyễn Trung Nghĩa
@trungnghi4
So in your opinion, is the cause of the GATT 133 error?
Can you give me a solution to fix this problem?
Dariusz Seweryn
@dariuszseweryn
I have just updated the post on the wiki. I have described there all I know about 133
Nguyễn Trung Nghĩa
@trungnghi4
ok thanks u
Nguyễn Trung Nghĩa
@trungnghi4
@dariuszseweryn How do I get Gatt Bluetooth?
I want to clear all data when disconnected in addition to using dispose ()
jeevankibbcom
@jeevankibbcom
@dariuszseweryn Hi, Just want to know can we get ble connection state like if device is connected or disconnected and if connection is lost, I am using ReplayingShare instance for connecting, reading and writing in my project
if yes, can you share an example of a code snippet on the same
Dariusz Seweryn
@dariuszseweryn
What do you want to use it for?
jeevankibbcom
@jeevankibbcom
For updating UI and to stop further reading and writing to the device
Dariusz Seweryn
@dariuszseweryn
For updating UI there is a convenience method RxBleDevice.observeConnectionStateChanges() or something like that. To correctly stop communication you need to observe RxBleConnection.establishConnection(). There is no sample code for ReplayingShare in this library but you should be able to find some examples on the internet. It is a plain RxJava 2 code after all
jeevankibbcom
@jeevankibbcom
@dariuszseweryn thanks I will check
Mike Simone
@simonemike95
@dariuszseweryn Hi, been stuck on an issue for a few days now, wondering if you had any input. I can successfully connect and write to a device and its characteristics, but I'm having issues reading a characteristic and getting its value. I can get the characteristic but there is never a value, despite the ble device updating the characteristic
In a previous version of the app code, this same characteristic's value was updated and read from properly (before implementing RxAndroidBle) so I know that it works properly
Dariusz Seweryn
@dariuszseweryn
Check notifications
jeevankibbcom
@jeevankibbcom
@dariuszseweryn I implemented the RxBleDevice.observeConnectionStateChanges() but i am only getting connecting and connected status but I am not getting disconnecting and disconnected status even when ble is turned off
I am getting this in logs when ble is turned off
2020-07-05 12:42:01.535 30183-800/se.ctek.ctekapp D/BluetoothGatt: onClientConnectionState() - status=8 clientIf=9 device=84:0D:8E:E6:8A:06
2020-07-05 12:42:01.542 30183-800/se.ctek.ctekapp I/RxBle#GattCallback: MAC='84:0D:8E:E6:8A:XX'  onConnectionStateChange(), status=8, value=0
2020-07-05 12:42:01.545 30183-800/se.ctek.ctekapp D/RxBle#ConnectionOperationQueue: Connection operations queue to be terminated (MAC='84:0D:8E:E6:8A:XX')
    com.polidea.rxandroidble2.exceptions.BleDisconnectedException: Disconnected from MAC='84:0D:8E:E6:8A:XX' with status 8 (GATT_INSUF_AUTHORIZATION or GATT_CONN_TIMEOUT)
        at com.polidea.rxandroidble2.internal.connection.RxBleGattCallback$2.onConnectionStateChange(RxBleGattCallback.java:81)
        at android.bluetooth.BluetoothGatt$1$4.run(BluetoothGatt.java:297)
        at android.bluetooth.BluetoothGatt.runOrQueueCallback(BluetoothGatt.java:860)
        at android.bluetooth.BluetoothGatt.access$200(BluetoothGatt.java:45)
        at android.bluetooth.BluetoothGatt$1.onClientConnectionState(BluetoothGatt.java:292)
        at android.bluetooth.IBluetoothGattCallback$Stub.onTransact(IBluetoothGattCallback.java:199)
        at android.os.Binder.execTransactInternal(Binder.java:1021)
        at android.os.Binder.execTransact(Binder.java:994)
2020-07-05 12:42:01.547 30183-30043/se.ctek.ctekapp V/RxBle#Executors: Terminated (MAC='84:0D:8E:E6:8A:XX')
jeevankibbcom
@jeevankibbcom
Is this the proper behavior or am I missing something here
Dariusz Seweryn
@dariuszseweryn

I have just tried to connect and turn of BT and got all statuses:

2020-07-06 12:31:41.095 28092-28119/com.polidea.rxandroidbleplayground I/RxBle#ClientOperationQueue: RUNNING  ConnectOperation{MAC='XX:XX:XX:XX:XX:XX', autoConnect=false}
2020-07-06 12:31:41.135 28092-28124/com.polidea.rxandroidbleplayground I/CONNECTION: CONNECTING
2020-07-06 12:31:41.152 28092-28124/com.polidea.rxandroidbleplayground D/BluetoothGatt: connect() - device: XX:XX:XX:XX:XX:XX, auto: false
(...)
2020-07-06 12:31:42.012 28092-28126/com.polidea.rxandroidbleplayground D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=5 device=XX:XX:XX:XX:XX:XX
2020-07-06 12:31:42.014 28092-28126/com.polidea.rxandroidbleplayground I/RxBle#GattCallback: MAC='XX:XX:XX:XX:XX:XX'  onConnectionStateChange(), status=0, value=2
2020-07-06 12:31:42.017 28092-28122/com.polidea.rxandroidbleplayground I/CONNECTION: CONNECTED
2020-07-06 12:31:42.022 28092-28119/com.polidea.rxandroidbleplayground D/RxBle#ClientOperationQueue: FINISHED ConnectOperation(31011143) in 928 ms
(...)
2020-07-06 12:32:02.984 28092-28092/com.polidea.rxandroidbleplayground I/RxBle#LoadedApk: Adapter state changed: STATE_TURNING_OFF
2020-07-06 12:32:02.987 28092-28092/com.polidea.rxandroidbleplayground V/RxBle#DisconnectionRouter: An exception received, indicating that the adapter has became unusable.
2020-07-06 12:32:02.991 28092-28092/com.polidea.rxandroidbleplayground D/RxBle#ConnectionOperationQueue: Connection operations queue to be terminated (MAC='XX:XX:XX:XX:XX:XX')
    com.polidea.rxandroidble2.exceptions.BleDisconnectedException: Disconnected from MAC='XX:XX:XX:XX:XX:XX' with status -1 (UNKNOWN)
(...)
2020-07-06 12:32:02.993 28092-28121/com.polidea.rxandroidbleplayground V/RxBle#Executors: Terminated (MAC='XX:XX:XX:XX:XX:XX')
2020-07-06 12:32:02.996 28092-28092/com.polidea.rxandroidbleplayground D/RxBle#ClientOperationQueue: QUEUED   DisconnectOperation(52793970)
2020-07-06 12:32:03.001 28092-28119/com.polidea.rxandroidbleplayground D/RxBle#ClientOperationQueue: STARTED  DisconnectOperation(52793970)
2020-07-06 12:32:03.002 28092-28119/com.polidea.rxandroidbleplayground I/RxBle#ClientOperationQueue: RUNNING  DisconnectOperation{MAC='XX:XX:XX:XX:XX:XX'}
2020-07-06 12:32:03.003 28092-28124/com.polidea.rxandroidbleplayground I/CONNECTION: DISCONNECTING
2020-07-06 12:32:03.003 28092-28124/com.polidea.rxandroidbleplayground D/BluetoothManager: getConnectionState()
2020-07-06 12:32:03.003 28092-28124/com.polidea.rxandroidbleplayground D/BluetoothManager: getConnectedDevices
2020-07-06 12:32:03.007 28092-28192/com.polidea.rxandroidbleplayground D/BluetoothGatt: setCharacteristicNotification() - uuid: UUID enable: false
2020-07-06 12:32:03.015 28092-28124/com.polidea.rxandroidbleplayground D/BluetoothGatt: cancelOpen() - device: XX:XX:XX:XX:XX:XX
2020-07-06 12:32:03.019 28092-28126/com.polidea.rxandroidbleplayground D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=5 device=XX:XX:XX:XX:XX:XX
2020-07-06 12:32:03.021 28092-28126/com.polidea.rxandroidbleplayground I/RxBle#GattCallback: MAC='XX:XX:XX:XX:XX:XX'  onConnectionStateChange(), status=0, value=0
2020-07-06 12:32:03.022 28092-28124/com.polidea.rxandroidbleplayground D/BluetoothGatt: close()
2020-07-06 12:32:03.023 28092-28124/com.polidea.rxandroidbleplayground D/BluetoothGatt: unregisterApp() - mClientIf=5
2020-07-06 12:32:03.024 28092-28124/com.polidea.rxandroidbleplayground I/CONNECTION: DISCONNECTED
2020-07-06 12:32:03.026 28092-28119/com.polidea.rxandroidbleplayground D/RxBle#ClientOperationQueue: FINISHED DisconnectOperation(52793970) in 25 ms

After subscribing to:

rxBleDevice.observeConnectionStateChanges().subscribe { Log.i("CONNECTION", it.name) }
Martin Erlic
@SeloSlav

I'm trying to write a command to my device but I keep getting the following error: com.polidea.rxandroidble2.exceptions.BleAlreadyConnectedException: Already connected to device with MAC address 34:81:F4:C6:09:0F

I've been following the sample app here: https://github.com/Polidea/RxAndroidBle/blob/master/sample-kotlin/src/main/kotlin/com/polidea/rxandroidble2/samplekotlin/example4_characteristic/CharacteristicOperationExampleActivity.kt

When my app starts I have a connection observable running to receive notifications when the device sensor is triggered. But I can't write commands to it without getting the above error.

Is it because I'm not disposing of the previous connection?

Dariusz Seweryn
@dariuszseweryn
Yes
Martin Erlic
@SeloSlav
image.png
This code works for me just fine but in Android Studio I get a warning "The result of subscribe is not used". Seems to me that I am using the result though?
Martin Erlic
@SeloSlav
I am not understanding something. If I can connect to a device so that I can subscribe to a notification, how can I send commands to the device? Should the notification subscription be in some background thread?
It seems like I can listen to the notification but it prevents sending new write operations to the device in the meantime
Dariusz Seweryn
@dariuszseweryn

This code works for me just fine but in Android Studio I get a warning "The result of subscribe is not used". Seems to me that I am using the result though?

No :D Lint is giving you a good suggestion

If I can connect to a device so that I can subscribe to a notification, how can I send commands to the device?

Use the same RxBleConnection (preferably in the same chain ended by a single .subscribe). There are examples of this on the Stackoverflow already. Search for tag [rxandroidble]

Should the notification subscription be in some background thread?

No. The library does the minimal amount of threading for you so the BLE stack will not trip over

It seems like I can listen to the notification but it prevents sending new write operations to the device in the meantime

Again, no. I know RxJava is often referred to have a "steep learning curve" but understanding basics will give you enough info on what can you do. (Spoiler – there are operators that allow you to share the same Observable and others that can allow for merging/combining multiple into one)

Martin Erlic
@SeloSlav
Thanks for the replies. Still learning Rx. Might be getting ahead of myself. Managed to implement my solution by using the same observable. Sharing it between fragments was tricky initially.
Dariusz Seweryn
@dariuszseweryn
Usually you would want to keep BLE related code in objects that are not bound to UI lifecycle.
But that is an architectural discussion and there are tons and tons of approaches
Mike Simone
@simonemike95
Is there an easy way to clear the device cache? Looked at a few topics on SO but nothing has worked for me thus far. My BLE device will reset itself when some settings are changed in the app, I dispose all disposables, but it seems that upon attempting to reconnect, the app is using a cached version of the device sometimes? Not quite sure where I'm going wrong with things.
To be clear - sometimes the disconnect and connect will happen properly, other times the app connects, and the device immediately disconnects, but GATT seems to think it is still connected somehow. Connection state observing works flawlessly on initial connection, only seeing issues after the device is resetting.
Dariusz Seweryn
@dariuszseweryn
If you think about BluetoothGatt.refresh() then check wiki for custom operations. Other than that I do not know how to interpret your case
Mike Simone
@simonemike95
How would I pass in the BluetoothGatt object? From what I understand, it's not directly accessible using the library
Dariusz Seweryn
@dariuszseweryn
I encourage you to check wiki I mentioned
Alex Vo
@vtatntpt_twitter
How to retry connecting with n times? With n = 3. Thanks
Alex Vo
@vtatntpt_twitter
Dariusz Seweryn
@dariuszseweryn
You're welcome! :D
Alex Vo
@vtatntpt_twitter
I have problem, this error: "with status 8 (GATT_INSUF_AUTHORIZATION or GATT_CONN_TIMEOUT)" always happens with some phone models use Android 10 but others normal. Is there any way to fix it? Thanks.
7 replies
Joshua
@joshdaquino
Has anyone used RxAndroidBle to connect to multiple devices at the same time?
5 replies
Hasan Abdullah
@hasancse91
Hello guys! I've a question.
Is this library work properly in an Android phone without play service? e.g: some Huawei device (without play service)
1 reply
Gilad Raz
@seotrader
Hello guys, is this library good for scanning on the background BLE devices near me while spending only a little of the battery? what is the best practice to achieve that with the library?
1 reply
jeevankibbcom
@jeevankibbcom
Hi, how to unsubscribe from a notification without closing the connection to BLE, I see in some posts they are disposing the connection to unsubscribe I don't want that for me BLE connection should be there I just want to unsubscribe from some notifications on I am using replayshare and compositdisposable. Is this possible, if yes can you guide me how???
7 replies
Tran Van Luat
@luattv_gitlab
hi there,
I have the same problem with @AlexVo above, that i meet the problem
"with status 8 (GATT_INSUF_AUTHORIZATION or GATT_CONN_TIMEOUT)"
With device AQOUS R5G.
Because the problem is under investigating, so I decided to make an exception for app when release,
And so, I want to know how it is on other device.
Does any-one here have the same problem? if yes plz share the device name with me?
Thank you very much!
Roman Myronov
@post_mortem_gitlab
Same problem for Galaxy S10+