Skip to content

Example of Product Configuration and Quick Access

Introduction

This section explains how to configure a product and quickly access Developer Center in QuecOpen solution.

FunctionDescription
Ql_iotInit()Initializes configurations and enables QuecThing.
Ql_iotConfigSetEventCB()Sets a callback function for device and Developer Center interaction event.
Ql_iotConfigSetProductinfo()Sets product information.
Ql_iotConfigSetConnmode()Configures the connection mode between the device and Developer Center.
Ql_iotGetWorkState()Gets the connection mode between the device and Developer Center.

Note: See Product Configuration 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 QuecOpen solution with Ql_iotInit(). This function completes the basic configuration of the module after it is powered on, enabling it to connect to the network and Developer Center and report its status.

c
/* Initialize QuecThing SDK */
Ql_iotInit();

2. Callback Function

Ql_iotEventCB() callback function is registered as a listener for a specific event on an event source (component). The function will be triggered automatically when the corresponding event is detected by the event source (component). This way, the developer does not need to constantly check for the occurrence of events, as the listening task will handle them automatically.

c
/* Register event callback function */
Ql_iotConfigSetEventCB(Ql_iotEventCB);

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*/
Ql_iotConfigSetProductinfo("p1xxxS", "VnhyxxxxxxxxSTFh");

4. Access Developer Center

The device accesses and establishes a safe and stable communication with Developer Center to enable device management, monitoring and control.

c
/* Access Developer Center */
Ql_iotConfigSetConnmode(1);

5. Query Connection Status

To confirm if the device has successfully connected to Developer Center, call Ql_iotGetWorkState() to query the connection status. If the device has connected successfully, it can communicate with Developer Center.

c
/* Get the current connection status */
QIot_state_e status = Ql_iotGetWorkState();

Connection statuses:

Response ValueDescription
0Uninitialized
1Initialized
2Authenticating
3Authenticated
4Authentication failed
5Registering
6Registered and waiting to subscribe
7Registration failed
8Subscribed and data can be sent
9Subscription failed
10Deregistering
11Deregistered
12Deregistration failed