Overview
This Tutorial provides a walk-through of available APIs to perform End Point Configuration operation using RFID3 API
This Feature is supported only with RFD40XX/90XX premium and premium plus devices.
Create The Project
- Start by creating a new project in Android Studio. For help, see the Android Studio tutorial.
- Refer Hello RFID to prepare basic setup to work with RFID Reader and then follow this guide
Saving new or Updating End Point Configuration
The application can call method reader.Config.setEndpointConfiguration to save a new or update the existing end point configuration.
public void setEndPointConfiguration(String name, ENUM_EP_TYPE type, ENUM_EP_OPERATION operation, ENUM_EP_PROTOCOL_TYPE protocol,
String url, int port, int keepAlive, String tenantId, boolean cleanSession,
int minReconnectDelay, int maxReconnectDelay, ENUM_HOST_VERIFY hostVerify, String userName,
String password, String caCertName, String certName, String keyName, String cmdTopic,
String responseTopic, String eventTopic) {
try {
EndpointConfigurationInfo endpointConfigurationInfo = new EndpointConfigurationInfo();
endpointConfigurationInfo.setEpname(name);
endpointConfigurationInfo.setType(type);
endpointConfigurationInfo.setOperation(operation); //SAVE OR UPDATE enum values based on Use case
endpointConfigurationInfo.setProtocol(protocol);
endpointConfigurationInfo.setUrl(url);
endpointConfigurationInfo.setPort(port);
endpointConfigurationInfo.setKeepalive(keepAlive);
endpointConfigurationInfo.setTenantid(tenantId);
if(cleanSession) {
endpointConfigurationInfo.setEncleanss(true);
} else {
endpointConfigurationInfo.setDscleanss(false);
}
endpointConfigurationInfo.setRcdelaymin(minReconnectDelay);
endpointConfigurationInfo.setRcdelaymax(maxReconnectDelay);
endpointConfigurationInfo.setHostvfy(hostVerify);
endpointConfigurationInfo.setUsername(userName);
endpointConfigurationInfo.setPassword(password);
/* Start of ENUM_EP_TYPE.MDM Type only params */
endpointConfigurationInfo.setCacertname(caCertName);
endpointConfigurationInfo.setCertname(certName);
endpointConfigurationInfo.setKeyname(keyName);
endpointConfigurationInfo.setSubname(cmdTopic);
endpointConfigurationInfo.setPub1name(responseTopic);
endpointConfigurationInfo.setPub2name(eventTopic);
/* End of ENUM_EP_TYPE.MDM Type only params */
RFIDResults result = reader.Config.setEndpointConfiguration(endpointConfigurationInfo);
/* Below Code is to Save the above submitted Configuration */
EndpointConfigurationInfo saveEPConfig = new EndpointConfigurationInfo();
saveEPConfig.setOperation(ENUM_EP_OPERATION.SAVE);
result = reader.Config.setEndpointConfiguration(endpointConfigurationInfo);
}catch (InvalidUsageException | OperationFailureException e) {
e.printStackTrace(); // Failure Cases Throws exception
}
}
Fetch All Saved End point Configuration Names
The application can call method reader.Config.getEndpointNames to get the list of previously saved configuration names.
public ArrayList getSavedEndPoints() {
ArrayList endpointNames = null;
try {
endpointNames = reader.Config.getEndpointNames();
} catch (InvalidUsageException | OperationFailureException e) {
e.printStackTrace(); // Failure Cases Throws exception
}
return endpointNames;
}
Fetch Saved End point Configuration
The application can call method reader.Config.getEndpointConfigByName to get the saved configuration based on provided end point configuration name.
public EndpointConfigurationInfo getEndPointConfiguration(String endPointName) {
EndpointConfigurationInfo endpointConfigurationInfo = null;
try {
endpointConfigurationInfo = reader.Config.getEndpointConfigByName(endPointName);
} catch (InvalidUsageException | OperationFailureException e) {
e.printStackTrace(); // Failure Cases Throws exception
}
return endpointConfigurationInfo;
}
Activate Saved End point Configuration
The application can call method reader.Config.activateEndpoint to activate the saved end point configuration based on provided end point configuration name.
public RFIDResults activateEndPointConfiguration(String endPointName) {
try {
IotConfigInfo iotConfigInfo = new IotConfigInfo();
iotConfigInfo.setActivemgmtep(endPointName);
return reader.Config.activateEndpoint(iotConfigInfo);
} catch (InvalidUsageException | OperationFailureException e) {
e.printStackTrace(); // Failure Cases Throws exception
}
return RFIDResults.RFID_API_UNKNOWN_ERROR;
}
Fetch Active End Point Configuration Name
The application can call method reader.Config.getActiveEndpoints to fetch the activated end point configuration.
public String getActiveEndPointName() {
try {
IotConfigInfo iotConfigInfo = reader.Config.getActiveEndpoints();
return iotConfigInfo.getActivemgmtep();
} catch (InvalidUsageException | OperationFailureException e) {
e.printStackTrace();
}
return null;
}