Basic Functionality

Last Updated on : 2022-11-24 09:20:18download

This topic describes the APIs used to implement the basic functionality of a gateway.

Structs

TY_IOT_APP_CBS_S

typedef struct {
    GW_APP_LOG_PATH_CB gw_app_log_path_cb;
}TY_IOT_APP_CBS_S;

Functional description

The application callback, such as requesting the locally stored logs.

Member description

Member Description
gw_app_log_path_cb For more information, see gw_app_log_path_cb.

GW_PROD_INFO_S

typedef struct {
    CHAR_T *uuid;
    CHAR_T *auth_key;
} GW_PROD_INFO_S;

Functional description

The gateway authorization information, applying to the wireless connection SDK.

Member description

Member Description
uuid The UUID string. It cannot be NULL.
auth_key The AuthKey string. It cannot be NULL.

WF_GW_PROD_INFO_S

typedef struct {
    CHAR_T *uuid;
    CHAR_T *auth_key;
    CHAR_T *ap_ssid;
    CHAR_T *ap_passwd;
} WF_GW_PROD_INFO_S;

Functional description

The gateway authorization information, applying to the wired connection SDK.

Member description

Member Description
uuid The UUID string. It cannot be NULL. Its length must be less than or equal to 16 bytes.
auth_key The AuthKey string. It cannot be NULL. Its length must be less than or equal to 32 bytes.
ap_ssid The SSID prefix. Its length must be less than or equal to 16 bytes. If it is set to NULL, the SSID prefix defaults to SmartLife-XXXX where XXXX is the MAC address.
ap_passwd Its length must be less than or equal to 16 bytes. It defaults to NULL.

GW_ATTACH_ATTR_T

typedef struct {
    /** attach ota channel */
    GW_PERMIT_DEV_TP_T tp;
    /** attach version, format xx.xx.xx */
    CHAR_T ver[SW_VER_LEN+1];
}GW_ATTACH_ATTR_T;

Functional description

The version information of the module that is connected to the gateway.

Member description

Member Description
tp The update channel. Its value must match the update channel you configure for the custom firmware on the Tuya IoT Development Platform.
ver The version number.

TY_GW_INFRA_CBS_S

typedef struct {
    VOID (*gw_reset_cb)(GW_RESET_TYPE_E type);
    VOID (*gw_reboot_cb)(VOID);
    VOID (*gw_upgrade_cb)(CONST FW_UG_S *fw);
    VOID (*gw_active_stat_cb)(GW_STATUS_E stat);
    VOID (*gw_active_url_cb)(CHAR_T *url);
} TY_GW_INFRA_CBS_S;

Functional description

The callbacks used for firmware update, reset, restart, and activation.

Member description

Member Description
gw_reset_cb For more information, see gw_reset_cb.
gw_reboot_cb For more information, see gw_reboot_cb.
gw_upgrade_cb For more information, see gw_upgrade_cb.
gw_active_stat_cb For more information, see gw_active_stat_cb.
gw_active_url_cb For more information, see gw_active_url_cb.

TY_GW_NCP_DETECT_S

typedef struct {
    GW_PERMIT_DEV_TP_T type;
    TIME_T timeout;
    GW_GET_NCP_VER_CB get_ver_cb;
} TY_GW_NCP_DETECT_S;

Functional description

Gets the version information of the module that is connected to the gateway.

Member description

Member Description
type The type of the module. Its value is associated with the update channel.
timeout The specified timeout, in seconds. If the gateway does not receive the version number of the module on a specific sub-device within the timeout period, it will not report the information of this module.
get_ver_cb A callback that reads the firmware version number. For more information, see GW_GET_NCP_VER_CB.

FW_UG_S

typedef struct {
    DEV_TYPE_T tp;
    UPGRADE_TYPE_T type;
    CHAR_T fw_url[FW_URL_LEN+1];
    CHAR_T sw_ver[SW_VER_LEN+1];
    UINT_T file_size;
    CHAR_T fw_hmac[FW_HMAC_LEN+1];
} FW_UG_S;

Functional description

The firmware update information.

Member description

Member Description
tp The type of the firmware. Its value is associated with the update channel.
type The update methods:
UPGRADE_TYPE_NORMAL: Normal update.
UPGRADE_TYPE_SILENT: Auto update.
fw_url The update download URL.
sw_ver The firmware version number.
file_size The size of the firmware update.
fw_hmac The firmware HMAC code.

API reference

tuya_os_intf_init

int tuya_os_intf_init(void)

Functional description

Initializes the OS layer of the SDK. This API must be called first after the SDK starts.

Parameter description

Parameter name Description
VOID /

Return value

Return value Description
Error code For more information about the error code, see tuya_error_code.h.

tuya_iot_init

OPERATE_RET tuya_iot_init(IN CONST CHAR_T *fs_storge_path)

Functional description

Initializes the IoT layer of the SDK. This API must be called after the tuya_os_intf_init but before other APIs.

Parameter description

Parameter name Description
fs_storge_path The storage path that must be read/write. Its length must not exceed 110 bytes.

Return value

Return value Description
Error code For more information about the error code, see tuya_error_code.h.

tuya_iot_sdk_pre_init

OPERATE_RET tuya_iot_sdk_pre_init(BOOL_T is_gw)

Functional description

Preinitializes the service layer of the SDK.

Parameter description

Parameter name Description
is_gw tuya_iot_wf_sdk_init is used to identify whether a device is a gateway product.
  • TRUE: A gateway.
  • FALSE: Not a gateway.

Return value

Return value Description
Error code For more information about the error code, see tuya_error_code.h.

tuya_iot_sdk_init

OPERATE_RET tuya_iot_sdk_init(IN CONST CHAR_T *product_key,
                              IN CONST CHAR_T *sw_ver,
							  IN CONST GW_ATTACH_ATTR_T *attr,
                              IN CONST UINT_T attr_num)

Functional description

Initializes the service layer of the SDK, applying to the wired connection SDK.

Parameter description

Parameter name Description
product_key The product ID (PID) of the product that you create on the Tuya IoT Development Platform.
sw_ver The firmware version number.
attr The version information of the module that is connected to the gateway. For more information, see GW_ATTACH_ATTR_T.
attr_num The number of connected modules that support the OTA update feature.

Return value

Return value Description
OPRT_OK Operation succeeded.
Error code For more information about the error code, see tuya_error_code.h.

tuya_iot_wf_sdk_init

OPERATE_RET tuya_iot_wf_sdk_init(IN CONST GW_WF_CFG_MTHD_SEL cfg,
                                 IN CONST GW_WF_START_MODE start_mode,
                                 IN CONST CHAR_T *product_key,IN CONST CHAR_T *sw_ver,
                                 IN CONST GW_ATTACH_ATTR_T *attr,
                                 IN CONST UINT_T attr_num)

Functional description

Initializes the service layer of the SDK, applying to the wired connection SDK.

Parameter description

Parameter name Description
cfg The Wi-Fi work mode.
start_mode The pairing mode over the wireless network.
product_key The product ID (PID) of the product that you create on the Tuya IoT Development Platform.
wf_sw_ver The firmware version number.
attr The version information of the module that is connected to the gateway. For more information, see GW_ATTACH_ATTR_T.
attr_num The number of connected modules that support the OTA update feature.

Return value

Return value Description
OPRT_OK Success
Error code For more information about the error code, see tuya_error_code.h.

tuya_iot_wired_wf_sdk_init

OPERATE_RET tuya_iot_wired_wf_sdk_init(IN CONST IOT_GW_NET_TYPE_T net_mode,
                                       IN CONST GW_WF_CFG_MTHD_SEL cfg,
                                       IN CONST GW_WF_START_MODE start_mode,
                                       IN CONST CHAR_T *product_key,
                                       IN CONST CHAR_T *sw_ver,
                                       IN CONST GW_ATTACH_ATTR_T *attr,
                                       IN CONST UINT_T attr_num)

Functional description

Initializes the service layer of the SDK, applying to the wired and wireless combo connection SDK.

Parameter description

Parameter name Description
net_mode The types of network connection:
  • IOT_GW_NET_WIRED: Wired connection.
  • IOT_GW_NET_WIFI: Wireless connection.
  • IOT_GW_NET_WIRED_WIFI: Wired and wireless combo connection.
cfg The types of Wi-Fi work mode:
  • GWCM_OLD: Standard power mode.
  • GWCM_LOW_POWER: Low-power mode.
  • GWCM_OLD_PROD: Low power and production test combo mode.
start_mode The types of pairing mode over the wireless network:
  • WF_START_AP_ONLY: AP mode only.
  • WF_START_SMART_ONLY: EZ mode only.
  • WF_START_AP_FIRST: AP mode and EZ mode are both available, with AP mode prioritized.
  • WF_START_SMART_FIRST: AP mode and EZ mode are both available, with EZ mode prioritized.
  • WF_START_SMART_AP_CONCURRENT: AP mode and EZ mode coexist.
product_key The product ID (PID) of the product that you create on the Tuya IoT Development Platform.
wf_sw_ver The firmware version number.
attr The version information of the module that is connected to the gateway. For more information, see GW_ATTACH_ATTR_T.
attr_num The number of connected modules that support the OTA update feature.

Return value

Return value Description
OPRT_OK Operation succeeded.
Error code For more information about the error code, see tuya_error_code.h.

tuya_iot_app_cbs_init

VOID tuya_iot_app_cbs_init(IN CONST TY_IOT_APP_CBS_S *app_cbs)

Functional description

Registers the application callback, such as requesting the locally stored logs.

Parameter description

Parameter name Description
app_cbs The struct containing application callback. For more information, see TY_IOT_APP_CBS_S.

Return value

Return value Description
VOID /

tuya_iot_get_sdk_info

CHAR_T *tuya_iot_get_sdk_info(VOID)

Functional description

Gets the information about the Tuya SDK for use.

Parameter description

Parameter name Description
VOID /

Return value

Return value Description
A string The SDK information includes the build time, platform, version number, and enabled features.

tuya_iot_set_gw_prod_info

OPERATE_RET tuya_iot_set_gw_prod_info(IN CONST GW_PROD_INFO_S *prod_info)

Functional description

Sets the authorization information for the wired gateway. The authorization information must be obtained from the Tuya IoT Development Platform. Otherwise, the gateway cannot work as expected. This API applies to the wired connection SDK.

Parameter description

Parameter name Description
prod_info The authorization information. For more information, see GW_PROD_INFO_S.

Return value

Return value Description
OPRT_OK Operation succeeded.
Error code For more information about the error code, see tuya_error_code.h.

tuya_iot_set_wf_gw_prod_info

OPERATE_RET tuya_iot_set_wf_gw_prod_info(IN CONST WF_GW_PROD_INFO_S *wf_prod_info)

Functional description

Sets the authorization information for the wireless gateway. The authorization information must be obtained from the Tuya IoT Development Platform. Otherwise, the gateway cannot work as expected. This API applies to the wireless connection SDK.

Parameter description

Parameter name Description
wf_prod_info The authorization information. For more information, see WF_GW_PROD_INFO_S.

Return value

Return value Description
OPRT_OK Operation succeeded.
Error code For more information about the error code, see tuya_error_code.h.

tuya_iot_gw_unactive

OPERATE_RET tuya_iot_gw_unactive(VOID);

Functional description

Unbinds the gateway locally, applying to the wired connection SDK. This API does not erase the device data.

Parameter description

Parameter name Description
VOID /

Return value

Return value Description
OPRT_OK Operation succeeded.
Error code For more information about the error code, see tuya_error_code.h.

tuya_iot_wf_gw_unactive

OPERATE_RET tuya_iot_wf_gw_unactive(VOID);

Functional description

Unbinds the gateway locally, applying to the wireless connection SDK. This API does not erase the device data.

Parameter description

Parameter name Description
VOID /

Return value

Return value Description
OPRT_OK Operation succeeded.
Error code For more information about the error code, see tuya_error_code.h.

tuya_iot_wired_wifi_gw_unactive

OPERATE_RET tuya_iot_wired_wifi_gw_unactive(VOID);

Functional description

Unbinds the gateway locally, applying to the wired and wireless combo connection SDK. This API does not erase the device data.

Parameter description

Parameter name Description
VOID /

Return value

Return value Description
OPRT_OK Operation succeeded.
Error code For more information about the error code, see tuya_error_code.h.

tuya_iot_gw_reset

OPERATE_RET tuya_iot_gw_reset(VOID);

Functional description

Unbinds the gateway locally, applying to the wired connection SDK. This API erases the device data.

Parameter description

Parameter name Description
VOID /

Return value

Return value Description
OPRT_OK Operation succeeded.
Error code For more information about the error code, see tuya_error_code.h.

tuya_iot_wf_gw_reset

OPERATE_RET tuya_iot_wf_gw_reset(VOID);

Functional description

Unbinds the gateway locally, applying to the wireless connection SDK. This API erases the device data.

Parameter description

Parameter name Description
VOID /

Return value

Return value Description
OPRT_OK Operation succeeded.
Error code For more information about the error code, see tuya_error_code.h.

tuya_iot_wired_wifi_gw_reset

OPERATE_RET tuya_iot_wired_wifi_gw_reset(VOID);

Functional description

Unbinds the gateway locally, applying to the wired and wireless combo connection SDK. This API erases the device data.

Parameter description

Parameter name Description
VOID /

Return value

Return value Description
OPRT_OK Operation succeeded.
Error code For more information about the error code, see tuya_error_code.h.

tuya_iot_sdk_reg_netstat_cb

OPERATE_RET tuya_iot_sdk_reg_netstat_cb(IN CONST SDK_GET_NW_STAT_CB nw_stat_cb,
                                        IN CONST SDK_WIRED_NW_STAT_CB wr_nw_stat_cb,
                                        IN CONST SDK_WIFI_NW_STAT_CB wf_nw_stat_cb)

Functional description

Registers the callbacks for network status management.

Parameter description

Parameter name Description
nw_stat_cb A callback to invoke when the network status changes. For more information, see SDK_GET_NW_STAT_CB.
wr_nw_stat_cb A callback to invoke when the status of the wired connection changes. For more information, see SDK_WIRED_NW_STAT_CB.
wf_nw_stat_cb A callback to invoke when the status of the wireless connection changes. For more information, see SDK_WIFI_NW_STAT_CB.

tuya_iot_set_prod_ability

VOID tuya_iot_set_prod_ability(GW_ABI abi)

Functional description

Sets the capability of the gateway. It must be called before tuya_iot_sdk_init.

Parameter description

Parameter name Description
abi The types of the gateway capability:
  • GW_VIRTUAL: The gateway cannot connect to sub-devices.
  • GW_ENTITY_ATTH_DEV: The gateway can connect to sub-devices and has its own data points.
  • GW_ENTITY: The gateway can connect to sub-devices but does not have its own data points.

Return value

Return value Description
VOID /

tuya_iot_get_gw_stat

OPERATE_RET tuya_iot_get_gw_stat(TY_GW_STAT_T *stat)

Functional description

Gets the activation state of the gateway.

Parameter description

Parameter name Description
stat The activation states:
  • GW_UNREGISTERED: Not registered.
  • GW_REGISTERED: Registered and being activated.
  • GW_ACTIVATED: Activated.
  • GW_BLE_ACTIVING: Being activated over a Bluetooth connection.
  • GW_BLE_ACTIVATED: Activated over a Bluetooth connection.

Return value

Return value Description
OPRT_OK Operation succeeded.
Error code For more information about the error code, see tuya_error_code.h.

tuya_iot_httpc_common_post

OPEROPERATE_RET tuya_iot_httpc_common_post(IN CONST CHAR_T *api_name,
                                           IN CONST CHAR_T *api_ver,
                                           IN CHAR_T *post_data,
                                           OUT ty_cJSON **pp_result)

Functional description

The HTTP POST method. It must be called after the gateway is activated.

Parameter description

Parameter name Description
api_name The API name.
api_ver The API version number.
post_data The payload.
pp_result The return result from the cloud, in JSON format.

Return value

Return value Description
OPRT_OK Operation succeeded.
Error code For more information about the error code, see tuya_error_code.h.

tuya_iot_httpc_download_file

OPERATE_RET tuya_iot_httpc_download_file(IN CONST CHAR_T *url,
                                         IN CONST UINT_T mlk_buf_len,
                                         IN CONST GW_GET_FILE_DATA_CB cb,
                                         IN PVOID_T priv_data,
                                         IN CONST UINT_T total_len,
                                         INOUT BYTE_T file_hmac[32])

Functional description

Downloads files from the cloud. It must be called after the gateway is activated.

Parameter description

Parameter name Description
url The URL.
mlk_buf_len The size of each packet when a large file is transferred in multiple packets.
cb The data reception callback.
priv_data The private data, used as the parameter of the callback.
total_len The total size of the file.
file_hmac The HMAC check value.

Return value

Return value Description
OPRT_OK Operation succeeded.
Error code For more information about the error code, see tuya_error_code.h.

tuya_iot_enable_blemesh_compatible

VOID tuya_iot_enable_blemesh_compatible(VOID)

Functional description

Enables the Bluetooth mesh capability. If you do not choose the Bluetooth mesh protocol for your gateway product, you can call this API to enable the Bluetooth mesh feature for it. It must be called after the gateway is activated.

Parameter description

Parameter name Description
VOID /

Return value

Return value Description
VOID /

tuya_iot_dev_join_permit

OPERATE_RET tuya_iot_dev_join_permit(GW_PERMIT_DEV_TP_T tp,
                                     BOOL_T permit,
                                     UINT_T timeout);

Functional description

Locally enables or disables sub-devices to join the network.

Parameter description

Parameter name Description
tp The device type.
permit Enable or disable joining the network.
timeout The specified timeout, in seconds.

Return value

Return value Description
OPRT_OK Operation succeeded.
Error code For more information about the error code, see tuya_error_code.h.

tuya_user_svc_init

OPERATE_RET tuya_user_svc_init(CONST GW_INFRA_CBS_S *cbs)

Functional description

Initializes the user services.

Parameter description

Parameter name Description
cb The struct containing the user callback. For more information, see TY_GW_INFRA_CBS_S.

Return value

Return value Description
OPRT_OK Operation succeeded.
Error code For more information about the error code, see tuya_error_code.h.

tuya_user_svc_start

OPERATE_RET tuya_user_svc_start(CONST VOID *cbs)

Functional description

Starts the user services.

Parameter description

Parameter name Description
cbs A reserved parameter. You can set it to NULL.

Return value

Return value Description
OPRT_OK Operation succeeded.
Error code For more information about the error code, see tuya_error_code.h.

tuya_user_ncp_ver_upload_reg

OPERATE_RET tuya_user_ncp_ver_upload_reg(TY_GW_NCP_DETECT_S *ncp)

Functional description

Reports the version information of the module that is connected to the gateway, which is performed asynchronously after initialization. It works for the same purpose as the attr in the tuya_iot_sdk_init. To use this API, make sure to set the attr and attr_num in tuya_iot_sdk_init to NULL and 0 respectively.

Parameter description

Parameter name Description
ncp A reserved parameter. You can set it to NULL.

Return value

Return value Description
OPRT_OK Operation succeeded.
Error code For more information about the error code, see tuya_error_code.h.

tuya_user_iot_get_gw_nw_stat

OPERATE_RET tuya_user_iot_get_gw_nw_stat(GW_NW_STAT_T *stat)

Functional description

Gets the network status of the gateway.

Parameter description

Parameter name Description
stat The network status:
  • GNS_UNVALID: No IP address is available.
  • GNS_LAN_VALID: There is an IP address but no internet connection.
  • GNS_WAN_VALID: Internet connection works fine.

Return value

Return value Description
OPRT_OK Operation succeeded.
Error code For more information about the error code, see tuya_error_code.h.

tuya_user_iot_set_gw_ext_stat

VOID tuya_user_iot_set_gw_ext_stat(IN CONST GW_EXT_STAT_T ext_stat)

Functional description

Sets the extension state of the gateway.

Parameter description

Parameter name Description
ext_stat The extension states:
  • EXT_UNAUTH: Not authenticated.
  • EXT_PROD_TEST: Production test.
  • EXT_NORMAL_S: Normal.
  • EXT_GW_UPGRD: Gateway update.
  • EXT_DEV_UPGRD: Sub-device update.
  • EXT_DEV_ADD: Add a sub-device.
  • EXT_REG_FAIL: Registration failed.
  • EXT_NET_FAIL: Network error.
  • EXT_CONFIG_BACK_UP: Backup for failover.
  • EXT_CONFIG_RESTORE: Resume with failover operation.

Return value

Return value Description
OPRT_OK Operation succeeded.
Error code For more information about the error code, see tuya_error_code.h.

tuya_user_iot_wd_common_write

OPERATE_RET tuya_user_iot_wd_common_write(IN CONST CHAR_T *key,
                                          IN CONST BYTE_T *value,
                                          IN CONST UINT_T len)

Functional description

Writes key-value pair to the database.

Parameter description

Parameter name Description
key The unique ID.
value Binary data.
len Data length.

Return value

Return value Description
OPRT_OK Operation succeeded.
Error code For more information about the error code, see tuya_error_code.h.

tuya_user_iot_wd_common_read

OPERATE_RET tuya_user_iot_wd_common_read(IN CONST CHAR_T *key,
                                         OUT BYTE_T **value,
                                         OUT UINT_T *p_len)

Functional description

Reads key-value pair from the database.

Parameter description

Parameter name Description
key The unique ID.
value Binary data. Freeing memory is necessary.
len Data length.

Return value

Return value Description
OPRT_OK Operation succeeded.
Error code For more information about the error code, see tuya_error_code.h.

tuya_user_iot_wd_common_delete

OPERATE_RET tuya_user_iot_wd_common_delete(IN CONST CHAR_T *key)

Functional description

Deletes key-value pair from the database.

Parameter description

Parameter name Description
key The unique ID.

Return value

Return value Description
OPRT_OK Operation succeeded.
Error code For more information about the error code, see tuya_error_code.h.

tuya_user_iot_set_country_code

OPERATE_RET tuya_user_iot_set_country_code(CHAR_T *country_code)

Functional description

Sets the country code.

Parameter description

Parameter name Description
country_code Follows ISO 3166-1 country code standard, such as US and CN.

Return value

Return value Description
OPRT_OK Operation succeeded.
Error code For more information about the error code, see tuya_error_code.h.

Callback functions

SDK_GET_NW_STAT_CB

typedef VOID (*SDK_GET_NW_STAT_CB)(IN CONST SDK_NW_STAT_T stat)

Functional description

A callback to invoke when the network status changes.

Parameter description

Parameter name Description
stat The network status:
  • SDK_NWK_OFFLINE: Offline.
  • SDK_NWK_ONLINE: Online.

Return value

Return value Description
VOID /

SDK_WIRED_NW_STAT_CB

typedef VOID (*SDK_WIRED_NW_STAT_CB)(IN CONST SDK_WIRED_NW_STAT_T stat)

Functional description

A callback to invoke when the status of the wired connection changes.

Parameter description

Parameter name Description
stat The status of the wired network:
  • SDK_STAT_LAN_UNCONN: Ethernet cable is connected.
  • SDK_STAT_LAN_CONN: Ethernet cable is not connected.

Return value

Return value Description
VOID /

SDK_WIFI_NW_STAT_CB

typedef VOID (*SDK_WIFI_NW_STAT_CB)(IN CONST SDK_WIFI_NW_STAT_T stat)

Functional description

A callback to invoke when the status of the wireless connection changes.

Parameter description

Parameter name Description
stat The status of the wireless network:
  • SDK_STAT_LOW_POWER: Initial status.
  • SDK_STAT_UNPROVISION: Operate in AP or EZ mode for pairing.
  • SDK_STAT_AP_STA_UNCFG: Wireless network is not configured.
  • SDK_STAT_AP_STA_DISC: Wireless network is configured but not connected, with AP and station coexisting.
  • SDK_STAT_AP_STA_CONN: Wireless network is configured and connected, with AP and station coexisting.
  • SDK_STAT_STA_DISC: Wireless network is not connected.
  • SDK_STAT_STA_CONN: Wireless network is connected.

Return value

Return value Description
VOID /

GW_GET_NCP_VER_CB

typedef OPERATE_RET (*GW_GET_NCP_VER_CB)(OUT CHAR_T *ver)

Functional description

A callback to invoke when the firmware version number of the module is read.

Parameter description

Parameter name Description
ver The firmware version number.

Return value

Return value Description
OPRT_OK Operation succeeded.
Error code For more information about the error code, see tuya_error_code.h.

gw_reset_cb

VOID gw_reset_cb(GW_RESET_TYPE_E type)

Functional description

A callback to invoke when the gateway is reset.

Parameter description

Parameter name Description
type The types of resetting:
  • GW_LOCAL_RESET_FACTORY: The gateway is reset with physical buttons and its data is erased.
  • GW_REMOTE_UNACTIVE: The gateway is reset with mobile app operation.
  • GW_LOCAL_UNACTIVE: The gateway is reset with physical buttons.
  • GW_REMOTE_RESET_FACTORY: The gateway is reset with mobile app operation and its data is erased.
  • GW_RESET_DATA_FACTORY: The data of the gateway is erased on activation.

Return value

Return value Description
VOID /

gw_reboot_cb

VOID (*gw_reboot_cb)(VOID)

Functional description

A callback to invoke when applications are restarted. You need to implement application restart in this callback.

Parameter description

Parameter name Description
VOID /

Return value

Return value Description
VOID /

gw_upgrade_cb

VOID (*gw_upgrade_cb)(CONST FW_UG_S *fw)

Functional description

A callback to invoke when an update notification is received. You need to implement the firmware update functionality in this callback.

Parameter description

Parameter name Description
fw The firmware information. For more information, see FW_UG_S.

Return value

Return value Description
VOID /

gw_active_stat_cb

VOID (*gw_active_stat_cb)(GW_STATUS_E stat)

Functional description

A callback to invoke when the gateway status changes.

Parameter description

Parameter name Description
stat The gateway status:
  • GW_RESET: The gateway is reset.
  • GW_ACTIVED: The gateway is activated.
  • GW_FIRST_START: The gateway is started for the first time.
  • GW_NORMAL: The gateway is activated and started as expected.
  • GW_BLE_ACTIVED: The gateway is activated over a Bluetooth connection.

Return value

Return value Description
VOID /

gw_active_url_cb

VOID (*gw_active_url_cb)(CHAR_T *url)

Functional description

A callback to invoke when a URL for generating a QR code is received.

Parameter description

Parameter name Description
url A URL used to generate a QR code for pairing.

Return value

Return value Description
VOID /

app_log_path_cb

VOID app_log_path_cb(OUT CHAR_T *path, IN CONST INT_T len)

Functional description

A callback to invoke when a local log request is received. You need to assign the log path to the variable path in this callback.

Parameter description

Parameter name Description
path The path buffer. Assign the log path to this variable.
len The size of the path buffer.

Return value

Return value Description
VOID /