Skip to content

Commit

Permalink
fix(readme) add reboot
Browse files Browse the repository at this point in the history
feat(routes) add get routes debug
  • Loading branch information
smarthomeagentur committed Oct 7, 2023
1 parent b3d176b commit c79bdb2
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 20 deletions.
53 changes: 36 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ All Responses have the general structure to verify if the response is a success:

The Return value describes the `data` property

### Get status
### Get status (WIP)

```
GET http://XXX.XXX.XXX.XXX:3009/status
Expand All @@ -65,32 +65,31 @@ GET http://XXX.XXX.XXX.XXX:3009/status
}
```

### Shutdown computer 📴

> [!WARNING]
> This will also shut down the network of Raspberry Pi computers, so it will not react to any WOL triggers. The Device needs to be powered on manually after this!
### Wake computer

Shuts down the computer.
Wake up the device from sleep. Turn on all the periphery and return to normal usage. This takes some time (1-5 minutes)

```
POST http://XXX.XXX.XXX.XXX:3009/shutdown
POST http://XXX.XXX.XXX.XXX:3009/wake
```

#### Returns

```json
{
"status": "prepare-shutdown",
"display": "active"
[...]
"data": {
"status": "all devices awake"
}
}
```

### Wake computer
### Sleep computer

Wake up the device from sleep. Turn on all the periphery and return to normal usage.
Sleep the computer and turn all the periphery off.

```
POST http://XXX.XXX.XXX.XXX:3009/wake
POST http://XXX.XXX.XXX.XXX:3009/sleep
```

#### Returns
Expand All @@ -99,17 +98,17 @@ POST http://XXX.XXX.XXX.XXX:3009/wake
{
[...]
"data": {
"status": "all devices awake"
"status": "all devices sleeping"
}
}
```

### Sleep computer
### Reboot computer

Sleep the computer and turn all the periphery off.
reboot and reset the system completely.

```
POST http://XXX.XXX.XXX.XXX:3009/sleep
POST http://XXX.XXX.XXX.XXX:3009/reboot
```

#### Returns
Expand All @@ -118,11 +117,31 @@ POST http://XXX.XXX.XXX.XXX:3009/sleep
{
[...]
"data": {
"status": "all devices sleeping"
"status": "success"
}
}
```

### Shutdown computer (experimental) 📴

> [!WARNING]
> This will also shut down the network of Raspberry Pi computers, so it will not react to any WOL triggers. The Device needs to be powered off and on manually after this!
Shut down the computer.

```
POST http://XXX.XXX.XXX.XXX:3009/shutdown
```

#### Returns

```json
{
"status": "prepare-shutdown",
"display": "active"
}
```

### Screenshot 📸

Enable `public device url`. Make sure you also have [xserver](https://github.com/wirewirewirewire/xserver) running. This will allow you to get a screenshot of the application currently running on the public device url.
Expand Down
20 changes: 17 additions & 3 deletions app/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,40 @@ module.exports = function (app) {
//let file = req.files[Object.keys(req.files)[0]].tempFilePath;
res.send({ success: true, error: status.Data, data: status.Data });
});

app.post("/reboot", async function (req, res) {
if (DEBUG) console.log("[API] post reboot");
console.log("[API] post reboot");
var timeout;
let status = await control.setBalenaRestart(timeout);
//let file = req.files[Object.keys(req.files)[0]].tempFilePath;
res.send({ success: true, error: null, data: status.Data });
});
app.post("/sleep", async function (req, res) {
if (DEBUG) console.log("[API] post sleep");
console.log("[API] post sleep");
let status = await control.setBalenaSleep();
//let file = req.files[Object.keys(req.files)[0]].tempFilePath;
res.send({ success: true, error: null, data: { status } });
});
app.post("/wake", async function (req, res) {
if (DEBUG) console.log("[API] post wake");
console.log("[API] post wake");
let status = await control.setBalenaWake();
//let file = req.files[Object.keys(req.files)[0]].tempFilePath;
res.send({ success: true, error: null, data: { status } });
});

app.get("/reboot", async function (req, res) {
console.log("[API] get reboot");
res.send({ success: true, error: null, data: true });
});
app.get("/sleep", async function (req, res) {
console.log("[API] get sleep");
res.send({ success: true, error: null, data: true });
});
app.get("/wake", async function (req, res) {
console.log("[API] get wake");
res.send({ success: true, error: null, data: true });
});

app.get("/display", async function (req, res) {
if (DEBUG) console.log("[API] get display");
if (DEBUG) console.log(req.body);
Expand Down

0 comments on commit c79bdb2

Please sign in to comment.