You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I used your code as a base for writing a little test program for a different device that also has an accelerometer.
When I dumped the data to stdout, it looked a bit strange. While shaking the device, for every 3 realistic looking samples there was one sample with all zeros.
I tracked it down to this:
CBMicroBitBridge.mm, didUpdateValueForCharacteristic method does a call to [peripheral readValueForCharacteristic:characteristic]. I believe this is wrong.
The doc for didUpdateValueForCharacteristic says:
Core Bluetooth invokes this method when your app calls the readValueForCharacteristic: method. A peripheral also invokes this method to notify your app of a change to the value of the characteristic for which the app previously enabled notifications by calling setNotifyValue:forCharacteristic:.
Since your code uses notifications, there is no need to call readValueForCharacteristic manually. And doing that seems to be causing issues somehow. After I removed this call, I'm not getting all-zeros samples anymore. You might want to add && !error in the if condition as well, although I was not getting errors, just all-zeros samples.
Best regards
Gene
The text was updated successfully, but these errors were encountered:
Hello there,
I used your code as a base for writing a little test program for a different device that also has an accelerometer.
When I dumped the data to stdout, it looked a bit strange. While shaking the device, for every 3 realistic looking samples there was one sample with all zeros.
I tracked it down to this:
CBMicroBitBridge.mm,
didUpdateValueForCharacteristic
method does a call to[peripheral readValueForCharacteristic:characteristic]
. I believe this is wrong.The doc for
didUpdateValueForCharacteristic
says:Since your code uses notifications, there is no need to call
readValueForCharacteristic
manually. And doing that seems to be causing issues somehow. After I removed this call, I'm not getting all-zeros samples anymore. You might want to add&& !error
in theif
condition as well, although I was not getting errors, just all-zeros samples.Best regards
Gene
The text was updated successfully, but these errors were encountered: