Skip to content

Commit

Permalink
Merge pull request #84 from Mediatek-Cloud/MCS-3430-7688Tutorial-&-FO…
Browse files Browse the repository at this point in the history
…TA-update

Mcs 3430 7688 tutorial & fota update
  • Loading branch information
anchi1216 authored Jul 12, 2016
2 parents 1f1f32d + f69ad9e commit 3d551e6
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 6 deletions.
5 changes: 5 additions & 0 deletions content/en/tutorial.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ <h5 class="componentCard__detail--tutorialTitle">
Getting started step by step
</a>
</li>
<li>
<a href="tutorial/communication_channels" >
TCP and MQTT connections
</a>
</li>
</ul>
</article>
</div>
Expand Down
43 changes: 38 additions & 5 deletions content/en/tutorial/7688_led_tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
});
Expand All @@ -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.
Expand Down
12 changes: 11 additions & 1 deletion content/en/tutorial/communication_channels.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -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**
Expand All @@ -106,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).



0 comments on commit 3d551e6

Please sign in to comment.