Configuring Login Parameters

API Function

This API is used to set the parameters required for device connection.

API Description

1
public static boolean setConfig(int key, String value);

Class

LoginConfig

Parameter Description

Parameter

Mandatory or Optional

Type

Description

key

Mandatory

int

Configuration items used for device connection.

  • Device ID: LoginConfig.LOGIN_CONFIG_DEVICEID
  • AppId: LoginConfig.LOG IN_CONFIG_APPID
  • Secret: LoginConfig.LOGIN_CONFIG_SECRET
  • HTTP address: LoginConfig.LOGIN_CONFIG_IOCM_ADDR
  • HTTP port: LoginConfig.LOGIN_CONFIG_IOCM_PORT
  • MQTT address: LoginConfig.LOGIN_CONFIG_MQTT_ADDR
  • MQTT port: LoginConfig.LOGIN_CONFIG_MQTT_PORT

value

Mandatory

String

Value of each configuration item.

  • Device ID: obtained from the callback returned after the device is bound successfully
  • Application ID: obtained from the callback returned after the device is bound successfully
  • Secret: obtained from the callback returned after the device is bound successfully
  • HTTP address: access address for the AgentLite to connect to the platform
  • HTTP port: 8943
  • MQTT address: access address for the AgentLite SDK to connect to the platform
  • MQTT port: 8883

Return Value

Return Value

Description

true

Success

false

Failure

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
// Configure device connection. (deviceID, secret, and appID are the parameters returned after the device is bound.)
private void configLoginPara() {
    LoginConfig.setConfig(LoginConfig.LOGIN_CONFIG_DEVICEID, GatewayInfo.getDeviceID());
    LoginConfig.setConfig(LoginConfig.LOGIN_CONFIG_APPID, GatewayInfo.getAppID());
    LoginConfig.setConfig(LoginConfig.LOGIN_CONFIG_SECRET, GatewayInfo.getSecret());
    LoginConfig.setConfig(LoginConfig.LOGIN_CONFIG_IOCM_ADDR, GatewayInfo.getHaAddress());
    LoginConfig.setConfig(LoginConfig.LOGIN_CONFIG_IOCM_PORT, "8943");
    LoginConfig.setConfig(LoginConfig.LOGIN_CONFIG_MQTT_ADDR, GatewayInfo.getHaAddress());
    LoginConfig.setConfig(LoginConfig.LOGIN_CONFIG_MQTT_PORT, "8883");
}