problem porting from an older sming version
Posted: Thu Dec 14, 2017 3:37 am
Hi Board,
I have inherited a piece of firmware that was written on an older version of the Sming framework, and have been struggling to get to a point where I can even maintain it, let alone improve on it.
I have set up a current Sming in a container (thanks for this method, that finally made it straight forward and simple to get to a working environment).
Now, however, I stumble on a rather unexpected point and my understanding of (modern) c++ isn't good enough to really figure out what's going wrong here.
So I understand that this uses a delegate to provide the callback to the updater for the simple reason that this code resides inside a class instance and cannot or should not be called from the outside.
However, I wonder, has the syntax for the OtaUpdateDelegate (which is really just an UpdateDelegate) changed over the recent Sming updates? The error would suggest that UpdateDelegate requests
My understanding is that, in rBootHttpUpdate.h, OtaUpdateDelegate is defined like this
which would make it of type void, which is what the error message complains about.
where am I going wrong?
kind regards
pj
I have inherited a piece of firmware that was written on an older version of the Sming framework, and have been struggling to get to a point where I can even maintain it, let alone improve on it.
I have set up a current Sming in a container (thanks for this method, that finally made it straight forward and simple to get to a working environment).
Now, however, I stumble on a rather unexpected point and my understanding of (modern) c++ isn't good enough to really figure out what's going wrong here.
Code: Select all
void ApplicationOTA::start(String romurl, String spiffsurl) {
debugapp("ApplicationOTA::start");
Serial.println("Starting OTA ...");
reset();
status = OTASTATUS::OTA_PROCESSING;
if (otaUpdater) {
delete otaUpdater;
}
otaUpdater = new rBootHttpUpdate();
rboot_config bootconf = rboot_get_config();
rom_slot = app.getRomSlot();
if (rom_slot == 0) {
rom_slot = 1;
} else {
rom_slot = 0;
}
otaUpdater->addItem(bootconf.roms[rom_slot], romurl);
if (rom_slot == 0) {
otaUpdater->addItem(RBOOT_SPIFFS_0, spiffsurl);
} else {
otaUpdater->addItem(RBOOT_SPIFFS_1, spiffsurl);
}
otaUpdater->setCallback(OtaUpdateDelegate(&ApplicationOTA::rBootCallback, this));
beforeOTA();
otaUpdater->start();
}
So I understand that this uses a delegate to provide the callback to the updater for the simple reason that this code resides inside a class instance and cannot or should not be called from the outside.
However, I wonder, has the syntax for the OtaUpdateDelegate (which is really just an UpdateDelegate) changed over the recent Sming updates? The error would suggest that UpdateDelegate requests
Code: Select all
app/otaupdate.cpp: In member function 'void ApplicationOTA::start(String, String)':
app/otaupdate.cpp:51:56: error: no matching function for call to 'rBootHttpUpdate::setCallback(void (ApplicationOTA::*)(bool))'
otaUpdater->setCallback(&ApplicationOTA::rBootCallback);
^
app/otaupdate.cpp:51:56: note: candidate is:
In file included from /workspace/Sming/Sming/Wiring/../SmingCore/SmingCore.h:50:0,
from /workspace/Sming/Sming/Wiring/Arduino.h:8,
from include/RGBWWLed/RGBWWLed.h:38,
from include/RGBWWCtrl.h:57,
from app/otaupdate.cpp:22:
/workspace/Sming/Sming/Wiring/../SmingCore/Network/rBootHttpUpdate.h:52:7: note: void rBootHttpUpdate::setCallback(OtaUpdateDelegate)
void setCallback(OtaUpdateDelegate reqUpdateDelegate);
^
/workspace/Sming/Sming/Wiring/../SmingCore/Network/rBootHttpUpdate.h:52:7: note: no known conversion for argument 1 from 'void (ApplicationOTA::*)(bool)' to 'OtaUpdateDelegate {aka Delegate<void(rBootHttpUpdate&, bool)>}'
/workspace/Sming/Sming/Makefile-rboot.mk:590: recipe for target 'out/build/app/otaupdate.o' failed
make: *** [out/build/app/otaupdate.o] Error 1
My understanding is that, in rBootHttpUpdate.h, OtaUpdateDelegate is defined like this
Code: Select all
//typedef void (*otaCallback)(bool result);
typedef Delegate<void(rBootHttpUpdate& client, bool result)> OtaUpdateDelegate;
which would make it of type void, which is what the error message complains about.
where am I going wrong?
kind regards
pj