Publishing messages to target remote devices in JavaScript
Now, we will create a new JavaScript file named home_automation.js
that will provide an APP.HomeAutomation.Manager
object with many strings, objects, and functions that we will use to make it easy to establish a connection with MQTT over WebSockets. The functions will work with the Paho JavaScript client.
We will split the code for the home_automation.js
file in many code snippets to make it easier for us to understand each code section. The following lines start the declaration of the APP.HomeAutomation.Manager
object. The code file for the sample is included in the mqtt_essentials_gaston_hillar_05
folder, in the home_automation.js
file:
var APP = APP || {}; var APP = APP || {}; APP.HomeAutomation ...
Get MQTT Essentials - A Lightweight IoT Protocol now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.