add handling to check the chip type in the update UI
This commit is contained in:
parent
2b42cc53e7
commit
54693e0b27
|
@ -94,6 +94,7 @@ __attribute__((section(".rodata_custom_desc"))) esp_app_desc_t custom_app_desc =
|
|||
|
||||
|
||||
String firmwareType(FIRMWARE_TYPE);
|
||||
String chipType(BOARD_INFO);
|
||||
|
||||
typedef std::map<String,String> StringMap;
|
||||
|
||||
|
@ -371,7 +372,7 @@ public:
|
|||
protected:
|
||||
virtual void processRequest()
|
||||
{
|
||||
GwJsonDocument status(290 +
|
||||
GwJsonDocument status(300 +
|
||||
countNMEA2KIn.getJsonSize()+
|
||||
countNMEA2KOut.getJsonSize() +
|
||||
channels.getJsonSize()
|
||||
|
@ -386,6 +387,7 @@ protected:
|
|||
GwConfigHandler::toHex(base,buffer,bsize);
|
||||
status["salt"] = buffer;
|
||||
status["fwtype"]= firmwareType;
|
||||
status["chiptype"]=chipType.substring(2);
|
||||
status["heap"]=(long)xPortGetFreeHeapSize();
|
||||
Nmea2kTwai::Status n2kState=NMEA2000.getStatus();
|
||||
Nmea2kTwai::STATE driverState=n2kState.state;
|
||||
|
|
|
@ -100,6 +100,10 @@
|
|||
<span class="label">firmware type</span>
|
||||
<span class="value status-fwtype">---</span>
|
||||
</div>
|
||||
<div class="row">
|
||||
<span class="label">chip type</span>
|
||||
<span class="value status-chiptype">---</span>
|
||||
</div>
|
||||
<div class="row">
|
||||
<span class="label">currentVersion</span>
|
||||
<span class="value status-version">---</span>
|
||||
|
|
18
web/index.js
18
web/index.js
|
@ -1564,9 +1564,15 @@ function uploadBin(ev){
|
|||
.then(function (result) {
|
||||
let currentType;
|
||||
let currentVersion;
|
||||
let chiptype;
|
||||
forEl('.status-version', function (el) { currentVersion = el.textContent });
|
||||
forEl('.status-fwtype', function (el) { currentType = el.textContent });
|
||||
forEl('.status-chiptype', function (el) { chiptype = el.textContent });
|
||||
let confirmText = 'Ready to update firmware?\n';
|
||||
if (result.chip.match(/^@@/) && (result.chip.substr(2) != chiptype)){
|
||||
confirmText += "WARNING: the chiptype in the image ("+result.chip.substr(2);
|
||||
confirmText +=") does not match the current chip type ("+chiptype+").\n";
|
||||
}
|
||||
if (currentType != result.fwtype) {
|
||||
confirmText += "WARNING: image has different type: " + result.fwtype + "\n";
|
||||
confirmText += "** Really update anyway? - device can become unusable **";
|
||||
|
@ -1643,7 +1649,8 @@ function uploadBin(ev){
|
|||
let HDROFFSET=288;
|
||||
let VERSIONOFFSET=16;
|
||||
let NAMEOFFSET=48;
|
||||
let MINSIZE=HDROFFSET+NAMEOFFSET+32;
|
||||
let CHIPOFFSET=NAMEOFFSET+64;
|
||||
let MINSIZE = HDROFFSET + CHIPOFFSET + 32;
|
||||
let imageCheckBytes={
|
||||
0: 0xe9, //image magic
|
||||
288: 0x32, //app header magic
|
||||
|
@ -1678,9 +1685,11 @@ function checkImageFile(file){
|
|||
}
|
||||
let version=decodeFromBuffer(content,HDROFFSET+VERSIONOFFSET,32);
|
||||
let fwtype=decodeFromBuffer(content,HDROFFSET+NAMEOFFSET,32);
|
||||
let chip=decodeFromBuffer(content,HDROFFSET+CHIPOFFSET,32);
|
||||
let rt={
|
||||
fwtype:fwtype,
|
||||
version: version,
|
||||
chip:chip
|
||||
};
|
||||
resolve(rt);
|
||||
});
|
||||
|
@ -1742,7 +1751,12 @@ window.addEventListener('load', function () {
|
|||
checkImageFile(file)
|
||||
.then(function(res){
|
||||
forEl('#imageProperties',function(iel){
|
||||
iel.textContent=res.fwtype+", "+res.version;
|
||||
let txt="";
|
||||
if (res.chip.match(/^@@/)){
|
||||
txt=res.chip.substr(2)+", "
|
||||
}
|
||||
txt+=res.fwtype+", "+res.version;
|
||||
iel.textContent=txt;
|
||||
iel.classList.remove("error");
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue