Skip to content

Commit

Permalink
add common restart command (so can be called via mqtt) (#3)
Browse files Browse the repository at this point in the history
* add common restart command (so can be called via mqtt)

* update version
  • Loading branch information
sumnerboy12 authored Sep 1, 2022
1 parent 33e5e67 commit 9a65abd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=OXRS-IO-WT32-ESP32-LIB
version=1.0.0
version=1.1.0
author=OXRS Core Team
maintainer=moinmoin-sh <[email protected]>
sentence=WT32-SC01 library for Open eXtensible Rack System projects
Expand Down
11 changes: 11 additions & 0 deletions src/OXRS_WT32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ void _getCommandSchemaJson(JsonVariant json)
{
_mergeJson(properties, _fwCommandSchema.as<JsonVariant>());
}

// Restart command
JsonObject restart = properties.createNestedObject("restart");
restart["title"] = "Restart";
restart["type"] = "boolean";
}

/* API callbacks */
Expand Down Expand Up @@ -229,6 +234,12 @@ void _mqttConfig(JsonVariant json)

void _mqttCommand(JsonVariant json)
{
// Core restart command
if (json.containsKey("restart") && json["restart"].as<bool>())
{
ESP.restart();
}

// Pass on to the firmware callback
if (_onCommand)
{
Expand Down

0 comments on commit 9a65abd

Please sign in to comment.