0.0.10 • Published 9 years ago

ml-mcs v0.0.10

Weekly downloads
-
License
ISC
Repository
-
Last release
9 years ago

ml-mcs

Required

  • ml-wifi

API

// Regist MCS.
__mcs(
  host,        // string
  port,        // string
  datachannel, // string
  client,      // string
  Qos,         // number
  func,        // callback function, handle the MQTT msg.
)

// Send a datapoint.
__mcsSend(
  topic,       // string
  data,        // string
  Qos,         // number
)

Example

Show a case: Get a message from MCS and send a message to MCS.

  var sendChannel = 'sendmsg';
  var receiveChannel = 'receivemsg';
  var deviceId = 'Input your deviceId';
  var deviceKey = 'Input your deviceKey';

  var topic = 'mcs/' + deviceId + '/' + deviceKey + '/';

  __wifi({
    mode: 'station', // default is station
    auth: 'PSK_WPA2',
    ssid: 'Input your ssid',
    password: 'Input your password',
  });

  global.eventStatus.on('mcsConnect', function() {
    print('MCS connect!');
  });

  global.eventStatus.on(receiveChannel, function(data) {
    print(data);
    var msg = "hello world";
    return __mcsSend(topic + sendChannel, ',,' + msg , 0);
  });

  global.eventStatus.on('wifiConnect', function() {
    __mcs(
      'mqtt.mcs.mediatek.com',
      '1883',
      topic + '+',
      'mqtt-7687-client',
      1,
      function(data) {
        global.eventStatus.emit(data.split(',')[1], data);
      }
    );
  });
0.0.10

9 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago