Skip to Content
Learning AWS IoT
book

Learning AWS IoT

by Agus Kurniawan
January 2018
Intermediate to advanced
278 pages
5h 13m
English
Packt Publishing
Content preview from Learning AWS IoT

How to work with the program?

Now we will review our program, comp-demo.js. The following is a list of steps for the program:

  1. Firstly, we apply the required library from AWS IoT SDK for JavaScript. Then, we declare our device based on our IoT thing from AWS IoT:
var awsIot = require('aws-iot-device-sdk');var device = awsIot.device({    keyPath: 'cert/macos-computer.private.key',   certPath: 'cert/macos-computer.cert.pem',     caPath: 'cert/root-CA.crt',       host: 'xxxxxxx.iot.ap-southeast-1.amazonaws.com',   clientId: 'user-testing',     region: 'ap-southeast-' });
  1. We try to connect to AWS IoT. After we are connected, we subscribe a specific topic, for instance, topic_1. Then, we send a message by calling the publish() function:
device .on('connect', function() ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learn AWS Serverless Computing

Learn AWS Serverless Computing

Scott Patterson

Publisher Resources

ISBN: 9781788396110Supplemental Content