Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

processReq() is not implemented for UpdateFirmware Request #334

Open
vadhura opened this issue Jul 12, 2024 · 1 comment
Open

processReq() is not implemented for UpdateFirmware Request #334

vadhura opened this issue Jul 12, 2024 · 1 comment

Comments

@vadhura
Copy link

vadhura commented Jul 12, 2024

Hi @matth-x
I am trying to Initiate command for UpdateFirmware request from server but I am getting the message as Unsupported operation: processReq() is not implemented.

[2024-07-10 15:27:42.936] [MO] Recv: [2,"00e7fc4a-059a-477f-99b8-efcaedd164c8","UpdateFirmware",{"location": "anything"}]
[2024-07-10 15:27:42.947] [MO] ERROR (Operation.cpp:38): Unsupported operation: processReq() is not implemented
[2024-07-10 15:27:42.952] [MO] Send: [4,"00e7fc4a-059a-477f-99b8-efcaedd164c8","NotImplemented","",{}]

Can you please help me on this.
Thank you.

@matth-x
Copy link
Owner

matth-x commented Jul 12, 2024

Hi @vadhura, this happens when the FW write handlers are not set. To set the FW handlers, see the built-in updater for the ESP32 on Arduino:

std::unique_ptr<FirmwareService> MicroOcpp::makeDefaultFirmwareService(Context& context) {
std::unique_ptr<FirmwareService> fwService = std::unique_ptr<FirmwareService>(new FirmwareService(context));
auto ftServicePtr = fwService.get();
fwService->setDownloadFileWriter(
[ftServicePtr] (const unsigned char *data, size_t size) -> size_t {
if (!Update.isRunning()) {
MO_DBG_DEBUG("start writing FW");
MO_DBG_WARN("Built-in updater for ESP32 is only intended for demonstration purposes");
ftServicePtr->setInstallationStatusInput([](){return InstallationStatus::NotInstalled;});
auto ret = Update.begin();
if (!ret) {
MO_DBG_ERR("cannot start update: %i", ret);
return 0;
}
}
size_t written = Update.write((uint8_t*) data, size);
#if MO_DBG_LEVEL >= MO_DL_INFO
{
size_t progress = Update.progress();
bool printProgress = false;
if (progress <= 10000) {
size_t p1k = progress / 1000;
printProgress = progress < p1k * 1000 + written && progress >= p1k * 1000;
} else if (progress <= 100000) {
size_t p10k = progress / 10000;
printProgress = progress < p10k * 10000 + written && progress >= p10k * 10000;
} else {
size_t p100k = progress / 100000;
printProgress = progress < p100k * 100000 + written && progress >= p100k * 100000;
}
if (printProgress) {
MO_DBG_INFO("update progress: %zu kB", progress / 1000);
}
}
#endif //MO_DBG_LEVEL >= MO_DL_DEBUG
return written;
}, [] (MO_FtpCloseReason reason) {
if (reason != MO_FtpCloseReason_Success) {
Update.abort();
}
});
fwService->setOnInstall([ftServicePtr] (const char *location) {
if (Update.isRunning() && Update.end(true)) {
MO_DBG_DEBUG("update success");
ftServicePtr->setInstallationStatusInput([](){return InstallationStatus::Installed;});
ESP.restart();
} else {
MO_DBG_ERR("update failed");
ftServicePtr->setInstallationStatusInput([](){return InstallationStatus::InstallationFailed;});
}
return true;
});
fwService->setInstallationStatusInput([] () {
return InstallationStatus::NotInstalled;
});
return fwService;
}

Instead of instantiating the FirmwareService like in L382, you should use the FWService returned by this:

MicroOcpp/src/MicroOcpp.h

Lines 344 to 355 in 8b1f0fd

/*
* You need to configure this object if FW updates are relevant for you. This project already
* brings a simple configuration for the ESP32 and ESP8266 for prototyping purposes, however
* for the productive system you will have to develop a configuration targeting the specific
* OCPP backend.
* See MicroOcpp/Model/FirmwareManagement/FirmwareService.h
*
* Lazy initialization: The FW Service will be created at the first call to this function
*
* To use, add `#include <MicroOcpp/Model/FirmwareManagement/FirmwareService.h>`
*/
MicroOcpp::FirmwareService *getFirmwareService();

Then you can implement the DownloadFileWriter which is being passed the download chunk by chunk. And the same goes for the other callback functions from the reference implementation above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants