Lesson 3 Connect your device to QIoT Suite Lite using MQTTS


In Lesson 2 , we complete deploy sample code to your device .In this lesson, you will learn how yo use sample code to connect to QIoT Suite Lite.

And there are three parts:

A: Generate resource info inside QIoT Suite

B: Download sample code

C: Other Protocol

Part A :Generate resource info inside QIoT Suite



  • Click the "Connect a Device":


create_certificate_button

 

  • Choose MQTTS and click "Generate a Device Certificate" :


8.gnerate_certificate

  • In "Download the files to connect", click the links to download the "Device Certificate", "CA Certificate", and "Private Key" to your PC. Do not rename these files. Click "OK".
    downloadcertificate

  • Click "Download JSON file".


10.downloadjsonfile

 

Part B :Download sample code



  • Download sample code from QNAP QIoT Suite Lite GitHub.


  • Set the data structure like as in the following image.

    • The "resource.json" file must be saved in the "res" folder, and the device Certificate, CA Certificate, and Private Key must be saved in the "ssl" folder.




data_structure

  • Open Terminal application (such as WinSCP) on your PC and login to your device.

    • LinkIt 7688 only supports the SCP protocol. SFTP can be installed  using "openssh-sftp-server".

      root@mylinkit:~# opkg update
      root@mylinkit:~# opkg install openssh-sftp-server





scp


scpToFolder

 

  • Open a Terminal application (such as PuTTY) on your PC.Connect to your device by using SSH and enter the folder where the sample code is stored (for example: /home/root/bundle).


ssh_img

  • To Install sample code dependencies, enter the following commands:

    root@mylinkit:~# cd {folder where you put sample code}
    root@mylinkit:/home/root/bundle# pip install -r requirements.txt


  • Run the sample code

    root@mylinkit:/home/root/bundle# python mqtt.py


  • The device will send a message to the topic "temp" (or the topic you defined)


15


Part C : Using another protocol



  • Click "Connect a Device".


create_certificate_button

  • You can select another protocol.


12_another_protocol

  • Connect to your device using SSH, and enter the following commands:

    root@mylinkit:~# cd /home/{{user}}/bundle
    root@mylinkit:/home/root/bundle# pip install -r requirements.txt

    // mqtt(dont' need certificate,just put JSON file to "res" folder):
    root@mylinkit:/home/root/bundle# python mqtt.py

    // http
    root@mylinkit:/home/root/bundle# python http.py

    // https
    root@mylinkit:/home/root/bundle# python https.py

    // coap
    root@mylinkit:/home/root/bundle# python coap.py


  • In next Lesson ,we will integrate Power BI to visualize senser data . Lesson 4 Integrate Power BI


Please visit QNAP github for QIoT Suite Lite sample code


"QNAP-Github"

arrow
arrow
    全站熱搜

    tttt 發表在 痞客邦 留言(0) 人氣()