Now that you've generated code for you gateway and edge devices, you're ready to deploy the code and test out your M2M application. We'll start by running the MQTT gateway, then starting up the gateway and edge device Choreo programs.
1Make sure that you have the latest Temboo image or package for your gateway device - this will ensure that you have the necessary Temboo MQTT gateway libraries on your device. You can find Samsung's ARTIK images here, and for the Arduino Yún you can run:
opkg upgrade temboo
2SSH into your gateway device and run the MQTT gateway. After navigating to the location of the Temboo MQTT gateway, you'll first want to start the Mosquitto broker on your device. The
-d option makes the broker operate in the background, but does not suppress any of the messages. After starting the broker, you may see some debug notices, but you can still start the gateway by navigating to the location of the gateway script and then by running the script. You can see this in action in the gif below.
Samsung ARTIK 10 gateway location
Arduino Yún gateway location
Start MQTT gateway
python TemooMQTTGateway.pyc -s yes -d
Starting the Temboo MQTT gateway
Now's a good time to review the script options that we're using above. We've chosen to use HTTPS to send Choreo requests to Temboo from our gateway, and to turn debug mode on so that we can monitor activity more clearly. You can adjust these options as desired.
-s yes|no|ifavailable, --https=yes|no|ifavailable
Note: The Arduino Yún does not include SSL for Python by default, so you'll need to install that yourself if required. Communication with edge devices is always handled via HTTP.
For instructions on how to get set up with other protools, check out our CoAP and HTTP tutorials.
3The last step is to compile and run your gateway and edge device Choreo programs. If you haven't run Temboo code on a device before and and would like to learn more about the basics, we have simple getting started instructions for all devices. Building the files for Arduino or TI devices follows the standard process via their respective IDEs. Building edge device code for MQTT on the Samsung ARTIK requires running the command below, where
myEdgeDeviceProgram should be replaced with the name of the file containing your edge device code.
g++ -L/opt/iothub/artik/temboo/temboo_artik_library/lib -ltemboomqtt -I/opt/iothub/artik/temboo/temboo_artik_library/include/m2m myEdgeDeviceProgram.cpp -o myEdgeDeviceProgram
When the Choreo programs are running successfully, you'll be able to monitor the MQTT messages being sent to the gateway by watching the output on the terminal window that you used to start your gateway.
4That's it! You've built a multi-device M2M application that uses MQTT to communicate with with Temboo via an internet-connected gateway.
Now that you know how to generate code for multiple devices, why not check out the 2000+ Choreos in our Library and start thinking about all the possibilities for your next M2M application?
We're always happy to help. Just email us at email@example.com, and we'll answer your questions.