openScale icon indicating copy to clipboard operation
openScale copied to clipboard

java.lang.NullPointerException: no valid characteristic provided

Open mist opened this issue 3 years ago • 1 comments

Describe the bug openScale crashes when it shouldn't

To Reproduce Happened only once, so no reproduction

Steps I did when it happened:

  1. Switched on the scale, stepped on it and started weighting
  2. Switched on my tablet (while weight was not measured yet) and saw openscale connecting
  3. Scale showed bluetooth-symbol
  4. openscale showed currently measured weight as toast
  5. Scale finished measurements normally
  6. openscale toast vanished
  7. I waited some time if the measurement will arrive in the app but it didn't happen
  8. switched bluetooth off inside openscale and back on
  9. Crash. (Pretty instant after switching on bluetooth)
  10. I restarted the app, it didn't connect. I did another measurement, nothing appeared in the app. Tried reconnecting, force close, the usual stuff.
  11. I removed the batteries of the scale and reinserted them
  12. Both measurements appeared in openscale and everything is fine again.

Expected behavior

  • No crash.
  • If possible recovery of weird app-scale state.

Debug log

Scale: Sanitas SBF70
Build version: 2.3.5 
Build date: 1981-01-01 01:01:02 
Current date: 2021-03-18 11:05:05 
Device: Samsung SM-T719 
OS version: Android 7.0 (SDK 24) 
 
Stack trace:  
java.lang.NullPointerException: no valid characteristic provided
 at java.util.Objects.requireNonNull(Objects.java:228)
 at com.welie.blessed.BluetoothPeripheral.writeCharacteristic(BluetoothPeripheral.java:1182)
 at com.health.openscale.core.bluetooth.BluetoothCommunication.writeBytes(BluetoothCommunication.java:200)
 at com.health.openscale.core.bluetooth.BluetoothCommunication.writeBytes(BluetoothCommunication.java:188)
 at com.health.openscale.core.bluetooth.BluetoothBeurerSanitas.writeBytes(BluetoothBeurerSanitas.java:573)
 at com.health.openscale.core.bluetooth.BluetoothBeurerSanitas.sendAlternativeStartCode(BluetoothBeurerSanitas.java:602)
 at com.health.openscale.core.bluetooth.BluetoothBeurerSanitas.onNextStep(BluetoothBeurerSanitas.java:179)
 at com.health.openscale.core.bluetooth.BluetoothCommunication.nextMachineStep(BluetoothCommunication.java:460)
 at com.health.openscale.core.bluetooth.BluetoothCommunication.nextMachineStep(BluetoothCommunication.java:462)
 at com.health.openscale.core.bluetooth.BluetoothCommunication.resumeMachineState(BluetoothCommunication.java:173)
 at com.health.openscale.core.bluetooth.BluetoothCommunication$1.onServicesDiscovered(BluetoothCommunication.java:329)
 at com.welie.blessed.BluetoothPeripheral$1$1.run(BluetoothPeripheral.java:323)
 at android.os.Handler.handleCallback(Handler.java:751)
 at android.os.Handler.dispatchMessage(Handler.java:95)
 at android.os.Looper.loop(Looper.java:154)
 at android.app.ActivityThread.main(ActivityThread.java:6780)
 at java.lang.reflect.Method.invoke(Native Method)
 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1500)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1390)

mist avatar Mar 18 '21 20:03 mist

please try out the latest openScale dev version.

oliexdev avatar May 16 '21 09:05 oliexdev