Merge branch 'origin/dev'

This commit is contained in:
Proddy
2023-09-09 14:12:07 +02:00
71 changed files with 1485 additions and 2358 deletions

View File

@@ -2,7 +2,6 @@
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"arcanis.vscode-zipfs",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"platformio.platformio-ide"

View File

@@ -41,5 +41,6 @@
"**/*.min.*",
"**/*.map",
"**/ArduinoJson/**"
]
],
"cSpell.enableFiletypes": ["!cpp"]
}

View File

@@ -5,6 +5,27 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
# [3.6.1] September 9 2023
## **IMPORTANT! BREAKING CHANGES**
- `shower_data` MQTT topic shows duration is seconds (was previously a full english sentence)
## Added
- show WiFi rssi in Network Status Page, show quality as color
## Fixed
- Issue in espMqttClient causing a memory leak when MQTT broker is disconnected due to network unavailability [#1264](https://github.com/emsesp/EMS-ESP32/issues/1264)
- Using MQTT enum values correctly formatted in MQTT Discovery [#1280](https://github.com/emsesp/EMS-ESP32/issues/1280)
## Changed
- mqtt free mem check set to 60 kb
- small cosmetic changes to Searching in Customization web page
- updated to espressif32@6.4.0
# [3.6.0] August 13 2023
## **IMPORTANT! BREAKING CHANGES**

View File

@@ -1,11 +1,22 @@
# Changelog
# [3.7.0]
## [3.6.1]
## **IMPORTANT! BREAKING CHANGES**
- `shower_data` MQTT topic shows duration is seconds (was previously a full english sentence)
## Added
- show WiFi rssi in Network Status Page, show quality as color
## Fixed
- Issue in espMqttClient causing a memory leak when MQTT broker is disconnected due to network unavailability [#1264](https://github.com/emsesp/EMS-ESP32/issues/1264)
- Using MQTT enum values correctly formatted in MQTT Discovery [#1280](https://github.com/emsesp/EMS-ESP32/issues/1280)
## Changed
- mqtt free mem check set to 60 kb
- small cosmetic changes to Searching in Customization web page
- updated to espressif32@6.4.0

View File

@@ -42,7 +42,7 @@ DEFINES += -DARDUINOJSON_ENABLE_STD_STRING=1 -DARDUINOJSON_ENABLE_PROGMEM=1 -DAR
DEFINES += -DEMSESP_DEBUG -DEMSESP_STANDALONE -DEMSESP_TEST -D__linux__ -DEMC_RX_BUFFER_SIZE=1500
DEFINES += $(ARGS)
DEFAULTS = -DEMSESP_DEFAULT_LOCALE=\"en\" -DEMSESP_DEFAULT_TX_MODE=8 -DEMSESP_DEFAULT_VERSION=\"3.6.0-dev\" -DEMSESP_DEFAULT_BOARD_PROFILE=\"S32\"
DEFAULTS = -DEMSESP_DEFAULT_LOCALE=\"en\" -DEMSESP_DEFAULT_TX_MODE=8 -DEMSESP_DEFAULT_VERSION=\"3.7.0-dev\" -DEMSESP_DEFAULT_BOARD_PROFILE=\"S32\"
#----------------------------------------------------------------------
# Sources & Files

View File

@@ -1,5 +1,5 @@
{
"adapter": "react",
"baseLocale": "pl",
"$schema": "https://unpkg.com/typesafe-i18n@5.26.0/schema/typesafe-i18n.json"
"$schema": "https://unpkg.com/typesafe-i18n@5.26.2/schema/typesafe-i18n.json"
}

View File

@@ -12,7 +12,7 @@
"build-hosted": "vite build --mode hosted",
"preview": "vite preview",
"preview-standalone": "npm-run-all -p preview typesafe-i18n mock-api",
"mock-api": "nodemon --watch ../mock-api ../mock-api/server.js",
"mock-api": "node --watch ../mock-api ../mock-api/server.js",
"standalone": "npm-run-all -p dev typesafe-i18n mock-api",
"typesafe-i18n": "typesafe-i18n",
"format": "prettier --write '**/*.{ts,tsx,js,css,json,md}'",
@@ -22,55 +22,54 @@
"@alova/adapter-xhr": "^1.0.1",
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@mui/icons-material": "^5.14.3",
"@mui/material": "^5.14.4",
"@mui/icons-material": "^5.14.8",
"@mui/material": "^5.14.8",
"@preact/compat": "^17.1.2",
"@prefresh/vite": "^2.4.1",
"@table-library/react-table-library": "4.1.7",
"@types/lodash-es": "^4.17.8",
"@types/node": "^20.4.10",
"@types/react": "^18.2.20",
"@types/lodash-es": "^4.17.9",
"@types/node": "^20.6.0",
"@types/react": "^18.2.21",
"@types/react-dom": "^18.2.7",
"@types/react-router-dom": "^5.3.3",
"alova": "^2.10.0",
"alova": "^2.11.1",
"async-validator": "^4.2.5",
"history": "^5.3.0",
"jwt-decode": "^3.1.2",
"lodash-es": "^4.17.21",
"mime-types": "^2.1.35",
"preact": "^10.16.0",
"preact": "^10.17.1",
"react": "latest",
"react-dom": "latest",
"react-dropzone": "^14.2.3",
"react-icons": "^4.10.1",
"react-icons": "^4.11.0",
"react-router-dom": "^6.15.0",
"react-toastify": "^9.1.3",
"sockette": "^2.0.6",
"typesafe-i18n": "^5.26.0",
"typescript": "^5.1.6"
"typesafe-i18n": "^5.26.2",
"typescript": "^5.2.2"
},
"devDependencies": {
"@babel/core": "^7.22.10",
"@babel/core": "^7.22.17",
"@preact/preset-vite": "^2.5.0",
"@types/babel__core": "^7",
"@typescript-eslint/eslint-plugin": "^6.3.0",
"@typescript-eslint/parser": "^6.3.0",
"eslint": "^8.47.0",
"@typescript-eslint/eslint-plugin": "^6.6.0",
"@typescript-eslint/parser": "^6.6.0",
"eslint": "^8.49.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-typescript": "^17.1.0",
"eslint-config-prettier": "^9.0.0",
"eslint-import-resolver-typescript": "^3.6.0",
"eslint-plugin-autofix": "^1.1.0",
"eslint-plugin-import": "^2.28.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-prettier": "alpha",
"eslint-plugin-react": "^7.33.1",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"nodemon": "^3.0.1",
"npm-run-all": "^4.1.5",
"prettier": "^3.0.1",
"prettier": "^3.0.3",
"rollup-plugin-visualizer": "^5.9.2",
"terser": "^5.19.2",
"terser": "^5.19.4",
"vite": "^4.4.9",
"vite-plugin-svgr": "^3.2.0",
"vite-tsconfig-paths": "^4.2.0"

View File

@@ -38,6 +38,15 @@ const networkStatusHighlight = ({ status }: NetworkStatus, theme: Theme) => {
}
};
const networkQualityHighlight = ({ rssi }: NetworkStatus, theme: Theme) => {
if (rssi <= -85) {
return theme.palette.error.main;
} else if (rssi <= -75) {
return theme.palette.warning.main;
}
return theme.palette.success.main;
};
export const isWiFi = ({ status }: NetworkStatus) => status === NetworkConnectionStatus.WIFI_STATUS_CONNECTED;
export const isEthernet = ({ status }: NetworkStatus) => status === NetworkConnectionStatus.ETHERNET_STATUS_CONNECTED;
@@ -110,11 +119,11 @@ const NetworkStatusForm: FC = () => {
<>
<ListItem>
<ListItemAvatar>
<Avatar>
<Avatar sx={{ bgcolor: networkQualityHighlight(data, theme) }}>
<SettingsInputAntennaIcon />
</Avatar>
</ListItemAvatar>
<ListItemText primary="SSID" secondary={data.ssid} />
<ListItemText primary="SSID (RSSI)" secondary={data.ssid + ' (' + data.rssi + ' dBm)'} />
</ListItem>
<Divider variant="inset" component="li" />
</>

View File

@@ -1,10 +1,11 @@
import LockIcon from '@mui/icons-material/Lock';
import LockOpenIcon from '@mui/icons-material/LockOpen';
import WifiIcon from '@mui/icons-material/Wifi';
import { Avatar, Badge, List, ListItem, ListItemAvatar, ListItemIcon, ListItemText } from '@mui/material';
import { Avatar, Badge, List, ListItem, ListItemAvatar, ListItemIcon, ListItemText, useTheme } from '@mui/material';
import { useContext } from 'react';
import { WiFiConnectionContext } from './WiFiConnectionContext';
import type { Theme } from '@mui/material';
import type { FC } from 'react';
import type { WiFiNetwork, WiFiNetworkList } from 'types';
import { MessageBox } from 'components';
@@ -42,8 +43,18 @@ export const networkSecurityMode = ({ encryption_type }: WiFiNetwork) => {
}
};
const networkQualityHighlight = ({ rssi }: WiFiNetwork, theme: Theme) => {
if (rssi <= -85) {
return theme.palette.error.main;
} else if (rssi <= -75) {
return theme.palette.warning.main;
}
return theme.palette.success.main;
};
const WiFiNetworkSelector: FC<WiFiNetworkSelectorProps> = ({ networkList }) => {
const { LL } = useI18nContext();
const theme = useTheme();
const wifiConnectionContext = useContext(WiFiConnectionContext);
@@ -57,8 +68,8 @@ const WiFiNetworkSelector: FC<WiFiNetworkSelectorProps> = ({ networkList }) => {
secondary={'Security: ' + networkSecurityMode(network) + ', Ch: ' + network.channel}
/>
<ListItemIcon>
<Badge badgeContent={network.rssi + 'db'}>
<WifiIcon />
<Badge badgeContent={network.rssi + 'dBm'}>
<WifiIcon sx={{ color: networkQualityHighlight(network, theme) }} />
</Badge>
</ListItemIcon>
</ListItem>

View File

@@ -86,7 +86,7 @@ const SettingsCustomization: FC = () => {
const entities_theme = useTheme({
Table: `
--data-table-library_grid-template-columns: 150px repeat(1, minmax(80px, 1fr)) 45px minmax(45px, auto) minmax(120px, auto);
--data-table-library_grid-template-columns: 156px repeat(1, minmax(80px, 1fr)) 45px minmax(45px, auto) minmax(120px, auto);
`,
BaseRow: `
font-size: 14px;
@@ -192,17 +192,9 @@ const SettingsCustomization: FC = () => {
return value;
}
function formatName(de: DeviceEntity) {
return (
<>
{de.n && (de.n[0] === '!' ? LL.COMMAND(1) + ': ' + de.n.slice(1) : de.cn && de.cn !== '' ? de.cn : de.n) + ' '}(
<Link target="_blank" href={APIURL + devices?.devices[selectedDevice].tn + '/' + de.id}>
{de.id}
</Link>
)
</>
);
}
const formatName = (de: DeviceEntity, withShortname: boolean) =>
(de.n && de.n[0] === '!' ? LL.COMMAND(1) + ': ' + de.n.slice(1) : de.cn && de.cn !== '' ? de.cn : de.n) +
(withShortname ? ' ' + de.id : '');
const getMaskNumber = (newMask: string[]) => {
let new_mask = 0;
@@ -232,10 +224,13 @@ const SettingsCustomization: FC = () => {
return new_masks;
};
const filter_entity = (de: DeviceEntity) =>
(de.m & selectedFilters || !selectedFilters) && formatName(de, true).includes(search.toLocaleLowerCase());
const maskDisabled = (set: boolean) => {
setDeviceEntities(
deviceEntities.map(function (de) {
if ((de.m & selectedFilters || !selectedFilters) && de.id.toLowerCase().includes(search.toLowerCase())) {
if (filter_entity(de)) {
return {
...de,
m: set
@@ -353,7 +348,7 @@ const SettingsCustomization: FC = () => {
margin="normal"
select
>
<MenuItem disabled key={0} value={-1}>
<MenuItem disabled key={-1} value={-1}>
{LL.SELECT_DEVICE()}...
</MenuItem>
{devices.devices.map((device: DeviceShort, index) => (
@@ -370,9 +365,7 @@ const SettingsCustomization: FC = () => {
return;
}
const shown_data = deviceEntities.filter(
(de) => (de.m & selectedFilters || !selectedFilters) && de.id.toLowerCase().includes(search.toLowerCase())
);
const shown_data = deviceEntities.filter((de) => filter_entity(de));
return (
<>
@@ -470,7 +463,13 @@ const SettingsCustomization: FC = () => {
<Cell stiff>
<EntityMaskToggle onUpdate={updateDeviceEntity} de={de} />
</Cell>
<Cell>{formatName(de)}</Cell>
<Cell>
{formatName(de, false)}&nbsp;(
<Link target="_blank" href={APIURL + devices?.devices[selectedDevice].tn + '/' + de.id}>
{de.id}
</Link>
)
</Cell>
<Cell>{!(de.m & DeviceEntityMask.DV_READONLY) && formatValue(de.mi)}</Cell>
<Cell>{!(de.m & DeviceEntityMask.DV_READONLY) && formatValue(de.ma)}</Cell>
<Cell>{formatValue(de.v)}</Cell>

View File

@@ -1,4 +1,5 @@
import CancelIcon from '@mui/icons-material/Cancel';
import CloseIcon from '@mui/icons-material/Close';
import DoneIcon from '@mui/icons-material/Done';
import {
@@ -67,15 +68,34 @@ const SettingsCustomizationDialog = ({ open, onClose, onSave, selectedItem }: Se
<Dialog sx={dialogStyle} open={open} onClose={close}>
<DialogTitle>{LL.EDIT() + ' ' + LL.ENTITY()}</DialogTitle>
<DialogContent dividers>
<Box color="warning.main">
<Typography variant="body2">{editItem.id}</Typography>
</Box>
<Box color="warning.main" mt={1} mb={2}>
<Typography variant="body2">
{LL.DEFAULT(1) + ' ' + LL.ENTITY_NAME(1)}:&nbsp;{editItem.n}
<Grid container direction="row">
<Typography variant="body2" color="warning.main">
{LL.ENTITY() + ' ID'}:&nbsp;
</Typography>
</Box>
<Box mb={3}>
<Typography variant="body2">{editItem.id}</Typography>
</Grid>
<Grid container direction="row">
<Typography variant="body2" color="warning.main">
{LL.DEFAULT(1) + ' ' + LL.ENTITY_NAME(1)}:&nbsp;
</Typography>
<Typography variant="body2">{editItem.n}</Typography>
</Grid>
<Grid container direction="row">
<Typography variant="body2" color="warning.main">
{LL.WRITEABLE()}:&nbsp;
</Typography>
<Typography variant="body2">
{editItem.w ? (
<DoneIcon color="success" sx={{ fontSize: 16 }} />
) : (
<CloseIcon color="error" sx={{ fontSize: 16 }} />
)}
</Typography>
</Grid>
<Box mt={1} mb={2}>
<EntityMaskToggle onUpdate={updateDeviceEntity} de={editItem} />
</Box>
<Grid container spacing={1}>

View File

@@ -13,7 +13,7 @@ import { toast } from 'react-toastify';
import SettingsEntitiesDialog from './SettingsEntitiesDialog';
import * as EMSESP from './api';
import { DeviceValueUOM_s } from './types';
import { DeviceValueTypeNames, DeviceValueUOM_s } from './types';
import { entityItemValidation } from './validators';
import type { EntityItem } from './types';
import type { FC } from 'react';
@@ -57,7 +57,7 @@ const SettingsEntities: FC = () => {
const entity_theme = useTheme({
Table: `
--data-table-library_grid-template-columns: repeat(1, minmax(60px, 1fr)) minmax(80px, auto) 80px 80px 80px;
--data-table-library_grid-template-columns: repeat(1, minmax(60px, 1fr)) minmax(80px, auto) 80px 80px 80px 90px;
`,
BaseRow: `
font-size: 14px;
@@ -81,6 +81,9 @@ const SettingsEntities: FC = () => {
&:nth-of-type(5) {
text-align: center;
}
&:nth-of-type(6) {
text-align: center;
}
`,
HeaderRow: `
text-transform: uppercase;
@@ -208,8 +211,9 @@ const SettingsEntities: FC = () => {
<HeaderCell>{LL.NAME(0)}</HeaderCell>
<HeaderCell stiff>{LL.ID_OF(LL.DEVICE())}</HeaderCell>
<HeaderCell stiff>{LL.ID_OF(LL.TYPE(1))}</HeaderCell>
<HeaderCell stiff>Offset</HeaderCell>
<HeaderCell stiff>{LL.VALUE(0)}</HeaderCell>
<HeaderCell stiff>{LL.OFFSET()}</HeaderCell>
<HeaderCell stiff>{LL.VALUE(1) + ' ' + LL.TYPE(1)}</HeaderCell>
<HeaderCell stiff>{LL.VALUE(1)}</HeaderCell>
</HeaderRow>
</Header>
<Body>
@@ -219,6 +223,7 @@ const SettingsEntities: FC = () => {
<Cell>{showHex(ei.device_id as number, 2)}</Cell>
<Cell>{showHex(ei.type_id as number, 3)}</Cell>
<Cell>{ei.offset}</Cell>
<Cell>{DeviceValueTypeNames[ei.value_type]}</Cell>
<Cell>{formatValue(ei.value, ei.uom)}</Cell>
</Row>
))}

View File

@@ -148,7 +148,7 @@ const SettingsEntitiesDialog = ({
<ValidatedTextField
fieldErrors={fieldErrors}
name="offset"
label="Offset"
label={LL.OFFSET()}
margin="normal"
fullWidth
type="number"
@@ -159,7 +159,7 @@ const SettingsEntitiesDialog = ({
<Grid item xs={4}>
<TextField
name="value_type"
label="Value Type"
label={LL.VALUE(1) + ' ' + LL.TYPE(1)}
value={editItem.value_type}
variant="outlined"
onChange={updateFormValue}

View File

@@ -1,6 +1,6 @@
import AddIcon from '@mui/icons-material/Add';
import CancelIcon from '@mui/icons-material/Cancel';
import CheckCircleIcon from '@mui/icons-material/CheckCircle';
import CircleIcon from '@mui/icons-material/Circle';
import WarningIcon from '@mui/icons-material/Warning';
import { Box, Typography, Divider, Stack, Button } from '@mui/material';
@@ -216,7 +216,11 @@ const SettingsScheduler: FC = () => {
{tableList.map((si: ScheduleItem) => (
<Row key={si.id} item={si} onClick={() => editScheduleItem(si)}>
<Cell stiff>
{si.active && <CheckCircleIcon sx={{ color: '#79D200', fontSize: 16, verticalAlign: 'middle' }} />}
{si.active ? (
<CircleIcon color="success" sx={{ fontSize: 16, verticalAlign: 'middle' }} />
) : (
<CircleIcon color="error" sx={{ fontSize: 16, verticalAlign: 'middle' }} />
)}
</Cell>
<Cell stiff>
<Stack spacing={1} direction="row">

View File

@@ -1,6 +1,5 @@
import AddIcon from '@mui/icons-material/Add';
import CancelIcon from '@mui/icons-material/Cancel';
import CheckCircleIcon from '@mui/icons-material/CheckCircle';
import DoneIcon from '@mui/icons-material/Done';
import RemoveIcon from '@mui/icons-material/RemoveCircleOutline';
@@ -184,11 +183,6 @@ const SettingsSchedulerDialog = ({
control={<Checkbox checked={editItem.active} onChange={updateFormValue} name="active" />}
label={LL.ACTIVE()}
/>
{editItem.active && (
<Grid item sx={{ mt: 1 }}>
<CheckCircleIcon sx={{ color: '#79D200', fontSize: 16, verticalAlign: 'middle' }} />
</Grid>
)}
</Grid>
<Grid container>
<TextField

View File

@@ -379,3 +379,16 @@ export const enum DeviceValueType {
STRING,
CMD
}
export const DeviceValueTypeNames = [
'BOOL',
'INT',
'UINT',
'SHORT',
'USHORT',
'ULONG',
'TIME',
'ENUM',
'STRING',
'CMD'
];

View File

@@ -50,9 +50,9 @@ export default defineConfig(({ command, mode }) => {
server: {
open: true,
port: 3000,
watch: {
usePolling: true
},
// watch: {
// usePolling: true
// },
proxy: {
'/rest': 'http://localhost:3080',
'/api': {

File diff suppressed because it is too large Load Diff

View File

@@ -103,7 +103,7 @@ bool MqttClient::disconnected() const {
}
bool MqttClient::connect() {
bool result = true;
bool result = false;
if (_state == State::disconnected) {
EMC_SEMAPHORE_TAKE();
if (_addPacketFront(_cleanSession,
@@ -116,19 +116,21 @@ bool MqttClient::connect() {
_willPayloadLength,
(uint16_t)(_keepAlive / 1000), // 32b to 16b doesn't overflow because it comes from 16b orignally
_clientId)) {
result = true;
_state = State::connectingTcp1;
#if defined(ARDUINO_ARCH_ESP32)
if (_useInternalTask == espMqttClientTypes::UseInternalTask::YES) {
vTaskResume(_taskHandle);
}
#endif
_state = State::connectingTcp1;
} else {
EMC_SEMAPHORE_GIVE();
emc_log_e("Could not create CONNECT packet");
_onError(0, Error::OUT_OF_MEMORY);
result = false;
}
EMC_SEMAPHORE_GIVE();
} else if (_state <= State::connected) { // already connected or connecting
result = true;
}
return result;
}
@@ -196,6 +198,14 @@ const char * MqttClient::getClientId() const {
return _clientId;
}
size_t MqttClient::queueSize() {
size_t ret = 0;
EMC_SEMAPHORE_TAKE();
ret = _outbox.size();
EMC_SEMAPHORE_GIVE();
return ret;
}
void MqttClient::loop() {
switch ((State)_state) { // modified by proddy for EMS-ESP compiling standalone
case State::disconnected:
@@ -335,7 +345,6 @@ int MqttClient::_sendPacket() {
size_t wantToWrite = 0;
size_t written = 0;
if (packet && (wantToWrite == written)) {
// mixing signed with unsigned here but safe because of MQTT packet size limits
wantToWrite = packet->packet.available(_bytesSent);
if (wantToWrite == 0) {
EMC_SEMAPHORE_GIVE();
@@ -630,9 +639,6 @@ void MqttClient::_onPubcomp() {
// if it doesn't match the ID, return
if ((it.get()->packet.packetType()) == PacketType.PUBREL) {
if (it.get()->packet.packetId() == idToMatch) {
// if (!_addPacket(PacketType.PUBCOMP, idToMatch)) {
// emc_log_e("Could not create PUBCOMP packet");
// }
callback = true;
_outbox.remove(it);
break;
@@ -697,20 +703,6 @@ void MqttClient::_onUnsuback() {
}
}
uint16_t MqttClient::getQueue() const {
EMC_SEMAPHORE_TAKE();
espMqttClientInternals::Outbox<OutgoingPacket>::Iterator it = _outbox.front();
uint16_t count = 0;
while (it) {
// if (it.get()->packet.packetType() == PacketType.PUBLISH) {
++count;
// }
++it;
}
EMC_SEMAPHORE_GIVE();
return count;
}
void MqttClient::_clearQueue(int clearData) {
emc_log_i("clearing queue (clear session: %d)", clearData);
EMC_SEMAPHORE_TAKE();

View File

@@ -65,7 +65,7 @@ class MqttClient {
uint16_t publish(const char * topic, uint8_t qos, bool retain, espMqttClientTypes::PayloadCallback callback, size_t length);
void clearQueue(bool deleteSessionData = false); // Not MQTT compliant and may cause unpredictable results when `deleteSessionData` = true!
const char * getClientId() const;
uint16_t getQueue() const;
size_t queueSize(); // No const because of mutex
void loop();
protected:
@@ -131,8 +131,9 @@ class MqttClient {
uint32_t timeSent;
espMqttClientInternals::Packet packet;
template <typename... Args>
OutgoingPacket(uint32_t t, espMqttClientTypes::Error error, Args &&... args)
: timeSent(t)
OutgoingPacket(uint32_t t, espMqttClientTypes::Error & error, Args &&... args)
: // NOLINT(runtime/references)
timeSent(t)
, packet(error, std::forward<Args>(args)...) {
}
};
@@ -150,18 +151,26 @@ class MqttClient {
bool _addPacket(Args &&... args) {
espMqttClientTypes::Error error(espMqttClientTypes::Error::SUCCESS);
espMqttClientInternals::Outbox<OutgoingPacket>::Iterator it = _outbox.emplace(0, error, std::forward<Args>(args)...);
if (it && error == espMqttClientTypes::Error::SUCCESS)
if (it && error == espMqttClientTypes::Error::SUCCESS) {
return true;
return false;
} else {
if (it)
_outbox.remove(it);
return false;
}
}
template <typename... Args>
bool _addPacketFront(Args &&... args) {
espMqttClientTypes::Error error(espMqttClientTypes::Error::SUCCESS);
espMqttClientInternals::Outbox<OutgoingPacket>::Iterator it = _outbox.emplaceFront(0, error, std::forward<Args>(args)...);
if (it && error == espMqttClientTypes::Error::SUCCESS)
if (it && error == espMqttClientTypes::Error::SUCCESS) {
return true;
return false;
} else {
if (it)
_outbox.remove(it);
return false;
}
}
void _checkOutbox();

View File

@@ -163,6 +163,16 @@ class Outbox {
return false;
}
size_t size() const {
Node* n = _first;
size_t count = 0;
while (n) {
n = n->next;
++count;
}
return count;
}
private:
Node* _first;
Node* _last;

View File

@@ -100,7 +100,7 @@ Packet::Packet(espMqttClientTypes::Error& error,
(password ? 2 + strlen(password) : 0);
// allocate memory
if (!_allocate(remainingLength)) {
if (!_allocate(remainingLength, false)) {
error = espMqttClientTypes::Error::OUT_OF_MEMORY;
return;
}
@@ -300,8 +300,8 @@ Packet::Packet(espMqttClientTypes::Error& error, MQTTPacketType type)
}
bool Packet::_allocate(size_t remainingLength) {
if (EMC_GET_FREE_MEMORY() < EMC_MIN_FREE_MEMORY) {
bool Packet::_allocate(size_t remainingLength, bool check) {
if (check && EMC_GET_FREE_MEMORY() < EMC_MIN_FREE_MEMORY) {
emc_log_w("Packet buffer not allocated: low memory");
return false;
}

View File

@@ -133,7 +133,7 @@ class Packet {
private:
// pass remainingLength = total size - header - remainingLengthLength!
bool _allocate(size_t remainingLength);
bool _allocate(size_t remainingLength, bool check = true);
// fills header and returns index of next available byte in buffer
size_t _fillPublishHeader(uint16_t packetId,

View File

@@ -6,6 +6,10 @@ NetworkSettingsService::NetworkSettingsService(AsyncWebServer * server, FS * fs,
: _httpEndpoint(NetworkSettings::read, NetworkSettings::update, this, server, NETWORK_SETTINGS_SERVICE_PATH, securityManager)
, _fsPersistence(NetworkSettings::read, NetworkSettings::update, this, fs, NETWORK_SETTINGS_FILE)
, _lastConnectionAttempt(0) {
addUpdateHandler([&](const String & originId) { reconfigureWiFiConnection(); }, false);
}
void NetworkSettingsService::begin() {
// We want the device to come up in opmode=0 (WIFI_OFF), when erasing the flash this is not the default.
// If needed, we save opmode=0 before disabling persistence so the device boots with WiFi disabled in the future.
if (WiFi.getMode() != WIFI_OFF) {
@@ -21,10 +25,6 @@ NetworkSettingsService::NetworkSettingsService(AsyncWebServer * server, FS * fs,
WiFi.onEvent(std::bind(&NetworkSettingsService::WiFiEvent, this, _1));
addUpdateHandler([&](const String & originId) { reconfigureWiFiConnection(); }, false);
}
void NetworkSettingsService::begin() {
_fsPersistence.readFromFS();
reconfigureWiFiConnection();
}

View File

@@ -5,15 +5,14 @@
"author": "proddy",
"main": "server.js",
"scripts": {
"dev": "nodemon ./server.js localhost 3080",
"dev": "node --watch ./server.js localhost 3080",
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"@msgpack/msgpack": "^2.8.0",
"compression": "^1.7.4",
"express": "^4.18.2",
"multer": "^1.4.5-lts.1",
"nodemon": "^3.0.1"
"multer": "^1.4.5-lts.1"
},
"packageManager": "yarn@3.4.1"
}

View File

@@ -299,7 +299,7 @@ const SIGN_IN_ENDPOINT = REST_ENDPOINT_ROOT + 'signIn';
const GENERATE_TOKEN_ENDPOINT = REST_ENDPOINT_ROOT + 'generateToken';
let system_status = {
emsesp_version: '3.6.0-demo',
emsesp_version: '3.7.0-demo',
esp_platform: 'ESP32',
max_alloc_heap: 89,
psram_size: 0,
@@ -2627,7 +2627,7 @@ rest_server.get(EMSESP_BOARDPROFILE_ENDPOINT, (req, res) => {
// EMS-ESP API specific
const emsesp_info = {
System: {
version: '3.6.0',
version: '3.7.0',
uptime: '001+06:40:34.018',
'uptime (seconds)': 110434,
freemem: 131,

File diff suppressed because it is too large Load Diff

View File

@@ -18,6 +18,7 @@ default_envs = esp32_4M
; default_envs = esp32_16M
; default_envs = lolin_s3
; default_envs = standalone
; default_envs = debug
[env:esp32_4M]
; if using OTA enter your details below
@@ -33,6 +34,8 @@ upload_port = /dev/ttyUSB*
; override arduino espressif core
platform = espressif32 ; take latest
; platform = espressif32@5.3.0
; platform = espressif32@6.3.2
; platform = espressif32@6.4.0
extra_scripts =
pre:scripts/build_interface.py ; comment out if you don't want to re-build the WebUI each time
@@ -52,13 +55,21 @@ extra_scripts =
; options for debugging are: EMSESP_DEBUG EMSESP_UART_DEBUG EMSESP_DEBUG_SENSOR
[env:debug]
board = esp32dev
framework = arduino
platform = espressif32
board_build.partitions = esp32_partition_debug.csv
; board_build.partitions = esp32_partition_4M.csv
board_upload.flash_size = 4MB
board_build.filesystem = littlefs
upload_protocol = esptool
build_type = debug
monitor_raw = no
monitor_filters = esp32_exception_decoder
debug_tool = esp-prog
debug_init_break = tbreak setup
build_flags = ${factory_settings.build_flags} -DONEWIRE_CRC16=0 -DNO_GLOBAL_ARDUINOOTA -DARDUINOJSON_ENABLE_STD_STRING=1 -DESP32=1 -DARDUINO_ARCH_ESP32=1
extra_scripts = pre:scripts/build_interface.py
build_flags = ${factory_settings.build_flags} -DEMSESP_EN_ONLY -DCORE_DEBUG_LEVEL=5 -DONEWIRE_CRC16=0 -DNO_GLOBAL_ARDUINOOTA -DARDUINOJSON_ENABLE_STD_STRING=1 -DESP32=1 -DARDUINO_ARCH_ESP32=1
upload_port = /dev/ttyUSB0
extra_scripts =
; pre:scripts/build_interface.py ; comment out if you don't want to re-build the WebUI each time
scripts/rename_fw.py
; post:scripts/app-tls-size.py

View File

@@ -39,7 +39,7 @@ unbuild_flags =
${common.core_unbuild_flags}
[espressi32_base]
platform = espressif32@6.3.2
platform = espressif32
framework = arduino
build_flags = ${common.build_flags}
build_unflags = ${common.unbuild_flags}
@@ -65,6 +65,8 @@ check_flags =
; the Web interface is built seperately
[env:ci]
extends = espressi32_base
; stay on platform 6.3.2 until heap issue is solved
platform = espressif32@6.3.2
extra_scripts = scripts/rename_fw.py
board = esp32dev
board_build.partitions = esp32_partition_4M.csv
@@ -85,6 +87,8 @@ build_unflags = ${common.unbuild_flags}
[env:esp32_4M]
extends = espressi32_base
; stay on platform 6.3.2 until heap issue is solved
platform = espressif32@6.3.2
board = esp32dev
board_upload.flash_size = 4MB
board_build.partitions = esp32_partition_4M.csv
@@ -92,6 +96,8 @@ build_flags = ${common.build_flags} -Os
[env:esp32_4Mplus]
extends = espressi32_base
; stay on platform 6.3.2 until heap issue is solved
platform = espressif32@6.3.2
board = esp32dev
board_upload.flash_size = 4MB
board_build.partitions = esp32_asym_partition_4M.csv
@@ -99,6 +105,8 @@ build_flags = ${common.build_flags}
[env:esp32_16M]
extends = espressi32_base
; stay on platform 6.3.2 until heap issue is solved
platform = espressif32@6.3.2
board = esp32dev
board_upload.flash_size = 16MB
board_build.partitions = esp32_partition_16M.csv
@@ -143,7 +151,7 @@ platform = native
build_flags =
-DARDUINOJSON_ENABLE_STD_STRING=1 -DARDUINOJSON_ENABLE_PROGMEM=1 -DARDUINOJSON_ENABLE_ARDUINO_STRING -DARDUINOJSON_USE_DOUBLE=0
-DEMSESP_DEBUG -DEMSESP_STANDALONE -DEMSESP_TEST -D__linux__
-DEMSESP_DEFAULT_LOCALE=\"en\" -DEMSESP_DEFAULT_TX_MODE=8 -DEMSESP_DEFAULT_VERSION=\"3.6.0-dev\" -DEMSESP_DEFAULT_BOARD_PROFILE=\"S32\"
-DEMSESP_DEFAULT_LOCALE=\"en\" -DEMSESP_DEFAULT_TX_MODE=8 -DEMSESP_DEFAULT_VERSION=\"3.7.0-dev\" -DEMSESP_DEFAULT_BOARD_PROFILE=\"S32\"
-lpthread
-std=gnu++11 -Og -ggdb
build_src_flags =

View File

@@ -1,17 +1,21 @@
# testing EMS-ESP API
# use with https://marketplace.visualstudio.com/items?itemName=humao.rest-client
# use with "REST Client" extension in Visual Studio Code
# https://marketplace.visualstudio.com/items?itemName=humao.rest-client
@host = http://ems-esp.local
@host_dev = http://ems-esp2.local
@token = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwiYWRtaW4iOnRydWV9.2bHpWya2C7Q12WjNUBD6_7N3RCD7CMl-EGhyQVzFdDg
GET http://ems-esp.local/api/system/info
GET {{host}}/api/system/info
###
GET http://ems-esp.local/api/thermostat/seltemp
GET {{host}}/api/thermostat/seltemp
###
POST http://ems-esp.local/api/thermostat/seltemp
POST {{host}}/api/thermostat/seltemp
Content-Type: application/json
Authorization: Bearer {{token}}
@@ -21,7 +25,7 @@ Authorization: Bearer {{token}}
###
POST http://ems-esp.local/api/thermostat
POST {{host}}/api/thermostat
Content-Type: application/json
Authorization: Bearer {{token}}
@@ -32,12 +36,61 @@ Authorization: Bearer {{token}}
###
POST http://10.10.10.134/api
POST {{host}}/api
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwiYWRtaW4iOnRydWV9.2bHpWya2C7Q12WjNUBD6_7N3RCD7CMl-EGhyQVzFdDg
Authorization: Bearer {{token}}
{
"device" : "boiler",
"entity" : "wwtapactivated",
"value" : "on"
}
}
###
GET {{host}}/api/system/restart
Authorization: Bearer {{token}}
###
GET {{host}}/api/boiler/coldshot
Authorization: Bearer {{token}}
###
GET {{host}}/api/temperaturesensor/info
###
#
# Test on dev
#
GET {{host_dev}}/api/system/info
# Run a test. EMS-ESP must be compiled with -DEMSESP_TEST
# Use this to load up a dummy thermostat and boiler with data
###
GET {{host_dev}}/api?device=system&cmd=test&data=general
###
GET {{host_dev}}/api/boiler/info
###
GET {{host_dev}}/api/boiler/values
###
GET {{host_dev}}/api/analogsensor/info
###
GET {{host_dev}}/api/boiler/coldshot
Authorization: Bearer {{token}}
###
GET {{host_dev}}/api/system/commands

View File

@@ -1,7 +1,7 @@
sonar.organization=emsesp
sonar.projectKey=emsesp_EMS-ESP32
sonar.projectName=EMS-ESP32
sonar.projectVersion=3.6.0
sonar.projectVersion=3.7.0
sonar.sources=./src
sonar.cfamily.build-wrapper-output=build_wrapper_output_directory
sonar.sourceEncoding=UTF-8

View File

@@ -260,7 +260,7 @@ void AnalogSensor::measure() {
for (auto & sensor : sensors_) {
if (sensor.type() == AnalogType::DIGITAL_IN || sensor.type() == AnalogType::COUNTER || sensor.type() == AnalogType::TIMER
|| sensor.type() == AnalogType::RATE) {
auto old_value = sensor.value(); // remember current value before reading
auto old_value = sensor.value(); // remember current value before reading
auto current_reading = digitalRead(sensor.gpio());
if (sensor.poll_ != current_reading) { // check for pinchange
sensor.polltime_ = uuid::get_uptime(); // remember time of pinchange
@@ -274,7 +274,7 @@ void AnalogSensor::measure() {
} else if (!sensor.poll_) { // falling edge
if (sensor.type() == AnalogType::COUNTER) {
sensor.set_value(old_value + sensor.factor());
} else if (sensor.type() == AnalogType::RATE) { // dafault uom: Hz (1/sec) with factor 1
} else if (sensor.type() == AnalogType::RATE) { // dafault uom: Hz (1/sec) with factor 1
sensor.set_value(sensor.factor() * 1000 / (sensor.polltime_ - sensor.last_polltime_));
} else if (sensor.type() == AnalogType::TIMER) { // default seconds with factor 1
sensor.set_value(sensor.factor() * (sensor.polltime_ - sensor.last_polltime_) / 1000);
@@ -685,7 +685,7 @@ bool AnalogSensor::command_info(const char * value, const int8_t id, JsonObject
dataSensor["value"] = sensor.value();
} else if (id == 0) { // output values command
output[sensor.name()] = sensor.value();
} else { // if someone wants gpio numbers
} else { // if someone wants gpio numbers
char gpio_str[9];
snprintf(gpio_str, sizeof(gpio_str), "gpio_%02d", sensor.gpio());
output[gpio_str] = sensor.value();

View File

@@ -46,7 +46,7 @@ uint8_t Command::process(const char * path, const bool is_admin, const JsonObjec
if (!strncmp(path, Mqtt::base().c_str(), Mqtt::base().length())) {
char new_path[Mqtt::MQTT_TOPIC_MAX_SIZE];
strlcpy(new_path, path, sizeof(new_path));
p.parse(new_path + Mqtt::base().length() + 1); // re-parse the stripped path
p.parse(new_path + Mqtt::base().length() + 1); // re-parse the stripped path
} else {
return message(CommandRet::ERROR, "unrecognized path", output); // error
}
@@ -194,7 +194,7 @@ uint8_t Command::process(const char * path, const bool is_admin, const JsonObjec
} else if (data.isNull()) {
return_code = Command::call(device_type, command_p, "", is_admin, id_n, output); // empty, will do a query instead
} else {
return message(CommandRet::ERROR, "cannot parse command", output); // can't process
return message(CommandRet::ERROR, "cannot parse command", output); // can't process
}
return return_code;
}
@@ -301,9 +301,14 @@ uint8_t Command::call(const uint8_t device_type, const char * cmd, const char *
auto cf = find_command(device_type, device_id, cmd);
// check if its a call to and end-point to a device
// except for system commands as this is a special device without any queryable entities (device values)
if ((device_type > EMSdevice::DeviceType::SYSTEM) && (!value || !strlen(value))) {
if (!cf || !cf->cmdfunction_json_) {
// this is used to fetch the attributes of the device entity, or call a command directly
bool single_command = (!value || !strlen(value));
if (single_command) {
// exception 1: anything that is from System
// exception 2: boiler coldshot command
bool get_attributes = (!cf || !cf->cmdfunction_json_) && (device_type > EMSdevice::DeviceType::SYSTEM) && (strcmp(cmd, F_(coldshot)) != 0);
if (get_attributes) {
LOG_DEBUG("Calling %s command '%s' to retrieve attributes", dname, cmd);
return EMSESP::get_device_value_info(output, cmd, id, device_type) ? CommandRet::OK : CommandRet::ERROR; // entity = cmd
}
@@ -344,7 +349,7 @@ uint8_t Command::call(const uint8_t device_type, const char * cmd, const char *
// check if read-only. This also checks for valid tags (e.g. heating circuits)
if (cf->cmdfunction_) {
if (EMSESP::cmd_is_readonly(device_type, device_id, cmd, id)) {
if (!single_command && EMSESP::cmd_is_readonly(device_type, device_id, cmd, id)) {
return_code = CommandRet::INVALID; // readonly or invalid hc
} else {
return_code = ((cf->cmdfunction_)(value, id)) ? CommandRet::OK : CommandRet::ERROR;
@@ -593,7 +598,7 @@ void Command::show_devices(uuid::console::Shell & shell) {
// output list of all commands to console
// calls show with verbose mode set
void Command::show_all(uuid::console::Shell & shell) {
shell.println("Available commands (*=do not need authorization): ");
shell.println("Available commands (*=authorization not required): ");
// show system first
shell.print(COLOR_BOLD_ON);

View File

@@ -56,7 +56,7 @@ class Command {
struct CmdFunction {
uint8_t device_type_; // DeviceType::
uint8_t device_id_;
uint8_t flags_; // mqtt flags for command subscriptions
uint8_t flags_; // mqtt flags for command subscriptions
const char * cmd_;
cmd_function_p cmdfunction_;
cmd_json_function_p cmdfunction_json_;

View File

@@ -137,6 +137,9 @@ static void setup_commands(std::shared_ptr<Commands> & commands) {
Test::run_test(shell, arguments[0].c_str(), arguments[1].c_str());
}
});
commands->add_command(ShellContext::MAIN, CommandFlags::USER, string_vector{"t"}, [=](Shell & shell, const std::vector<std::string> & arguments) {
Test::run_test(shell, "default");
});
#endif
commands->add_command(ShellContext::MAIN, CommandFlags::USER, string_vector{F_(su)}, [=](Shell & shell, const std::vector<std::string> & arguments) {
@@ -419,7 +422,6 @@ static void setup_commands(std::shared_ptr<Commands> & commands) {
to_app(shell).send_read_request(type_id, device_id, 0, EMS_MAX_TELEGRAM_LENGTH, true);
}
to_app(shell).set_read_id(type_id);
});
commands->add_command(ShellContext::MAIN,
@@ -433,11 +435,11 @@ static void setup_commands(std::shared_ptr<Commands> & commands) {
if (!arguments.empty()) {
// get raw/pretty
if (arguments[0] == (F_(raw))) {
to_app(shell).watch(to_app(shell).WATCH_RAW); // raw
to_app(shell).watch(to_app(shell).WATCH_RAW); // raw
} else if (arguments[0] == (FL_(on)[0])) {
to_app(shell).watch(to_app(shell).WATCH_ON); // on
to_app(shell).watch(to_app(shell).WATCH_ON); // on
} else if (arguments[0] == (FL_(off)[0])) {
to_app(shell).watch(to_app(shell).WATCH_OFF); // off
to_app(shell).watch(to_app(shell).WATCH_OFF); // off
} else if (arguments[0] == (FL_(unknown)[0])) {
to_app(shell).watch(to_app(shell).WATCH_UNKNOWN); // unknown
watch_id = WATCH_ID_NONE;
@@ -445,7 +447,7 @@ static void setup_commands(std::shared_ptr<Commands> & commands) {
watch_id = Helpers::hextoint(arguments[0].c_str());
if (watch_id > 0
&& ((to_app(shell).watch() == to_app(shell).WATCH_OFF) || (to_app(shell).watch() == to_app(shell).WATCH_UNKNOWN))) {
to_app(shell).watch(to_app(shell).WATCH_ON); // on
to_app(shell).watch(to_app(shell).WATCH_ON); // on
} else if (watch_id == 0) {
to_app(shell).watch(to_app(shell).WATCH_OFF); // off
return;
@@ -480,7 +482,7 @@ static void setup_commands(std::shared_ptr<Commands> & commands) {
} else if (watch == to_app(shell).WATCH_RAW) {
shell.printfln("Watching incoming telegrams, displayed as raw bytes"); // WATCH_RAW
} else {
shell.printfln("Watching unknown telegrams"); // WATCH_UNKNOWN
shell.printfln("Watching unknown telegrams"); // WATCH_UNKNOWN
}
watch_id = to_app(shell).watch_id();
@@ -623,7 +625,7 @@ void EMSESPShell::stopped() {
void EMSESPShell::display_banner() {
println();
printfln("┌────────────────────────────────────────┐");
printfln("│ %sEMS-ESP version %-12s%s │", COLOR_BOLD_ON, EMSESP_APP_VERSION, COLOR_BOLD_OFF);
printfln("│ %sEMS-ESP version %-12s%s ", COLOR_BOLD_ON, EMSESP_APP_VERSION, COLOR_BOLD_OFF);
printfln("│ %s%shttps://github.com/emsesp/EMS-ESP32%s │", COLOR_BRIGHT_GREEN, COLOR_UNDERLINE, COLOR_RESET);
printfln("│ │");
printfln("│ type %shelp%s to show available commands │", COLOR_UNDERLINE, COLOR_RESET);

View File

@@ -980,13 +980,13 @@ void Boiler::process_UBASettingsWW(std::shared_ptr<const Telegram> telegram) {
// Boiler(0x08) -> Me(0x0B), UBAParameterWW(0x33), data: 08 FF 30 FB FF 28 FF 07 46 00 00
void Boiler::process_UBAParameterWW(std::shared_ptr<const Telegram> telegram) {
// has_bitupdate(telegram, wwEquipt_,0,3); // 8=boiler has ww
has_update(telegram, wwActivated_, 1); // 0xFF means on
has_update(telegram, wwActivated_, 1); // 0xFF means on
has_update(telegram, wwSelTemp_, 2);
has_update(telegram, wwHystOn_, 3); // Hyst on (default -5)
has_update(telegram, wwHystOff_, 4); // Hyst off (default -1)
has_update(telegram, wwFlowTempOffset_, 5); // default 40
has_update(telegram, wwCircPump_, 6); // 0xFF means on
has_update(telegram, wwCircMode_, 7); // 0=off, 1=1x3min 6=6x3min 7=continuous
has_update(telegram, wwHystOn_, 3); // Hyst on (default -5)
has_update(telegram, wwHystOff_, 4); // Hyst off (default -1)
has_update(telegram, wwFlowTempOffset_, 5); // default 40
has_update(telegram, wwCircPump_, 6); // 0xFF means on
has_update(telegram, wwCircMode_, 7); // 0=off, 1=1x3min 6=6x3min 7=continuous
has_update(telegram, wwDisinfectionTemp_, 8);
has_bitupdate(telegram, wwChargeType_, 10, 0); // 0 = charge pump, 0xff = 3-way valve
@@ -1089,7 +1089,7 @@ void Boiler::process_UBAMonitorSlow(std::shared_ptr<const Telegram> telegram) {
has_update(telegram, outdoorTemp_, 0);
has_update(telegram, boilTemp_, 2);
has_update(telegram, exhaustTemp_, 4);
has_update(telegram, switchTemp_, 25); // only if there is a mixer module present
has_update(telegram, switchTemp_, 25); // only if there is a mixer module present
has_update(telegram, heatingPumpMod_, 9);
has_update(telegram, burnStarts_, 10, 3); // force to 3 bytes
has_update(telegram, burnWorkMin_, 13, 3); // force to 3 bytes
@@ -1414,7 +1414,7 @@ void Boiler::process_UBAErrorMessage(std::shared_ptr<const Telegram> telegram) {
// data: displaycode(2), errornumber(2), year, month, hour, day, minute, duration(2), src-addr
if (telegram->message_data[4] & 0x80) { // valid date
static uint32_t lastCodeDate_ = 0; // last code date
static uint32_t lastCodeDate_ = 0; // last code date
char code[3] = {0};
uint16_t codeNo = EMS_VALUE_SHORT_NOTSET;
code[0] = telegram->message_data[0];
@@ -1530,12 +1530,12 @@ void Boiler::process_HpSilentMode(std::shared_ptr<const Telegram> telegram) {
has_update(telegram, wwAltOpPrioWw_, 3); // range 30-120 minutes on Buderus WSW196i
has_update(telegram, silentMode_, 10); // enum off-auto-on
has_update(telegram, minTempSilent_, 11);
has_update(telegram, hpHystHeat_, 37); // is / 5
has_update(telegram, hpHystCool_, 35); // is / 5, maybe offset swapped with pool
has_update(telegram, hpHystPool_, 33); // is / 5
has_update(telegram, hpHystHeat_, 37); // is / 5
has_update(telegram, hpHystCool_, 35); // is / 5, maybe offset swapped with pool
has_update(telegram, hpHystPool_, 33); // is / 5
has_update(telegram, hpCircPumpWw_, 46);
has_update(telegram, silentFrom_, 52); // in steps of 15 min
has_update(telegram, silentTo_, 53); // in steps of 15 min
has_update(telegram, silentFrom_, 52); // in steps of 15 min
has_update(telegram, silentTo_, 53); // in steps of 15 min
}
// Boiler(0x08) -B-> All(0x00), ?(0x0488), data: 8E 00 00 00 00 00 01 03
@@ -1556,7 +1556,7 @@ void Boiler::process_HpAdditionalHeater(std::shared_ptr<const Telegram> telegram
has_update(telegram, manDefrost_, 0); // off/on
has_update(telegram, auxHeaterOnly_, 1);
has_update(telegram, auxHeaterOff_, 2);
has_update(telegram, auxHeatMode_, 4); // eco/comfort
has_update(telegram, auxHeatMode_, 4); // eco/comfort
has_update(telegram, tempParMode_, 5);
has_update(telegram, auxMaxLimit_, 14); // is * 10
has_update(telegram, auxLimitStart_, 15); // is * 10
@@ -2131,6 +2131,7 @@ bool Boiler::set_tapwarmwater_activated(const char * value, const int8_t id) {
wwTapActivated_ = 1;
}
// LOG_INFO("calling EMS_TYPE_UBAFunctionTest with %d", v);
write_command(EMS_TYPE_UBAFunctionTest, 0, message_data, sizeof(message_data), 0);
return true;

View File

@@ -87,9 +87,9 @@ class Boiler : public EMSdevice {
uint32_t wwWorkM_; // DHW minutes
int8_t wwHystOn_;
int8_t wwHystOff_;
uint8_t wwTapActivated_; // maintenance-mode to switch DHW off
uint16_t wwMixerTemp_; // mixing temperature
uint16_t wwCylMiddleTemp_; // Cyl middle temperature (TS3)
uint8_t wwTapActivated_; // maintenance-mode to switch DHW off
uint16_t wwMixerTemp_; // mixing temperature
uint16_t wwCylMiddleTemp_; // Cyl middle temperature (TS3)
uint16_t wwSolarTemp_;
uint8_t wwAlternatingOper_; // alternating operation on/off
uint8_t wwAltOpPrioHeat_; // alternating operation, prioritize heat time

View File

@@ -170,7 +170,7 @@ void Mixer::process_MMPLUSStatusMessage_HC(std::shared_ptr<const Telegram> teleg
void Mixer::process_MMPLUSStatusMessage_WWC(std::shared_ptr<const Telegram> telegram) {
has_update(telegram, flowTempHc_, 0); // is * 10
has_bitupdate(telegram, pumpStatus_, 2, 0);
has_update(telegram, status_, 11); // temp status
has_update(telegram, status_, 11); // temp status
}
// Mixer IPM - 0x010C
@@ -220,7 +220,7 @@ void Mixer::process_MMStatusMessage(std::shared_ptr<const Telegram> telegram) {
has_update(telegram, flowTempHc_, 1); // is * 10
has_bitupdate(telegram, pumpStatus_, 3, 2); // is 0 or 0x64 (100%), check only bit 2
has_update(telegram, flowSetTemp_, 0);
has_update(telegram, status_, 4); // valve status -100 to 100
has_update(telegram, status_, 4); // valve status -100 to 100
}
/*

View File

@@ -685,9 +685,9 @@ void Solar::process_SM100Monitor(std::shared_ptr<const Telegram> telegram) {
has_update(telegram, cylBottomTemp2_, 16); // is *10 - TS5: Temperature sensor 2 cylinder, bottom, or swimming pool
has_update(telegram, heatExchangerTemp_, 20); // is *10 - TS6: Heat exchanger temperature sensor
has_update(telegram, collector2Temp_, 6); // is *10 - TS7: Temperature sensor for collector array 2
has_update(telegram, cylMiddleTemp_, 8); // is *10 - TS14: cylinder middle temperature
has_update(telegram, retHeatAssist_, 10); // is *10 - TS15: return temperature heating assistance
has_update(telegram, collector2Temp_, 6); // is *10 - TS7: Temperature sensor for collector array 2
has_update(telegram, cylMiddleTemp_, 8); // is *10 - TS14: cylinder middle temperature
has_update(telegram, retHeatAssist_, 10); // is *10 - TS15: return temperature heating assistance
}
// SM100wwTemperature - 0x07D6
@@ -749,8 +749,8 @@ void Solar::process_SM100Monitor2(std::shared_ptr<const Telegram> telegram) {
has_update(telegram->read_value(heatCntFlowTemp_, 0)); // is *10
has_update(telegram->read_value(heatCntRetTemp_, 2)); // is *10
has_update(telegram->read_value(heatCnt_, 12));
has_update(telegram->read_value(swapRetTemp_, 6)); // is *10
has_update(telegram->read_value(swapFlowTemp_, 8)); // is *10
has_update(telegram->read_value(swapRetTemp_, 6)); // is *10
has_update(telegram->read_value(swapFlowTemp_, 8)); // is *10
}
#pragma GCC diagnostic push
@@ -879,7 +879,7 @@ void Solar::process_ISM1StatusMessage(std::shared_ptr<const Telegram> telegram)
has_update(telegram, collectorTemp_, 4); // Collector Temperature
has_update(telegram, cylBottomTemp_, 6); // Temperature Bottom of Solar Boiler cyl
uint16_t Wh = energyLastHour_ / 10;
telegram->read_value(Wh, 2); // Solar Energy produced in last hour only ushort, is not * 10
telegram->read_value(Wh, 2); // Solar Energy produced in last hour only ushort, is not * 10
if (energyLastHour_ != Wh * 10) {
energyLastHour_ = Wh * 10;
has_update(&energyLastHour_);

View File

@@ -58,9 +58,9 @@ class Solar : public EMSdevice {
uint32_t energyLastHour_;
uint32_t energyToday_;
uint32_t energyTotal_;
uint32_t pumpWorkTime_; // Total solar pump operating time
uint32_t pump2WorkTime_; // Total solar pump 2 operating time
uint32_t m1WorkTime_; // differential control work time
uint32_t pumpWorkTime_; // Total solar pump operating time
uint32_t pump2WorkTime_; // Total solar pump 2 operating time
uint32_t m1WorkTime_; // differential control work time
uint8_t cylHeated_;
uint8_t collectorShutdown_; // Collector shutdown on/off

View File

@@ -661,8 +661,8 @@ void Thermostat::process_RC20Set_2(std::shared_ptr<const Telegram> telegram) {
return;
}
has_update(telegram, hc->heatingtype, 0);
has_update(telegram, hc->nighttemp, 1); // is * 2,
has_update(telegram, hc->daytemp, 2); // is * 2,
has_update(telegram, hc->nighttemp, 1); // is * 2,
has_update(telegram, hc->daytemp, 2); // is * 2,
has_update(telegram, hc->mode, 3);
has_enumupdate(telegram, hc->program, 11, 1); // 1 .. 9 predefined programs
has_update(telegram, hc->tempautotemp, 13);
@@ -798,8 +798,8 @@ void Thermostat::process_RC35wwSettings(std::shared_ptr<const Telegram> telegram
has_update(telegram, wwDisinfecting_, 4); // 0-off, 0xFF on
has_update(telegram, wwDisinfectDay_, 5); // 0-6 Day of week, 7 every day
has_update(telegram, wwDisinfectHour_, 6);
has_update(telegram, wwMaxTemp_, 8); // Limiter 60 degrees
has_update(telegram, wwOneTimeKey_, 9); // 0-off, 0xFF on
has_update(telegram, wwMaxTemp_, 8); // Limiter 60 degrees
has_update(telegram, wwOneTimeKey_, 9); // 0-off, 0xFF on
}
// Settings WW 0x3A - RC30
@@ -951,7 +951,7 @@ void Thermostat::process_RC300Monitor(std::shared_ptr<const Telegram> telegram)
return;
}
has_update(telegram, hc->roomTemp, 0); // is * 10
has_update(telegram, hc->roomTemp, 0); // is * 10
has_bitupdate(telegram, hc->modetype, 10, 1);
has_bitupdate(telegram, hc->mode, 10, 0); // bit 1, mode (auto=1 or manual=0)
@@ -1013,8 +1013,8 @@ void Thermostat::process_RC300Set(std::shared_ptr<const Telegram> telegram) {
}
has_update(hc->tempautotemp, tat);
has_update(telegram, hc->manualtemp, 10); // is * 2
has_enumupdate(telegram, hc->program, 11, 1); // timer program 1 or 2
has_update(telegram, hc->manualtemp, 10); // is * 2
has_enumupdate(telegram, hc->program, 11, 1); // timer program 1 or 2
has_enumupdate(telegram, hc->reducemode, 5, 1); // 1-outdoor temp threshold, 2-room temp threshold, 3-reduced mode
has_update(telegram, hc->reducetemp, 9);
@@ -1097,7 +1097,7 @@ void Thermostat::process_RC300WWtemp(std::shared_ptr<const Telegram> telegram) {
// RC300WWmode(0x2F5), data: 01 FF 04 00 00 00 08 05 00 08 04 00 00 00 00 00 00 00 00 00 01
void Thermostat::process_RC300WWmode(std::shared_ptr<const Telegram> telegram) {
// circulation pump see: https://github.com/Th3M3/buderus_ems-wiki/blob/master/Einstellungen%20der%20Bedieneinheit%20RC310.md
has_update(telegram, wwCircPump_, 1); // FF=off, 0=on ?
has_update(telegram, wwCircPump_, 1); // FF=off, 0=on ?
has_update(telegram, wwMode_, 2); // 0=off, 1=low, 2=high, 3=auto, 4=own prog
has_update(telegram, wwCircMode_, 3); // 0=off, 1=on, 2=auto, 4=own?
@@ -1207,11 +1207,11 @@ void Thermostat::process_RC30Set(std::shared_ptr<const Telegram> telegram) {
has_update(telegram, mixingvalves_, 17); // Number of Mixing Valves: (0x00=0, 0x01=1, 0x02=2)
has_update(telegram, brightness_, 18); // Screen brightness 0F=dark F1=light
has_update(telegram, hc->mode, 23);
has_update(telegram, hc->nofrosttemp, 24); // Set Temperature when mode is Off / 10 (e.g.: 0x0F = 7.5 degrees Celsius)
has_update(telegram, heatingpid_, 25); // PID setting 00=1 01=2 02=3
has_update(telegram, preheating_, 26); // Preheating in the clock program: (0x00 = off, 0xFF = on)
has_update(telegram, hc->tempautotemp, 28); // is * 2
has_update(telegram, hc->manualtemp, 29); // manualtemp is * 2
has_update(telegram, hc->nofrosttemp, 24); // Set Temperature when mode is Off / 10 (e.g.: 0x0F = 7.5 degrees Celsius)
has_update(telegram, heatingpid_, 25); // PID setting 00=1 01=2 02=3
has_update(telegram, preheating_, 26); // Preheating in the clock program: (0x00 = off, 0xFF = on)
has_update(telegram, hc->tempautotemp, 28); // is * 2
has_update(telegram, hc->manualtemp, 29); // manualtemp is * 2
}
// type 0x40 (HC1) - for reading the operating mode from the RC30 thermostat (0x10)
@@ -1274,13 +1274,13 @@ void Thermostat::process_RC35Set(std::shared_ptr<const Telegram> telegram) {
return;
}
has_update(telegram, hc->heatingtype, 0); // 0- off, 1-radiator, 2-convector, 3-floor
has_update(telegram, hc->nighttemp, 1); // is * 2
has_update(telegram, hc->daytemp, 2); // is * 2
has_update(telegram, hc->holidaytemp, 3); // is * 2
has_update(telegram, hc->roominfluence, 4); // is * 1
has_update(telegram, hc->offsettemp, 6); // is * 2
has_update(telegram, hc->mode, 7); // night, day, auto
has_update(telegram, hc->heatingtype, 0); // 0- off, 1-radiator, 2-convector, 3-floor
has_update(telegram, hc->nighttemp, 1); // is * 2
has_update(telegram, hc->daytemp, 2); // is * 2
has_update(telegram, hc->holidaytemp, 3); // is * 2
has_update(telegram, hc->roominfluence, 4); // is * 1
has_update(telegram, hc->offsettemp, 6); // is * 2
has_update(telegram, hc->mode, 7); // night, day, auto
has_update(telegram, hc->wwprio, 21); // 0xFF for on
has_update(telegram, hc->summertemp, 22); // is * 1
@@ -1291,10 +1291,10 @@ void Thermostat::process_RC35Set(std::shared_ptr<const Telegram> telegram) {
has_update(telegram, hc->control, 26); // 0-off, 1-RC20 (remote), 2-RC35
has_update(telegram, hc->controlmode, 33); // 0-outdoortemp, 1-roomtemp
has_update(telegram, hc->tempautotemp, 37);
has_update(telegram, hc->noreducetemp, 38); // outdoor temperature for no reduce
has_update(telegram, hc->reducetemp, 39); // temperature for off/reduce
has_update(telegram, hc->vacreducetemp, 40); // temperature for off/reduce in vacations
has_update(telegram, hc->vacreducemode, 41); // vacations reduce mode
has_update(telegram, hc->noreducetemp, 38); // outdoor temperature for no reduce
has_update(telegram, hc->reducetemp, 39); // temperature for off/reduce
has_update(telegram, hc->vacreducetemp, 40); // temperature for off/reduce in vacations
has_update(telegram, hc->vacreducemode, 41); // vacations reduce mode
has_update(telegram, hc->minflowtemp, 16);
// RC35 stores values for floorheating in different position
@@ -1416,7 +1416,7 @@ void Thermostat::process_RCTime(std::shared_ptr<const Telegram> telegram) {
bool ivtclock = (telegram->message_data[0] & 0x80) == 0x80; // dont sync ivt-clock, #439
bool junkersclock = model() == EMSdevice::EMS_DEVICE_FLAG_JUNKERS;
time_t ttime = mktime(tm_); // thermostat time
time_t ttime = mktime(tm_); // thermostat time
// correct thermostat clock if we have valid ntp time, and could write the command
if (!ivtclock && !junkersclock && tset_ && EMSESP::system_.ntp_connected() && !EMSESP::system_.readonly_mode() && has_command(&dateTime_)) {
double difference = difftime(now, ttime);
@@ -1426,7 +1426,7 @@ void Thermostat::process_RCTime(std::shared_ptr<const Telegram> telegram) {
}
}
#ifndef EMSESP_STANDALONE
if (!tset_ && tm_->tm_year > 110) { // emsesp clock not set, but thermostat clock
if (!tset_ && tm_->tm_year > 110) { // emsesp clock not set, but thermostat clock
if (ivtclock) {
tm_->tm_isdst = -1; // determine dst
ttime = mktime(tm_); // thermostat time
@@ -2302,7 +2302,7 @@ bool Thermostat::set_datetime(const char * value, const int8_t id) {
data[6] = (tm_->tm_wday + 6) % 7; // Bosch counts from Mo, time from Su
data[7] = tm_->tm_isdst + 2; // set DST and flag for ext. clock
if (model() == EMSdevice::EMS_DEVICE_FLAG_JUNKERS) {
data[6]++; // Junkers use 1-7;
data[6]++; // Junkers use 1-7;
data[7] = 0;
}
} else if (dt.length() == 23) {
@@ -2500,7 +2500,7 @@ bool Thermostat::set_mode_n(const uint8_t mode, const uint8_t hc_num) {
if (mode == HeatingCircuit::Mode::AUTO) {
set_mode_value = 0xFF; // special value for auto
} else {
set_mode_value = 0; // everything else, like manual/day etc..
set_mode_value = 0; // everything else, like manual/day etc..
}
break;
case EMSdevice::EMS_DEVICE_FLAG_JUNKERS:
@@ -3121,7 +3121,7 @@ bool Thermostat::set_temperature(const float temperature, const uint8_t mode, co
offset = 0x0A; // manual offset
break;
case HeatingCircuit::Mode::TEMPAUTO:
offset = 0x08; // auto offset
offset = 0x08; // auto offset
if (temperature == -1) {
factor = 1; // to write 0xFF
}

View File

@@ -256,9 +256,9 @@ class Thermostat : public EMSdevice {
static constexpr uint16_t EMS_TYPE_RCOutdoorTemp = 0xA3; // is an automatic thermostat broadcast, outdoor external temp
// Type offsets
static constexpr uint8_t EMS_OFFSET_RC10StatusMessage_setpoint = 1; // setpoint temp
static constexpr uint8_t EMS_OFFSET_RC10StatusMessage_curr = 2; // current temp
static constexpr uint8_t EMS_OFFSET_RC10Set_temp = 4; // position of thermostat setpoint temperature
static constexpr uint8_t EMS_OFFSET_RC10StatusMessage_setpoint = 1; // setpoint temp
static constexpr uint8_t EMS_OFFSET_RC10StatusMessage_curr = 2; // current temp
static constexpr uint8_t EMS_OFFSET_RC10Set_temp = 4; // position of thermostat setpoint temperature
static constexpr uint8_t EMS_OFFSET_RC20StatusMessage_setpoint = 1; // setpoint temp
static constexpr uint8_t EMS_OFFSET_RC20StatusMessage_curr = 2; // current temp
@@ -267,9 +267,9 @@ class Thermostat : public EMSdevice {
static constexpr uint8_t EMS_OFFSET_RC20Set_temp_auto = 28; // position of thermostat setpoint temperature
static constexpr uint8_t EMS_OFFSET_RC20Set_temp_manual = 29; // position of thermostat setpoint temperature
static constexpr uint8_t EMS_OFFSET_RC20_2_Set_mode = 3; // ES72 - see https://github.com/emsesp/EMS-ESP/issues/334
static constexpr uint8_t EMS_OFFSET_RC20_2_Set_temp_night = 1; // ES72
static constexpr uint8_t EMS_OFFSET_RC20_2_Set_temp_day = 2; // ES72
static constexpr uint8_t EMS_OFFSET_RC20_2_Set_mode = 3; // ES72 - see https://github.com/emsesp/EMS-ESP/issues/334
static constexpr uint8_t EMS_OFFSET_RC20_2_Set_temp_night = 1; // ES72
static constexpr uint8_t EMS_OFFSET_RC20_2_Set_temp_day = 2; // ES72
static constexpr uint8_t EMS_OFFSET_RC30StatusMessage_setpoint = 1; // setpoint temp
static constexpr uint8_t EMS_OFFSET_RC30StatusMessage_curr = 2; // current temp
@@ -308,8 +308,8 @@ class Thermostat : public EMSdevice {
static constexpr uint8_t EMS_OFFSET_RC35Set_temp_summer = 22;
static constexpr uint8_t EMS_OFFSET_RC35Set_temp_nofrost = 23;
static constexpr uint8_t EMS_OFFSET_EasyStatusMessage_setpoint = 10; // setpoint temp
static constexpr uint8_t EMS_OFFSET_EasyStatusMessage_curr = 8; // current temp
static constexpr uint8_t EMS_OFFSET_EasyStatusMessage_setpoint = 10; // setpoint temp
static constexpr uint8_t EMS_OFFSET_EasyStatusMessage_curr = 8; // current temp
static constexpr uint8_t EMS_OFFSET_RCPLUSStatusMessage_mode = 10; // thermostat mode (auto, manual)
static constexpr uint8_t EMS_OFFSET_RCPLUSStatusMessage_setpoint = 3; // setpoint temp

View File

@@ -520,7 +520,7 @@ void EMSdevice::add_device_value(uint8_t tag, // to b
// get fullname, getting translation if it exists
const char * const * fullname;
if (Helpers::count_items(name) == 1) {
fullname = nullptr; // no translations available, use empty
fullname = nullptr; // no translations available, use empty
} else {
fullname = &name[1]; // translations start at index 1
}
@@ -1311,7 +1311,7 @@ void EMSdevice::dump_value_info() {
if (dv.type == DeviceValueType::BOOL) {
snprintf(entityid, sizeof(entityid), "binary_sensor.%s", entity_with_tag); // binary sensor (for booleans)
} else {
snprintf(entityid, sizeof(entityid), "sensor.%s", entity_with_tag); // normal HA sensor
snprintf(entityid, sizeof(entityid), "sensor.%s", entity_with_tag); // normal HA sensor
}
}
@@ -1767,6 +1767,11 @@ const char * EMSdevice::telegram_type_name(std::shared_ptr<const Telegram> teleg
bool EMSdevice::handle_telegram(std::shared_ptr<const Telegram> telegram) {
for (auto & tf : telegram_functions_) {
if (tf.telegram_type_id_ == telegram->type_id) {
// for telegram desitnation only read telegram
if (telegram->dest == device_id_ && telegram->message_length > 0) {
tf.process_function_(telegram);
return true;
}
// if the data block is empty and we have not received data before, assume that this telegram
// is not recognized by the bus master. So remove it from the automatic fetch list
if (telegram->message_length == 0 && telegram->offset == 0 && !tf.received_) {

View File

@@ -459,7 +459,7 @@ class EMSdevice {
std::vector<TelegramFunction> telegram_functions_; // each EMS device has its own set of registered telegram types
std::vector<DeviceValue> devicevalues_; // all the device values
std::vector<DeviceValue> devicevalues_; // all the device values
std::vector<uint16_t> handlers_ignored_;
};

View File

@@ -145,12 +145,12 @@ class DeviceValue {
DV_NUMOP_MUL15 = -15
};
uint8_t device_type; // EMSdevice::DeviceType
uint8_t tag; // DeviceValueTAG::*
void * value_p; // pointer to variable of any type
uint8_t type; // DeviceValueType::*
const char * const ** options; // options as a flash char array
const char * const * options_single; // options are not translated
uint8_t device_type; // EMSdevice::DeviceType
uint8_t tag; // DeviceValueTAG::*
void * value_p; // pointer to variable of any type
uint8_t type; // DeviceValueType::*
const char * const ** options; // options as a flash char array
const char * const * options_single; // options are not translated
int8_t numeric_operator;
uint8_t options_size; // number of options in the char array, calculated
const char * const short_name; // used in MQTT and API

View File

@@ -341,7 +341,7 @@ void EMSESP::dump_all_values(uuid::console::Shell & shell) {
if (device.product_id == 160) { // MM100
device_id = 0x28; // wwc
} else {
device_id = 0x20; // hc
device_id = 0x20; // hc
}
} else {
device_id = 0x20; // should cover all the other device types
@@ -926,7 +926,7 @@ bool EMSESP::process_telegram(std::shared_ptr<const Telegram> telegram) {
if (telegram->type_id == publish_id_) {
publish_id_ = 0;
}
emsdevice->has_update(false); // reset flag
emsdevice->has_update(false); // reset flag
if (!Mqtt::publish_single()) {
publish_device_values(emsdevice->device_type()); // publish to MQTT if we explicitly have too
}
@@ -939,6 +939,8 @@ bool EMSESP::process_telegram(std::shared_ptr<const Telegram> telegram) {
emsdevice->add_handlers_ignored(telegram->type_id);
}
break;
} else if (emsdevice->is_device_id(telegram->dest)) {
emsdevice->handle_telegram(telegram);
}
}
@@ -1118,7 +1120,7 @@ bool EMSESP::add_device(const uint8_t device_id, const uint8_t product_id, const
name = "Modem";
device_type = DeviceType::CONNECT;
} else if (device_id == EMSdevice::EMS_DEVICE_ID_CONVERTER) {
name = "Converter"; // generic
name = "Converter"; // generic
} else if (device_id == EMSdevice::EMS_DEVICE_ID_CLOCK) {
name = "Clock"; // generic
device_type = DeviceType::CONTROLLER;
@@ -1390,7 +1392,7 @@ void EMSESP::incoming_telegram(uint8_t * data, const uint8_t length) {
#endif
Roomctrl::check((data[1] ^ 0x80 ^ rxservice_.ems_mask()), data); // check if there is a message for the roomcontroller
rxservice_.add(data, length); // add to RxQueue
rxservice_.add(data, length); // add to RxQueue
}
}
@@ -1470,8 +1472,8 @@ void EMSESP::start() {
bool factory_settings = false;
#endif
esp8266React.begin(); // loads core system services settings (network, mqtt, ap, ntp etc)
webLogService.begin(); // start web log service. now we can start capturing logs to the web log
esp8266React.begin(); // loads core system services settings (network, mqtt, ap, ntp etc)
webLogService.begin(); // start web log service. now we can start capturing logs to the web log
LOG_INFO("Starting EMS-ESP version %s", EMSESP_APP_VERSION); // welcome message
LOG_DEBUG("System is running in Debug mode");
@@ -1491,7 +1493,7 @@ void EMSESP::start() {
system_.system_restart();
};
system_.reload_settings(); // ... and store some of the settings locally
system_.reload_settings(); // ... and store some of the settings locally
webCustomizationService.begin(); // load the customizations
webSchedulerService.begin(); // load the scheduler events

View File

@@ -163,7 +163,7 @@ class EMSESP {
}
static void watch(uint8_t watch) {
watch_ = watch; // 0=off, 1=on, 2=raw
watch_ = watch; // 0=off, 1=on, 2=raw
if (watch == WATCH_OFF) {
watch_id_ = 0; // reset watch id if watch is disabled
}

View File

@@ -385,7 +385,7 @@ std::string Helpers::data_to_hex(const uint8_t * data, const uint8_t length) {
*p++ = buffer[1];
*p++ = ' '; // space
}
*--p = '\0'; // null terminate just in case, loosing the trailing space
*--p = '\0'; // null terminate just in case, loosing the trailing space
return std::string(str);
}

View File

@@ -80,6 +80,7 @@ MAKE_WORD(info)
MAKE_WORD(settings)
MAKE_WORD(value)
MAKE_WORD(entities)
MAKE_WORD(coldshot)
// device types - lowercase, used in MQTT
MAKE_WORD(boiler)

View File

@@ -70,6 +70,7 @@ MAKE_WORD_TRANSLATION(system_info_cmd, "show system status", "Zeige System-Statu
MAKE_WORD_TRANSLATION(schedule_cmd, "enable schedule item", "Aktiviere Zeitplan", "activeer tijdschema item", "", "aktywuj wybrany harmonogram", "", "", "program öğesini etkinleştir", "abilitare l'elemento programmato") // TODO translate
MAKE_WORD_TRANSLATION(entity_cmd, "set custom value on ems", "Sende eigene Entitäten zu EMS", "verstuur custom waarde naar EMS", "", "wyślij własną wartość na EMS", "", "", "", "imposta valori personalizzati su EMS") // TODO translate
MAKE_WORD_TRANSLATION(commands_response, "get response", "Hole Antwort", "Verzoek om antwoord", "", "", "", "", "") // TODO translate
MAKE_WORD_TRANSLATION(coldshot_cmd, "send a cold shot of water", "", "", "", "", "", "", "", "") // TODO translate
// tags
MAKE_WORD_TRANSLATION(tag_boiler_data_ww, "dhw", "WW", "dhw", "VV", "CWU", "dhw", "ecs", "SKS", "dhw")

View File

@@ -124,6 +124,8 @@ void Mqtt::resubscribe() {
// Main MQTT loop - sends out top item on publish queue
void Mqtt::loop() {
queuecount_ = mqttClient_->queueSize();
// exit if MQTT is not enabled or if there is no network connection
if (!connected()) {
return;
@@ -142,7 +144,7 @@ void Mqtt::loop() {
EMSESP::publish_sensor_values(false);
}
queuecount_ = mqttClient_->getQueue();
// wait for empty queue before sending scheduled device messages
if (queuecount_ > 0) {
return;
}
@@ -278,9 +280,13 @@ void Mqtt::on_message(const char * topic, const uint8_t * payload, size_t len) c
if (return_code != CommandRet::OK) {
char error[100];
if (output.size()) {
snprintf(error, sizeof(error), "Call failed with error: %s (%s)", (const char *)output["message"], Command::return_code_string(return_code).c_str());
snprintf(error,
sizeof(error),
"MQTT command failed with error: %s (%s)",
(const char *)output["message"],
Command::return_code_string(return_code).c_str());
} else {
snprintf(error, sizeof(error), "Call failed with error code (%s)", Command::return_code_string(return_code).c_str());
snprintf(error, sizeof(error), "MQTT command failed with error code (%s)", Command::return_code_string(return_code).c_str());
}
LOG_ERROR(error);
Mqtt::queue_publish("response", error);
@@ -478,7 +484,7 @@ void Mqtt::on_connect() {
connecting_ = true;
connectcount_++; // count # reconnects. not currently used.
queuecount_ = 0;
queuecount_ = mqttClient_->queueSize();
load_settings(); // reload MQTT settings - in case they have changes
@@ -506,7 +512,7 @@ void Mqtt::on_connect() {
// publish to the last will topic (see Mqtt::start() function) to say we're alive
queue_publish_retain("status", "online", true); // with retain on
mqtt_publish_fails_ = 0; // reset fail count to 0
// mqtt_publish_fails_ = 0; // reset fail count to 0
}
// Home Assistant Discovery - the main master Device called EMS-ESP
@@ -586,14 +592,25 @@ bool Mqtt::queue_message(const uint8_t operation, const std::string & topic, con
if (!mqtt_enabled_ || topic.empty()) {
return false; // quit, not using MQTT
}
// check free mem
#ifndef EMSESP_STANDALONE
if (ESP.getFreeHeap() < 60 * 1204) {
if (operation == Operation::PUBLISH) {
mqtt_message_id_++;
mqtt_publish_fails_++;
}
LOG_DEBUG("%s failed: low memory", operation == Operation::PUBLISH ? "Publish" : operation == Operation::SUBSCRIBE ? "Subscribe" : "Unsubscribe");
return false; // quit
}
#endif
uint16_t packet_id = 0;
char fulltopic[MQTT_TOPIC_MAX_SIZE];
if (topic.find(discovery_prefix_) == 0) {
strlcpy(fulltopic, topic.c_str(), sizeof(fulltopic)); // leave topic as it is
strlcpy(fulltopic, topic.c_str(), sizeof(fulltopic)); // leave discovery topic as it is
} else {
// it's a discovery topic, added the mqtt base to the topic path
// it's not a discovery topic, added the mqtt base to the topic path
snprintf(fulltopic, sizeof(fulltopic), "%s/%s", mqtt_base_.c_str(), topic.c_str()); // uses base
}
@@ -679,7 +696,7 @@ bool Mqtt::queue_remove_topic(const char * topic) {
if (ha_enabled_) {
return queue_publish_message(Mqtt::discovery_prefix() + topic, "", true); // publish with retain to remove from broker
} else {
return queue_publish_message(topic, "", true); // publish with retain to remove from broker
return queue_publish_message(topic, "", true); // publish with retain to remove from broker
}
}
@@ -691,7 +708,7 @@ bool Mqtt::queue_ha(const char * topic, const JsonObject & payload) {
std::string payload_text;
payload_text.reserve(measureJson(payload) + 1);
serializeJson(payload, payload_text); // convert json to string
serializeJson(payload, payload_text); // convert json to string
return queue_publish_message(Mqtt::discovery_prefix() + topic, payload_text, true); // with retain true
}
@@ -860,7 +877,7 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev
if (type == DeviceValueType::BOOL) {
snprintf(topic, sizeof(topic), "binary_sensor/%s", config_topic); // binary sensor (for booleans)
} else {
snprintf(topic, sizeof(topic), "sensor/%s", config_topic); // normal HA sensor
snprintf(topic, sizeof(topic), "sensor/%s", config_topic); // normal HA sensor
}
}
@@ -874,13 +891,13 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev
// build the payload
StaticJsonDocument<EMSESP_JSON_SIZE_LARGE> doc;
doc["uniq_id"] = uniq_id;
doc["obj_id"] = uniq_id; // same as unique_id
doc["obj_id"] = uniq_id; // same as unique_id
const char * ic_ha = "ic"; // icon - only set this if there is no device class
const char * sc_ha = "stat_cla"; // state class
const char * uom_ha = "unit_of_meas"; // unit of measure
char sample_val[30] = "0"; // sample, correct(!) entity value, used only to prevent warning/error in HA if real value is not published yet
char sample_val[30] = "0"; // sample, correct(!) entity value, used only to prevent warning/error in HA if real value is not published yet
// handle commands, which are device entities that are writable
// we add the command topic parameter
@@ -898,10 +915,20 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev
// for enums, add options
if (type == DeviceValueType::ENUM) {
JsonArray option_list = doc.createNestedArray("ops"); // options
for (uint8_t i = 0; i < options_size; i++) {
option_list.add(Helpers::translated_word(options[i]));
if (EMSESP::system_.enum_format() == ENUM_FORMAT_INDEX) {
// use index numbers
for (uint8_t i = 0; i < options_size; i++) {
option_list.add(Helpers::itoa(i)); // as a string
}
snprintf(sample_val, sizeof(sample_val), "'0'");
} else {
// use strings
for (uint8_t i = 0; i < options_size; i++) {
option_list.add(Helpers::translated_word(options[i]));
}
snprintf(sample_val, sizeof(sample_val), "'%s'", Helpers::translated_word(options[0]));
}
snprintf(sample_val, sizeof(sample_val), "'%s'", Helpers::translated_word(options[0]));
} else if (type != DeviceValueType::STRING && type != DeviceValueType::BOOL) {
// Must be Numeric....
doc["mode"] = "box"; // auto, slider or box
@@ -952,7 +979,7 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev
} else {
snprintf(ha_name, sizeof(ha_name), "%s", F_name); // no tag
}
free(F_name); // very important!
free(F_name); // very important!
doc["name"] = ha_name;
// value template
@@ -1164,7 +1191,7 @@ bool Mqtt::publish_ha_climate_config(const uint8_t tag, const bool has_roomtemp,
if (Mqtt::entity_format() == entityFormat::MULTI_SHORT) {
snprintf(uniq_id_s, sizeof(uniq_id_s), "%s_thermostat_hc%d", mqtt_basename_.c_str(), hc_num); // add basename
} else {
snprintf(uniq_id_s, sizeof(uniq_id_s), "thermostat_hc%d", hc_num); // backward compatible with v3.4
snprintf(uniq_id_s, sizeof(uniq_id_s), "thermostat_hc%d", hc_num); // backward compatible with v3.4
}
snprintf(temp_cmd_s, sizeof(temp_cmd_s), "~/thermostat/hc%d/seltemp", hc_num);

View File

@@ -22,6 +22,8 @@ namespace emsesp {
uuid::log::Logger Shower::logger_{F_(shower), uuid::log::Facility::CONSOLE};
static bool force_coldshot = false;
void Shower::start() {
EMSESP::webSettingsService.read([&](WebSettings & settings) {
shower_timer_ = settings.shower_timer;
@@ -30,7 +32,27 @@ void Shower::start() {
shower_alert_coldshot_ = settings.shower_alert_coldshot * 1000; // convert from seconds
});
set_shower_state(false, true); // turns shower to off and creates HA topic if not already done
Command::add(
EMSdevice::DeviceType::BOILER,
F_(coldshot),
[&](const char * value, const int8_t id, JsonObject & output) {
LOG_INFO("Forcing coldshot...");
if (shower_state_) {
output["message"] = "OK";
force_coldshot = true;
} else {
output["message"] = "Coldshot failed. Shower not active";
LOG_WARNING("Coldshot failed. Shower not active");
force_coldshot = false;
}
return true;
},
FL_(coldshot_cmd),
CommandFlag::ADMIN_ONLY);
if (shower_timer_) {
set_shower_state(false, true); // turns shower to off and creates HA topic if not already done
}
}
void Shower::loop() {
@@ -57,10 +79,10 @@ void Shower::loop() {
// first check to see if hot water has been on long enough to be recognized as a Shower/Bath
if (!shower_state_ && (time_now - timer_start_) > SHOWER_MIN_DURATION) {
set_shower_state(true);
LOG_DEBUG("[Shower] hot water still running, starting shower timer");
LOG_DEBUG("hot water still running, starting shower timer");
}
// check if the shower has been on too long
else if ((time_now - timer_start_) > shower_alert_trigger_) {
else if ((shower_alert_ && ((time_now - timer_start_) > shower_alert_trigger_)) || force_coldshot) {
shower_alert_start();
}
}
@@ -79,11 +101,11 @@ void Shower::loop() {
if (duration_ > SHOWER_MIN_DURATION) {
StaticJsonDocument<EMSESP_JSON_SIZE_SMALL> doc;
char s[50];
snprintf(s, 50, "%d minutes and %d seconds", (uint8_t)(duration_ / 60000), (uint8_t)((duration_ / 1000) % 60));
doc["duration"] = s;
// char s[50];
// snprintf(s, 50, "%02u:%02u:%02u", (uint8_t)(duration_ / 3600000UL), (uint8_t)(duration_ / 60000UL), (uint8_t)((duration_ / 1000UL) % 60));
doc["duration"] = (uint8_t)(duration_ / 1000UL); // seconds
Mqtt::queue_publish("shower_data", doc.as<JsonObject>());
LOG_DEBUG("[Shower] finished with duration %d", duration_);
LOG_INFO("finished with duration %d", duration_);
}
}
@@ -106,21 +128,22 @@ void Shower::loop() {
}
}
// turn off hot water to send a shot of cold
void Shower::shower_alert_start() {
LOG_DEBUG("Shower Alert started");
(void)Command::call(EMSdevice::DeviceType::BOILER, "wwtapactivated", "false");
doing_cold_shot_ = true;
force_coldshot = false;
alert_timer_start_ = uuid::get_uptime(); // timer starts now
}
// turn back on the hot water for the shower
void Shower::shower_alert_stop() {
if (doing_cold_shot_) {
LOG_DEBUG("Shower Alert stopped");
(void)Command::call(EMSdevice::DeviceType::BOILER, "wwtapactivated", "true");
doing_cold_shot_ = false;
}
}
// turn off hot water to send a shot of cold
void Shower::shower_alert_start() {
if (shower_alert_) {
LOG_DEBUG("Shower Alert started");
(void)Command::call(EMSdevice::DeviceType::BOILER, "wwtapactivated", "false");
doing_cold_shot_ = true;
alert_timer_start_ = uuid::get_uptime(); // timer starts now
force_coldshot = false;
}
}
@@ -128,15 +151,11 @@ void Shower::shower_alert_start() {
// and creates the HA config topic if HA enabled
// force is used by EMSESP::publish_all_loop()
void Shower::set_shower_state(bool state, bool force) {
if (!shower_timer_ && !shower_alert_) {
return;
}
// sets the state
shower_state_ = state;
// only publish if that state has changed
static bool old_shower_state_;
static bool old_shower_state_ = false;
if ((shower_state_ == old_shower_state_) && !force) {
return;
}
@@ -149,10 +168,15 @@ void Shower::set_shower_state(bool state, bool force) {
// send out HA MQTT Discovery config topic
if ((Mqtt::ha_enabled()) && (!ha_configdone_ || force)) {
StaticJsonDocument<EMSESP_JSON_SIZE_LARGE> doc;
char topic[Mqtt::MQTT_TOPIC_MAX_SIZE];
char str[70];
char stat_t[50];
//
// shower_active topic
//
doc["name"] = "Shower Active";
char str[70];
if (Mqtt::entity_format() == Mqtt::entityFormat::MULTI_SHORT) {
snprintf(str, sizeof(str), "%s_shower_active", Mqtt::basename().c_str());
} else {
@@ -161,7 +185,6 @@ void Shower::set_shower_state(bool state, bool force) {
doc["uniq_id"] = str;
doc["object_id"] = str;
char stat_t[50];
snprintf(stat_t, sizeof(stat_t), "%s/shower_active", Mqtt::basename().c_str());
doc["stat_t"] = stat_t;
@@ -181,13 +204,39 @@ void Shower::set_shower_state(bool state, bool force) {
JsonArray ids = dev.createNestedArray("ids");
ids.add(Mqtt::basename());
// add "availability" section
Mqtt::add_avty_to_doc(stat_t, doc.as<JsonObject>());
Mqtt::add_avty_to_doc(stat_t, doc.as<JsonObject>()); // add "availability" section
char topic[Mqtt::MQTT_TOPIC_MAX_SIZE];
snprintf(topic, sizeof(topic), "binary_sensor/%s/shower_active/config", Mqtt::basename().c_str());
ha_configdone_ = Mqtt::queue_ha(topic, doc.as<JsonObject>()); // publish the config payload with retain flag
//
// shower_duaration topic
//
doc.clear();
snprintf(str, sizeof(str), "%s_shower_duration", Mqtt::basename().c_str());
doc["uniq_id"] = str;
doc["object_id"] = str;
snprintf(stat_t, sizeof(stat_t), "%s/shower_data", Mqtt::basename().c_str());
doc["stat_t"] = stat_t;
doc["name"] = "Shower Duration";
doc["val_tpl"] = "{{value_json.duration if value_json.duration is defined else 0}}";
doc["unit_of_meas"] = "s";
doc["stat_cla"] = "measurement";
doc["dev_cla"] = "duration";
doc["ent_cat"] = "diagnostic";
JsonObject dev2 = doc.createNestedObject("dev");
JsonArray ids2 = dev2.createNestedArray("ids");
ids2.add(Mqtt::basename());
Mqtt::add_avty_to_doc(stat_t, doc.as<JsonObject>(), "value_json.duration is defined"); // add "availability" section
snprintf(topic, sizeof(topic), "sensor/%s/shower_duration/config", Mqtt::basename().c_str());
Mqtt::queue_ha(topic, doc.as<JsonObject>()); // publish the config payload with retain flag
}
}

View File

@@ -30,6 +30,9 @@ class Shower {
void set_shower_state(bool state, bool force = false);
// commands
static bool command_coldshot(const char * value, const int8_t id);
private:
static uuid::log::Logger logger_;
@@ -46,9 +49,9 @@ class Shower {
uint32_t shower_alert_coldshot_; // default 10 seconds for cold water before turning back hot water
bool ha_configdone_ = false; // for HA MQTT Discovery
bool shower_state_;
uint32_t timer_start_; // ms
uint32_t timer_pause_; // ms
uint32_t duration_; // ms
uint32_t timer_start_; // ms
uint32_t timer_pause_; // ms
uint32_t duration_; // ms
// cold shot
uint32_t alert_timer_start_; // ms

View File

@@ -847,7 +847,7 @@ void System::led_monitor() {
}
if (led_on_) {
digitalWrite(led_gpio_, LED_ON); // LED off
digitalWrite(led_gpio_, LED_ON); // LED off
}
#endif
} else {
@@ -1432,27 +1432,27 @@ bool System::command_test(const char * value, const int8_t id) {
// 3 = RMII clock output from GPIO17, for 50hz inverted clock
bool System::load_board_profile(std::vector<int8_t> & data, const std::string & board_profile) {
if (board_profile == "S32") {
data = {2, 18, 23, 5, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0}; // BBQKees Gateway S32
data = {2, 18, 23, 5, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0}; // BBQKees Gateway S32
} else if (board_profile == "E32") {
data = {2, 4, 5, 17, 33, PHY_type::PHY_TYPE_LAN8720, 16, 1, 0}; // BBQKees Gateway E32
} else if (board_profile == "MH-ET") {
data = {2, 18, 23, 5, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0}; // MH-ET Live D1 Mini
data = {2, 18, 23, 5, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0}; // MH-ET Live D1 Mini
} else if (board_profile == "NODEMCU") {
data = {2, 18, 23, 5, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0}; // NodeMCU 32S
data = {2, 18, 23, 5, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0}; // NodeMCU 32S
} else if (board_profile == "LOLIN") {
data = {2, 18, 17, 16, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0}; // Lolin D32
data = {2, 18, 17, 16, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0}; // Lolin D32
} else if (board_profile == "OLIMEX") {
data = {0, 0, 36, 4, 34, PHY_type::PHY_TYPE_LAN8720, -1, 0, 0}; // Olimex ESP32-EVB (uses U1TXD/U1RXD/BUTTON, no LED or Temperature sensor)
} else if (board_profile == "OLIMEXPOE") {
data = {0, 0, 36, 4, 34, PHY_type::PHY_TYPE_LAN8720, 12, 0, 3}; // Olimex ESP32-POE
} else if (board_profile == "C3MINI") {
data = {7, 1, 4, 5, 9, PHY_type::PHY_TYPE_NONE, 0, 0, 0}; // Lolin C3 Mini
data = {7, 1, 4, 5, 9, PHY_type::PHY_TYPE_NONE, 0, 0, 0}; // Lolin C3 Mini
} else if (board_profile == "S2MINI") {
data = {15, 7, 11, 12, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0}; // Lolin S2 Mini
data = {15, 7, 11, 12, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0}; // Lolin S2 Mini
} else if (board_profile == "S3MINI") {
data = {17, 18, 8, 5, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0}; // Liligo S3
data = {17, 18, 8, 5, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0}; // Liligo S3
} else if (board_profile == "S32S3") {
data = {2, 18, 5, 17, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0}; // BBQKees Gateway S3
data = {2, 18, 5, 17, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0}; // BBQKees Gateway S3
} else if (board_profile == "CUSTOM") {
// send back current values
data = {(int8_t)EMSESP::system_.led_gpio_,

View File

@@ -148,11 +148,11 @@ void RxService::add(uint8_t * data, uint8_t length) {
// validate the CRC. if it fails then increment the number of corrupt/incomplete telegrams and only report to console/syslog
uint8_t crc = calculate_crc(data, length - 1);
if (data[length - 1] != crc) {
if ((data[0] & 0x7F) != ems_bus_id()) { // do not count echos as errors
if ((data[0] & 0x7F) != ems_bus_id()) { // do not count echos as errors
telegram_error_count_++;
LOG_WARNING("Incomplete Rx: %s", Helpers::data_to_hex(data, length - 1).c_str()); // exclude CRC
} else {
LOG_TRACE("Incomplete Rx: %s", Helpers::data_to_hex(data, length - 1).c_str()); // exclude CRC
LOG_TRACE("Incomplete Rx: %s", Helpers::data_to_hex(data, length - 1).c_str()); // exclude CRC
}
return;
}
@@ -347,7 +347,7 @@ void TxService::send_telegram(const QueuedTxTelegram & tx_telegram) {
telegram_raw[5] = (telegram->type_id >> 8) - 1; // type, 1st byte, high-byte, subtract 0x100
telegram_raw[6] = telegram->type_id & 0xFF; // type, 2nd byte, low-byte
message_p = 7;
copy_data = false; // there are no more data values after the type_id when reading on EMS+
copy_data = false; // there are no more data values after the type_id when reading on EMS+
}
} else {
// EMS 1.0
@@ -396,11 +396,11 @@ void TxService::send_telegram(const QueuedTxTelegram & tx_telegram) {
if (status == EMS_TX_STATUS_ERR) {
LOG_ERROR("Failed to transmit Tx via UART.");
if (telegram->operation == Telegram::Operation::TX_READ) {
increment_telegram_read_fail_count(); // another Tx fail
increment_telegram_read_fail_count(); // another Tx fail
} else {
increment_telegram_write_fail_count(); // another Tx fail
}
tx_state(Telegram::Operation::NONE); // nothing send, tx not in wait state
tx_state(Telegram::Operation::NONE); // nothing send, tx not in wait state
return;
}
@@ -456,7 +456,7 @@ void TxService::add(const uint8_t operation,
if (front) {
tx_telegrams_.emplace_front(tx_telegram_id_++, std::move(telegram), false, validateid); // add to front of queue
} else {
tx_telegrams_.emplace_back(tx_telegram_id_++, std::move(telegram), false, validateid); // add to back of queue
tx_telegrams_.emplace_back(tx_telegram_id_++, std::move(telegram), false, validateid); // add to back of queue
}
if (validateid != 0) {
EMSESP::wait_validate(validateid);
@@ -595,14 +595,14 @@ bool TxService::send_raw(const char * telegram_data) {
void TxService::retry_tx(const uint8_t operation, const uint8_t * data, const uint8_t length) {
// have we reached the limit? if so, reset count and give up
if (++retry_count_ > MAXIMUM_TX_RETRIES) {
reset_retry_count(); // give up
EMSESP::wait_validate(0); // do not wait for validation
reset_retry_count(); // give up
EMSESP::wait_validate(0); // do not wait for validation
if (operation == Telegram::Operation::TX_READ) {
if (telegram_last_->offset > 0) { // ignore errors for higher offsets
LOG_DEBUG("Last Tx Read operation failed after %d retries. Ignoring request: %s", MAXIMUM_TX_RETRIES, telegram_last_->to_string().c_str());
return;
}
increment_telegram_read_fail_count(); // another Tx fail
increment_telegram_read_fail_count(); // another Tx fail
} else {
increment_telegram_write_fail_count(); // another Tx fail
}

View File

@@ -48,8 +48,8 @@ static constexpr int16_t EMS_VALUE_SHORT_NOTSET = 0x7D00; // 32000: for 2-
static constexpr uint32_t EMS_VALUE_ULONG_NOTSET = 0x00FFFFFF; // for 3-byte longs
static constexpr uint32_t EMS_VALUE_ULLONG_NOTSET = 0xFFFFFFFF; // for 4-byte longs
static constexpr uint8_t EMS_MAX_TELEGRAM_LENGTH = 32; // max length of a complete EMS telegram
static constexpr uint8_t EMS_MAX_TELEGRAM_MESSAGE_LENGTH = 27; // max length of message block, assuming EMS1.0
static constexpr uint8_t EMS_MAX_TELEGRAM_LENGTH = 32; // max length of a complete EMS telegram
static constexpr uint8_t EMS_MAX_TELEGRAM_MESSAGE_LENGTH = 27; // max length of message block, assuming EMS1.0
#define EMS_VALUE_DEFAULT_INT EMS_VALUE_INT_NOTSET
#define EMS_VALUE_DEFAULT_UINT EMS_VALUE_UINT_NOTSET
@@ -232,13 +232,13 @@ class EMSbus {
private:
static constexpr uint32_t EMS_BUS_TIMEOUT = 30000; // timeout in ms before recognizing the ems bus is offline (30 seconds)
static uint32_t last_bus_activity_; // timestamp of last time a valid Rx came in
static uint32_t bus_uptime_start_; // timestamp of first time we connected to the bus
static bool bus_connected_; // start assuming the bus hasn't been connected
static uint8_t ems_mask_; // unset=0xFF, buderus=0x00, junkers/ht3=0x80
static uint8_t ems_bus_id_; // the bus id, which configurable and stored in settings
static uint8_t tx_mode_; // local copy of the tx mode
static uint8_t tx_state_; // state of the Tx line (NONE or waiting on a TX_READ or TX_WRITE)
static uint32_t last_bus_activity_; // timestamp of last time a valid Rx came in
static uint32_t bus_uptime_start_; // timestamp of first time we connected to the bus
static bool bus_connected_; // start assuming the bus hasn't been connected
static uint8_t ems_mask_; // unset=0xFF, buderus=0x00, junkers/ht3=0x80
static uint8_t ems_bus_id_; // the bus id, which configurable and stored in settings
static uint8_t tx_mode_; // local copy of the tx mode
static uint8_t tx_state_; // state of the Tx line (NONE or waiting on a TX_READ or TX_WRITE)
};
class RxService : public EMSbus {
@@ -433,17 +433,17 @@ class TxService : public EMSbus {
private:
std::deque<QueuedTxTelegram> tx_telegrams_; // the Tx queue
uint32_t telegram_read_count_ = 0; // # Tx successful reads
uint32_t telegram_write_count_ = 0; // # Tx successful writes
uint32_t telegram_read_fail_count_ = 0; // # Tx unsuccessful transmits
uint32_t telegram_write_fail_count_ = 0; // # Tx unsuccessful transmits
uint32_t telegram_read_count_ = 0; // # Tx successful reads
uint32_t telegram_write_count_ = 0; // # Tx successful writes
uint32_t telegram_read_fail_count_ = 0; // # Tx unsuccessful transmits
uint32_t telegram_write_fail_count_ = 0; // # Tx unsuccessful transmits
std::shared_ptr<Telegram> telegram_last_;
uint16_t telegram_last_post_send_query_; // which type ID to query after a successful send, to read back the values just written
uint8_t retry_count_ = 0; // count for # Tx retries
uint32_t delayed_send_ = 0; // manage delay for post send query
uint8_t tx_telegram_id_ = 0; // queue counter
uint8_t tx_telegram_id_ = 0; // queue counter
void send_telegram(const QueuedTxTelegram & tx_telegram);
};

View File

@@ -214,7 +214,7 @@ void TemperatureSensor::loop() {
// LOG_DEBUG("Adding %d sensor(s) from first scan", firstscan_);
} else if ((scancnt_ <= 0) && (firstscan_ != sensors_.size())) { // check 2 times for no change of sensor #
scancnt_ = SCAN_START;
sensors_.clear(); // restart scanning and clear to get correct numbering
sensors_.clear(); // restart scanning and clear to get correct numbering
}
state_ = State::IDLE;
}
@@ -576,7 +576,7 @@ TemperatureSensor::Sensor::Sensor(const uint8_t addr[])
(unsigned int)(internal_id_ >> 48) & 0xFF,
(unsigned int)(internal_id_ >> 32) & 0xFFFF,
(unsigned int)(internal_id_ >> 16) & 0xFFFF,
(unsigned int)(internal_id_)&0xFFFF);
(unsigned int)(internal_id_) & 0xFFFF);
id_ = std::string(id_s);
name_ = std::string{}; // name (alias) is empty
offset_ = 0; // 0 degrees offset

View File

@@ -132,7 +132,7 @@ class TemperatureSensor {
static constexpr uint8_t TYPE_DS18B20 = 0x28;
static constexpr uint8_t TYPE_DS18S20 = 0x10;
static constexpr uint8_t TYPE_DS1822 = 0x22;
static constexpr uint8_t TYPE_DS1825 = 0x3B; // also DS1826
static constexpr uint8_t TYPE_DS1825 = 0x3B; // also DS1826
static constexpr uint32_t READ_INTERVAL_MS = 5000; // 5 seconds
static constexpr uint32_t CONVERSION_MS = 1000; // 1 seconds

View File

@@ -266,7 +266,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
shell.printfln("Testing adding a general boiler & thermostat...");
run_test("general");
// shell.invoke_command("show devices");
// shell.invoke_command("show values");
shell.invoke_command("show values");
shell.invoke_command("call system publish");
// shell.invoke_command("show mqtt");
ok = true;
@@ -280,6 +280,21 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
ok = true;
}
if (command == "coldshot") {
shell.printfln("Testing coldshot...");
run_test("general");
#ifdef EMSESP_STANDALONE
AsyncWebServerRequest request;
request.method(HTTP_GET);
request.url("/api/boiler/coldshot");
EMSESP::webAPIService.webAPIService_get(&request);
#else
shell.invoke_command("call boiler coldshot");
#endif
ok = true;
}
if (command == "string2minutes") {
shell.printfln("Testing string2minutes()...");
std::string time_s = "12:00";
@@ -1005,10 +1020,10 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
EMSESP::mqtt_.incoming("ems-esp/thermostat_hc1", "22"); // HA only
EMSESP::mqtt_.incoming("ems-esp/thermostat_hc1", "off"); // HA only
EMSESP::mqtt_.incoming("ems-esp/system/send", "11 12 13");
EMSESP::mqtt_.incoming("ems-esp/boiler/syspress"); // empty payload
EMSESP::mqtt_.incoming("ems-esp/thermostat/mode"); // empty payload
EMSESP::mqtt_.incoming("ems-esp/boiler/syspress"); // empty payload
EMSESP::mqtt_.incoming("ems-esp/thermostat/mode"); // empty payload
EMSESP::mqtt_.incoming("ems-esp/system/publish");
EMSESP::mqtt_.incoming("ems-esp/thermostat/seltemp"); // empty payload
EMSESP::mqtt_.incoming("ems-esp/thermostat/seltemp"); // empty payload
EMSESP::mqtt_.incoming("ems-esp/boiler/wwseltemp", "59");
EMSESP::mqtt_.incoming("ems-esp/boiler/wwseltemp");
@@ -1204,7 +1219,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
uart_telegram("30 00 FF 0A 02 6A 04"); // SM100 pump on 1
uart_telegram("30 00 FF 00 02 64 00 00 00 04 00 00 FF 00 00 1E 0B 09 64 00 00 00 00"); // SM100 modulation
uart_telegram("30 00 FF 0A 02 6A 03"); // SM100 pump off 0
uart_telegram("30 00 FF 0A 02 6A 03"); // SM100 pump off 0
shell.invoke_command("show");
ok = true;
@@ -1446,7 +1461,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
shell.invoke_command("call");
shell.invoke_command("call system info");
EMSESP::mqtt_.incoming("ems-esp/system", "{\"cmd\":\"info\"}"); // this should fail
EMSESP::mqtt_.incoming("ems-esp/system", "{\"cmd\":\"info\"}"); // this should fail
EMSESP::mqtt_.incoming("ems-esp/thermostat", "{\"cmd\":\"temp\",\"data\":23.45}"); // this should work just fine
EMSESP::mqtt_.incoming("ems-esp/thermostat", "{\"cmd\":\"TeMP\",\"data\":23.45}"); // test mix cased cmd
@@ -1559,7 +1574,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
// EMSESP::mqtt_.incoming(system_topic, "{\"cmd\":\"pin\",\"id\":12,\"data\":\"1\"}");
EMSESP::mqtt_.incoming(thermostat_topic, "{\"cmd\":\"wwmode\",\"data\":\"auto\"}");
EMSESP::mqtt_.incoming(thermostat_topic, "{\"cmd\":\"mode\",\"data\":\"typo\",\"id\":2}"); // invalid mode
EMSESP::mqtt_.incoming(thermostat_topic, "{\"cmd\":\"mode\",\"data\":\"typo\",\"id\":2}"); // invalid mode
EMSESP::mqtt_.incoming(thermostat_topic, "{\"cmd\":\"mode\",\"data\":\"auto\",\"id\":2}");
EMSESP::mqtt_.incoming(thermostat_topic, "{\"cmd\":\"mode\",\"data\":\"auto\",\"hc\":2}"); // hc as number
EMSESP::mqtt_.incoming(thermostat_topic, "{\"cmd\":\"seltemp\",\"data\":19.5,\"hc\":1}"); // data as number

View File

@@ -26,11 +26,12 @@
namespace emsesp {
// #define EMSESP_DEBUG_DEFAULT "general"
// #define EMSESP_DEBUG_DEFAULT "thermostat"
// #define EMSESP_DEBUG_DEFAULT "solar"
// #define EMSESP_DEBUG_DEFAULT "web"
// #define EMSESP_DEBUG_DEFAULT "mqtt"
#define EMSESP_DEBUG_DEFAULT "general"
// #define EMSESP_DEBUG_DEFAULT "boiler"
// #define EMSESP_DEBUG_DEFAULT "mqtt2"
// #define EMSESP_DEBUG_DEFAULT "mqtt_nested"
@@ -53,6 +54,7 @@ namespace emsesp {
// #define EMSESP_DEBUG_DEFAULT "custom"
// #define EMSESP_DEBUG_DEFAULT "entity_dump"
// #define EMSESP_DEBUG_DEFAULT "memory"
#define EMSESP_DEBUG_DEFAULT "coldshot"
class Test {
public:

View File

@@ -86,7 +86,7 @@ void EMSuart::start(const uint8_t tx_mode, const uint8_t rx_gpio, const uint8_t
uart_set_pin(EMSUART_NUM, tx_gpio, rx_gpio, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
uart_driver_install(EMSUART_NUM, 129, 0, (EMS_MAXBUFFERSIZE + 1) * 2, &uart_queue, 0); // buffer must be > fifo
uart_set_rx_full_threshold(EMSUART_NUM, 1);
uart_set_rx_timeout(EMSUART_NUM, 0); // disable
uart_set_rx_timeout(EMSUART_NUM, 0); // disable
// note esp32s3 crashes with 2k stacksize, stack overflow here sometimes wipes settingsfiles.
xTaskCreate(uart_event_task, "uart_event_task", 2560, NULL, configMAX_PRIORITIES - 1, NULL);

View File

@@ -24,7 +24,7 @@
#ifndef EMSESP_EMSUART_H
#define EMSESP_EMSUART_H
#define EMS_MAXBUFFERSIZE 33 // max size of the buffer. EMS packets are max 32 bytes, plus extra for BRK
#define EMS_MAXBUFFERSIZE 33 // max size of the buffer. EMS packets are max 32 bytes, plus extra for BRK
#define EMSUART_NUM UART_NUM_1 // on C3 and S2 there is no UART2, use UART1 for all
#define EMSUART_BAUD 9600 // uart baud rate for the EMS circuit

View File

@@ -1 +1 @@
#define EMSESP_APP_VERSION "3.6.0"
#define EMSESP_APP_VERSION "3.6.1"

View File

@@ -121,9 +121,9 @@ void WebAPIService::parse(AsyncWebServerRequest * request, JsonObject & input) {
if (return_code != CommandRet::OK) {
char error[100];
if (output.size()) {
snprintf(error, sizeof(error), "Call failed with error: %s (%s)", (const char *)output["message"], Command::return_code_string(return_code).c_str());
snprintf(error, sizeof(error), "API failed with error: %s (%s)", (const char *)output["message"], Command::return_code_string(return_code).c_str());
} else {
snprintf(error, sizeof(error), "Call failed with error code (%s)", Command::return_code_string(return_code).c_str());
snprintf(error, sizeof(error), "API failed with error code (%s)", Command::return_code_string(return_code).c_str());
}
emsesp::EMSESP::logger().err(error);
api_fails_++;

View File

@@ -156,7 +156,7 @@ void WebDataService::sensor_data(AsyncWebServerRequest * request) {
if (sensor.type() != AnalogSensor::AnalogType::NOTUSED) {
obj["v"] = Helpers::transformNumFloat(sensor.value(), 0); // is optional and is a float
} else {
obj["v"] = 0; // must have a value for web sorting to work
obj["v"] = 0; // must have a value for web sorting to work
}
}
}

View File

@@ -31,6 +31,7 @@ WebEntityService::WebEntityService(AsyncWebServer * server, FS * fs, SecurityMan
void WebEntityService::begin() {
_fsPersistence.readFromFS();
EMSESP::logger().info("Starting Custom entity service");
Mqtt::subscribe(EMSdevice::DeviceType::CUSTOM, "custom/#", nullptr); // use empty function callback
}
// this creates the entity file, saving it to the FS
@@ -60,6 +61,7 @@ StateUpdateResult WebEntity::update(JsonObject & root, WebEntity & webEntity) {
Command::erase_command(EMSdevice::DeviceType::CUSTOM, entityItem.name.c_str());
}
webEntity.entityItems.clear();
EMSESP::webEntityService.ha_reset();
if (root["entities"].is<JsonArray>()) {
for (const JsonObject ei : root["entities"].as<JsonArray>()) {
@@ -219,8 +221,8 @@ bool WebEntityService::get_value_info(JsonObject & output, const char * cmd) {
return false;
}
if (Helpers::toLower(cmd) == "commands") {
output["info"] = "lists all values";
output["commands"] = "lists all commands";
output["info"] = "list all values";
output["commands"] = "list all commands";
for (const auto & entity : *entityItems) {
output[entity.name] = "custom entitiy";
}
@@ -318,7 +320,8 @@ void WebEntityService::publish(const bool force) {
}
DynamicJsonDocument doc(EMSESP_JSON_SIZE_XLARGE);
JsonObject output = doc.to<JsonObject>();
JsonObject output = doc.to<JsonObject>();
bool ha_created = ha_registered_;
for (const EntityItem & entityItem : *entityItems) {
render_value(output, entityItem);
// create HA config
@@ -382,11 +385,10 @@ void WebEntityService::publish(const bool force) {
// add "availability" section
Mqtt::add_avty_to_doc(stat_t, config.as<JsonObject>(), val_cond);
if (Mqtt::queue_ha(topic, config.as<JsonObject>())) {
ha_registered_ = true;
}
ha_created |= Mqtt::queue_ha(topic, config.as<JsonObject>());
}
}
ha_registered_ = ha_created;
if (output.size() > 0) {
Mqtt::queue_publish("custom_data", output);
}

View File

@@ -63,6 +63,9 @@ class WebEntityService : public StatefulService<WebEntity> {
uint8_t count_entities();
uint8_t has_commands();
void generate_value_web(JsonObject & output);
void ha_reset() {
ha_registered_ = false;
}
private:

View File

@@ -66,7 +66,7 @@ class WebLogService : public uuid::log::Handler {
void setValues(AsyncWebServerRequest * request, JsonVariant & json);
AsyncCallbackJsonWebHandler setValues_; // for POSTs
AsyncCallbackJsonWebHandler setValues_; // for POSTs
uint64_t last_transmit_ = 0; // Last transmit time
size_t maximum_log_messages_ = MAX_LOG_MESSAGES; // Maximum number of log messages to buffer before they are output

View File

@@ -31,6 +31,7 @@ WebSchedulerService::WebSchedulerService(AsyncWebServer * server, FS * fs, Secur
void WebSchedulerService::begin() {
_fsPersistence.readFromFS();
EMSESP::logger().info("Starting Scheduler service");
Mqtt::subscribe(EMSdevice::DeviceType::SCHEDULER, "scheduler/#", nullptr); // use empty function callback
}
// this creates the scheduler file, saving it to the FS
@@ -70,6 +71,7 @@ StateUpdateResult WebScheduler::update(JsonObject & root, WebScheduler & webSche
Command::erase_command(EMSdevice::DeviceType::SCHEDULER, scheduleItem.name.c_str());
}
webScheduler.scheduleItems.clear();
EMSESP::webSchedulerService.ha_reset();
if (root["schedule"].is<JsonArray>()) {
for (const JsonObject schedule : root["schedule"].as<JsonArray>()) {
@@ -85,7 +87,7 @@ StateUpdateResult WebScheduler::update(JsonObject & root, WebScheduler & webSche
// calculated elapsed minutes
si.elapsed_min = Helpers::string2minutes(si.time);
si.retry_cnt = 0xFF; // no startup retries
si.retry_cnt = 0xFF; // no startup retries
webScheduler.scheduleItems.push_back(si); // add to list
if (!webScheduler.scheduleItems.back().name.empty()) {
@@ -218,6 +220,12 @@ void WebSchedulerService::publish_single(const char * name, const bool state) {
// publish to Mqtt
void WebSchedulerService::publish(const bool force) {
if (force) {
ha_registered_ = false;
}
if (!Mqtt::enabled()) {
return;
}
EMSESP::webSchedulerService.read([&](WebScheduler & webScheduler) { scheduleItems = &webScheduler.scheduleItems; });
if (scheduleItems->size() == 0) {
return;
@@ -229,6 +237,7 @@ void WebSchedulerService::publish(const bool force) {
}
DynamicJsonDocument doc(EMSESP_JSON_SIZE_XLARGE);
bool ha_created = ha_registered_;
for (const ScheduleItem & scheduleItem : *scheduleItems) {
if (!scheduleItem.name.empty() && !doc.containsKey(scheduleItem.name)) {
if (EMSESP::system_.bool_format() == BOOL_FORMAT_TRUEFALSE) {
@@ -241,7 +250,7 @@ void WebSchedulerService::publish(const bool force) {
}
// create HA config
if (Mqtt::ha_enabled() && force) {
if (Mqtt::ha_enabled() && !ha_registered_) {
StaticJsonDocument<EMSESP_JSON_SIZE_MEDIUM> config;
char stat_t[50];
snprintf(stat_t, sizeof(stat_t), "%s/scheduler_data", Mqtt::basename().c_str());
@@ -283,10 +292,11 @@ void WebSchedulerService::publish(const bool force) {
// add "availability" section
Mqtt::add_avty_to_doc(stat_t, config.as<JsonObject>(), val_cond);
Mqtt::queue_ha(topic, config.as<JsonObject>());
ha_created |= Mqtt::queue_ha(topic, config.as<JsonObject>());
}
}
}
ha_registered_ = ha_created;
if (doc.size() > 0) {
Mqtt::queue_publish("scheduler_data", doc.as<JsonObject>());
}

View File

@@ -22,8 +22,8 @@
#define EMSESP_SCHEDULER_FILE "/config/emsespScheduler.json"
#define EMSESP_SCHEDULER_SERVICE_PATH "/rest/schedule" // GET and POST
#define SCHEDULEFLAG_SCHEDULE_TIMER 0x80 // 7th bit for Timer
#define MAX_STARTUP_RETRIES 3 // retry the start-up commands x times
#define SCHEDULEFLAG_SCHEDULE_TIMER 0x80 // 7th bit for Timer
#define MAX_STARTUP_RETRIES 3 // retry the start-up commands x times
namespace emsesp {
@@ -58,6 +58,9 @@ class WebSchedulerService : public StatefulService<WebScheduler> {
bool has_commands();
bool command_setvalue(const char * value, const std::string name);
bool get_value_info(JsonObject & output, const char * cmd);
void ha_reset() {
ha_registered_ = false;
}
// make all functions public so we can test in the debug and standalone mode
#ifndef EMSESP_STANDALONE
@@ -69,6 +72,7 @@ class WebSchedulerService : public StatefulService<WebScheduler> {
FSPersistence<WebScheduler> _fsPersistence;
std::list<ScheduleItem> * scheduleItems; // pointer to the list of schedule events
bool ha_registered_ = false;
};
} // namespace emsesp

View File

@@ -166,9 +166,9 @@ void WebStatusService::webStatusService(AsyncWebServerRequest * request) {
if (Mqtt::enabled()) {
statJson = statsJson.createNestedObject();
statJson["id"] = 5;
statJson["s"] = Mqtt::publish_count();
statJson["s"] = Mqtt::publish_count() - Mqtt::publish_fails();
statJson["f"] = Mqtt::publish_fails();
statJson["q"] = Mqtt::publish_count() == 0 ? 100 : 100 - (uint8_t)((100 * Mqtt::publish_fails()) / (Mqtt::publish_count() + Mqtt::publish_fails()));
statJson["q"] = Mqtt::publish_count() == 0 ? 100 : 100 - (uint8_t)((100 * Mqtt::publish_fails()) / Mqtt::publish_count());
}
statJson = statsJson.createNestedObject();
@@ -228,61 +228,61 @@ void WebStatusService::mDNS_start() const {
const char * WebStatusService::disconnectReason(uint8_t code) {
#ifndef EMSESP_STANDALONE
switch (code) {
case WIFI_REASON_UNSPECIFIED: // = 1,
case WIFI_REASON_UNSPECIFIED: // = 1,
return "unspecified";
case WIFI_REASON_AUTH_EXPIRE: // = 2,
case WIFI_REASON_AUTH_EXPIRE: // = 2,
return "auth expire";
case WIFI_REASON_AUTH_LEAVE: // = 3,
case WIFI_REASON_AUTH_LEAVE: // = 3,
return "auth leave";
case WIFI_REASON_ASSOC_EXPIRE: // = 4,
case WIFI_REASON_ASSOC_EXPIRE: // = 4,
return "assoc expired";
case WIFI_REASON_ASSOC_TOOMANY: // = 5,
case WIFI_REASON_ASSOC_TOOMANY: // = 5,
return "assoc too many";
case WIFI_REASON_NOT_AUTHED: // = 6,
case WIFI_REASON_NOT_AUTHED: // = 6,
return "not authenticated";
case WIFI_REASON_NOT_ASSOCED: // = 7,
case WIFI_REASON_NOT_ASSOCED: // = 7,
return "not assoc";
case WIFI_REASON_ASSOC_LEAVE: // = 8,
case WIFI_REASON_ASSOC_LEAVE: // = 8,
return "assoc leave";
case WIFI_REASON_ASSOC_NOT_AUTHED: // = 9,
case WIFI_REASON_ASSOC_NOT_AUTHED: // = 9,
return "assoc not authed";
case WIFI_REASON_DISASSOC_PWRCAP_BAD: // = 10,
case WIFI_REASON_DISASSOC_PWRCAP_BAD: // = 10,
return "disassoc powerCAP bad";
case WIFI_REASON_DISASSOC_SUPCHAN_BAD: // = 11,
case WIFI_REASON_DISASSOC_SUPCHAN_BAD: // = 11,
return "disassoc supchan bad";
case WIFI_REASON_IE_INVALID: // = 13,
case WIFI_REASON_IE_INVALID: // = 13,
return "IE invalid";
case WIFI_REASON_MIC_FAILURE: // = 14,
case WIFI_REASON_MIC_FAILURE: // = 14,
return "MIC failure";
case WIFI_REASON_4WAY_HANDSHAKE_TIMEOUT: // = 15,
case WIFI_REASON_4WAY_HANDSHAKE_TIMEOUT: // = 15,
return "4way handshake timeout";
case WIFI_REASON_GROUP_KEY_UPDATE_TIMEOUT: // = 16,
return "group key-update timeout";
case WIFI_REASON_IE_IN_4WAY_DIFFERS: // = 17,
case WIFI_REASON_IE_IN_4WAY_DIFFERS: // = 17,
return "IE in 4way differs";
case WIFI_REASON_GROUP_CIPHER_INVALID: // = 18,
case WIFI_REASON_GROUP_CIPHER_INVALID: // = 18,
return "group cipher invalid";
case WIFI_REASON_PAIRWISE_CIPHER_INVALID: // = 19,
case WIFI_REASON_PAIRWISE_CIPHER_INVALID: // = 19,
return "pairwise cipher invalid";
case WIFI_REASON_AKMP_INVALID: // = 20,
case WIFI_REASON_AKMP_INVALID: // = 20,
return "AKMP invalid";
case WIFI_REASON_UNSUPP_RSN_IE_VERSION: // = 21,
case WIFI_REASON_UNSUPP_RSN_IE_VERSION: // = 21,
return "unsupported RSN_IE version";
case WIFI_REASON_INVALID_RSN_IE_CAP: // = 22,
case WIFI_REASON_INVALID_RSN_IE_CAP: // = 22,
return "invalid RSN_IE_CAP";
case WIFI_REASON_802_1X_AUTH_FAILED: // = 23,
case WIFI_REASON_802_1X_AUTH_FAILED: // = 23,
return "802 X1 auth failed";
case WIFI_REASON_CIPHER_SUITE_REJECTED: // = 24,
case WIFI_REASON_CIPHER_SUITE_REJECTED: // = 24,
return "cipher suite rejected";
case WIFI_REASON_BEACON_TIMEOUT: // = 200,
case WIFI_REASON_BEACON_TIMEOUT: // = 200,
return "beacon timeout";
case WIFI_REASON_NO_AP_FOUND: // = 201,
case WIFI_REASON_NO_AP_FOUND: // = 201,
return "no AP found";
case WIFI_REASON_AUTH_FAIL: // = 202,
case WIFI_REASON_AUTH_FAIL: // = 202,
return "auth fail";
case WIFI_REASON_ASSOC_FAIL: // = 203,
case WIFI_REASON_ASSOC_FAIL: // = 203,
return "assoc fail";
case WIFI_REASON_HANDSHAKE_TIMEOUT: // = 204,
case WIFI_REASON_HANDSHAKE_TIMEOUT: // = 204,
return "handshake timeout";
default:
return "unknown";