chenyc
2025-12-09 545c24c6a711d71b65f3d4e8122fee3837fb1edc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const aliyunIot = require('../');
const fixtures = require('../test/fixtures');
 
 
 
const device = aliyunIot.device({
    productKey: "a1aq9sQk2JE",
    deviceName: "sdk_device1",
    deviceSecret: "shvvZGkq4mM641WUhpfJpyInVeJhAH2y",
    keepalive:100,
    clean:false,
    // qos:1,
    // brokerUrl: 'tcp://127.0.0.1:1883/'
  });
  
  
  device.on('connect', () => {
    console.log('connect successfully!');
    device.serve('property/set', params => {
      console.log('receieve property/set serivce call, params is:', params);
      device.setProps(params);
    });
    device.serve('turnOff', () => {
      console.log('receieve turnOff serivce call');  
    });
  });