Skip to content

Commit 004659b

Browse files
authored
Changes to support upgrade of platform-espressif32 to 4.3.0 (#301)
* support latest espressif32 PIO platform * upgrade react, react router, axios and material
1 parent baae203 commit 004659b

21 files changed

+895
-772
lines changed

interface/package-lock.json

+835-728
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

interface/package.json

+14-14
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,29 @@
44
"private": true,
55
"proxy": "http://192.168.0.23",
66
"dependencies": {
7-
"@emotion/react": "^11.7.1",
8-
"@emotion/styled": "^11.6.0",
9-
"@mui/icons-material": "^5.2.4",
10-
"@mui/material": "^5.2.4",
7+
"@emotion/react": "^11.9.0",
8+
"@emotion/styled": "^11.8.1",
9+
"@mui/icons-material": "^5.8.0",
10+
"@mui/material": "^5.8.0",
1111
"@types/lodash": "^4.14.176",
1212
"@types/node": "^16.11.14",
13-
"@types/react": "^17.0.37",
14-
"@types/react-dom": "^17.0.11",
15-
"async-validator": "^4.0.7",
16-
"axios": "^0.24.0",
13+
"@types/react": "^18.0.9",
14+
"@types/react-dom": "^18.0.4",
15+
"async-validator": "^4.1.1",
16+
"axios": "^0.27.2",
1717
"http-proxy-middleware": "^2.0.1",
1818
"jwt-decode": "^3.1.2",
1919
"lodash": "^4.17.21",
20-
"notistack": "^2.0.3",
20+
"notistack": "^2.0.5",
2121
"parse-ms": "^3.0.0",
22-
"react": "^17.0.2",
22+
"react": "^18.1.0",
2323
"react-app-rewired": "^2.1.8",
24-
"react-dom": "^17.0.2",
24+
"react-dom": "^18.1.0",
2525
"react-dropzone": "^11.4.2",
26-
"react-router-dom": "^6.0.2",
27-
"react-scripts": "5.0.0",
26+
"react-router-dom": "^6.3.0",
27+
"react-scripts": "5.0.1",
2828
"sockette": "^2.0.6",
29-
"typescript": "^4.5.4"
29+
"typescript": "^4.6.4"
3030
},
3131
"scripts": {
3232
"start": "react-app-rewired start",

interface/src/CustomTheme.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { CssBaseline } from '@mui/material';
44
import { createTheme, responsiveFontSizes, ThemeProvider } from '@mui/material/styles';
55
import { indigo, blueGrey, orange, red, green } from '@mui/material/colors';
66

7+
import { RequiredChildrenProps } from './utils';
8+
79
const theme = responsiveFontSizes(
810
createTheme({
911
palette: {
@@ -28,7 +30,7 @@ const theme = responsiveFontSizes(
2830
})
2931
);
3032

31-
const CustomTheme: FC = ({ children }) => (
33+
const CustomTheme: FC<RequiredChildrenProps> = ({ children }) => (
3234
<ThemeProvider theme={theme}>
3335
<CssBaseline />
3436
{children}

interface/src/components/SectionContent.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import React from 'react';
22

33
import { Paper, Typography } from '@mui/material';
44

5-
interface SectionContentProps {
5+
import { RequiredChildrenProps } from '../utils';
6+
7+
interface SectionContentProps extends RequiredChildrenProps {
68
title: string;
79
titleGutter?: boolean;
810
}

interface/src/components/layout/Layout.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ import { useLocation } from 'react-router-dom';
55
import { Box, Toolbar } from '@mui/material';
66

77
import { PROJECT_NAME } from '../../api/env';
8+
import { RequiredChildrenProps } from '../../utils';
9+
810
import LayoutDrawer from './LayoutDrawer';
911
import LayoutAppBar from './LayoutAppBar';
1012
import { LayoutContext } from './context';
1113

1214
export const DRAWER_WIDTH = 280;
1315

14-
const Layout: FC = ({ children }) => {
16+
const Layout: FC<RequiredChildrenProps> = ({ children }) => {
1517

1618
const [mobileOpen, setMobileOpen] = useState(false);
1719
const [title, setTitle] = useState(PROJECT_NAME);

interface/src/components/routing/RequireAdmin.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import { FC, useContext } from 'react';
22
import { Navigate } from "react-router-dom";
33

44
import { AuthenticatedContext } from '../../contexts/authentication';
5+
import { RequiredChildrenProps } from '../../utils';
56

6-
const RequireAdmin: FC = ({ children }) => {
7+
const RequireAdmin: FC<RequiredChildrenProps> = ({ children }) => {
78
const authenticatedContext = useContext(AuthenticatedContext);
89
return authenticatedContext.me.admin ? <>{children}</> : <Navigate replace to='/' />;
910
};

interface/src/components/routing/RequireAuthenticated.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import { Navigate, useLocation } from "react-router-dom";
33

44
import { AuthenticatedContext, AuthenticatedContextValue, AuthenticationContext } from '../../contexts/authentication/context';
55
import { storeLoginRedirect } from '../../api/authentication';
6+
import { RequiredChildrenProps } from '../../utils';
67

7-
const RequireAuthenticated: FC = ({ children }) => {
8+
const RequireAuthenticated: FC<RequiredChildrenProps> = ({ children }) => {
89
const authenticationContext = useContext(AuthenticationContext);
910
const location = useLocation();
1011

interface/src/components/routing/RequireUnauthenticated.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ import { Navigate } from "react-router-dom";
33

44
import * as AuthenticationApi from '../../api/authentication';
55
import { AuthenticationContext } from '../../contexts/authentication';
6+
import { RequiredChildrenProps } from '../../utils';
67
import { FeaturesContext } from '../../contexts/features';
78

8-
const RequireUnauthenticated: FC = ({ children }) => {
9+
const RequireUnauthenticated: FC<RequiredChildrenProps> = ({ children }) => {
910
const { features } = useContext(FeaturesContext);
1011
const authenticationContext = useContext(AuthenticationContext);
1112

interface/src/components/routing/RouterTabs.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import { useNavigate } from 'react-router-dom';
44

55
import { Tabs, useMediaQuery, useTheme } from '@mui/material';
66

7-
interface RouterTabsProps {
7+
import { RequiredChildrenProps } from '../../utils';
8+
9+
interface RouterTabsProps extends RequiredChildrenProps {
810
value: string | false;
911
}
1012

interface/src/contexts/authentication/Authentication.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ import { useNavigate } from 'react-router-dom';
44

55
import * as AuthenticationApi from '../../api/authentication';
66
import { ACCESS_TOKEN } from '../../api/endpoints';
7+
import { RequiredChildrenProps } from '../../utils';
78
import { LoadingSpinner } from '../../components';
89
import { Me } from '../../types';
10+
911
import { FeaturesContext } from '../features';
1012
import { AuthenticationContext } from './context';
1113

12-
const Authentication: FC = ({ children }) => {
14+
const Authentication: FC<RequiredChildrenProps> = ({ children }) => {
1315
const { features } = useContext(FeaturesContext);
1416
const navigate = useNavigate();
1517
const { enqueueSnackbar } = useSnackbar();

interface/src/contexts/features/FeaturesLoader.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import { FC, useCallback, useEffect, useState } from 'react';
22

33
import * as FeaturesApi from '../../api/features';
44

5-
import { extractErrorMessage } from '../../utils';
5+
import { extractErrorMessage, RequiredChildrenProps } from '../../utils';
66
import { Features } from '../../types';
77
import {ApplicationError, LoadingSpinner} from '../../components';
88

99
import { FeaturesContext } from '.';
1010

11-
const FeaturesLoader: FC = (props) => {
11+
const FeaturesLoader: FC<RequiredChildrenProps> = (props) => {
1212

1313
const [errorMessage, setErrorMessage] = useState<string>();
1414
const [features, setFeatures] = useState<Features>();

interface/src/utils/endpoints.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { AxiosError } from "axios";
22

3-
export const extractErrorMessage = (error: AxiosError, defaultMessage: string) => (
4-
(error.response && error.response.data ? error.response.data.message : error.message) || defaultMessage
3+
export const extractErrorMessage = (error: AxiosError<{ message?: string }>, defaultMessage: string) => (
4+
(error?.response?.data?.message ? error.response.data.message : error.message) || defaultMessage
55
);

interface/src/utils/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ export * from './submit';
55
export * from './time';
66
export * from './useRest';
77
export * from './useWs';
8+
export * from './props';

interface/src/utils/props.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export interface RequiredChildrenProps {
2+
children: React.ReactNode;
3+
}

lib/framework/ESPFS.h

-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,2 @@
1-
#ifdef ESP32
2-
#include <SPIFFS.h>
3-
#define ESPFS SPIFFS
4-
#elif defined(ESP8266)
51
#include <LittleFS.h>
62
#define ESPFS LittleFS
7-
#endif

lib/framework/MqttSettingsService.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ MqttSettingsService::MqttSettingsService(AsyncWebServer* server, FS* fs, Securit
3434
#ifdef ESP32
3535
WiFi.onEvent(
3636
std::bind(&MqttSettingsService::onStationModeDisconnected, this, std::placeholders::_1, std::placeholders::_2),
37-
WiFiEvent_t::SYSTEM_EVENT_STA_DISCONNECTED);
37+
WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_DISCONNECTED);
3838
WiFi.onEvent(std::bind(&MqttSettingsService::onStationModeGotIP, this, std::placeholders::_1, std::placeholders::_2),
39-
WiFiEvent_t::SYSTEM_EVENT_STA_GOT_IP);
39+
WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_GOT_IP);
4040
#elif defined(ESP8266)
4141
_onStationModeDisconnectedHandler = WiFi.onStationModeDisconnected(
4242
std::bind(&MqttSettingsService::onStationModeDisconnected, this, std::placeholders::_1));

lib/framework/NTPSettingsService.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ NTPSettingsService::NTPSettingsService(AsyncWebServer* server, FS* fs, SecurityM
1313
#ifdef ESP32
1414
WiFi.onEvent(
1515
std::bind(&NTPSettingsService::onStationModeDisconnected, this, std::placeholders::_1, std::placeholders::_2),
16-
WiFiEvent_t::SYSTEM_EVENT_STA_DISCONNECTED);
16+
WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_DISCONNECTED);
1717
WiFi.onEvent(std::bind(&NTPSettingsService::onStationModeGotIP, this, std::placeholders::_1, std::placeholders::_2),
18-
WiFiEvent_t::SYSTEM_EVENT_STA_GOT_IP);
18+
WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_GOT_IP);
1919
#elif defined(ESP8266)
2020
_onStationModeDisconnectedHandler = WiFi.onStationModeDisconnected(
2121
std::bind(&NTPSettingsService::onStationModeDisconnected, this, std::placeholders::_1));

lib/framework/OTASettingsService.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ OTASettingsService::OTASettingsService(AsyncWebServer* server, FS* fs, SecurityM
66
_arduinoOTA(nullptr) {
77
#ifdef ESP32
88
WiFi.onEvent(std::bind(&OTASettingsService::onStationModeGotIP, this, std::placeholders::_1, std::placeholders::_2),
9-
WiFiEvent_t::SYSTEM_EVENT_STA_GOT_IP);
9+
WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_GOT_IP);
1010
#elif defined(ESP8266)
1111
_onStationModeGotIPHandler =
1212
WiFi.onStationModeGotIP(std::bind(&OTASettingsService::onStationModeGotIP, this, std::placeholders::_1));

lib/framework/WiFiSettingsService.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ WiFiSettingsService::WiFiSettingsService(AsyncWebServer* server, FS* fs, Securit
1919
WiFi.mode(WIFI_MODE_NULL);
2020
WiFi.onEvent(
2121
std::bind(&WiFiSettingsService::onStationModeDisconnected, this, std::placeholders::_1, std::placeholders::_2),
22-
WiFiEvent_t::SYSTEM_EVENT_STA_DISCONNECTED);
22+
WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_DISCONNECTED);
2323
WiFi.onEvent(std::bind(&WiFiSettingsService::onStationModeStop, this, std::placeholders::_1, std::placeholders::_2),
24-
WiFiEvent_t::SYSTEM_EVENT_STA_STOP);
24+
WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_STOP);
2525
#elif defined(ESP8266)
2626
_onStationModeDisconnectedHandler = WiFi.onStationModeDisconnected(
2727
std::bind(&WiFiSettingsService::onStationModeDisconnected, this, std::placeholders::_1));

lib/framework/WiFiStatus.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ WiFiStatus::WiFiStatus(AsyncWebServer* server, SecurityManager* securityManager)
66
securityManager->wrapRequest(std::bind(&WiFiStatus::wifiStatus, this, std::placeholders::_1),
77
AuthenticationPredicates::IS_AUTHENTICATED));
88
#ifdef ESP32
9-
WiFi.onEvent(onStationModeConnected, WiFiEvent_t::SYSTEM_EVENT_STA_CONNECTED);
10-
WiFi.onEvent(onStationModeDisconnected, WiFiEvent_t::SYSTEM_EVENT_STA_DISCONNECTED);
11-
WiFi.onEvent(onStationModeGotIP, WiFiEvent_t::SYSTEM_EVENT_STA_GOT_IP);
9+
WiFi.onEvent(onStationModeConnected, WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_CONNECTED);
10+
WiFi.onEvent(onStationModeDisconnected, WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_DISCONNECTED);
11+
WiFi.onEvent(onStationModeGotIP, WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_GOT_IP);
1212
#elif defined(ESP8266)
1313
_onStationModeConnectedHandler = WiFi.onStationModeConnected(onStationModeConnected);
1414
_onStationModeDisconnectedHandler = WiFi.onStationModeDisconnected(onStationModeDisconnected);
@@ -23,7 +23,7 @@ void WiFiStatus::onStationModeConnected(WiFiEvent_t event, WiFiEventInfo_t info)
2323

2424
void WiFiStatus::onStationModeDisconnected(WiFiEvent_t event, WiFiEventInfo_t info) {
2525
Serial.print(F("WiFi Disconnected. Reason code="));
26-
Serial.println(info.disconnected.reason);
26+
Serial.println(info.wifi_sta_disconnected.reason);
2727
}
2828

2929
void WiFiStatus::onStationModeGotIP(WiFiEvent_t event, WiFiEventInfo_t info) {

platformio.ini

+6-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,11 @@ extra_scripts =
3434

3535
lib_deps =
3636
ArduinoJson@>=6.0.0,<7.0.0
37-
ESP Async WebServer@>=1.2.0,<2.0.0
38-
AsyncMqttClient@>=0.8.2,<1.0.0
37+
; The following allows the use of the latest code for ESPAsyncWebServer - there hasn't been a release in a while
38+
; Work around for https://github.com/me-no-dev/ESPAsyncWebServer/issues/1151
39+
https://github.com/me-no-dev/ESPAsyncWebServer
40+
;ESP Async WebServer@>=1.2.0,<2.0.0
41+
AsyncMqttClient@>=0.9.0,<1.0.0
3942

4043
[env:esp12e]
4144
platform = espressif8266
@@ -48,3 +51,4 @@ board_build.filesystem = littlefs
4851
board_build.partitions = min_spiffs.csv
4952
platform = espressif32
5053
board = node32s
54+
board_build.filesystem = littlefs

0 commit comments

Comments
 (0)