mirror of
https://github.com/Koenkk/zigbee-OTA.git
synced 2026-06-24 13:18:14 +00:00
Fix image parsing when the upgrade file identifier is not at position 0 (#59)
This commit is contained in:
@@ -8,7 +8,10 @@ function parseSubElement(buffer, position) {
|
|||||||
return {tagID, length, data};
|
return {tagID, length, data};
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseImage(buffer) {
|
function parseImage(rawBuffer) {
|
||||||
|
const start = rawBuffer.indexOf(upgradeFileIdentifier);
|
||||||
|
const buffer = rawBuffer.slice(start);
|
||||||
|
|
||||||
const header = {
|
const header = {
|
||||||
otaUpgradeFileIdentifier: buffer.subarray(0, 4),
|
otaUpgradeFileIdentifier: buffer.subarray(0, 4),
|
||||||
otaHeaderVersion: buffer.readUInt16LE(4),
|
otaHeaderVersion: buffer.readUInt16LE(4),
|
||||||
@@ -55,4 +58,4 @@ function parseImage(buffer) {
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
parseImage
|
parseImage
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user