bridge.class.php VS REST calls in browser

I have spend the last couple of days looking into the bridge.class.php, and I do not quite understand it and what it does.

Can someone explain in what situations I can benefit from the bridge class instead of using REST like in this Scuola example. I guess it is better for two way communication and maybe more secure?

For my project I only need to send a message to the Arduino from a website hosted in the www-folder, and I will never need anything back from again. Which option should I use?

SomethingClever:
For my project I only need to send a message to the Arduino from a website hosted in the www-folder, and I will never need anything back from again. Which option should I use?

Use REST calls. It’s the perfect tool for that sort of interaction: it’s easy to format the request on the calling end, and it’s easy to parse on the Arduino end.

The bridge get/put calls allow storing information by either the Arduino side or the Linux side using named values. A typical use for this would be a case where the Arduino side does some timing critical I/O processing, then wants to send the data to the Linux side for some more sophisticated processing, storage, or communications. (The Arduino side is great at real-time I/O and some processing, but has limited speed and memory. The Linux side is faster and has lots more memory, but isn’t as adept at I/O and isn’t truly real-time.)

Besides sending data from Arduino to Linux, data can also flow the other way (to send an output pin state, for example.) This data can originate from the Linux code logic, or it can be communicated from the network through some Linux code.

Bridge get/put has lots of flexibility when coupled with some code on the Linux side, but doesn’t have to work that way. Data that has been “put” by the Arduino side can be retrieved remotely using a URL like arduino.local/data/get/. A similar call can be made to a URL like arduino.local/data/put// to send data to the Arduino side, where the Arduino code can the call get() to read it.

This last call is similar to the straight REST API call, but there is a significant difference: doing the data/put just stores the value, without notifying the Arduino code: it’s up to the code to poll the value and look for a change. This means that it will not be able to determine if the same value has been sent twice. Using the regular REST call format, the Arduino code is notified of every call, and can act immediately on it, even if it’s the same value as last time.

If you just want to send commands and data to the Arduino side, I would use a simple REST call, and save bridge get/put for when the situation gets more complicated.

Thank you very much!

Just to be clear: I should follow the Scoula example and make my own API on the Arduino side to interpret what is being sent? :slight_smile: Kinda like they have also done here: Tutorial/Bridge?

SomethingClever:
Just to be clear: I should follow the Scoula example and make my own API on the Arduino side to interpret what is being sent? :slight_smile: Kinda like they have also done here: Tutorial/Bridge?

Yes, once you send the data the Arduino side has to process it.

Super :slight_smile: Thank you both!