{"action":"created","issue":{"url":"https://api.github.com/repos/evothings/cordova-ble/issues/109","repository_url":"https://api.github.com/repos/evothings/cordova-ble","labels_url":"https://api.github.com/repos/evothings/cordova-ble/issues/109/labels{/name}","comments_url":"https://api.github.com/repos/evothings/cordova-ble/issues/109/comments","events_url":"https://api.github.com/repos/evothings/cordova-ble/issues/109/events","html_url":"https://github.com/evothings/cordova-ble/issues/109","id":165315521,"number":109,"title":"Empty String and/or odd characters from readCharacteristic","user":{"login":"myyellowshoe","id":518084,"avatar_url":"https://avatars.githubusercontent.com/u/518084?v=3","gravatar_id":"","url":"https://api.github.com/users/myyellowshoe","html_url":"https://github.com/myyellowshoe","followers_url":"https://api.github.com/users/myyellowshoe/followers","following_url":"https://api.github.com/users/myyellowshoe/following{/other_user}","gists_url":"https://api.github.com/users/myyellowshoe/gists{/gist_id}","starred_url":"https://api.github.com/users/myyellowshoe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/myyellowshoe/subscriptions","organizations_url":"https://api.github.com/users/myyellowshoe/orgs","repos_url":"https://api.github.com/users/myyellowshoe/repos","events_url":"https://api.github.com/users/myyellowshoe/events{/privacy}","received_events_url":"https://api.github.com/users/myyellowshoe/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-07-13T13:06:01Z","updated_at":"2016-07-13T22:18:21Z","closed_at":null,"body":"Hey Fellas, and ladies :)\r\n\r\nFor some odd reason I'm getting an empty string and other seamingly random characters when I do a read on a characteristic. Running android with crosswalk on 4.3.\r\n\r\nI've used nrfmastercontrolpanel ( https://play.google.com/store/apps/details?id=no.nordicsemi.android.mcp&hl=en) and things work great with a do a read on the characteristic. \r\n\r\nSo far I've see \"d\", \"2\", \"8\", \"5\" \".\" \"+\"\r\nI copied my logs and mashed them together not sure if they hold any significance. but somthing is definitely up.\r\n%225.385.5225.2.858 2252.525.8285.5.235858+8583.+8.+5.522.29d2dd222+\r\n\r\nHere's my code as well as some low level logs looking at the calls into readCharacteristic. Thoughts?\r\n\r\n```\r\n    module.readPower = function(){\r\n\r\n        var characteristic = _findUuid(module.data.powerService.characteristics, \"00002a19\");\r\n        var desHandle = (_findUuid(characteristic.descriptors, \"00002902\")).handle;\r\n\r\n        var success = function(buffer){\r\n          var data = evothings.ble.fromUtf8(buffer);\r\n          console.log(data);\r\n          /////// Returns \"\";\r\n        };\r\n\r\n        var failure = function(buffer){\r\n          var data = new Uint8Array(buffer);\r\n          console.log(data);\r\n        };\r\n\r\n        //Read data\r\n        evothings.ble.readCharacteristic(module.data.deviceHandle, characteristic.handle, success, failure);\r\n        return 0;\r\n    };\r\n```\r\n\r\n```\r\n\r\n\r\n/************* NRF CONTROL PANEL *************\\\r\nD/BluetoothGatt(13013): readCharacteristic() - uuid: 00002a19-0000-1000-8000-00805f9b34fb\r\nD/BtGatt.btif(12866): btif_gattc_read_char\r\nD/BtGatt.btif(12866): btgattc_handle_event: Event 1013\r\nD/AbsListView(13013): unregisterIRListener() is called\r\nD/BtGatt.btif(12866): btif_gattc_upstreams_evt: Event 3\r\nI/BtGatt.btif(12866): set_read_value unformat.len = 1\r\nD/BluetoothGatt(13013): onCharacteristicRead() - Device=19:00:00:00:00:19 UUID=00002a19-0000-1000-8000-00805f9b34fb Status=0\r\nD/AbsListView(13013): unregisterIRListener() is called\r\nI/AudioService(  331): getStreamVolume 3 index 40\r\nD/AbsListView(13013): unregisterIRListener() is called\r\nD/AbsListView(13013): unregisterIRListener() is called\r\nE/Watchdog(  331): !@Sync 1351\r\nD/STATUSBAR-NetworkController(  807): refreshSignalCluster: data=-1 bt=false\r\nD/STATUSBAR-IconMerger(  807): checkOverflow(192), More:true, Req:true Child:16\r\nD/lights  (  331): button : 0 +\r\nD/lights  (  331): button : 0 -\r\nI/AudioService(  331): getStreamVolume 3 index 40\r\nE/SMD     (  161): DCD ON\r\n\r\n\r\n/************* CORDOVA APP *************\\\r\nI/Sensors (  331): Enabled 9 axis sensor fusion\r\nI/MPL-mldl_cfg_mpu:(  331): inv_mpu_resume(,,,,0000) -> 0000\r\nV/Sensors (  331): Stopping DMP\r\nI/Sensors (  331): Disabled 9 axis sensor fusion\r\nI/MPL-mldl_cfg_mpu:(  331): inv_mpu_suspend(,,,,7fff) -> 0000\r\nD/BluetoothGatt(13639): readCharacteristic() - uuid: 00002a19-0000-1000-8000-00805f9b34fb\r\nD/BtGatt.btif(12866): btif_gattc_read_char\r\nD/BtGatt.btif(12866): btgattc_handle_event: Event 1013\r\nI/AudioService(  331): getStreamVolume 3 index 40\r\nD/BtGatt.btif(12866): btif_gattc_upstreams_evt: Event 3\r\nI/BtGatt.btif(12866): set_read_value unformat.len = 1\r\nD/BluetoothGatt(13639): onCharacteristicRead() - Device=19:00:00:00:00:19 UUID=00002a19-0000-1000-8000-00805f9b34fb Status=0\r\nD/STATUSBAR-NetworkController(  807): refreshSignalCluster: data=-1 bt=false\r\nD/STATUSBAR-IconMerger(  807): checkOverflow(192), More:true, Req:true Child:16\r\nI/AudioService(  331): getStreamVolume 3 index 40\r\nI/chromium(13639): [INFO:CONSOLE(624)] \"No Content-Security-Policy meta tag found. Please add one when using the cordova-plugin-whitelist plugin.\", source: file:///android_asset/www/js/jslog.js (624)\r\nI/AudioService(  331): getStreamVolume 3 index 40\r\nD/STATUSBAR-NetworkController(  807): refreshSignalCluster: data=-1 bt=false\r\nD/STATUSBAR-IconMerger(  807): checkOverflow(192), More:true, Req:true Child:16\r\nE/SMD     (  161): DCD ON\r\n```\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/evothings/cordova-ble/issues/comments/232503637","html_url":"https://github.com/evothings/cordova-ble/issues/109#issuecomment-232503637","issue_url":"https://api.github.com/repos/evothings/cordova-ble/issues/109","id":232503637,"user":{"login":"myyellowshoe","id":518084,"avatar_url":"https://avatars.githubusercontent.com/u/518084?v=3","gravatar_id":"","url":"https://api.github.com/users/myyellowshoe","html_url":"https://github.com/myyellowshoe","followers_url":"https://api.github.com/users/myyellowshoe/followers","following_url":"https://api.github.com/users/myyellowshoe/following{/other_user}","gists_url":"https://api.github.com/users/myyellowshoe/gists{/gist_id}","starred_url":"https://api.github.com/users/myyellowshoe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/myyellowshoe/subscriptions","organizations_url":"https://api.github.com/users/myyellowshoe/orgs","repos_url":"https://api.github.com/users/myyellowshoe/repos","events_url":"https://api.github.com/users/myyellowshoe/events{/privacy}","received_events_url":"https://api.github.com/users/myyellowshoe/received_events","type":"User","site_admin":false},"created_at":"2016-07-13T22:18:21Z","updated_at":"2016-07-13T22:18:21Z","body":"Ok i've figured out a bit more. It looks like the byte array is getting returned properly from the device. In my case i'm looking for a number returned from the device.\r\n\r\nI debugged the actual function running on the java side.\r\n\r\n```\r\npublic void onCharacteristicRead(BluetoothGatt g, BluetoothGattCharacteristic c, int status)\r\n\t\t{\r\n\t\t\tLog.d(\"DEBUG\", \"#~#~#~# characteristic read: \" + c.getValue()[0]);\r\n\t\t\tif (status == BluetoothGatt.GATT_SUCCESS) {\r\n\t\t\t\tmCurrentOpContext.success(c.getValue());\r\n\t\t\t} else {\r\n\t\t\t\tmCurrentOpContext.error(status);\r\n\t\t\t}\r\n\t\t\tmCurrentOpContext = null;\r\n\t\t\tprocess();\r\n\t\t}\r\n``` \r\nGives me:\r\n```\r\n#~#~#~# characteristic read: 100\r\n```\r\n\r\nJust what I need. So in since this is the proper value, its a problem with how I'm reading the buffer in javascript.\r\n\r\nShouldn't the following be more than needed?\r\n\r\n```\r\n          var data = evothings.ble.fromUtf8(buffer);\r\n          console.log(data);\r\n```\r\n"}}
{"actor":{"display_login":"myyellowshoe"}}