Skip to content

Commit

Permalink
Merge pull request #1 from tbnobody/master
Browse files Browse the repository at this point in the history
merge 23.6.26
  • Loading branch information
AloisKlingler authored Jun 28, 2023
2 parents 5684efa + a510afe commit 909e53b
Show file tree
Hide file tree
Showing 41 changed files with 422 additions and 357 deletions.
16 changes: 6 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- name: Get default environments
id: envs
run: |
echo "environments=$(pio project config --json-output | jq -cr '.[0][1][0][1]')" >> $GITHUB_OUTPUT
echo "environments=$(pio project config --json-output | jq -cr '.[1][1][0][1]|split(",")')" >> $GITHUB_OUTPUT
outputs:
environments: ${{ steps.envs.outputs.environments }}
Expand Down Expand Up @@ -98,17 +98,15 @@ jobs:
- name: Rename Firmware
run: mv .pio/build/${{ matrix.environment }}/firmware.bin .pio/build/${{ matrix.environment }}/opendtu-${{ matrix.environment }}.bin

- name: Copy boot_app0.bin
run: cp ~/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin .pio/build/${{ matrix.environment }}/boot_app0.bin
- name: Rename Factory Firmware
run: mv .pio/build/${{ matrix.environment }}/firmware.factory.bin .pio/build/${{ matrix.environment }}/opendtu-${{ matrix.environment }}.factory.bin

- uses: actions/upload-artifact@v3
with:
name: opendtu-${{ matrix.environment }}
path: |
.pio/build/${{ matrix.environment }}/opendtu-${{ matrix.environment }}.bin
.pio/build/${{ matrix.environment }}/partitions.bin
.pio/build/${{ matrix.environment }}/bootloader.bin
.pio/build/${{ matrix.environment }}/boot_app0.bin
.pio/build/${{ matrix.environment }}/opendtu-${{ matrix.environment }}.factory.bin
release:
name: Create Release
Expand All @@ -121,7 +119,7 @@ jobs:

- name: Build Changelog
id: github_release
uses: mikepenz/release-changelog-builder-action@v3.7.0
uses: mikepenz/release-changelog-builder-action@v3
with:
failOnError: true
commitMode: true
Expand All @@ -133,12 +131,10 @@ jobs:
with:
path: artifacts/

- name: Create ZIPs
- name: Move all files to the same location
run: |
ls -R
sudo apt install zip
cd artifacts
for i in */; do zip -r "${i%/}.zip" "$i"; done
for i in */; do cp ${i}opendtu-*.bin ./; done
- name: Create release
Expand Down
14 changes: 2 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,7 @@ It is recommended to make all changes only in the 'platformio_override.ini', th

### using the pre-compiled .bin files

The pre-compiled binary files can be found here on the [github page behind "Releases"](https://github.com/tbnobody/OpenDTU/releases) (look at the right column). For a first installation on an ESP32, download `opendtu-generic.zip`, unpack and use a ESP32 flash tool of your choice (see next chapter) to flash the `.bin` files to the right addresses:

| Address | File |
| ---------| ---------------------- |
| 0x1000 | bootloader.bin |
| 0x8000 | partitions.bin |
| 0xe000 | boot_app0.bin |
| 0x10000 | opendtu-*.bin |
The pre-compiled binary files can be found here on the [github page behind "Releases"](https://github.com/tbnobody/OpenDTU/releases) (look at the right column). For a first installation on an ESP32, download `opendtu-generic.factory.bin` and use a ESP32 flash tool of your choice to flash the `.bin` file to the address `0x0`. (The previous method with different .bin files is no more necessary.)

For further updates download `opendtu-generic.bin` and use the over-the-air firmware update in OpenDTU's web interface.

Expand All @@ -226,10 +219,7 @@ For further updates download `opendtu-generic.bin` and use the over-the-air firm
```bash
esptool.py --port /dev/ttyUSB0 --chip esp32 --before default_reset --after hard_reset \
write_flash --flash_mode dout --flash_freq 40m --flash_size detect \
0x1000 bootloader.bin \
0x8000 partitions.bin \
0xe000 boot_app0.bin \
0x10000 opendtu-generic.bin
0x0 opendtu-generic.factory.bin
```

#### Flash with Espressif Flash Download Tool (Windows)
Expand Down
96 changes: 63 additions & 33 deletions docs/DeviceProfiles/nodemcu_esp32.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"name": "Generic NodeMCU 32",
"name": "NRF24",
"nrf24": {
"miso": 19,
"mosi": 23,
Expand All @@ -10,17 +10,11 @@
"cs": 5
},
"eth": {
"enabled": false,
"phy_addr": -1,
"power": -1,
"mdc": -1,
"mdio": -1,
"type": 0,
"clk_mode": 0
"enabled": false
}
},
{
"name": "Generic NodeMCU 32 with CMT2300A",
"name": "CMT2300A",
"nrf24": {
"miso": -1,
"mosi": -1,
Expand All @@ -38,17 +32,11 @@
"gpio3": 16
},
"eth": {
"enabled": false,
"phy_addr": -1,
"power": -1,
"mdc": -1,
"mdio": -1,
"type": 0,
"clk_mode": 0
"enabled": false
}
},
{
"name": "Generic NodeMCU 32 with SSD1306",
"name": "NRF24 with SSD1306",
"nrf24": {
"miso": 19,
"mosi": 23,
Expand All @@ -58,13 +46,7 @@
"cs": 5
},
"eth": {
"enabled": false,
"phy_addr": -1,
"power": -1,
"mdc": -1,
"mdio": -1,
"type": 0,
"clk_mode": 0
"enabled": false
},
"display": {
"type": 2,
Expand All @@ -73,7 +55,7 @@
}
},
{
"name": "Generic NodeMCU 32 with SH1106",
"name": "NRF24 with SH1106",
"nrf24": {
"miso": 19,
"mosi": 23,
Expand All @@ -83,13 +65,7 @@
"cs": 5
},
"eth": {
"enabled": false,
"phy_addr": -1,
"power": -1,
"mdc": -1,
"mdio": -1,
"type": 0,
"clk_mode": 0
"enabled": false
},
"display": {
"type": 3,
Expand All @@ -98,7 +74,61 @@
}
},
{
"name": "Generic NodeMCU 32 with NRF + CMT Module",
"name": "CMT2300A with SSD1306",
"nrf24": {
"miso": -1,
"mosi": -1,
"clk": -1,
"irq": -1,
"en": -1,
"cs": -1
},
"cmt": {
"clk": 18,
"cs": 4,
"fcs": 5,
"sdio": 23,
"gpio2": 19,
"gpio3": 16
},
"eth": {
"enabled": false
},
"display": {
"type": 2,
"data": 21,
"clk": 22
}
},
{
"name": "CMT2300A with SH1106",
"nrf24": {
"miso": -1,
"mosi": -1,
"clk": -1,
"irq": -1,
"en": -1,
"cs": -1
},
"cmt": {
"clk": 18,
"cs": 4,
"fcs": 5,
"sdio": 23,
"gpio2": 19,
"gpio3": 16
},
"eth": {
"enabled": false
},
"display": {
"type": 3,
"data": 21,
"clk": 22
}
},
{
"name": "NRF24 + CMT2300A",
"nrf24": {
"miso": 19,
"mosi": 23,
Expand Down
21 changes: 21 additions & 0 deletions docs/DeviceProfiles/wemos-lolin32-oled.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[
{
"name": "Wemos Lolin32 OLED",
"nrf24": {
"miso": 2,
"mosi": 14,
"clk": 12,
"irq": 0,
"en": 15,
"cs": 13
},
"eth": {
"enabled": false
},
"display": {
"type": 2,
"data": 5,
"clk": 4
}
}
]
7 changes: 2 additions & 5 deletions docs/UpgradePartition.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,10 @@ There are several possibilities to update the partition table:

- Any kind of flash interface

If you like to use any kind of flash interface like `esptool.py`, Espressif Flash Download Tool, ESP_Flasher or esptool-js you have to make sure to upload **ALL** provided .bin files. It is important to enter the correct target addresses.
If you like to use any kind of flash interface like `esptool.py`, Espressif Flash Download Tool, ESP_Flasher or esptool-js you have to make sure to upload the provided .factory.bin file. It is important to enter the correct target address.

| Address | File |
| ---------| ---------------------- |
| 0x1000 | bootloader.bin |
| 0x8000 | partitions.bin |
| 0xe000 | boot_app0.bin |
| 0x10000 | opendtu-*.bin |
| 0x0 | opendtu-*.factory.bin |

After upgrading the ESP32 will open the intergrated access point (AP) again. Just connect to it using the default password ("openDTU42"). If you are connected, just visit <http://192.168.4.1> and enter the "Configuration Management". Recover the previously backuped config files.
Binary file modified docs/esp32_flash_download_tool.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 63 additions & 0 deletions lib/Hoymiles/src/HoymilesRadio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,69 @@ void HoymilesRadio::sendLastPacketAgain()
sendEsbPacket(cmd);
}

void HoymilesRadio::handleReceivedPackage()
{
if (_busyFlag && _rxTimeout.occured()) {
Hoymiles.getMessageOutput()->println("RX Period End");
std::shared_ptr<InverterAbstract> inv = Hoymiles.getInverterBySerial(_commandQueue.front().get()->getTargetAddress());

if (nullptr != inv) {
CommandAbstract* cmd = _commandQueue.front().get();
uint8_t verifyResult = inv->verifyAllFragments(cmd);
if (verifyResult == FRAGMENT_ALL_MISSING_RESEND) {
Hoymiles.getMessageOutput()->println("Nothing received, resend whole request");
sendLastPacketAgain();

} else if (verifyResult == FRAGMENT_ALL_MISSING_TIMEOUT) {
Hoymiles.getMessageOutput()->println("Nothing received, resend count exeeded");
_commandQueue.pop();
_busyFlag = false;

} else if (verifyResult == FRAGMENT_RETRANSMIT_TIMEOUT) {
Hoymiles.getMessageOutput()->println("Retransmit timeout");
_commandQueue.pop();
_busyFlag = false;

} else if (verifyResult == FRAGMENT_HANDLE_ERROR) {
Hoymiles.getMessageOutput()->println("Packet handling error");
_commandQueue.pop();
_busyFlag = false;

} else if (verifyResult > 0) {
// Perform Retransmit
Hoymiles.getMessageOutput()->print("Request retransmit: ");
Hoymiles.getMessageOutput()->println(verifyResult);
sendRetransmitPacket(verifyResult);

} else {
// Successful received all packages
Hoymiles.getMessageOutput()->println("Success");
_commandQueue.pop();
_busyFlag = false;
}
} else {
// If inverter was not found, assume the command is invalid
Hoymiles.getMessageOutput()->println("RX: Invalid inverter found");
_commandQueue.pop();
_busyFlag = false;
}
} else if (!_busyFlag) {
// Currently in idle mode --> send packet if one is in the queue
if (!_commandQueue.empty()) {
CommandAbstract* cmd = _commandQueue.front().get();

auto inv = Hoymiles.getInverterBySerial(cmd->getTargetAddress());
if (nullptr != inv) {
inv->clearRxFragmentBuffer();
sendEsbPacket(cmd);
} else {
Hoymiles.getMessageOutput()->println("TX: Invalid inverter found");
_commandQueue.pop();
}
}
}
}

void HoymilesRadio::dumpBuf(const uint8_t buf[], uint8_t len, bool appendNewline)
{
for (uint8_t i = 0; i < len; i++) {
Expand Down
4 changes: 4 additions & 0 deletions lib/Hoymiles/src/HoymilesRadio.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once

#include "TimeoutHelper.h"
#include "commands/CommandAbstract.h"
#include "types.h"
#include <memory>
Expand Down Expand Up @@ -30,9 +31,12 @@ class HoymilesRadio {
virtual void sendEsbPacket(CommandAbstract* cmd) = 0;
void sendRetransmitPacket(uint8_t fragment_id);
void sendLastPacketAgain();
void handleReceivedPackage();

serial_u _dtuSerial;
std::queue<std::shared_ptr<CommandAbstract>> _commandQueue;
bool _isInitialized = false;
bool _busyFlag = false;

TimeoutHelper _rxTimeout;
};
Loading

0 comments on commit 909e53b

Please sign in to comment.