Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/proddy/EMS-ESP32 into dev2
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDvP committed Sep 9, 2024
2 parents fde9d49 + 5b8d0b9 commit 83676e1
Show file tree
Hide file tree
Showing 18 changed files with 277 additions and 237 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.vscode/c_cpp_properties.json
.vscode/extensions.json
.vscode/launch.json
#.vscode/settings.json
.vscode/settings.json

# c++ compiling
.clang_complete
Expand Down
2 changes: 1 addition & 1 deletion interface/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"@types/react": "^18.3.5",
"@types/react-dom": "^18.3.0",
"@types/react-router-dom": "^5.3.3",
"concurrently": "^8.2.2",
"concurrently": "^9.0.0",
"eslint": "^9.10.0",
"eslint-config-prettier": "^9.1.0",
"formidable": "^3.5.1",
Expand Down
71 changes: 39 additions & 32 deletions interface/src/app/status/SystemLog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ import WarningIcon from '@mui/icons-material/Warning';
import { Box, Button, Checkbox, MenuItem, TextField, styled } from '@mui/material';
import Grid from '@mui/material/Grid2';

import * as SystemApi from 'api/system';
import { fetchLogES } from 'api/system';
import {
fetchLog,
fetchLogES,
readLogSettings,
updateLogSettings
} from 'api/system';

import { useRequest, useSSE } from 'alova/client';
import {
Expand All @@ -22,20 +26,18 @@ import type { LogEntry, LogSettings } from 'types';
import { LogLevel } from 'types';
import { updateValueDirty, useRest } from 'utils';

const ButtonTextColors = {
const TextColors = {
[LogLevel.ERROR]: '#ff0000', // red
[LogLevel.WARNING]: '#ffcc00', // yellow
[LogLevel.WARNING]: '#ff0000', // red
[LogLevel.NOTICE]: '#ffffff', // white
[LogLevel.INFO]: '#ffffff', // yellow
[LogLevel.INFO]: '#ffcc00', // yellow
[LogLevel.DEBUG]: '#00ffff', // cyan
[LogLevel.TRACE]: '#00ffff' // cyan
};

const LogEntryLine = styled('div')(
const LogEntryLine = styled('span')(
({ details: { level } }: { details: { level: LogLevel } }) => ({
color: ButtonTextColors[level],
font: '14px monospace',
whiteSpace: 'nowrap'
color: TextColors[level]
})
);

Expand Down Expand Up @@ -79,8 +81,8 @@ const SystemLog = () => {
saveData,
errorMessage
} = useRest<LogSettings>({
read: SystemApi.readLogSettings,
update: SystemApi.updateLogSettings
read: readLogSettings,
update: updateLogSettings
});

const [logEntries, setLogEntries] = useState<LogEntry[]>([]);
Expand Down Expand Up @@ -114,7 +116,7 @@ const SystemLog = () => {
});

// called on page load to reset pointer and fetch all log entries
useRequest(SystemApi.fetchLog());
useRequest(fetchLog());

const paddedLevelLabel = (level: LogLevel) => {
const label = levelLabel(level);
Expand Down Expand Up @@ -190,23 +192,25 @@ const SystemLog = () => {
<MenuItem value={9}>ALL</MenuItem>
</TextField>
</Grid>
<Grid size={2}>
<TextField
name="max_messages"
label={LL.BUFFER_SIZE()}
value={data.max_messages}
fullWidth
variant="outlined"
onChange={updateFormValue}
margin="normal"
select
>
<MenuItem value={25}>25</MenuItem>
<MenuItem value={50}>50</MenuItem>
<MenuItem value={75}>75</MenuItem>
<MenuItem value={100}>100</MenuItem>
</TextField>
</Grid>
{data.psram && (
<Grid size={2}>
<TextField
name="max_messages"
label={LL.BUFFER_SIZE()}
value={data.max_messages}
fullWidth
variant="outlined"
onChange={updateFormValue}
margin="normal"
select
>
<MenuItem value={25}>25</MenuItem>
<MenuItem value={50}>50</MenuItem>
<MenuItem value={75}>75</MenuItem>
<MenuItem value={100}>100</MenuItem>
</TextField>
</Grid>
)}
<Grid>
<BlockFormControlLabel
control={
Expand Down Expand Up @@ -251,14 +255,17 @@ const SystemLog = () => {
}}
>
{logEntries.map((e) => (
<LogEntryLine details={{ level: e.l }} key={e.i}>
<div style={{ font: '14px monospace', whiteSpace: 'nowrap' }}>
<span>{e.t}</span>
<span>{paddedLevelLabel(e.l)}&nbsp;</span>
<span>{paddedIDLabel(e.i)} </span>
<span>{paddedNameLabel(e.n)} </span>
<span>{e.m}</span>
</LogEntryLine>
<LogEntryLine details={{ level: e.l }} key={e.i}>
{e.m}
</LogEntryLine>
</div>
))}

<div ref={ref} />
</Box>
</>
Expand Down
1 change: 1 addition & 0 deletions interface/src/types/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,5 @@ export interface LogSettings {
level: number;
max_messages: number;
compact: boolean;
psram: boolean;
}
30 changes: 6 additions & 24 deletions interface/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ __metadata:
languageName: node
linkType: hard

"@babel/runtime@npm:^7.0.0, @babel/runtime@npm:^7.12.5, @babel/runtime@npm:^7.18.3, @babel/runtime@npm:^7.21.0, @babel/runtime@npm:^7.5.5, @babel/runtime@npm:^7.8.7":
"@babel/runtime@npm:^7.0.0, @babel/runtime@npm:^7.12.5, @babel/runtime@npm:^7.18.3, @babel/runtime@npm:^7.5.5, @babel/runtime@npm:^7.8.7":
version: 7.25.0
resolution: "@babel/runtime@npm:7.25.0"
dependencies:
Expand Down Expand Up @@ -1734,7 +1734,7 @@ __metadata:
"@types/react-router-dom": "npm:^5.3.3"
alova: "npm:3.0.16"
async-validator: "npm:^4.2.5"
concurrently: "npm:^8.2.2"
concurrently: "npm:^9.0.0"
eslint: "npm:^9.10.0"
eslint-config-prettier: "npm:^9.1.0"
formidable: "npm:^3.5.1"
Expand Down Expand Up @@ -2340,23 +2340,21 @@ __metadata:
languageName: node
linkType: hard

"concurrently@npm:^8.2.2":
version: 8.2.2
resolution: "concurrently@npm:8.2.2"
"concurrently@npm:^9.0.0":
version: 9.0.0
resolution: "concurrently@npm:9.0.0"
dependencies:
chalk: "npm:^4.1.2"
date-fns: "npm:^2.30.0"
lodash: "npm:^4.17.21"
rxjs: "npm:^7.8.1"
shell-quote: "npm:^1.8.1"
spawn-command: "npm:0.0.2"
supports-color: "npm:^8.1.1"
tree-kill: "npm:^1.2.2"
yargs: "npm:^17.7.2"
bin:
conc: dist/bin/concurrently.js
concurrently: dist/bin/concurrently.js
checksum: 10c0/0e9683196fe9c071d944345d21d8f34aa6c0cc50c0dd897e95619f2f1c9eb4871dca851b2569da17888235b7335b4c821ca19deed35bebcd9a131ee5d247f34c
checksum: 10c0/65251009f4540c25eda0d5b2f367ba8755eac83db2ce562802132160e9241c5cd755228b18c330ea29ccd5b0a033302da8a670d724e89fe462c26253e3046f2e
languageName: node
linkType: hard

Expand Down Expand Up @@ -2535,15 +2533,6 @@ __metadata:
languageName: node
linkType: hard

"date-fns@npm:^2.30.0":
version: 2.30.0
resolution: "date-fns@npm:2.30.0"
dependencies:
"@babel/runtime": "npm:^7.21.0"
checksum: 10c0/e4b521fbf22bc8c3db332bbfb7b094fd3e7627de0259a9d17c7551e2d2702608a7307a449206065916538e384f37b181565447ce2637ae09828427aed9cb5581
languageName: node
linkType: hard

"debug@npm:4, debug@npm:^4.1.0, debug@npm:^4.1.1, debug@npm:^4.3.1, debug@npm:^4.3.2, debug@npm:^4.3.3, debug@npm:^4.3.4":
version: 4.3.6
resolution: "debug@npm:4.3.6"
Expand Down Expand Up @@ -6395,13 +6384,6 @@ __metadata:
languageName: node
linkType: hard

"spawn-command@npm:0.0.2":
version: 0.0.2
resolution: "spawn-command@npm:0.0.2"
checksum: 10c0/b22f2d71239e6e628a400831861ba747750bbb40c0a53323754cf7b84330b73d81e40ff1f9055e6d1971818679510208a9302e13d9ff3b32feb67e74d7a1b3ef
languageName: node
linkType: hard

"spdx-correct@npm:^3.0.0":
version: 3.2.0
resolution: "spdx-correct@npm:3.2.0"
Expand Down
2 changes: 1 addition & 1 deletion lib/framework/FSPersistence.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class FSPersistence {
// hard-coded emergency defaults are now applied.
#ifdef EMSESP_DEBUG
Serial.println();
Serial.printf("Applying defaults to %s ", _filePath);
Serial.printf("Applying defaults to %s", _filePath);
Serial.println();
#endif
applyDefaults();
Expand Down
4 changes: 2 additions & 2 deletions lib/framework/NetworkSettingsService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,9 @@ void NetworkSettingsService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info)
case ARDUINO_EVENT_ETH_GOT_IP6:
#if !TASMOTA_SDK && ESP_IDF_VERSION_MAJOR < 5
if (emsesp::EMSESP::system_.ethernet_connected()) {
emsesp::EMSESP::logger().info("Local IPv6=%s", ETH.localIPv6().toString().c_str());
emsesp::EMSESP::logger().info("Local IPv6 (Eth) =%s", ETH.localIPv6().toString().c_str());
} else {
emsesp::EMSESP::logger().info("Local IPv6=%s", WiFi.localIPv6().toString().c_str());
emsesp::EMSESP::logger().info("Local IPv6 (WiFi)=%s", WiFi.localIPv6().toString().c_str());
}
#else
emsesp::EMSESP::logger().info("Local IPv6=%s", IPAddress(IPv6, (uint8_t *)info.got_ip6.ip6_info.ip.addr, 0).toString().c_str());
Expand Down
13 changes: 11 additions & 2 deletions mock-api/mockServer.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// used to simulate
// - file uploads
// - EventSource (SSE) for log messages
import formidable from 'formidable';

function pad(number) {
Expand Down Expand Up @@ -99,15 +102,21 @@ export default () => {

let count = 0;
const interval = setInterval(() => {
let message = 'message #' + count;
if (count % 6 === 1) {
message +=
' with a long message that will be wrapped, to see if it stays one a single line';
}
const data = {
t: new Date().toISOString(),
l: 3 + (count % 6),
i: count,
n: 'system',
m: 'message #' + count++
m: message
};
count++;
res.write(`data: ${JSON.stringify(data)}\n\n`);
}, 1000);
}, 800);

// if client closes connection
res.on('close', () => {
Expand Down
2 changes: 1 addition & 1 deletion mock-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"dependencies": {
"@msgpack/msgpack": "^2.8.0",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"eslint": "^9.9.1",
"eslint": "^9.10.0",
"eslint-config-prettier": "^9.1.0",
"formidable": "^3.5.1",
"itty-router": "^5.0.18",
Expand Down
3 changes: 2 additions & 1 deletion mock-api/rest_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ const LOG_SETTINGS_ENDPOINT = REST_ENDPOINT_ROOT + 'logSettings';
let log_settings = {
level: 6,
max_messages: 50,
compact: true
compact: true,
psram: true
};

const FETCH_LOG_ENDPOINT = REST_ENDPOINT_ROOT + 'fetchLog';
Expand Down
31 changes: 20 additions & 11 deletions mock-api/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@ __metadata:
languageName: node
linkType: hard

"@eslint/js@npm:9.9.1":
version: 9.9.1
resolution: "@eslint/js@npm:9.9.1"
checksum: 10c0/a3a91de2ce78469f7c4eee78c1eba77360706e1d0fa0ace2e19102079bcf237b851217c85ea501dc92c4c3719d60d9df966977abc8554d4c38e3638c1f53dcb2
"@eslint/js@npm:9.10.0":
version: 9.10.0
resolution: "@eslint/js@npm:9.10.0"
checksum: 10c0/2ac45a002dc1ccf25be46ea61001ada8d77248d1313ab4e53f3735e5ae00738a757874e41f62ad6fbd49df7dffeece66e5f53ff0d7b78a99ce4c68e8fea66753
languageName: node
linkType: hard

Expand All @@ -222,6 +222,15 @@ __metadata:
languageName: node
linkType: hard

"@eslint/plugin-kit@npm:^0.1.0":
version: 0.1.0
resolution: "@eslint/plugin-kit@npm:0.1.0"
dependencies:
levn: "npm:^0.4.1"
checksum: 10c0/fae97cd4efc1c32501c286abba1b5409848ce8c989e1ca6a5bb057a304a2cd721e6e957f6bc35ce95cfd0871e822ed42df3c759fecdad72c30e70802e26f83c7
languageName: node
linkType: hard

"@humanwhocodes/module-importer@npm:^1.0.1":
version: 1.0.1
resolution: "@humanwhocodes/module-importer@npm:1.0.1"
Expand Down Expand Up @@ -574,15 +583,16 @@ __metadata:
languageName: node
linkType: hard

"eslint@npm:^9.9.1":
version: 9.9.1
resolution: "eslint@npm:9.9.1"
"eslint@npm:^9.10.0":
version: 9.10.0
resolution: "eslint@npm:9.10.0"
dependencies:
"@eslint-community/eslint-utils": "npm:^4.2.0"
"@eslint-community/regexpp": "npm:^4.11.0"
"@eslint/config-array": "npm:^0.18.0"
"@eslint/eslintrc": "npm:^3.1.0"
"@eslint/js": "npm:9.9.1"
"@eslint/js": "npm:9.10.0"
"@eslint/plugin-kit": "npm:^0.1.0"
"@humanwhocodes/module-importer": "npm:^1.0.1"
"@humanwhocodes/retry": "npm:^0.3.0"
"@nodelib/fs.walk": "npm:^1.2.8"
Expand All @@ -605,7 +615,6 @@ __metadata:
is-glob: "npm:^4.0.0"
is-path-inside: "npm:^3.0.3"
json-stable-stringify-without-jsonify: "npm:^1.0.1"
levn: "npm:^0.4.1"
lodash.merge: "npm:^4.6.2"
minimatch: "npm:^3.1.2"
natural-compare: "npm:^1.4.0"
Expand All @@ -619,7 +628,7 @@ __metadata:
optional: true
bin:
eslint: bin/eslint.js
checksum: 10c0/5e71efda7c0a14ee95436d5cdfed04ee61dfb1d89d7a32b50a424de2e680af82849628ea6581950c2e0726491f786a3cfd0032ce013c1c5093786e475cfdfb33
checksum: 10c0/7357f3995b15043eea83c8c0ab16c385ce3f28925c1b11cfcd6b2ede8faab3d91ede84a68173dd5f6e3e176e177984e6218de58b7b8388e53e2881f1ec07c836
languageName: node
linkType: hard

Expand Down Expand Up @@ -960,7 +969,7 @@ __metadata:
dependencies:
"@msgpack/msgpack": "npm:^2.8.0"
"@trivago/prettier-plugin-sort-imports": "npm:^4.3.0"
eslint: "npm:^9.9.1"
eslint: "npm:^9.10.0"
eslint-config-prettier: "npm:^9.1.0"
formidable: "npm:^3.5.1"
itty-router: "npm:^5.0.18"
Expand Down
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ extends = espressi32_base
board = esp32dev
board_upload.flash_size = 16MB
board_build.partitions = esp32_partition_16M.csv
board_build.extra_flags = -DBOARD_HAS_PSRAM '-DEMSESP_DEFAULT_BOARD_PROFILE="S32"'
board_build.extra_flags = -DBOARD_HAS_PSRAM '-DEMSESP_DEFAULT_BOARD_PROFILE="E32V2"'

[env:c3_mini_4M]
extends = espressi32_base_tasmota
Expand Down
Loading

0 comments on commit 83676e1

Please sign in to comment.