evothings / cordova-ble

Bluetooth Low Energy plugin for Cordova
http://www.evothings.com/
Apache License 2.0
242 stars 103 forks source link

writeCharacteristic causing FC #134

Open storm1er opened 7 years ago

storm1er commented 7 years ago

Hi

I'm trying to send time throung bluetooth to my rpi. but i can't get evothings.ble.writeCharacteristic to wrok for unknown reason :/

app.js :

        ui.append('Time is being updated ...');
        device.writeCharacteristic(
            app.SYSTEMINFORMATIONSERVICE,
            characteristic_uuid,
            new Uint8Array([1]),
            function(){
                ui.append('DONE', true);
            },
                function(error){
                ui.append('ERROR', true);
                ui.text('Warning : '+error);
            }
        );

The app crash just after displaying "Time is being updated ..."

logcat :

02-05 11:03:54.416 20011 20011 D BluetoothGatt: readCharacteristic() - uuid: ffffffff-ffff-ffff-ffff-fffffffffff1
02-05 11:03:54.577  1049  1049 E WifiTrafficPoller: TRAFFIC_STATS_POLL true Token 65 num clients 9
02-05 11:03:54.578  1049  1049 E WifiTrafficPoller:  packet count Tx=94854 Rx=127944

02-05 11:03:54.670  2185  2206 I bt_btif_gatt: set_read_value unformat.len = 42 
02-05 11:03:54.671 20011 20878 D BluetoothGatt: onCharacteristicRead() - Device=B8:27:EB:6C:4F:9C UUID=ffffffff-ffff-ffff-ffff-fffffffffff1 Status=0 srvcType=0 srvcInstId=0 charInstId=0
02-05 11:03:54.694 20011 20011 E AndroidRuntime: FATAL EXCEPTION: main
02-05 11:03:54.694 20011 20011 E AndroidRuntime: Process: com.evothings.evothingsviewer, PID: 20011
02-05 11:03:54.694 20011 20011 E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.bluetooth.BluetoothGattCharacteristic.setWriteType(int)' on a null object reference
02-05 11:03:54.694 20011 20011 E AndroidRuntime:    at com.evothings.BLE$12.run(BLE.java:988)
02-05 11:03:54.694 20011 20011 E AndroidRuntime:    at android.os.Handler.handleCallback(Handler.java:815)
02-05 11:03:54.694 20011 20011 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:104)
02-05 11:03:54.694 20011 20011 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:207)
02-05 11:03:54.694 20011 20011 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:5728)
02-05 11:03:54.694 20011 20011 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
02-05 11:03:54.694 20011 20011 E AndroidRuntime:    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
02-05 11:03:54.694 20011 20011 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)

And on serveur side, everything is fine except that OnWriteRequest isn't called. So android app is crashing before sending information.

Giving some visibility with StackOverflow http://stackoverflow.com/questions/42051102/evothings-ble-write-causing-fc