Connecting a Device
API Function
This API is used to connect a device to the IoT platform after the device is bound to the IoT platform for the first time or the device restarts.
API Description
1 |
public static boolean login();
|
Class
LoginService
Parameter Description
N/A
Return Value
Return Value |
Description |
---|---|
true |
Success |
false |
Failure |
Return values only show API calling results. For example, the return value true indicates that the API is called successfully but does not indicate that the login is successful. The login is successful only after the LoginService broadcast is received. Before login, the API for Setting Service Parameters (LoginConfig.setConfig) is used to transfer the required login information.
Example
Call this API to connect a device to the IoT platform.
1 |
LoginService.login();
|
Implement the observer API provided by the AgentLite before calling this API.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
public class AgentliteLogin implements MyObserver {
public AgentliteLogin (Observable loginService) {
loginService. registerObserver (this);
}
//Override the update method in the AgentliteLogin.
@Override
public void update(IotaMessage arg0) {
// TODO Auto-generated method stub
System.out.println("LoginManager receives a notification:" + arg0)
int mMsgType = arg0.getMsgType();
switch(mMsgType) {
case 1:
loginResultAction(arg0);
break;
case 2:
logoutResultAction(arg0);
break;
default:
break;
}
}
|
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot