Closed ExoMemphiz closed 5 years ago
Could you add more context? The minimal code that shows the issue? So far it seems that you have a problem with the peripheral you use
Sure, we can assume I am connecting correctly, as I can read "normal" values, such as its serial number just fine.
Here is a snippet of the code to set up the "monitoring" of the 2 Glucose Characteristics, "Measure" and the "Measure Context"
https://hastebin.com/mekakotuqe.js
And to create the Base64, I used this Java code:
Also, just tried running the code again, got this, this time:
{"message":"Device .... was disconnected","errorCode":201,"attErrorCode":19,"iosErrorCode":null,"androidErrorCode":null,"reason":"Disconnected from .... with status 19 (UNKNOWN)"}
Thrown from the callback methods in the "monitorCharacteristicForService" function.
And stringified the error from the writeCharacteristic method, seems like it's an "Internal Error" for the device, so you are probably correct with the problem with the device I am using, any idea what I can do, though?
{"message":"Characteristic 00002a52-0000-1000-8000-00805f9b34fb write failed for device ....
and service 00001808-0000-1000-8000-00805f9b34fb","errorCode":401,"attErrorCode":null,
"iosErrorCode":null,"androidErrorCode":129,"reason":"GATT exception from MAC address ....,
status 129 (GATT_INTERNAL_ERROR), type BleGattOperation{description='CHARACTERISTIC_WRITE'}.
(Look up status 0x81 here https://android.googlesource.com/platform/external/bluetooth/bluedroid/+/android-5.1.0_r1/stack/include/gatt_api.h)",
"name":"BleError","line":94116,"column":28,"sourceURL":"...."}
"attErrorCode":19
is GATT_CONN_TERMINATE_PEER_USER
. The peripheral you use disconnects itself. Most probably because the bonding is not established. Bonding is managed by the system and the library does nothing with it.
You should ask the firmware developer what is the preferred way of interacting with this device and stick to it.
Fantastic, have contacted them, awaiting their response. If it's somewhat useable for others, and not ultra specific for my use case I will leave a comment with the answer that I got, otherwise I will close this issue, thanks for your swift replies!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
@ExoMemphiz
Fantastic, have contacted them, awaiting their response.
Did you find out what was the reason for that error?
I'm also having the same problem, @tymoxx you are also having this problem?
@joaovitorqueiroz In my case, the device was disconnecting after 45 seconds.
So I added setInterval
to do writeCharacteristicWithoutResponseForService
every 40 seconds(which just gets the status of the device).
And it keeps the device connected.
@joaovitorqueiroz In my case, the device was disconnecting after 45 seconds. So I added
setInterval
to dowriteCharacteristicWithoutResponseForService
every 40 seconds(which just gets the status of the device). And it keeps the device connected.
Hello, I have the same problem and wanted to implement your solution, where I put the setInterval, could you show me the code.
Thanks!
@harguus I put setInterval
inside the connect()
function.
Here is a simplified code. Your code will be different depending on how you connect to your device:
async connect(id) {
const device = await deviceManager.connectToDevice(id);
const discoveredDevice = await device.discoverAllServicesAndCharacteristics();
/* Sync periodically - to keep device connected*/
const interval = setInterval(function () {
const value = 'your_value'; // in my case, I synchronize time between the app and device. But you can do anything - it's just to keep the device connected.
discoveredDevice.writeCharacteristicWithResponseForService(SERVICE_UUID, WRITE_CHARACTERISTIC_UUID, value);
}, 40000);
dispatch(saveInterval(interval)); // I also save the instance of the interval to the state, so I can do clearInterval later.
}
@harguus I put
setInterval
inside theconnect()
function. Here is a simplified code. Your code will be different depending on how you connect to your device:async connect(id) { const device = await deviceManager.connectToDevice(id); const discoveredDevice = await device.discoverAllServicesAndCharacteristics(); /* Sync periodically - to keep device connected*/ const interval = setInterval(function () { const value = 'your_value'; // in my case, I synchronize time between the app and device. But you can do anything - it's just to keep the device connected. discoveredDevice.writeCharacteristicWithResponseForService(SERVICE_UUID, WRITE_CHARACTERISTIC_UUID, value); }, 40000); dispatch(saveInterval(interval)); // I also save the instance of the interval to the state, so I can do clearInterval later. }
Hello, thanks for the light at the end of the tunnel, I understood well, I used setInterval() but calling the write function passing a command to return the device version. resolved well so far.
Thank you!
Prerequisites
Expected Behavior
Monitoring a characteristic for notifications, should receive the notifications.
Current Behavior
Receive an error that is not very detailed, I tried adding logs to the java code, to see what happens and where. This is as far as I've come:
In BleModule.java, the function "safeMonitorCharacteristicForDevice", the setupMode is set to "QUICK_SETUP", and it setup a notification (
And the error function gets invoked:
The Log.e produce the following:
Where "...." is a unique device ID.
Steps to Reproduce
Please provide detailed steps for reproducing the issue.
Context