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 QuecOpen solution.

FunctionDescription
Qth_devInit()Initializes QuecThing SDK.
Qth_configSetEventCb()Sets user event callback function.
Qth_configSetProductInfo()Sets product information.
Qth_devStart()Initiates the connection to Developer Center.
Qth_devGetStatus()Gets the device status.

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 QuecOpen solution with Qth_decInit(). 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_devInit();

2. Register 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. */
Qth_eventCb_t event_cb = {0};
event_cb.devEventCb = devEventCb;
Qth_configSetEventCb(event_cb);

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_configSetProductInfo("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_devStart();

5. Bluetooth Pairing and Wi-Fi Network Provisioning on WonderFree

  1. Log in to QuecOne with your account. On the home page, click "" in the upper right corner and select "Detect Nearby Devices" in the pop-up.
img
  1. After you enter the "Detect Nearby Devices" page, the app automatically searches for the Bluetooth devices nearby, and the detected Bluetooth devices are displayed on the page. Click "" behind the device to start network provisioning.
img
  1. Enter the Wi-Fi name and password of the current network environment (only 2.4 GHz Wi-Fi is supported now).
img
  1. Please wait patiently during network provisioning.
img
  1. After the network provisioning, the successfully added device will be displayed in the device list on the home page, as shown below.
img
  1. At the same time, the device status changes to "Online" on Acceleronix Developer Center.

img

6. Query Connection Status (Optional)

When the device has connected to Developer Center, the event will be notified to you by the registered callback function Qth_configSetEventCb(). Or you can call Qth_devGetStatus() to query the device status. If the connection has been established, the device can communicate with Developer Center.

c
/* Get the device status. */
Qth_devStatus_e status;
Qth_devGetStatus(&status);

Device statuses:

Return ValueDescription
0Network provisioning.
2Network provisioned.
3Router connected.
4Platform connected.
5Idle status