@@ -10,7 +10,8 @@ options = {
10
10
}
11
11
12
12
// Connect to Arduino IoT Cloud MQTT Broker
13
- ArduinoIoTCloud . connect ( options ) . then ( ( ) => {
13
+ ArduinoIoTCloud . connect ( options )
14
+ . then ( ( ) => {
14
15
console . log ( "Connected to Arduino IoT Cloud MQTT broker" ) ;
15
16
16
17
// Init Arduino API Client
@@ -19,19 +20,22 @@ ArduinoIoTCloud.connect(options).then(() => {
19
20
20
21
const thingsAPI = new ArduinoIoTAPI . ThingsV2Api ( ArduinoIoTClient ) ;
21
22
const propertiesAPI = new ArduinoIoTAPI . PropertiesV2Api ( ArduinoIoTClient ) ;
22
- thingsAPI . thingsV2List ( ) . then ( things => {
23
+
24
+ thingsAPI . thingsV2List ( )
25
+ . then ( things => {
23
26
things . forEach ( thing => {
24
- propertiesAPI . propertiesV2List ( thing . id ) . then ( properties => {
25
- properties . forEach ( property => {
26
- ArduinoIoTCloud . onPropertyValue ( thing . id , property . variable_name , update = value => {
27
- console . log ( property . variable_name + ": " + value )
28
- } ) . then ( ( ) => {
29
- console . log ( "Callback registered for " + property . variable_name ) ;
30
- } ) ;
31
- } ) ;
27
+ propertiesAPI . propertiesV2List ( thing . id )
28
+ . then ( properties => {
29
+ properties . forEach ( property => {
30
+ ArduinoIoTCloud . onPropertyValue ( thing . id , property . variable_name ,
31
+ showUpdates = update = value => console . log ( property . variable_name + ": " + value ) )
32
+ . then ( ( ) => console . log ( "Callback registered for " + property . variable_name ) )
33
+ . catch ( error => console . error ( error ) ) ;
34
+ } ) ;
32
35
} )
36
+ . catch ( error => console . log ( error ) ) ;
33
37
} ) ;
34
- } , error => {
35
- console . log ( error )
36
- } ) ;
37
- } ) ;
38
+ } )
39
+ . catch ( error => console . error ( error ) ) ;
40
+ } )
41
+ . catch ( error => console . error ( error ) ) ;
0 commit comments