From 0384478660636036c726921d53b637e071cc2e85 Mon Sep 17 00:00:00 2001 From: Angie Chiu Date: Wed, 6 Jul 2016 11:55:15 +0800 Subject: [PATCH 1/6] MCS-3430 & FOTA MQTT format explanation --- content/en/tutorial/7688_led_tutorial.md | 43 ++++++++++++++++--- content/en/tutorial/communication_channels.md | 8 ++++ 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/content/en/tutorial/7688_led_tutorial.md b/content/en/tutorial/7688_led_tutorial.md index f978547..284d82d 100644 --- a/content/en/tutorial/7688_led_tutorial.md +++ b/content/en/tutorial/7688_led_tutorial.md @@ -76,19 +76,25 @@ MCS supports node.js and python. You can choose node.js or python base on your p Here is the Node.js example code that listens for commands from MCS web console. -1. Create a file app.js using an editor, vi is used in this example: +* Create a file app.js using an editor, vi is used in this example: ``` vim app.js ``` -2. Type **i** and Copy/paste the following code in the editor +### Connect Using Command Server or MQTT -``` js + +MCS provides two kinds of communication between the device and MCS, the **Command Server** and the **MQTT**. Please only choose one to implement on your device. + +#### Connect using Command Server +* Type **i** and Copy/paste the following code in the editor. + +``` var mcs = require('mcsjs'); var myApp = mcs.register({ - deviceId: 'ABC123', - deviceKey: 'XYZ123', + deviceId: 'Input your deviceId', + deviceKey: 'Input your deviceKey', host: 'api.mediatek.com' }); @@ -103,6 +109,33 @@ myApp.on('LED_Control', function(data, time) { } }); +``` +#### Connect using MQTT +* Type **i** and Copy/paste the following code in the editor. + +``` +var mcs = require('mcsjs'); + +var myApp = mcs.register({ + deviceId: 'Input your deviceId', + deviceKey: 'Input your deviceKey', + host: 'api.mediatek.com', + mqttHost: 'mqtt.mcs.mediatek.com', + method: 'mqtt', + port: 1883, + qos: 0 +}); +// Replace the device ID and device Key obtained from your test device +// created in MCS. + +myApp.on('LED_control', function(data, time) { + if(Number(data) === 1){ + console.log('blink'); + } else { + console.log('off'); + } +}); + ``` Next, run the Node.js example program. diff --git a/content/en/tutorial/communication_channels.md b/content/en/tutorial/communication_channels.md index 676eaf5..4d02798 100644 --- a/content/en/tutorial/communication_channels.md +++ b/content/en/tutorial/communication_channels.md @@ -94,6 +94,14 @@ The keep alive is a time interval, the client device commits to by sending regul ### FOTA via MQTT +Please note, if you would like to send FOTA using the MQTT communication, you have to subscibe one of the topic to the wilcard devel. + +The format is as following: + +``` +mcs/:deviceId/:deviceKey/+ +``` + Once the device is connected and online via MQTT, and user pushed firmware to device. MCS server will send the following FOTA information to the device: ** timestamp, FOTA, version, MD5, URL** From a5fab42c85cc9fe238d074eac5fd01e2266642da Mon Sep 17 00:00:00 2001 From: Angie Chiu Date: Wed, 6 Jul 2016 14:51:52 +0800 Subject: [PATCH 2/6] add TCP & MQTT connection section in tutorial page --- content/en/tutorial.html | 5 +++++ content/en/tutorial/communication_channels.md | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/content/en/tutorial.html b/content/en/tutorial.html index b4db991..4b84645 100755 --- a/content/en/tutorial.html +++ b/content/en/tutorial.html @@ -32,6 +32,11 @@
Getting started step by step +
  • + + TCP and MQTT connection + +
  • diff --git a/content/en/tutorial/communication_channels.md b/content/en/tutorial/communication_channels.md index b9a650d..2c8a1a4 100644 --- a/content/en/tutorial/communication_channels.md +++ b/content/en/tutorial/communication_channels.md @@ -45,7 +45,7 @@ Please note, MCS is using **server site signed** mechanism while using the encyp ### Subscribe & Publish -After you've connected to the MCS MQTT broker, you can subscribe to specific device or data channel; you can also publish to specific data channel. +After you've connected to the MCS MQTT broker. you can subscribe to specific device or data channel; you can also publish to specific data channel. For **subscription**, the topic is defined in the following format: @@ -85,8 +85,8 @@ QoS or Quality of Service is one of the key features of MQTT. Currently, MCS onl The MCS MQTT Broker also supports Retained message and Offline message as the MQTT standard defined. -* Retained message: This message will be sent everytime a client is subscribe to the topic. For example, a welcome message. -* Offline message: This message will be keep in the broker if the client is offline, and sent to the client when it goes online. +* Retained message:This message will be sent everytime a client is subscribe to the topic. For example, a welcome message. +* Offline message: This message will be keep in the broker if the client is offline, and sent to the client when it goes online. ### Keep Alive @@ -114,3 +114,5 @@ Once the device is connected and online via MQTT, and user pushed firmware to de For more information about FOTA, please refer to [this link](../tutorial/managing_firmware). + + From c828de34f31c67babd952d481d9857f15c4390c4 Mon Sep 17 00:00:00 2001 From: Angie Date: Mon, 11 Jul 2016 10:40:02 +0800 Subject: [PATCH 3/6] Update tutorial.html --- content/en/tutorial.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/en/tutorial.html b/content/en/tutorial.html index 4b84645..10d57ff 100755 --- a/content/en/tutorial.html +++ b/content/en/tutorial.html @@ -34,7 +34,7 @@
  • - TCP and MQTT connection + TCP and MQTT connections
  • From 523eacca3981aa65e0d80270cdd8801d701e4720 Mon Sep 17 00:00:00 2001 From: Angie Date: Mon, 11 Jul 2016 10:41:16 +0800 Subject: [PATCH 4/6] Update communication_channels.md --- content/en/tutorial/communication_channels.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/en/tutorial/communication_channels.md b/content/en/tutorial/communication_channels.md index 2c8a1a4..19cd592 100644 --- a/content/en/tutorial/communication_channels.md +++ b/content/en/tutorial/communication_channels.md @@ -45,7 +45,7 @@ Please note, MCS is using **server site signed** mechanism while using the encyp ### Subscribe & Publish -After you've connected to the MCS MQTT broker. you can subscribe to specific device or data channel; you can also publish to specific data channel. +After you've connected to the MCS MQTT broker. You can subscribe to specific device or data channel; you can also publish to specific data channel. For **subscription**, the topic is defined in the following format: From 6863391fdbae3c53d126870c7e7ec60085b5db89 Mon Sep 17 00:00:00 2001 From: Angie Date: Mon, 11 Jul 2016 10:41:51 +0800 Subject: [PATCH 5/6] Update communication_channels.md --- content/en/tutorial/communication_channels.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/en/tutorial/communication_channels.md b/content/en/tutorial/communication_channels.md index 19cd592..4fb8a0f 100644 --- a/content/en/tutorial/communication_channels.md +++ b/content/en/tutorial/communication_channels.md @@ -86,7 +86,7 @@ QoS or Quality of Service is one of the key features of MQTT. Currently, MCS onl The MCS MQTT Broker also supports Retained message and Offline message as the MQTT standard defined. * Retained message:This message will be sent everytime a client is subscribe to the topic. For example, a welcome message. -* Offline message: This message will be keep in the broker if the client is offline, and sent to the client when it goes online. +* Offline message: This message will be keep in the broker if the client is offline, and sent to the client when it goes online. ### Keep Alive From f69ad9e8b5b378aa79c0d34bd8ab2c505355c7fe Mon Sep 17 00:00:00 2001 From: Angie Date: Mon, 11 Jul 2016 10:42:13 +0800 Subject: [PATCH 6/6] Update communication_channels.md --- content/en/tutorial/communication_channels.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/en/tutorial/communication_channels.md b/content/en/tutorial/communication_channels.md index 4fb8a0f..0288c99 100644 --- a/content/en/tutorial/communication_channels.md +++ b/content/en/tutorial/communication_channels.md @@ -85,7 +85,7 @@ QoS or Quality of Service is one of the key features of MQTT. Currently, MCS onl The MCS MQTT Broker also supports Retained message and Offline message as the MQTT standard defined. -* Retained message:This message will be sent everytime a client is subscribe to the topic. For example, a welcome message. +* Retained message: This message will be sent everytime a client is subscribe to the topic. For example, a welcome message. * Offline message: This message will be keep in the broker if the client is offline, and sent to the client when it goes online. ### Keep Alive