Last Updated on : 2024-11-22 02:19:32download
This topic describes how to manage an e-key.
API description
ILockEkeyManager # void getEKeyList(EKeyListParams params, IThingResultCallback<EKeyListResp> callback);
Parameters
Parameter | Description |
---|---|
params | The parameter bean for requesting the e-key list. |
params.groupId | The site ID. Pass the siteId . |
params.deviceId | The device ID of the lock. |
params.ekeyName | The name of the e-key. |
params.periodType | The type of the time range. |
params.pageNo | The page number. |
params.pageSize | The number of items returned per page. |
callback | The callback. |
Example
EKeyListParams params = new EKeyListParams();
params.groupId = siteId;
params.pageNo = 1;
params.pageSize = 20;
params.deviceId = deviceId;
ThingOSLock.getEkeyManager().getEKeyList(params, new IThingResultCallback<EKeyListResp>() {
@Override
public void onSuccess(EKeyListResp result) {
// Got ekey list successfully
}
@Override
public void onError(String errorCode, String errorMessage) {
// Failed to get ekey list
}
});
API description
ILockEkeyManager # void createPermanentEKey(PermanentEKeyCreateParams params, IThingResultCallback<EKeyResp> callback);
Parameters
Parameter | Description |
---|---|
params | The parameter bean for creating a permanent e-key. |
params.countryCode | The country code of the account logged in to the app, for example, 86 for China. |
params.deviceId | The device ID of the lock. |
params.siteId | The ID of the site to which the lock belongs. |
params.ekeyName | The name of the e-key. |
params.account | The account of the e-key, which can be a mobile phone number or an email address. |
callback | The callback. |
Example
PermanentEKeyCreateParams params = new PermanentEKeyCreateParams();
params.account = "xxx@163.com"
params.countryCode = "86";
params.ekeyName = "Test EKey Name";
params.deviceId = deviceId;
params.siteId = siteId;
ThingOSLock.getEkeyManager().createPermanentEKey(params, new IThingResultCallback<EKeyResp>() {
@Override
public void onSuccess(EKeyResp result) {
//Created permanent ekey successfully
}
@Override
public void onError(String errorCode, String errorMessage) {
//Failed to create permanent ekey
}
});
API description
ILockEkeyManager # void createPeriodicityEKey(PeriodicityEKeyCreateParams params, IThingResultCallback<EKeyResp> callback);
Parameters
Parameter | Description |
---|---|
params | The parameter bean for creating a time-limited e-key. |
params.countryCode | The country code of the account logged in to the app, for example, 86 for China. |
params.deviceId | The device ID of the lock. |
params.siteId | The ID of the site to which the lock belongs. |
params.ekeyName | The name of the e-key. |
params.account | The account of the e-key, which can be a mobile phone number or an email address. |
params.effectiveTime | The timestamp when the e-key becomes active, in milliseconds. |
params.invalidTime | The timestamp when the e-key expires, in milliseconds. |
params.workingDay | The schedule, a 7-bit string, with each bit being either 0 or 1 . 0 indicates the schedule is off, while 1 indicates it is on. The bits from left to right represent Sunday through Saturday. |
params.startMinuteFormat | The start time for access, a string in the format of hh:mm . For example, 03:30 indicates the e-key becomes active at 03:30. |
params.endMinuteFormat | The end time for access, a string in the format of hh:mm . For example, 18:30 indicates the e-key becomes inactive at 18:30. |
callback | The callback. |
Example
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
PeriodicityEKeyCreateParams params = new PeriodicityEKeyCreateParams();
params.account = "xxx@163.com";
params.countryCode = "86";
params.ekeyName = "Account name";
params.deviceId = deviceId;
params.siteId = siteId;
try {
params.effectiveTime = dateFormat.parse("2023-03-01 10:00:00").getTime();
params.invalidTime = dateFormat.parse("2024-01-02 18:00:00").getTime();
} catch (ParseException e) {
}
params.startMinuteFormat = startTimeEditText.getText().toString().trim();
params.endMinuteFormat = endTimeEditText.getText().toString().trim();
params.workingDay = getWorkingDay();
ThingOSLock.getEkeyManager().createPeriodicityEKey(params, new IThingResultCallback<EKeyResp>() {
@Override
public void onSuccess(EKeyResp result) {
//Created time-limited ekey successfully
}
@Override
public void onError(String errorCode, String errorMessage) {
//Failed to create time-limited ekey
}
});
API description
ILockEkeyManager # void createOnceEKey(OnceEKeyCreateParams params, IThingResultCallback<EKeyResp> callback);
Parameters
Parameter | Description |
---|---|
params | The parameter bean for creating a one-time e-key. |
params.countryCode | The country code of the account logged in to the app, for example, 86 for China. |
params.deviceId | The device ID of the lock. |
params.siteId | The ID of the site to which the lock belongs. |
params.ekeyName | The name of the e-key. |
params.account | The account of the e-key, which can be a mobile phone number or an email address. |
callback | The callback. |
Example
OnceEKeyCreateParams params = new OnceEKeyCreateParams();
params.account = "xxx@163.com";
params.countryCode = "86";
params.ekeyName = "Once EKey name";
params.deviceId = deviceId;
params.siteId = siteId;
ThingOSLock.getEkeyManager().createOnceEKey(params, new IThingResultCallback<EKeyResp>() {
@Override
public void onSuccess(EKeyResp result) {
//Created one-time ekey successfully
}
@Override
public void onError(String errorCode, String errorMessage) {
//Failed to create one-time ekey
}
});
API description
ILockEkey # void getEKeyDetail(IThingResultCallback<EKeyBean> callback);
Parameters
Parameter | Description |
---|---|
callback | The callback. |
Example
ThingOSLock.newEKeyInstance(siteId, deviceId, ekeyId).getEKeyDetail(new IThingResultCallback<EKeyBean>() {
@Override
public void onSuccess(EKeyBean result) {
//Got ekey details successfully
}
@Override
public void onError(String errorCode, String errorMessage) {
//Failed to get ekey details
}
});
API description
ILockEkey # void updateEKey(EKeyUpdateParams params, IThingResultCallback<Boolean> callback);
Parameters
Parameter | Description |
---|---|
params | The parameter bean for modifying e-key information. |
params.deviceId | The device ID of the lock. |
params.groupId | The ID of the site to which the lock belongs. |
params.ekeyId | The ID of the e-key. |
params.ekeyName | The name of the e-key. |
params.effectiveTime | The timestamp when the e-key becomes active, in milliseconds. |
params.invalidTime | The timestamp when the e-key expires, in milliseconds. |
params.workingDay | The schedule, a 7-bit string, with each bit being either 0 or 1 . 0 indicates the schedule is off, while 1 indicates it is on. The bits from left to right represent Sunday through Saturday. |
params.startMinute | The start timestamp for access. It is calculated as: hours × 60 + minutes. For example, for 03:30, it would be 3 × 60 + 30 = 210. |
params.endMinute | The end timestamp for access. It is calculated as: hours × 60 + minutes. For example, for 23:59, it would be 23 × 60 + 59 = 1,439. |
callback | The callback. |
Example
EKeyUpdateParams params =...
ThingOSLock.newEKeyInstance(siteId, deviceId, ekeyId).updateEKey(params, new IThingResultCallback<Boolean>() {
@Override
public void onSuccess(Boolean result) {
//Updated ekey successfully
}
@Override
public void onError(String errorCode, String errorMessage) {
//Failed to update ekey
}
});
API description
ILockEkeyManager # void removeEKey(long siteId,String deviceId, String eKeyId, IThingResultCallback<Boolean> callback);
Parameters
Parameter | Description |
---|---|
siteId | The site ID. |
deviceId | The device ID of the lock. |
ekeyId | The ID of the e-key. |
callack | The callback. |
Example
ThingOSLock.getEkeyManager().removeEKey(siteId, deviceId, ekeyId, new IThingResultCallback<Boolean>() {
@Override
public void onSuccess(Boolean result) {
//Removed ekey successfully
}
@Override
public void onError(String errorCode, String errorMessage) {
//Failed to remove ekey
}
});
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback