Skip to content

Commit 80901d3

Browse files
committed
Updates
1 parent 3d5a794 commit 80901d3

File tree

1 file changed

+32
-25
lines changed

1 file changed

+32
-25
lines changed

README.md

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ extensions or configuration changes are required.
3131
- [Process image](#process-image-low-level)
3232
- [LED control](#led-control)
3333
- [Serial port access](#serial-port-access)
34+
- [Remote interface](#remote-interface)
3435
- [Low-level interface](#low-level-interface)
3536
- [Hardware devices (PiControl, Terminal)](#hardware-devices-picontrol-terminal)
3637
- [ProcessImage interface](#processimage-interface)
3738
- [SerialPort interface](#serialport-interface)
3839
- [Monitoring with custom monitors](#monitoring-with-custom-monitors)
39-
- [Remote module usage](#remote-module-usage)
4040
- [Deployment](#deployment)
4141
- [Example: Polling and running the event loop](#example-polling-and-running-the-event-loop)
4242
- [CLI Commands](#cli-commands)
@@ -244,6 +244,37 @@ $port->break();
244244

245245
---
246246

247+
## Remote interface
248+
249+
You can communicate with a *remote* RevPi device via a WebSocket by calling the `remote` method on the client before
250+
using the module.
251+
252+
```php
253+
use Flat3\RevPi\RevolutionPi;
254+
255+
$pi = new \App\MyPi;
256+
257+
// Adding the remote call creates a connection to a device
258+
$pi->remote('ws://10.1.2.3:12873');
259+
260+
// From now, other methods act remotely:
261+
$pi->output1 = 1;
262+
$status = $pi->input2;
263+
$pi->led(LedPosition::A1)->set(LedColour::Cyan);
264+
```
265+
266+
The remote device should listen for incoming connections, use `php artisan revpi:listen` to start the server on the
267+
device.
268+
269+
Remote devices support the same features that local devices do, including reading and writing to the process image,
270+
using the serial ports and setting up change monitors.
271+
272+
Out of the box the package does not provide for authentication or encryption. These can be added by creating a more
273+
complex websocket handshake object and passing it to the `remote` method. On the server-side, the basic `revpi:listen`
274+
code can be modified to support encryption and authentication.
275+
276+
---
277+
247278
## Low-level interface
248279

249280
### Hardware Devices (PiControl, Terminal)
@@ -296,30 +327,6 @@ $pi->module()->monitor('input1', new MyMonitor, function($newValue) {
296327
});
297328
```
298329

299-
### Remote Module Usage
300-
301-
You can communicate with a *remote* RevPi device via a WebSocket.
302-
303-
```php
304-
use Flat3\RevPi\RevolutionPi;
305-
306-
$pi = new \App\MyPi;
307-
308-
// Adding the remote call creates a connection to a device
309-
$pi->remote('ws://10.1.2.3:12873');
310-
311-
// From now, other methods act remotely:
312-
$pi->output1 = 1;
313-
$status = $pi->input2;
314-
$pi->led(LedPosition::A1)->set(LedColour::Cyan);
315-
```
316-
317-
The remote device should listen for incoming connections, use `php artisan revpi:listen` to start the server.
318-
319-
Out of the box the package does not provide for authentication, or encryption. These can be added by creating a more
320-
complex websocket handshake object and passing it to the `remote` method. On the server-side, the basic `revpi:listen`
321-
code can be modified to support encryption and authentication.
322-
323330
---
324331

325332
## Deployment

0 commit comments

Comments
 (0)