[DEPRECATED] ST_Anything - Arduino/ESP8266/ESP32

The easiest way to do this is to add another callback function (e.g. callbackRcvd( const String &msg) ) to your sketch. The st::everything class supports two optional callbacks, one for data being sent to SmartThings, and another for data coming from SmartThings. My example sketches demonstrate the first one. But you can easily add the second one as well.

Here are the function pointer definitions from Everything.h.

			static void (*callOnMsgSend)(const String &msg); //If this function pointer is assigned, the function it points to will be called upon every time a string is sent to the cloud.		
			static void (*callOnMsgRcvd)(const String &msg); //If this function pointer is assigned, the function it points to will be called upon every time a string is received from the cloud.

In the example sketches, you’ll find the following line of code in the setup() routine. Just add another uniquely named callback function, and add it as follows…

  //Initialize the optional local callback routine (safe to comment out if not desired)
  st::Everything::callOnMsgSend = callback;
  st::Everything::callOnMsgRcvd = callbackRcvd;

Hopefully this makes sense for the Arduino changes. Within your new callback, you can grab the name/ value pairs being sent from ST and do whatever you want in your sketch.

On the groovy side, just add appropriate calls to send the properly formatted name/value pairs to the Arduino.

3 Likes