Triggering Pusher client events from Arduino

With Pusher service one can send push messages from a mobile app (or a web page) to an embedded system to trigger some action, such as power up some lights or open a door. The system is quite simple: the webpage registers itself to send a message that is triggered on an user action, the embedded system registers itself to receive that specific message and waits for the message to arrive on a socket. But what if we want the embedded system to answer to the web page?

The officially sponsored library (link) for the Arduino platform does not have the support for triggering messages. This limitation is maybe due to the reduced memory available on the platform (2 KB) that can cause stack overflows, memory corruptions and unexpected hardware resets.

Since I need my webpage to reflect the actual status of an action realized by my Arduino I modified the library to support the missing features: the gathering of the socket id specified by the Pusher servers after handshaking and the SHA256 hashing of an authorization string. The main difficulties were the reduction of memory allocations and memory fragmentation and the reuse of existing buffers used to manage temporary strings. I uploaded the source code of the library (with an example) as a fork of the original library (link).

So I can now trigger client events on private channels, directly from the Arduino!

Leave a comment