SDK Integration

Last updated: 2020-05-13 18:26:06

    SDK Integration Guide


    This document describes how to integrate with the SDK and use the demo.

    SDK Composition

    SDK directory files and features description:

    Directory Description
    application The application entry and API use examples
    doc The directory of source code documentation
    include Directory of SDK header file xgAgent.h
    lib Directory of SDK static library libxgIoT.a
    Makefile Project management files SDK use instructions

    Using Demo

    This use method is based on the x86_64 platform. For other platforms, please see the corresponding SDK documentation.

    SDK provides a test demo, so you can compile demo executable files without modifying any code, and use the demo to perform push testing.

    Compiling Demo

    1. Go to the Demo source code root directory, and execute the compiling command:

    After compiling, you can see in the root directory that the xgDemo file has been generated.

    1. Clear the compilation file, and execute the command:
    make clean

    Launching Demo

    When launching, you need to pass in the accessID, accessKey, and deviceName to the test application. The command format is as follows:

    ./xgDemo [accessID] [accessKey] [deviceName]

    The following message indicates that the device operates successfully

    level":"D","message":"xgMqttRpcResult(811):cmd account "}
    [20190909_20:14:44]{"time":"2019-0909-12:14:43.830","level":"D","message":"agentSetStatusFlag(297):xgStatusFlag 0x1F "}

    Pushing Messages to Demo

    You can push a message in the console or by using the RESTful API. If the following content is shown in the xgDemo log, the push is successful.

    [20190909_20:15:22][demo Debug]$$$$$$$$$$$$$$$$$$$$$$$
    [20190909_20:15:22][demo Debug]Recv data 39Byte: {"audience_type":"all","Key1":"Value1"}

    Integration Steps

    1. In the SDK download page, select IoTSDK to download it.
    2. Copy libxgIoT.a in the lib directory and xgAgent.h in the include directory to the custom source code directory.
    3. Modify Makefile and in compilation options, add:
    -lxgIoT -lpthread -lrt
    1. To integrate SDK APIs into your source code, please see the main.c code under the application directory.

    Was this page helpful?

    Was this page helpful?

    • Not at all
    • Not very helpful
    • Somewhat helpful
    • Very helpful
    • Extremely helpful
    Send Feedback