Gateway Service

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

This topic describes the gateway service APIs that are used to implement features for your gateway product.

API list

Function name Description
user_svc_init Initializes the gateway.
oem_set Sets the OEM mode. The OEM mode setting depends on your firmware.
gen_gw_attr Sets the attributes of the gateway.
iot_sdk_pre_init Pre-initializes the gateway.
iot_wired_wf_sdk_init Initializes the IoT SDK for wired and wireless network.
iot_wf_sdk_init Initializes device pairing over a wireless network.
iot_sdk_reg_net_stat_cb Sets a network status listener.
user_svc_start Starts the gateway service.
gw_supprot_wired_wifi Checks if the SDK supports pairing over both the wired and wireless networks.
iot_sdk_init Initializes the IoT SDK.
gw_dev_report_dp_stat_sync_extend Uploads the data point (DP) information.
iot_get_gw_id Gets the gateway ID.
native_upgradeDownload Starts a firmware update.
gw_user_token_bindnd Binds with a token.
gwResetCallBack Gateway reset callback.
gwRebootCallBack Gateway restart callback.
onUpgradeInfo Gets invoked when the SDK receives a firmware update request.
onUpgradeDownloadStart Starts downloading the updates.
onUpgradeDownloadUpdate Syncs the progress of the update download.
upgradeFileDownloadFinished Gets invoked when the update download is finished.
gwActiveUrlCallBack Gateway pairing callback.
gwActiveStatusCallBack Gateway activation callback.
onGetIP Returns the IP of the network interface.
isOffline Returns the connection status of the gateway.
getNwkStatCallBack Wired network status callback.
getWifiNwkStatCallBack Wireless network status callback.

API description

user_svc_init

Function prototype

fun user_svc_init(gwListener: GwListener.GwInfraListener): Int

Function description

Initializes the gateway.

Parameter description

Parameter name Description
gwListener Gateway operation callback

Return value

Return value Description
0 Success
Other values Failure

oem_set

Function prototype

external fun oem_set()

Function description

Sets the OEM mode. The OEM mode setting depends on your firmware.

gen_gw_attr

Function prototype

fun gen_gw_attr(userModelList: List<UserModel>)

Function description

Sets the attributes of the gateway.

Parameter description

Parameter name Description
userModelList usermodel array

iot_sdk_pre_init

Function prototype

external fun iot_sdk_pre_init(): Int

Function description

Pre-initializes the gateway.

Return value

Return value Description
0 Success
Other values Failure

iot_wired_wf_sdk_init

Function prototype

fun iot_wired_wf_sdk_init(
        net_mode: DataEnum.IOT_GW_NET_TYPE_T,
        cfg: DataEnum.GW_WF_CFG_MTHD_SEL,
        start_mode: DataEnum.GW_WF_START_MODE,
        pid: String,
        version: String
    ): Int

Function description

Initializes the IoT SDK for wired and wireless network.

Parameter description

Parameter name Description
net_mode DataEnum.IOT_GW_NET_TYPE_T type
cfg DataEnum.GW_WF_CFG_MTHD_SEL
start_mode DataEnum.GW_WF_START_MODE
pid The PID of the product
version Th version number

Return value

Return value Description
0 Success
Other values Failure

iot_wf_sdk_init

Function prototype

fun iot_wf_sdk_init(
        cfg: DataEnum.GW_WF_CFG_MTHD_SEL, start_mode: DataEnum.GW_WF_START_MODE,
        pid: String, version: String
    ): Int

Function description

Initializes device pairing over a wireless network.

Parameter description

Parameter name Description
cfg DataEnum.GW_WF_CFG_MTHD_SEL
start_mode DataEnum.GW_WF_START_MODE
pid The PID of the product
version The version number

Return value

Return value Description
0 Success
Other values Failure

iot_sdk_reg_net_stat_cb

Function prototype

fun iot_sdk_reg_net_stat_cb(gwNwkStatusLsitener: GwListener.GwNwkStatusLsitener): Int

Function description

Sets a network status listener.

Return value

Return value Description
0 Success
Other values Failure

user_svc_start

Function prototype

external fun user_svc_start(): Int

Function description

Starts the gateway service.

Return value

Return value Description
0 Success
Other values Failure

gw_supprot_wired_wifi

Function prototype

external fun gw_supprot_wired_wifi(): Int

Function description

Checks if the SDK supports pairing over both the wired and wireless networks.

Return value

Return value Description
1 Supported
0 Not supported

iot_sdk_init

Function prototype

external fun iot_sdk_init(pid: String, version: String): Int

Function description

Initializes the IoT SDK.

Parameter description

Parameter name Description
pid The PID of the product
version The version number

Return value

Return value Description
0 Success
Other values Failure

gw_dev_report_dp_stat_sync_extend

Function prototype

gw_dev_report_dp_stat_sync_extend

Function description

Uploads the data point (DP) information.

Parameter description

Parameter name Description
devId The device ID.
dataPoint A collection of DPs.
timeout The timeout period.

Return value

Return value Description
true Turn on audio playing.
false Turned off audio playing.

iot_get_gw_id

Function prototype

external fun iot_get_gw_id(): String

Function description

Get the deviceId.

Return value

Return value Description
deviceId The device ID

native_upgradeDownload

Function prototype

external fun native_upgradeDownload(path: String)

Function description

Starts a firmware update.

Parameter description

Parameter name Description
path The URL to download the updates

gw_user_token_bindnd

Function prototype

fun gw_user_token_bindnd(token:String)

Function description

Binds with a token.

Parameter description

Parameter name Description
token The token used for activating a device

Return value

Return value Description
0 Success
Other values Failure

gwResetCallBack

Function prototype

fun gwResetCallBack(type: DataEnum.GW_RESET_TYPE_E)

Function description

Gateway reset callback.

Parameter description

Parameter name Description
type GW_RESET_TYPE_E

gwRebootCallBack

Function prototype

fun gwRebootCallBack()

Function description

Gateway restart callback.

onUpgradeInfo

Function prototype

fun onUpgradeInfo(version: String)

Function description

Gets invoked when the SDK receives a firmware update request.

Parameter description

Parameter name Description
version The version number

onUpgradeDownloadStart

Function prototype

fun onUpgradeDownloadStart()

Function description

Starts downloading the updates.

onUpgradeDownloadUpdate

Function prototype

fun onUpgradeDownloadUpdate(progress: Int)

Function description

Syncs the progress of the update download.

Parameter description

Parameter name Description
progress The value of the download progress ranges from 0 to 100.

upgradeFileDownloadFinished

Function prototype

fun upgradeFileDownloadFinished(success: Boolean)

Function description

Gets invoked when the update download is finished.

Parameter description

Parameter name Description
success
  • true: Download succeeded.
  • false: Download failed.

gwActiveUrlCallBack

Function prototype

fun gwActiveUrlCallBack(url: String)

Function description

Gateway pairing callback.

Parameter description

Parameter name Description
url The URL of the QR code

gwActiveStatusCallBack

Function prototype

fun gwActiveStatusCallBack(status: DataEnum.GW_STATUS_E)

Function description

Gateway activation callback.

Parameter description

Parameter name Description
status GW_STATUS_E

onGetIP

Function prototype

fun onGetIP():String

Function description

Returns the IP of the network interface.

Return value

Return value Description
string Returns the IP of the network interface.

isOffline

Function prototype

fun isOffline(): Boolean

Function description

Returns the connection status of the gateway.

Return value

Return value Description
Boolean
  • true: offline
  • false: online

getNwkStatCallBack

Function prototype

fun getNwkStatCallBack(status: Int)

Function description

Wired network status callback.

Parameter description

Parameter name Description
status
  • 0: offline
  • 1: online

getWifiNwkStatCallBack

Function prototype

fun getWifiNwkStatCallBack(status: Int)

Function description

Wireless network status callback.

Parameter description

Parameter name Description
status
  • 0: offline
  • 1: online