Skip to content

Commit

Permalink
Merge remote-tracking branch 'tbnobody/OpenDTU/master' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
helgeerbe committed Jul 2, 2023
2 parents 1f39ed7 + 9b0d2ff commit 9a4eb75
Show file tree
Hide file tree
Showing 16 changed files with 154 additions and 85 deletions.
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
}
}
]
11 changes: 10 additions & 1 deletion lib/Hoymiles/src/commands/MultiDataCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,13 @@ void MultiDataCommand::udpateCRC()
uint16_t crc = crc16(&_payload[10], 14); // From data_type till password
_payload[24] = (uint8_t)(crc >> 8);
_payload[25] = (uint8_t)(crc);
}
}

uint8_t MultiDataCommand::getTotalFragmentSize(fragment_t fragment[], uint8_t max_fragment_id)
{
uint8_t fragmentSize = 0;
for (uint8_t i = 0; i < max_fragment_id; i++) {
fragmentSize += fragment[i].len;
}
return fragmentSize;
}
1 change: 1 addition & 0 deletions lib/Hoymiles/src/commands/MultiDataCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class MultiDataCommand : public CommandAbstract {
void setDataType(uint8_t data_type);
uint8_t getDataType();
void udpateCRC();
static uint8_t getTotalFragmentSize(fragment_t fragment[], uint8_t max_fragment_id);

RequestFrameCommand _cmdRequestFrame;
};
13 changes: 13 additions & 0 deletions lib/Hoymiles/src/commands/RealTimeRunDataCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Copyright (C) 2022 Thomas Basler and others
*/
#include "RealTimeRunDataCommand.h"
#include "Hoymiles.h"
#include "inverters/InverterAbstract.h"

RealTimeRunDataCommand::RealTimeRunDataCommand(uint64_t target_address, uint64_t router_address, time_t time)
Expand All @@ -25,6 +26,18 @@ bool RealTimeRunDataCommand::handleResponse(InverterAbstract* inverter, fragment
return false;
}

// Check if at least all required bytes are received
// In case of low power in the inverter it occours that some incomplete fragments
// with a valid CRC are received.
uint8_t fragmentsSize = getTotalFragmentSize(fragment, max_fragment_id);
uint8_t expectedSize = inverter->Statistics()->getExpectedByteCount();
if (fragmentsSize < expectedSize) {
Hoymiles.getMessageOutput()->printf("ERROR in %s: Received fragment size: %d, min expected size: %d\r\n",
getCommandName().c_str(), fragmentsSize, expectedSize);

return false;
}

// Move all fragments into target buffer
uint8_t offs = 0;
inverter->Statistics()->clearBuffer();
Expand Down
12 changes: 12 additions & 0 deletions lib/Hoymiles/src/parser/StatisticsParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ void StatisticsParser::setByteAssignment(const byteAssign_t* byteAssignment, uin
{
_byteAssignment = byteAssignment;
_byteAssignmentSize = size;

for (uint8_t i = 0; i < _byteAssignmentSize; i++) {
if (_byteAssignment[i].div == CMD_CALC) {
continue;
}
_expectedByteCount = max<uint8_t>(_expectedByteCount, _byteAssignment[i].start + _byteAssignment[i].num);
}
}

uint8_t StatisticsParser::getExpectedByteCount()
{
return _expectedByteCount;
}

void StatisticsParser::clearBuffer()
Expand Down
4 changes: 4 additions & 0 deletions lib/Hoymiles/src/parser/StatisticsParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ class StatisticsParser : public Parser {

void setByteAssignment(const byteAssign_t* byteAssignment, uint8_t size);

// Returns 1 based amount of expected bytes of statistic data
uint8_t getExpectedByteCount();

const byteAssign_t* getAssignmentByChannelField(ChannelType_t type, ChannelNum_t channel, FieldId_t fieldId);
fieldSettings_t* getSettingByChannelField(ChannelType_t type, ChannelNum_t channel, FieldId_t fieldId);

Expand Down Expand Up @@ -139,6 +142,7 @@ class StatisticsParser : public Parser {

const byteAssign_t* _byteAssignment;
uint8_t _byteAssignmentSize;
uint8_t _expectedByteCount;
std::list<fieldSettings_t> _fieldSettings;

uint32_t _rxFailureCount = 0;
Expand Down
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ framework = arduino
platform = espressif32@6.3.1

build_flags =
-DCOMPONENT_EMBED_FILES=webapp_dist/index.html.gz:webapp_dist/zones.json.gz:webapp_dist/favicon.ico:webapp_dist/js/app.js.gz
-DCOMPONENT_EMBED_FILES=webapp_dist/index.html.gz:webapp_dist/zones.json.gz:webapp_dist/favicon.ico:webapp_dist/favicon.png:webapp_dist/js/app.js.gz
-DPIOENV=\"$PIOENV\"
-Wall -Wextra -Werror
-std=c++17
Expand Down
7 changes: 7 additions & 0 deletions src/WebApi_webapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@

extern const uint8_t file_index_html_start[] asm("_binary_webapp_dist_index_html_gz_start");
extern const uint8_t file_favicon_ico_start[] asm("_binary_webapp_dist_favicon_ico_start");
extern const uint8_t file_favicon_png_start[] asm("_binary_webapp_dist_favicon_png_start");
extern const uint8_t file_zones_json_start[] asm("_binary_webapp_dist_zones_json_gz_start");
extern const uint8_t file_app_js_start[] asm("_binary_webapp_dist_js_app_js_gz_start");

extern const uint8_t file_index_html_end[] asm("_binary_webapp_dist_index_html_gz_end");
extern const uint8_t file_favicon_ico_end[] asm("_binary_webapp_dist_favicon_ico_end");
extern const uint8_t file_favicon_png_end[] asm("_binary_webapp_dist_favicon_png_end");
extern const uint8_t file_zones_json_end[] asm("_binary_webapp_dist_zones_json_gz_end");
extern const uint8_t file_app_js_end[] asm("_binary_webapp_dist_js_app_js_gz_end");

Expand Down Expand Up @@ -41,6 +43,11 @@ void WebApiWebappClass::init(AsyncWebServer* server)
request->send(response);
});

_server->on("/favicon.png", HTTP_GET, [](AsyncWebServerRequest* request) {
AsyncWebServerResponse* response = request->beginResponse_P(200, "image/png", file_favicon_png_start, file_favicon_png_end - file_favicon_png_start);
request->send(response);
});

_server->on("/zones.json", HTTP_GET, [](AsyncWebServerRequest* request) {
AsyncWebServerResponse* response = request->beginResponse_P(200, "application/json", file_zones_json_start, file_zones_json_end - file_zones_json_start);
response->addHeader("Content-Encoding", "gzip");
Expand Down
2 changes: 2 additions & 0 deletions webapp/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<link rel="shortcut icon" type="image/png" href="/favicon.png">
<link rel="apple-touch-icon" href="/favicon.png">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>OpenDTU</title>
</head>
Expand Down
16 changes: 8 additions & 8 deletions webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,23 @@
"devDependencies": {
"@intlify/unplugin-vue-i18n": "^0.11.0",
"@rushstack/eslint-patch": "^1.3.2",
"@tsconfig/node18": "^2.0.1",
"@tsconfig/node18": "^18.2.0",
"@types/bootstrap": "^5.2.6",
"@types/node": "^20.3.1",
"@types/node": "^20.3.2",
"@types/sortablejs": "^1.15.1",
"@types/spark-md5": "^3.0.2",
"@vitejs/plugin-vue": "^4.2.3",
"@vue/eslint-config-typescript": "^11.0.3",
"@vue/tsconfig": "^0.4.0",
"eslint": "^8.43.0",
"eslint-plugin-vue": "^9.15.0",
"eslint-plugin-vue": "^9.15.1",
"npm-run-all": "^4.1.5",
"sass": "^1.63.5",
"terser": "^5.18.1",
"typescript": "^5.1.3",
"sass": "^1.63.6",
"terser": "^5.18.2",
"typescript": "^5.1.5",
"vite": "^4.3.9",
"vite-plugin-compression": "^0.5.1",
"vite-plugin-css-injected-by-js": "^3.1.1",
"vue-tsc": "^1.8.1"
"vite-plugin-css-injected-by-js": "^3.1.2",
"vue-tsc": "^1.8.3"
}
}
Binary file added webapp/public/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 15 additions & 15 deletions webapp/src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"Reload": "Reload"
},
"localeswitcher": {
"Dark": "Dark",
"Light": "Light",
"Dark": "Sombre",
"Light": "Clair",
"Auto": "Auto"
},
"apiresponse": {
Expand Down Expand Up @@ -230,13 +230,13 @@
},
"radioinfo": {
"RadioInformation": "Informations sur la radio",
"Status": "{module} Status",
"ChipStatus": "{module} sÉtat de la puce",
"Status": "{module} Statut",
"ChipStatus": "{module} État de la puce",
"ChipType": "{module} Type de puce",
"Connected": "connectée",
"NotConnected": "non connectée",
"Configured": "configured",
"NotConfigured": "not configured",
"Configured": "configurée",
"NotConfigured": "non configurée",
"Unknown": "Inconnue"
},
"networkinfo": {
Expand Down Expand Up @@ -285,12 +285,12 @@
"Synced": "synchronisée",
"NotSynced": "pas synchronisée",
"LocalTime": "Heure locale",
"Sunrise": "Sunrise",
"Sunset": "Sunset",
"Sunrise": "Lever du soleil",
"Sunset": "Coucher du soleil",
"NotAvailable": "Not Available",
"Mode": "Mode",
"Day": "Day",
"Night": "Night"
"Day": "Jour",
"Night": "Nuit"
},
"mqttinfo": {
"MqttInformation": "MQTT Information",
Expand Down Expand Up @@ -514,7 +514,7 @@
"InverterSerial": "Numéro de série de l'onduleur",
"InverterName": "Nom de l'onduleur :",
"InverterNameHint": "Ici, vous pouvez spécifier un nom personnalisé pour votre onduleur.",
"InverterStatus": "Receive / Send",
"InverterStatus": "Recevoir / Envoyer",
"PollEnable": "Interroger les données de l'onduleur",
"PollEnableNight": "Interroger les données de l'onduleur la nuit",
"CommandEnable": "Envoyer des commandes",
Expand Down Expand Up @@ -644,10 +644,10 @@
"ScreensaverHint": "Déplacez un peu l'écran à chaque mise à jour pour éviter le phénomène de brûlure. (Utile surtout pour les écrans OLED)",
"Contrast": "Contraste ({contrast}):",
"Rotation": "Rotation:",
"rot0": "No rotation",
"rot90": "90 degree rotation",
"rot180": "180 degree rotation",
"rot270": "270 degree rotation",
"rot0": "Pas de rotation",
"rot90": "Rotation de 90 degrés",
"rot180": "Rotation de 180 degrés",
"rot270": "Rotation de 270 degrés",
"DisplayLanguage": "Langue d'affichage",
"en": "Anglais",
"de": "Allemand",
Expand Down
Loading

0 comments on commit 9a4eb75

Please sign in to comment.