Structure-MQTT-device (community library)
Summary
Name | Value |
---|---|
Name | Structure-MQTT-device |
Version | 0.0.2 |
Installs | |
License | MIT |
Author | Charif Mahmoudi charif.mahmoudi.us@gmail.com |
URL | https://github.com/charifmahmoudi/getstructure-particle |
Repository | https://github.com/charifmahmoudi/getstructure-particle.git |
Download | .tar.gz |
All Versions | 0.0.2, 0.0.1 |
Enabling an MQTT comunicating
Example Build Testing
Device OS Version:
This table is generated from an automated build. Success only indicates that the code compiled successfully.
Library Read Me
This content is provided by the library maintainer and has not been validated or approved.
getstructure-particle
A Particle Builder library for integration with Losant
About
This library serves as a wrapper for the MQTT library for the integration with Losant Broker. It offers simplified methodes and an Device object to comunicate with Losant
Getting started
A getting started tutorial is availible at Hackster.io
https://www.hackster.io/charifmahmoudi/ez-device-lib-to-connect-particle-board-to-structure-0e624d
This getting started tutorial describes all the steps needed to integrates the library in your project.
Dependencies
This library depends on the SPARKJSON library that is availible as community library in the Particle Builder v2 update Library is added as depecdency using the new particle Libraries v2 feature
Features
The getstructure-particle library offers multiples cool features:
The callback method support directly JSon object. so you do not have to deal with boring char * and convert them by yourself.
// Callback for Structure subscriptions.
// Receive Your JsonObject from GetStructure.io
void myCallback(JsonObject& command) {
// If the command's name is "toggle", flip the LED.
if(String(command["name"].asString()).equals(String("toggle"))) {
ledValue = !ledValue;
digitalWrite(LED, ledValue ? HIGH : LOW);
}
}
Device Object that associate a photon to the Device at Structure
Is a wrapper for all the MQTT communication. It provides simply an object GetStructure::Device that you deal with. and it represents the devices on Structure application.
// The initialization of your device
GetStructure::Device photon("YOUR-DEVICE-ID", "YOUR-ACCESS-KEY", "YOUR-ACCESS-SECRET");
Just create your Json object and it send it for your to Structure application.
StaticJsonBuffer<100> jsonBuffer;
JsonObject& root = jsonBuffer.createObject();
...
//Publish directly your JsonObject !!!
photon.publish(root);
Simplified Json-based push methode and callback
Thanks
Thanks to Brandon Cannaday @TheReddest for his Blog Article
Thanks to GetStructure.io team for their free kits :D
Questions ?
Send me a tweet to @CharifUs :)
Trubleshoot
SparkJson missing
Structure-MQTT-device/Structure-MQTT-device.h:38:33: fatal error: SparkJson/SparkJson.h: No such file or directory
#include "SparkJson/SparkJson.h"
You need to add SPARKJSON library also from the community libraries to your project.
Browse Library Files