Use ESP.reset() rather than ESP.restart() - due to exceptions encountered on esp8266
This commit is contained in:
@ -13,4 +13,4 @@ export const SYSTEM_STATUS_ENDPOINT = ENDPOINT_ROOT + "systemStatus";
|
||||
export const SIGN_IN_ENDPOINT = ENDPOINT_ROOT + "signIn";
|
||||
export const VERIFY_AUTHORIZATION_ENDPOINT = ENDPOINT_ROOT + "verifyAuthorization";
|
||||
export const SECURITY_SETTINGS_ENDPOINT = ENDPOINT_ROOT + "securitySettings";
|
||||
export const RESTART_ENDPOINT = ENDPOINT_ROOT + "restart";
|
||||
export const RESET_ENDPOINT = ENDPOINT_ROOT + "reset";
|
||||
|
@ -22,7 +22,7 @@ import DataUsageIcon from '@material-ui/icons/DataUsage';
|
||||
import AutorenewIcon from '@material-ui/icons/Autorenew';
|
||||
import RefreshIcon from '@material-ui/icons/Refresh';
|
||||
|
||||
import { SYSTEM_STATUS_ENDPOINT, RESTART_ENDPOINT } from '../constants/Endpoints';
|
||||
import { SYSTEM_STATUS_ENDPOINT, RESET_ENDPOINT } from '../constants/Endpoints';
|
||||
import { restComponent } from '../components/RestComponent';
|
||||
import LoadingNotification from '../components/LoadingNotification';
|
||||
import SectionContent from '../components/SectionContent';
|
||||
@ -42,7 +42,7 @@ class SystemStatus extends Component {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
confirmRestart: false,
|
||||
confirmReset: false,
|
||||
processing: false
|
||||
}
|
||||
}
|
||||
@ -112,53 +112,53 @@ class SystemStatus extends Component {
|
||||
<Button startIcon={<RefreshIcon />} variant="contained" color="secondary" className={classes.button} onClick={this.props.loadData}>
|
||||
Refresh
|
||||
</Button>
|
||||
<Button startIcon={<AutorenewIcon />} variant="contained" color="secondary" className={classes.button} onClick={this.onRestart}>
|
||||
Restart
|
||||
<Button startIcon={<AutorenewIcon />} variant="contained" color="secondary" className={classes.button} onClick={this.onReset}>
|
||||
Reset
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
onRestart = () => {
|
||||
this.setState({ confirmRestart: true });
|
||||
onReset = () => {
|
||||
this.setState({ confirmReset: true });
|
||||
}
|
||||
|
||||
onRestartRejected = () => {
|
||||
this.setState({ confirmRestart: false });
|
||||
onResetRejected = () => {
|
||||
this.setState({ confirmReset: false });
|
||||
}
|
||||
|
||||
onRestartConfirmed = () => {
|
||||
onResetConfirmed = () => {
|
||||
this.setState({ processing: true });
|
||||
redirectingAuthorizedFetch(RESTART_ENDPOINT, { method: 'POST' })
|
||||
redirectingAuthorizedFetch(RESET_ENDPOINT, { method: 'POST' })
|
||||
.then(response => {
|
||||
if (response.status === 200) {
|
||||
this.props.enqueueSnackbar("Device is restarting", { variant: 'info' });
|
||||
this.setState({ processing: false, confirmRestart: false });
|
||||
this.props.enqueueSnackbar("Device is reseting", { variant: 'info' });
|
||||
this.setState({ processing: false, confirmReset: false });
|
||||
} else {
|
||||
throw Error("Invalid status code: " + response.status);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
this.props.enqueueSnackbar(error.message || "Problem restarting device", { variant: 'error' });
|
||||
this.setState({ processing: false, confirmRestart: false });
|
||||
this.props.enqueueSnackbar(error.message || "Problem resetting device", { variant: 'error' });
|
||||
this.setState({ processing: false, confirmReset: false });
|
||||
});
|
||||
}
|
||||
|
||||
renderRestartDialog() {
|
||||
renderResetDialog() {
|
||||
return (
|
||||
<Dialog
|
||||
open={this.state.confirmRestart}
|
||||
onClose={this.onRestartRejected}
|
||||
open={this.state.confirmReset}
|
||||
onClose={this.onResetRejected}
|
||||
>
|
||||
<DialogTitle>Confirm Restart</DialogTitle>
|
||||
<DialogTitle>Confirm Reset</DialogTitle>
|
||||
<DialogContent dividers={true}>
|
||||
Are you sure you want to restart the device?
|
||||
Are you sure you want to reset the device?
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button startIcon={<AutorenewIcon />} variant="contained" onClick={this.onRestartConfirmed} disabled={this.state.processing} color="primary" autoFocus>
|
||||
Restart
|
||||
<Button startIcon={<AutorenewIcon />} variant="contained" onClick={this.onResetConfirmed} disabled={this.state.processing} color="primary" autoFocus>
|
||||
Reset
|
||||
</Button>
|
||||
<Button variant="contained" onClick={this.onRestartRejected} color="secondary">
|
||||
<Button variant="contained" onClick={this.onResetRejected} color="secondary">
|
||||
Cancel
|
||||
</Button>
|
||||
</DialogActions>
|
||||
@ -178,7 +178,7 @@ class SystemStatus extends Component {
|
||||
() => this.renderSystemStatus(data, classes)
|
||||
}
|
||||
/>
|
||||
{this.renderRestartDialog()}
|
||||
{this.renderResetDialog()}
|
||||
</SectionContent>
|
||||
)
|
||||
}
|
||||
|
Reference in New Issue
Block a user