From 31a2bc9b76e0c32c74359f3cc21f9222aaa19c2b Mon Sep 17 00:00:00 2001 From: Jay Date: Thu, 10 Aug 2017 22:31:02 +0800 Subject: [PATCH] update --- gdata-characteristic.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/gdata-characteristic.js b/gdata-characteristic.js index 4be0314..a453fd5 100644 --- a/gdata-characteristic.js +++ b/gdata-characteristic.js @@ -16,22 +16,22 @@ class DataCharacteristic extends bleno.Characteristic { ] }) } - + onWriteRequest(data, offset, withoutResponse, callback) { console.log(`offset :: ${offset} , withoutRes :: ${withoutResponse}`) console.log(`get data`, data) - if(data.length == 1 && data[0] == 0x00){ - tmp = [] - console.log(data[0]) - }else if(data.length == 1 && data[0] == 0xff){ - //console.log(tmp) - console.log(new Buffer(tmp).toString()) - }else{ - tmp = [...tmp, ...data.slice(2, data.length)] - } + if (data.length == 1 && data[0] == 0x00) { + tmp = [] + console.log(data[0]) + } else if (data.length == 1 && data[0] == 0xff) { + //console.log(tmp) + console.log(new Buffer(tmp).toString()) + } else { + tmp = [...tmp, ...data.slice(2, data.length)] + } if (!withoutResponse) { - console.log('send response') + console.log('send response') callback(this.RESULT_SUCCESS) } }