Peer-to-peer via RESTful API!


Hi OptoFans,

A nifty use for our new-in-9.5 RESTful interface: easier peer-to-peer communication between PAC controllers! Here’s a simple example to show how.

This single-chart strategy lets you read and write to tags on a SNAP-PAC-R1 here at Opto 22 headquarters via that -R1’s RESTful server.

Included in this CLIENT example PAC Control Basic 9.5 strategy, you’ll find 5 subroutines:

2 to write (POST) values to a remote PAC,
2 to read (GET) values from a remote PAC,

One “Helper” subroutine that’s called by those four when building the HTTP headers for the RESTful calls to the remote PAC.

Note: you do NOT need to enable the RESTful server on the PAC which will run this. In fact, you don’t even have to run it on a hardware PAC, it’ll run on PAC Sim if you’d like!

You do need PAC Sim 9.5 or better, though, because I do have nested subroutines in here, and those require 9.5 or better to run.

Also note: although we’ve put a Learning Center directly on the Internet, configured for http (vs httpS) for demo purposes, we do NOT normally recommended this practice. See [U]this networking guide[/U] for the ways we DO recommend you connect your Opto 22 hardware to various networks.

Let me know what you think!
-OptoMary (27 KB)

Your better Peer-to-Peer for PAC

Thanks Mary!