Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
helgeerbe committed Apr 18, 2023
2 parents 1e16eca + a1b3bdf commit 545a18d
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 27 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ Compatibility with OpenDTU is most likly related to the serial number of the inv
Generated using: `git log --date=short --pretty=format:"* %h%x09%ad%x09%s" | grep BREAKING`

```code
* 59f43a8 2023-04-17 BREAKING CHANGE: Web API Endpoint /api/devinfo/status requires GET parameter inv=
* 318136d 2023-03-15 BREAKING CHANGE: Updated partition table: Make sure you have a configuration backup and completly reflash the device!
* 3b7aef6 2023-02-13 BREAKING CHANGE: Web API!
* d4c838a 2023-02-06 BREAKING CHANGE: Prometheus API!
Expand Down
5 changes: 5 additions & 0 deletions lib/Hoymiles/src/HoymilesRadio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ bool HoymilesRadio::isInitialized()
return _isInitialized;
}

bool HoymilesRadio::isConfigured()
{
return _isConfigured;
}

bool HoymilesRadio::isIdle()
{
return !_busyFlag;
Expand Down
2 changes: 2 additions & 0 deletions lib/Hoymiles/src/HoymilesRadio.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class HoymilesRadio {

bool isIdle();
bool isInitialized();
bool isConfigured();

template <typename T>
T* enqueCommand()
Expand All @@ -33,5 +34,6 @@ class HoymilesRadio {
serial_u _dtuSerial;
std::queue<std::shared_ptr<CommandAbstract>> _commandQueue;
bool _isInitialized = false;
bool _isConfigured = false;
bool _busyFlag = false;
};
11 changes: 6 additions & 5 deletions lib/Hoymiles/src/HoymilesRadio_CMT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,12 @@ void HoymilesRadio_CMT::init(int8_t pin_sdio, int8_t pin_clk, int8_t pin_cs, int

cmtSwitchDtuFreq(_inverterTargetFrequency); // start dtu at work freqency, for fast Rx if inverter is already on and frequency switched

if (_radio->isChipConnected()) {
Hoymiles.getMessageOutput()->println("Connection successful");
} else {
Hoymiles.getMessageOutput()->println("Connection error!!");
_isConfigured = true;
if (!_radio->isChipConnected()) {
Hoymiles.getMessageOutput()->println("CMT: Connection error!!");
return;
}
Hoymiles.getMessageOutput()->println("CMT: Connection successful");

if (pin_gpio2 >= 0) {
attachInterrupt(digitalPinToInterrupt(pin_gpio2), std::bind(&HoymilesRadio_CMT::handleInt1, this), RISING);
Expand Down Expand Up @@ -109,7 +110,7 @@ void HoymilesRadio_CMT::loop()
_radio->read(f.fragment, f.len);
_rxBuffer.push(f);
} else {
Hoymiles.getMessageOutput()->println("Buffer full");
Hoymiles.getMessageOutput()->println("CMT: Buffer full");
_radio->flush_rx();
}
}
Expand Down
11 changes: 6 additions & 5 deletions lib/Hoymiles/src/HoymilesRadio_NRF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ void HoymilesRadio_NRF::init(SPIClass* initialisedSpiBus, uint8_t pinCE, uint8_t
_radio->setAddressWidth(5);
_radio->setRetries(0, 0);
_radio->maskIRQ(true, true, false); // enable only receiving interrupts
if (_radio->isChipConnected()) {
Hoymiles.getMessageOutput()->println("Connection successful");
} else {
Hoymiles.getMessageOutput()->println("Connection error!!");
_isConfigured = true;
if (!_radio->isChipConnected()) {
Hoymiles.getMessageOutput()->println("NRF: Connection error!!");
return;
}
Hoymiles.getMessageOutput()->println("NRF: Connection successful");

attachInterrupt(digitalPinToInterrupt(pinIRQ), std::bind(&HoymilesRadio_NRF::handleIntr, this), FALLING);

Expand Down Expand Up @@ -60,7 +61,7 @@ void HoymilesRadio_NRF::loop()
_radio->read(f.fragment, f.len);
_rxBuffer.push(f);
} else {
Hoymiles.getMessageOutput()->println("Buffer full");
Hoymiles.getMessageOutput()->println("NRF: Buffer full");
_radio->flush_rx();
}
}
Expand Down
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ build_unflags =

lib_deps =
https://github.com/yubox-node-org/ESPAsyncWebServer
bblanchon/ArduinoJson @ ^6.21.1
bblanchon/ArduinoJson @ ^6.21.2
https://github.com/bertmelis/espMqttClient.git#v1.4.2
nrf24/RF24 @ ^1.4.5
olikraus/U8g2 @ ^2.34.17
Expand Down
29 changes: 17 additions & 12 deletions src/WebApi_devinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,27 @@ void WebApiDevInfoClass::onDevInfoStatus(AsyncWebServerRequest* request)
AsyncJsonResponse* response = new AsyncJsonResponse();
JsonObject root = response->getRoot();

for (uint8_t i = 0; i < Hoymiles.getNumInverters(); i++) {
auto inv = Hoymiles.getInverterByPos(i);

JsonObject devInfoObj = root[inv->serialString()].createNestedObject();
devInfoObj["valid_data"] = inv->DevInfo()->getLastUpdate() > 0;
devInfoObj["fw_bootloader_version"] = inv->DevInfo()->getFwBootloaderVersion();
devInfoObj["fw_build_version"] = inv->DevInfo()->getFwBuildVersion();
devInfoObj["hw_part_number"] = inv->DevInfo()->getHwPartNumber();
devInfoObj["hw_version"] = inv->DevInfo()->getHwVersion();
devInfoObj["hw_model_name"] = inv->DevInfo()->getHwModelName();
devInfoObj["max_power"] = inv->DevInfo()->getMaxPower();
uint64_t serial = 0;
if (request->hasParam("inv")) {
String s = request->getParam("inv")->value();
serial = strtoll(s.c_str(), NULL, 16);
}

auto inv = Hoymiles.getInverterBySerial(serial);

if (inv != nullptr) {
root["valid_data"] = inv->DevInfo()->getLastUpdate() > 0;
root["fw_bootloader_version"] = inv->DevInfo()->getFwBootloaderVersion();
root["fw_build_version"] = inv->DevInfo()->getFwBuildVersion();
root["hw_part_number"] = inv->DevInfo()->getHwPartNumber();
root["hw_version"] = inv->DevInfo()->getHwVersion();
root["hw_model_name"] = inv->DevInfo()->getHwModelName();
root["max_power"] = inv->DevInfo()->getMaxPower();

char timebuffer[32];
const time_t t = inv->DevInfo()->getFwBuildDateTime();
std::strftime(timebuffer, sizeof(timebuffer), "%Y-%m-%d %H:%M:%S", gmtime(&t));
devInfoObj["fw_build_datetime"] = String(timebuffer);
root["fw_build_datetime"] = String(timebuffer);
}

response->setLength();
Expand Down
4 changes: 2 additions & 2 deletions src/WebApi_sysstatus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ void WebApiSysstatusClass::onSystemStatus(AsyncWebServerRequest* request)

root["uptime"] = esp_timer_get_time() / 1000000;

root["nrf_configured"] = Hoymiles.getRadioNrf()->isInitialized();
root["nrf_configured"] = Hoymiles.getRadioNrf()->isConfigured();
root["nrf_connected"] = Hoymiles.getRadioNrf()->isConnected();
root["nrf_pvariant"] = Hoymiles.getRadioNrf()->isPVariant();

root["cmt_configured"] = Hoymiles.getRadioCmt()->isInitialized();
root["cmt_configured"] = Hoymiles.getRadioCmt()->isConfigured();
root["cmt_connected"] = Hoymiles.getRadioCmt()->isConnected();

response->setLength();
Expand Down
4 changes: 2 additions & 2 deletions webapp/src/views/HomeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -557,10 +557,10 @@ export default defineComponent({
},
onShowDevInfo(serial: number) {
this.devInfoLoading = true;
fetch("/api/devinfo/status", { headers: authHeader() })
fetch("/api/devinfo/status?inv=" + serial, { headers: authHeader() })
.then((response) => handleResponse(response, this.$emitter, this.$router))
.then((data) => {
this.devInfoList = data[serial][0];
this.devInfoList = data;
this.devInfoList.serial = serial;
this.devInfoLoading = false;
});
Expand Down
Binary file modified webapp_dist/js/app.js.gz
Binary file not shown.

0 comments on commit 545a18d

Please sign in to comment.