mirror of
https://github.com/thegecko/web-bluetooth-dfu.git
synced 2025-12-12 20:18:13 +08:00
Use the CRC we generate for the image in the init packet.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
var dfu = require('./index').dfu;
|
||||
var hex2bin = require('./index').hex2bin;
|
||||
var crc16 = require('./index').crc16;
|
||||
var fs = require('fs');
|
||||
|
||||
var log = console.log;
|
||||
@@ -40,8 +41,9 @@ dfu.findDevice({ services: [0x180D] })
|
||||
var hex = file.toString();
|
||||
var buffer = hex2bin(hex);
|
||||
log("file length: " + buffer.byteLength);
|
||||
var crc = crc16(buffer);
|
||||
|
||||
return dfu.provision(device, buffer);
|
||||
return dfu.provision(device, buffer, 4, crc);
|
||||
})
|
||||
.then(() => process.exit())
|
||||
.catch(error => {
|
||||
|
||||
Reference in New Issue
Block a user