Help Center > > API Reference> AgentLite API Reference (Android)> APIs> Access of Directly Connected Devices> Configuring Parameters> Setting Service Parameters

Setting Service Parameters

Updated at: Aug 28, 2019 GMT+08:00

API Function

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

API Description

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

Class

LoginConfig

Parameter Description

Parameter

Mandatory or Optional

Type

Description

key

Mandatory

int

Specifies the configuration items for device login.

  • Device ID: LoginConfig.LOGIN_CONFIG_DEVICEID
  • Application ID: LoginConfig.LOGIN_CONFIG_APPID
  • Password: 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

Specifies the values of the configuration items.

  • Device ID: obtained from the broadcast that indicates the device is bound successfully.
  • Application ID: obtained from the broadcast that indicates the device is bound successfully.
  • Secret: obtained from the broadcast that indicates the device is bound successfully.
  • HTTP address: address for the AgentLite to interwork with the IoT platform
  • HTTP port: 8943
  • MQTT address: address for the AgentLite to interwork with the IoT platform
  • MQTT port: 8883

Return Value

Return Value

Description

true

Success

false

Failure

Output

N/A

Example

Save the parameters carried in the device binding response.

1
2
3
4
5
6
7
8
9
private void saveBindPara(IotaMessage iotaMsg) { 
    LogUtil.i(this, TAG, "saveBindParaAndGotoLogin"); 
    String appId = iotaMsg.getString(BindService.BIND_IE_APPID); 
    String deviceId = iotaMsg.getString(BindService.BIND_IE_DEVICEID); 
    String secret = iotaMsg.getString(BindService.BIND_IE_DEVICESECRET); 
    String haAddress = AgentLiteUtil.get(ConfigName.platformIP); 

    saveGatewayInfo(appId, deviceId, secret, haAddress, null); 
} 

Set the parameters for device login.

1
2
3
4
5
6
7
8
9
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"); 
}

Did you find this page helpful?

Submit successfully!

Thank you for your feedback. Your feedback helps make our documentation better.

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel