Iot Device Management Development Guide Contents
Total Page:16
File Type:pdf, Size:1020Kb
IoT Device Management Development Guide Issue 02 Date 2019-08-28 HUAWEI TECHNOLOGIES CO., LTD. Copyright © Huawei Technologies Co., Ltd. 2019. All rights reserved. No part of this document may be reproduced or transmitted in any form or by any means without prior written consent of Huawei Technologies Co., Ltd. Trademarks and Permissions and other Huawei trademarks are trademarks of Huawei Technologies Co., Ltd. All other trademarks and trade names mentioned in this document are the property of their respective holders. Notice The purchased products, services and features are stipulated by the contract made between Huawei and the customer. All or part of the products, services and features described in this document may not be within the purchase scope or the usage scope. Unless otherwise specified in the contract, all statements, information, and recommendations in this document are provided "AS IS" without warranties, guarantees or representations of any kind, either express or implied. The information in this document is subject to change without notice. Every effort has been made in the preparation of this document to ensure accuracy of the contents, but all statements, information, and recommendations in this document do not constitute a warranty of any kind, express or implied. Issue 02 (2019-08-28) Copyright © Huawei Technologies Co., Ltd. i IoT Device Management Development Guide Contents Contents 1 Product Development................................................................................................................... 1 1.1 Obtaining Development Resources................................................................................................................................ 1 1.2 Creating a Project and Product....................................................................................................................................... 4 1.3 Developing a Product Model..........................................................................................................................................9 1.3.1 Development Guide.....................................................................................................................................................9 1.3.2 Offline Development................................................................................................................................................. 14 1.3.2.1 Profile Writing Guide............................................................................................................................................. 14 1.3.2.2 Profile Providing Method....................................................................................................................................... 17 1.3.2.3 Profile Field Description........................................................................................................................................ 18 1.3.3 Reference................................................................................................................................................................... 29 1.3.3.1 Product Model Sample........................................................................................................................................... 29 1.3.3.2 Fields in the Profile Sample....................................................................................................................................38 1.4 Developing a Codec......................................................................................................................................................49 1.4.1 Development Guide...................................................................................................................................................49 1.4.2 Offline Development................................................................................................................................................. 64 1.4.2.1 Preparing the Development Environment.............................................................................................................. 65 1.4.2.2 Importing the DEMO Project of the Codec............................................................................................................67 1.4.2.3 Developing a Codec................................................................................................................................................69 1.4.2.4 Packaging the Codec.............................................................................................................................................. 69 1.4.2.5 Inspecting the Quality of the Codec....................................................................................................................... 72 1.4.2.6 Signing the Codec Package with an Offline Signature...........................................................................................76 1.4.3 Codec Development Examples..................................................................................................................................78 1.4.3.1 Codec for Data Reporting and Command Delivery............................................................................................... 78 1.4.3.2 Codec for Multiple Data Reporting Messages....................................................................................................... 86 1.4.3.3 Codec for Strings and Variable-Length Strings......................................................................................................99 1.4.3.4 Codec for Arrays and Variable-Length Arrays.....................................................................................................117 1.4.3.5 Codec for Containing Command Execution Results............................................................................................135 1.4.4 Reference................................................................................................................................................................. 150 1.4.4.1 Message Processing Flow.....................................................................................................................................151 1.4.4.2 decode API Description........................................................................................................................................152 1.4.4.3 Description of encode API................................................................................................................................... 156 1.4.4.4 getManufacturerId Interface Description............................................................................................................. 159 1.4.4.5 getModel Interface Description............................................................................................................................ 160 Issue 02 (2019-08-28) Copyright © Huawei Technologies Co., Ltd. ii IoT Device Management Development Guide Contents 1.4.4.6 Precautions on Interface Implementation............................................................................................................. 160 1.4.4.7 Input/Output Format of the Codec Plug-In...........................................................................................................163 1.4.4.8 Implementation Sample Interpretation................................................................................................................. 165 1.4.4.9 Appendix: Encryption Algorithms Supported by the JDK...................................................................................173 1.5 Developing an Application.........................................................................................................................................174 1.5.1 Application Connection to the IoT Platform........................................................................................................... 175 1.5.2 Data Subscription.................................................................................................................................................... 176 1.5.3 Device Registration................................................................................................................................................. 178 1.5.4 Device Access to the IoT Platform..........................................................................................................................179 1.5.5 Data Reporting.........................................................................................................................................................180 1.5.6 Command Delivery..................................................................................................................................................182 1.5.7 Development of Other APIs.................................................................................................................................... 183 1.5.8 Reference................................................................................................................................................................. 183 1.5.8.1 Preparing the Java Development Environment.................................................................................................... 183 1.5.8.1.1 Installing JDK 1.8..............................................................................................................................................183 1.5.8.1.2 Configuring Java Environment Variables (Windows OS).................................................................................183