mirror of
https://github.com/Koenkk/zigbee-OTA.git
synced 2026-06-24 11:16:34 +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};
|
||||
}
|
||||
|
||||
function parseImage(buffer) {
|
||||
function parseImage(rawBuffer) {
|
||||
const start = rawBuffer.indexOf(upgradeFileIdentifier);
|
||||
const buffer = rawBuffer.slice(start);
|
||||
|
||||
const header = {
|
||||
otaUpgradeFileIdentifier: buffer.subarray(0, 4),
|
||||
otaHeaderVersion: buffer.readUInt16LE(4),
|
||||
@@ -55,4 +58,4 @@ function parseImage(buffer) {
|
||||
|
||||
module.exports = {
|
||||
parseImage
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user