update
This commit is contained in:
parent
65f56a6b14
commit
31a2bc9b76
@ -16,22 +16,22 @@ class DataCharacteristic extends bleno.Characteristic {
|
|||||||
]
|
]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
onWriteRequest(data, offset, withoutResponse, callback) {
|
onWriteRequest(data, offset, withoutResponse, callback) {
|
||||||
console.log(`offset :: ${offset} , withoutRes :: ${withoutResponse}`)
|
console.log(`offset :: ${offset} , withoutRes :: ${withoutResponse}`)
|
||||||
console.log(`get data`, data)
|
console.log(`get data`, data)
|
||||||
|
|
||||||
if(data.length == 1 && data[0] == 0x00){
|
if (data.length == 1 && data[0] == 0x00) {
|
||||||
tmp = []
|
tmp = []
|
||||||
console.log(data[0])
|
console.log(data[0])
|
||||||
}else if(data.length == 1 && data[0] == 0xff){
|
} else if (data.length == 1 && data[0] == 0xff) {
|
||||||
//console.log(tmp)
|
//console.log(tmp)
|
||||||
console.log(new Buffer(tmp).toString())
|
console.log(new Buffer(tmp).toString())
|
||||||
}else{
|
} else {
|
||||||
tmp = [...tmp, ...data.slice(2, data.length)]
|
tmp = [...tmp, ...data.slice(2, data.length)]
|
||||||
}
|
}
|
||||||
if (!withoutResponse) {
|
if (!withoutResponse) {
|
||||||
console.log('send response')
|
console.log('send response')
|
||||||
callback(this.RESULT_SUCCESS)
|
callback(this.RESULT_SUCCESS)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user