Throw warning containing raw bluetooth response if JSON parser fails.

This commit is contained in:
mmcwilliams 2020-05-18 21:45:20 -04:00
parent 476708de94
commit 27f996684b
1 changed files with 9 additions and 1 deletions

View File

@ -176,6 +176,7 @@ pwa.wble.read = async function (characteristicId) {
let characteristic;
let value;
let json;
let obj;
if (typeof pwa.wble.characteristics[characteristicId] === 'undefined') {
try {
@ -199,7 +200,14 @@ pwa.wble.read = async function (characteristicId) {
json = decoder.decode(value);
return JSON.parse(json);
try {
obj = JSON.parse(json);
} catch (err) {
console.warn(json);
throw err;
}
return obj;
}
pwa.wble.write = async function ( characteristicId, json) {