Skip to content

Network Provisioning API

API Overview

FunctionDescription
Qth_wifiOpenNetcfg()Enables network provisioning.
Qth_wifiCloseNetcfg()Disables network provisioning.
Qth_wifiGetCfgStatus()Gets Wi-Fi network provisioning status.

Note: See Product Configuration API for the details about Wi-Fi information configuration.

API Description

Qth_wifiOpenNetcfg

This function enables network provisioning.

Prototype

c
oprt_ret Qth_wifiOpenNetcfg(Qth_wifiConfigMode_e mode);

Parameter

  • Input Parameter

    • Qth_wifiConfigMode mode: Network provisioning mode.
      ValueDescription
      QTH_WIFI_CFGMODE_SLIENTIdle mode (The device enters idle mode after network provisioning fails.)
      QTH_WIFI_CFGMODE_BACKROUTEReconnect mode (The device attempts to reconnect to the previous router after network provisioning fails; if unsuccessful, enter idle mode.)
  • Output Parameter

  • None

  • Return Value

    • OPRT_OK: Successful execution
    • Other values: Failed execution. See Error Code List for details.

Example

c
oprt_ret ret = OPRT_OK;
ret = Qth_wifiOpenNetcfg(QTH_WIFI_CFGMODE_SLIENT);
if (OPRT_OK != ret)
{
    Quos_logPrintf(APPS_OPEN, LL_ERR, "open wifi netcfg error");
}

Qth_wifiCloseNetcfg

This function disables network provisioning.

Prototype

c
oprt_ret Qth_wifiCloseNetcfg(void);

Parameter

  • Input Parameter

    • None
  • Output Parameter

    • None
  • Return Value

    • OPRT_OK: Successful execution
    • Other values: Failed execution. See Error Code List for details.

Example

c
oprt_ret ret = OPRT_OK;
Qth_wifiOpenNetcfg();
Qhal_system_sleepMs(10000);
ret = Qth_wifiCloseNetcfg();
if (OPRT_OK != ret)
{
    Quos_logPrintf(APPS_OPEN, LL_ERR, "close wifi netcfg error");
}

Qth_wifiGetCfgStatus

This function gets Wi-Fi network provisioning status.

Prototype

c
Qth_wifiConfigStatus_e Qth_wifiGetCfgStatus(void);

Parameter

  • Input Parameter

  • None

  • Output Parameter

  • None

  • Return Value

    ValueDescription
    QTH_WIFI_CFGSTA_NOT_CONFIGWi-Fi network unprovisioned
    QTH_WIFI_CFGSTA_CONFIGINGWi-Fi network provisioning
    QTH_WIFI_CFGSTA_ALREADY_CONFIGWi-Fi network provisioned

Example

c
Qth_wifiConfigStatus_e status;
status = Qth_wifiGetCfgStatus();
Quos_logPrintf(APPS_OPEN, LL_DBG, "status:%d", status);

Error Code List

Enumeration ValueHexadecimalDecimalDescription
OPRT_OK-0x0000-0Successful execution.
OPRT_COM_ERROR-0x0001-1General error.
OPRT_INVALID_PARM-0x0002-2Invalid parameter.
OPRT_MALLOC_FAILED-0x0003-3Memory allocation failed.
OPRT_NOT_SUPPORTED-0x0004-4Not supported.
OPRT_NOT_FOUND-0x0005-5Object not found.
OPRT_INDEX_OUT_OF_BOUND-0x0006-6Index out of bounds.
OPRT_EXCEED_UPPER_LIMIT-0x0007-7Exceed upper limit.
OPRT_NOT_EXIST-0x0008-8Not exist.
OPRT_QTH_WIFI_OPEN_NETCFG_FAILED-0x1c00-7168Failed to enable Wi-Fi network provisioning.
OPRT_QTH_WIFI_CONN_ROUTER_FAILED-0x1c01-7169Failed to connect to the router.
OPRT_QTH_WIFI_ROUTER_DISCONNECTED-0x1c02-7170Router disconnected.