Skip to content

Example of Product Configuration and Quick Access

Introduction

This section explains how to configure a product and quickly connect a device to Developer Center in QuecPython solution.

FunctionDescription
Qth.init()Initializes QuecThing.
Qth.setEventCb()Sets the event callback function.
Qth.setProductInfo()Sets the product information.
Qth.start()Connects the device to Developer Center.

Note: See Product Configuration API and Device Connection API for details." />

Procedure

Operation on Developer Center

1. Log in to Developer Center

Log in to Developer Center. If you don't have an account, click Register Now to register.

2. Create a Product

For details about product creation, see Create a Product

Note: PK and PS should be in safekeeping, because they will be used for device authentication and product deletion.

Operation on Device

1. Initialize Configuration

Before development, you must initialize the project in QuecPython solution with Qth.init(). This function must be called before you use network services. Initialization means completing the basic configuration of the module after the module is powered on, enabling it to connect to the network and Developer Center and report its status.

c
/* Initialize QuecThing SDK */
Qth.init()

2. Callback Function

Registering a callback function means adding a listener task event_cb for the event source (component). When the device triggers an event, the listener will handle it automatically and the developer only needs to handle the event in event_cb under the corresponding event callback function.

c
/* Register event callback function */
eventCb={
    'devEvent':App_devEventCb, 
}
Qth.setEventCb(eventCb)

3. Configure Product Information (via First Connection)

The QuecThing SDK provides interfaces and reference implementations for reading and writing device information, which can be customized as needed. During the first connection, your device will send a bootstrap authentication request, and Developer Center will authenticate ProductKey and ProductSecret provided by the device. If the authentication succeeds, Developer Center will issue the required information for your device to connect to and access Developer Center.

c
/* Configure product information */
Qth.setProductInfo("p1xxxS", "VnhyxxxxxxxxSTFh")

4. Connect to Developer Center

The module connects to Developer Center and establishes safe and stable communication to enable device management, monitoring and control.

c
/* Connect the device to Developer Center. */
Qth.start()