@@ -31,12 +31,12 @@ extensions or configuration changes are required.
31
31
- [ Process image] ( #process-image-low-level )
32
32
- [ LED control] ( #led-control )
33
33
- [ Serial port access] ( #serial-port-access )
34
+ - [ Remote interface] ( #remote-interface )
34
35
- [ Low-level interface] ( #low-level-interface )
35
36
- [ Hardware devices (PiControl, Terminal)] ( #hardware-devices-picontrol-terminal )
36
37
- [ ProcessImage interface] ( #processimage-interface )
37
38
- [ SerialPort interface] ( #serialport-interface )
38
39
- [ Monitoring with custom monitors] ( #monitoring-with-custom-monitors )
39
- - [ Remote module usage] ( #remote-module-usage )
40
40
- [ Deployment] ( #deployment )
41
41
- [ Example: Polling and running the event loop] ( #example-polling-and-running-the-event-loop )
42
42
- [ CLI Commands] ( #cli-commands )
@@ -244,6 +244,37 @@ $port->break();
244
244
245
245
---
246
246
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
+
247
278
## Low-level interface
248
279
249
280
### Hardware Devices (PiControl, Terminal)
@@ -296,30 +327,6 @@ $pi->module()->monitor('input1', new MyMonitor, function($newValue) {
296
327
});
297
328
```
298
329
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
-
323
330
---
324
331
325
332
## Deployment
0 commit comments