mirror of
https://github.com/rvdbreemen/OTGW-firmware
synced 2024-11-16 04:33:49 +01:00
Version of new firmwares
This commit is contained in:
parent
0f5bb3b86b
commit
5b8b55990f
@ -159,6 +159,8 @@ void apifirmwarefilelist() {
|
||||
}
|
||||
DebugTf("version=%s\r\n", version.c_str());
|
||||
fwversion = GetVersion(hexfile); // only check if gateway firmware
|
||||
// String hexversion = OTGWSerial.readHexFileVersion(hexfile.c_str());
|
||||
// DebugTf("File version on hexfile: %s\r\n", hexversion.c_str());
|
||||
DebugTf("GetVersion(%s) returned [%s]\r\n", hexfile.c_str(), fwversion.c_str());
|
||||
if (fwversion.length() && strcmp(fwversion.c_str(),version.c_str())) { // versions do not match
|
||||
version=fwversion; // assign hex file version to version
|
||||
|
@ -106,7 +106,33 @@ void sendMQTTstateinformation(){
|
||||
//===================[ Reset OTGW ]===============================
|
||||
void resetOTGW() {
|
||||
//sPICfwversion ="No version found"; //reset versionstring
|
||||
|
||||
OTGWSerial.resetPic();
|
||||
|
||||
// 12 june 2022 - trying to determine the PIC hardware on reboot
|
||||
// char buffer[80]={0};
|
||||
// delay(100);
|
||||
// OTGWSerial.write(0x0f);
|
||||
// OTGWSerial.write(0x00);
|
||||
// OTGWSerial.write(0x03);
|
||||
// OTGWSerial.write(0xfd);
|
||||
// OTGWSerial.write(0x04);
|
||||
// delay(100);
|
||||
// OTGWSerial.write(0x0f);
|
||||
// OTGWSerial.write(0x08);
|
||||
// OTGWSerial.write(0x00);
|
||||
// OTGWSerial.write(0xf8);
|
||||
// OTGWSerial.write(0x04);
|
||||
// delay(100);
|
||||
// //then read the first response of the firmware to make sure it reads it
|
||||
// size_t lenbuf = OTGWSerial.readBytesUntil('\n', buffer, sizeof(buffer));
|
||||
|
||||
// OTGWDebugT("resetOTGW: ");
|
||||
// for (int i=0; i<(int)lenbuf; i++) {
|
||||
// OTGWDebugf("%02x ", buffer[i]);
|
||||
// }
|
||||
|
||||
|
||||
// //then read the first response of the firmware to make sure it reads it
|
||||
// String resp = OTGWSerial.readStringUntil('\n');
|
||||
// resp.trim();
|
||||
|
@ -37,6 +37,8 @@ DECLARE_TIMER_SEC(timerpollsensor, settingGPIOSENSORSinterval, CATCH_UP_MISSED_T
|
||||
|
||||
//=====================================================================
|
||||
void setup() {
|
||||
|
||||
|
||||
// Serial is initialized by OTGWSerial. It resets the pic and opens serialdevice.
|
||||
// OTGWSerial.begin();//OTGW Serial device that knows about OTGW PIC
|
||||
// while (!Serial) {} //Wait for OK
|
||||
@ -44,6 +46,7 @@ void setup() {
|
||||
OTGWSerial.println(F("\r\n[OTGW firmware - Nodoshop version]\r\n"));
|
||||
OTGWSerial.printf("Booting....[%s]\r\n\r\n", String(_FW_VERSION).c_str());
|
||||
WatchDogEnabled(0); // turn off watchdog
|
||||
|
||||
|
||||
//setup randomseed the right way
|
||||
randomSeed(RANDOM_REG32); //This is 8266 HWRNG used to seed the Random PRNG: Read more: https://config9.com/arduino/getting-a-truly-random-number-in-arduino/
|
||||
@ -81,6 +84,16 @@ void setup() {
|
||||
|
||||
|
||||
OTGWSerial.println(F("Setup finished!\r\n"));
|
||||
|
||||
// //delay for debugging
|
||||
// OTGWSerial.print("bootdelay ");
|
||||
// for (int i =0; i <10; i++) {
|
||||
// delay(1000);
|
||||
// OTGWSerial.print(i);
|
||||
// OTGWSerial.print(" ");
|
||||
// }
|
||||
// OTGWSerial.println();
|
||||
|
||||
// After resetting the OTGW PIC never send anything to Serial for debug
|
||||
// and switch to telnet port 23 for debug purposed.
|
||||
// Setup the OTGW PIC
|
||||
|
18
version.h
18
version.h
@ -2,15 +2,15 @@
|
||||
#define _VERSION_MAJOR 0
|
||||
#define _VERSION_MINOR 9
|
||||
#define _VERSION_PATCH 5
|
||||
#define _VERSION_BUILD 1738
|
||||
#define _VERSION_GITHASH "138387c"
|
||||
#define _VERSION_BUILD 1765
|
||||
#define _VERSION_GITHASH "0f5bb3b"
|
||||
//#define _VERSION_PRERELEASE beta //uncomment to define prerelease labels: alpha - beta - rc
|
||||
#define _VERSION_DATE "07-06-2022"
|
||||
#define _VERSION_TIME "19:39:11"
|
||||
#define _VERSION_DATE "12-06-2022"
|
||||
#define _VERSION_TIME "11:49:28"
|
||||
#define _SEMVER_CORE "0.9.5"
|
||||
#define _SEMVER_BUILD "0.9.5+1738"
|
||||
#define _SEMVER_GITHASH "0.9.5+138387c"
|
||||
#define _SEMVER_FULL "0.9.5+138387c"
|
||||
#define _SEMVER_NOBUILD "0.9.5 (07-06-2022)"
|
||||
#define _VERSION "0.9.5+138387c (07-06-2022)"
|
||||
#define _SEMVER_BUILD "0.9.5+1765"
|
||||
#define _SEMVER_GITHASH "0.9.5+0f5bb3b"
|
||||
#define _SEMVER_FULL "0.9.5+0f5bb3b"
|
||||
#define _SEMVER_NOBUILD "0.9.5 (12-06-2022)"
|
||||
#define _VERSION "0.9.5+0f5bb3b (12-06-2022)"
|
||||
//The version information is created automatically, more information here: https://github.com/rvdbreemen/autoinc-semver
|
||||
|
@ -10,7 +10,7 @@ static const char banner[] = "OpenTherm Gateway ";
|
||||
String GetVersion(const String hexfile){
|
||||
char hexbuf[48]={0};
|
||||
int len, addr, tag, data, offs, linecnt = 0;
|
||||
char datamem[256]={0};
|
||||
char datamem[256]={0}; // prevent buffer overrun
|
||||
unsigned short ptr;
|
||||
File f;
|
||||
DebugTf("GetVersion opening %s\r\n",hexfile.c_str());
|
||||
@ -19,13 +19,13 @@ String GetVersion(const String hexfile){
|
||||
{
|
||||
while (f.readBytesUntil('\n', hexbuf, sizeof(hexbuf)) != 0) {
|
||||
linecnt++;
|
||||
//DebugTf("reading line %d %s\n",linecnt,hexbuf);
|
||||
// DebugTf("reading line %d %s\n",linecnt,hexbuf);
|
||||
if (sscanf(hexbuf, ":%2x%4x%2x", &len, &addr, &tag) != 3)
|
||||
{
|
||||
DebugTf("Parse error on line %d\n",linecnt);// Parse error
|
||||
break;
|
||||
}
|
||||
//DebugTf("Read in %2x %4x %2x\n",len,addr,tag);
|
||||
// DebugTf("Read in %2x %4x %2x\n",len,addr,tag);
|
||||
if (len & 1)
|
||||
{
|
||||
DebugTf("Invalid data size on line %d\n",linecnt);// Invalid data size
|
||||
@ -35,12 +35,27 @@ String GetVersion(const String hexfile){
|
||||
len >>= 1;
|
||||
if (tag == 0)
|
||||
{
|
||||
//DebugTf("Checking address %4x on line %d\n",addr,linecnt);// Invalid data size
|
||||
if (addr >= 0x4200 && addr <= 0x4400)
|
||||
// DebugTf("Checking address %4x on line %d\r\n",addr,linecnt);// Invalid data size
|
||||
if (addr >= 0x4200 && addr <= 0x4300)
|
||||
{
|
||||
// Data memory
|
||||
// Data memory 16f88
|
||||
addr = (addr - 0x4200) >> 1;
|
||||
while (len > 0)
|
||||
{
|
||||
if (sscanf(hexbuf + offs, "%04x", &data) != 1)
|
||||
break;
|
||||
// if (!bitRead(datamap, addr / 64)) weight += WEIGHT_DATAPROG;
|
||||
// bitSet(datamap, addr / 64);
|
||||
//DebugTf("storing %x in %x\r\n",data,addr);
|
||||
datamem[addr++] = byteswap(data);
|
||||
offs += 4;
|
||||
len--;
|
||||
}
|
||||
} else if (addr >= 0xe000 && addr <= 0xe100)
|
||||
{
|
||||
// Data memory 16f1847
|
||||
addr = (addr - 0xe000) >> 1;
|
||||
while (len > 0)
|
||||
{
|
||||
if (sscanf(hexbuf + offs, "%04x", &data) != 1)
|
||||
break;
|
||||
@ -66,14 +81,14 @@ String GetVersion(const String hexfile){
|
||||
ptr = 0;
|
||||
while (ptr < 256)
|
||||
{
|
||||
//DebugTf("checking for %s at char pos %d\n",banner,ptr);
|
||||
//DebugTf("checking for %s at char pos %d\r\n",banner,ptr);
|
||||
char *s = strstr((char *)datamem + ptr, banner);
|
||||
if (!s)
|
||||
{
|
||||
//DebugTf("did not find the banner\n");
|
||||
//DebugTf("did not find the banner\r\n");
|
||||
ptr += strnlen((char *)datamem + ptr, 256 - ptr) + 1;
|
||||
} else {
|
||||
//DebugTf("hit the banner! returning version string %s\n",s);
|
||||
//DebugTf("hit the banner! returning version string %s\r\n",s);
|
||||
s += sizeof(banner) - 1;
|
||||
return String(s);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user