On Premise JAR User Manual
Contents
- 1 Instruction
1 Instruction
This manual describes the methods provided by the On Premise JAR (TTLockUtil). The utility classes are in the com.ttlock.util package:
TTLockUtil: lock-related utilities, including creating PIN codes, creating eKeys, getting lock info, updating lock data, generating unlock QR codes, etc.HotelUtil: hotel-related utilities, including creating a hotel, getting hotel info and getting the IC Key.
General notes:
- The
lockDataparameter of all methods must be generated by the APP SDK on premise after adding a lock, otherwise anIllegalArgumentExceptionis thrown. - All time parameters (startTime, endTime, etc.) are timestamps in milliseconds.
1.1 Create PIN code
1.1.1 TTLockUtil.createPIN
public static String createPIN(String lockData, Integer type, Long startTime, Long endTime, boolean isExclusive)Create a keyboard PIN code. The time is calibrated according to the lock's timezone: if the start time and end time are on the same day, they are floored to half an hour; otherwise they are floored to the hour.
1.1.2 Parameter Description
| Name | Type | Description |
|---|---|---|
| lockData | String | Lock data |
| KeyboardPwdType | Int | Values listed in the table below |
| startTime | Long | Start time |
| endTime | Long | End time |
| isExclusive | Boolean | Clear former used pin after used |
KeyboardPwdType values:
| Value | Code | Description |
|---|---|---|
| One Time | 1 | This code only valid for once within 6 hours from the Start Time |
| Permanent | 2 | This code must be used at least once within 24 Hours after the Start Time, Or it will be invalidated. |
| Timed | 3 | This code must be used at least once within 24 Hours after the Start Time, Or it will be invalidated. |
| Delete all | 4 | This code will delete all other codes |
| Weekend recurring | 5 | This code is valid during the time period at the weekend |
| Daily recurring | 6 | This code is valid during the time period everyday |
| Workday recurring | 7 | This code is valid during the time period on workdays |
| Mon recurring | 8 | This code is valid during the time period on Mondays |
| Tue recurring | 9 | This code is valid during the time period on Tuesdays |
| Wed recurring | 10 | This code is valid during the time period on Wednesdays |
| Thu recurring | 11 | This code is valid during the time period on Thursdays |
| Fri recurring | 12 | This code is valid during the time period on Fridays |
| Sat recurring | 13 | This code is valid during the time period on Saturdays |
| Sun recurring | 14 | This code is valid during the time period on Sundays |
1.1.3 Return
| Parameter | Type | Description |
|---|---|---|
| KeyboardPwd | String | PIN code |
1.2 Create ekey
1.2.1 TTLockUtil.createEkey
public static String createEkey(String lockData, Long startTime, Long endTime, Integer userID, boolean isAdmin)Create an eKey. The returned eKey data can be passed to the APP SDK for Bluetooth unlocking.
Note: the old 4-parameter method
createEkey(String lockData, Long startTime, Long endTime, Integer userID)is deprecated (@Deprecated). The eKey it creates has management rights by default. Use the new method with theisAdminparameter instead.
1.2.2 Parameter Description
| Name | Type | Description |
|---|---|---|
| lockData | String | Lock data |
| startTime | Long | Start time |
| endTime | Long | End time |
| userID | Int | User ID, identify users |
| isAdmin | Boolean | Whether the eKey is for an administrator. true: the eKey has management rights for the lock; false: a normal user eKey, which does not contain the admin code, PIN data or other management information |
1.2.3 Return
| Parameter | Type | Description |
|---|---|---|
| eKey | String | Ekey data |
1.3 Get admin code
1.3.1 TTLockUtil.getAdminCode
public static String getAdminCode(String lockData)1.3.2 Parameter Description
| Name | Type | Description |
|---|---|---|
| lockData | String | Lock data |
1.3.3 Return
| Parameter | Type | Description |
|---|---|---|
| noKeyPwd | String | Admin PIN code |
1.4 Create PIN code With Index
1.4.1 TTLockUtil.createPINWithIndex
public static String createPINWithIndex(String lockData, Integer type, Long startTime, Long endTime, boolean isExclusive, int index)Same as createPIN, with an extra index parameter to create different One Time / Permanent PIN codes for the same hour.
1.4.2 Parameter Description
| Name | Type | Description |
|---|---|---|
| lockData | String | Lock data |
| keyboardPwdType | Int | Values listed in the table below |
| startTime | Long | Start time |
| endTime | Long | End time |
| isExclusive | Boolean | Clear former used pin after used |
| index | Int | Index, begin at 0, available to One Time and Permanent pin type,create different pin code for the same hour. |
keyboardPwdType values:
| Value | Code | Description |
|---|---|---|
| One Time | 1 | This code only valid for once within 6 hours from the Start Time |
| Permanent | 2 | This code must be used at least once within 24 Hours after the Start Time, Or it will be invalidated. |
| Timed | 3 | This code must be used at least once within 24 Hours after the Start Time, Or it will be invalidated. |
| Delete all | 4 | This code will delete all other codes |
| Weekend recurring | 5 | This code is valid during the time period at the weekend |
| Daily recurring | 6 | This code is valid during the time period everyday |
| Workday recurring | 7 | This code is valid during the time period on workdays |
| Mon recurring | 8 | This code is valid during the time period on Mondays |
| Tue recurring | 9 | This code is valid during the time period on Tuesdays |
| Wed recurring | 10 | This code is valid during the time period on Wednesdays |
| Thu recurring | 11 | This code is valid during the time period on Thursdays |
| Fri recurring | 12 | This code is valid during the time period on Fridays |
| Sat recurring | 13 | This code is valid during the time period on Saturdays |
| Sun recurring | 14 | This code is valid during the time period on Sundays |
1.4.3 Return
| Parameter | Type | Description |
|---|---|---|
| keyboardPwd | String | PIN code |
1.5 Update lock timezone
When the lock is moved to a place with a new timezone, or enter light saving time, you can call this method to update the lock timezone.
1.5.1 TTLockUtil.updateTimezone
public static String updateTimezone(String lockData, int timezoneRawOffset)After updating, calibrate the lock clock with the returned new lockData via the APP SDK.
1.5.2 Parameter Description
| Name | Type | Description |
|---|---|---|
| lockData | String | Lock data |
| timezoneRawOffset | Int | Timezone raw offset,in milliseconds,for example:3600000 for UTC+1 |
1.5.3 Return
| Parameter | Type | Description |
|---|---|---|
| lockData | String | lockData with new timezone |
1.6 Update lock data
After modifying lock settings (such as enabling remote unlocking, upgrading lock firmware, resetting ekeys, or resetting passwords) via the APP SDK, the SDK will return updated lock data containing the modified parameters. This method is used to update the new parameters into the lock data, and the developer’s system can saves the updated lock data for subsequent operations.
1.6.1 TTLockUtil.updateLockData
public static String updateLockData(String lockData, String newLockData)The following properties are renewed from newLockData (only when present):
lockFlagPos: new flag position after resetting eKeyspwdInfo,timestamp: new PIN data after resetting passcodesfeatureValue: lock feature valuemodelNum,hardwareRevision,firmwareRevision: model number, hardware version and firmware version after a firmware upgrade
1.6.2 Parameter Description
| Name | Type | Description |
|---|---|---|
| lockData | String | Lock data |
| newLockData | String | The lock data returned by the APP SDK containing the modified parameters |
1.6.3 Return
| Parameter | Type | Description |
|---|---|---|
| lockData | String | New lockData |
1.7 Create hotel
1.7.1 HotelUtil.createHotel
public static String createHotel()Create a hotel with a randomly generated hotel number, IC Key and AES key, and return the hotel data. The developer's system should save the hotel data for subsequent operations.
1.7.2 Parameter Description
| Name | Type | Description |
|---|---|---|
| None | - | No parameters |
1.7.3 Return parameters
| Parameter | Type | Description |
|---|---|---|
| hotelData | String | Hotel Data |
1.8 Get hotel info
1.8.1 HotelUtil.getHotelInfo
public static String getHotelInfo(String hotelData)Get the hotel info, which is used to add hotel locks in the APP SDK. Throws IllegalArgumentException if the hotelData is invalid.
1.8.2 Parameter Description
| Name | Type | Description |
|---|---|---|
| hotelData | String | Hotel Data |
1.8.3 Return parameters
| Parameter | Type | Description |
|---|---|---|
| hotelInfo | String | Hotel info |
1.9 Get IC Key
1.9.1 HotelUtil.getIcKey
public static String getIcKey(String hotelData)Get the IC Key of the hotel, used for hotel IC card operations. Throws IllegalArgumentException if the hotelData is invalid.
1.9.2 Parameter Description
| Name | Type | Description |
|---|---|---|
| hotelData | String | Hotel Data |
1.9.3 Return parameters
| Parameter | Type | Description |
|---|---|---|
| icKey | String | IC Key |
1.10 Get Lock info
1.10.1 TTLockUtil.getLockInfo
public static LockInfo getLockInfo(String lockData) throws ExceptionParse the lock information from lockData, returns a com.ttlock.api.entity.LockInfo object.
1.10.2 Parameter Description
| Name | Type | Description |
|---|---|---|
| lockData | String | Lock Data |
1.10.3 Return parameters
| Parameter | Type | Description |
|---|---|---|
| lockInfo | LockInfo | Lock info object |
Fields in LockInfo Object:
| Field Name | Type | Description |
|---|---|---|
| lockMac | String | MAC address of lock |
| lockName | String | Bluetooth device name of lock |
| electricQuantity | int | Battery level, range [0-100]; -1 means unknown |
| noKeyPwd | String | Administrator keyboard PIN code |
| featureValue | String | Lock feature value, represents supported lock functions |
| wirelessKeypadFeatureValue | String | Wireless keypad feature value, default "0" |
| timezoneRawOffSet | Long | Time zone offset relative to UTC, unit: milliseconds |
| modelNum | String | Lock product model number |
| hardwareRevision | String | Hardware version number |
| firmwareRevision | String | Firmware version number |
| passageMode | Integer | Passage mode: 1-enabled, 2-disabled |
| passageModeAutoUnlock | Integer | Passage-mode auto unlock:1-enabled,2-disabled |
| autoLockTime | Integer | Auto-lock delay in seconds; -1 means auto-lock disabled |
| factoryDate | String | Lock factory production date |
| isFrozen | Integer | Lock frozen status:1-frozen,2-not frozen |
| lightingTime | Integer | Auto-lighting duration(seconds);0-disabled;-1-unknown |
| hotelMode | Integer | Hotel mode:1-enabled,2-disabled |
| privacyLock | Integer | Privacy lock switch:0-unknown,1-on,2-off |
| resetButton | Integer | Reset button switch:0-unknown,1-enabled,2-disabled |
| tamperAlert | Integer | Tamper alert switch:0-unknown,1-enabled,2-disabled |
| displayPasscode | Integer | Screen passcode display switch:0-unknown,1-on,2-off |
| lockSound | Integer | Lock prompt sound switch:0-unknown,1-on,2-off |
| soundVolume | Integer | Speaker volume level:1-5;0-unknown |
| openDirection | Integer | Door opening direction:0-unknown,1-left-opening,2-right-opening |
| sensitivity | Integer | Lock sensor sensitivity:-1-unknown,0-disabled,1-low,2-medium,3-high |
| doorNotClosedWarningTime | Integer | Door-not-closed alarm delay(seconds);0-disable alarm |
| passcodeKeyNumber | Integer | Number of numeric keys for incomplete-digit password lock; null for ordinary locks |
| doubleVerification | Integer | Dual-verification mode:1-enabled,2-disabled |
| latchBolt | Integer | Latch-bolt control:0-unknown,1-support control,2-no control |
| faceImageSize | int | Maximum face photo size, unit: KB |
| faceImageHeight | int | Face photo height, unit: pixel |
| faceImageWidth | int | Face photo width, unit: pixel |
| faceImageType | int | Face photo image type, 1 represents JPG format |
1.11 Get lock MAC
1.11.1 TTLockUtil.getMac
public static String getMac(String lockData)Get the Bluetooth MAC address of the lock from lockData.
1.11.2 Parameter Description
| Name | Type | Description |
|---|---|---|
| lockData | String | Lock data |
1.11.3 Return parameters
| Parameter | Type | Description |
|---|---|---|
| lockMac | String | Bluetooth MAC address of the lock, e.g. B4:99:4C:67:96:79 |
1.12 Update admin code
1.12.1 TTLockUtil.updateAdminCode
public static String updateAdminCode(String lockData, String adminCode)When the admin code of the lock has been changed in the lock, call this method to renew the lockData with the new admin code. The developer's system should save the new lockData for subsequent operations.
1.12.2 Parameter Description
| Name | Type | Description |
|---|---|---|
| lockData | String | Lock data |
| adminCode | String | The new admin code |
1.12.3 Return parameters
| Parameter | Type | Description |
|---|---|---|
| lockData | String | New lockData with the new admin code |
1.13 Get QR code data
1.13.1 TTLockUtil.getQrCodeData
public static String getQrCodeData(String lockData, short qrCodeNumber, Long startTime, Long endTime)Generate the unlock QR code content. Render the returned string into a QR code image, which can be scanned by the lock to unlock.
Restrictions:
- The lock must support the QR code function, otherwise an
IllegalArgumentExceptionis thrown. - endTime must be later than startTime.
- The valid period (endTime - startTime) can't be more than 1 hour.
1.13.2 Parameter Description
| Name | Type | Description |
|---|---|---|
| lockData | String | Lock data |
| qrCodeNumber | Short | QR code number, numbered from 1, maintained by the developer's system |
| startTime | Long | Start time, timestamp in milliseconds |
| endTime | Long | End time, timestamp in milliseconds |
1.13.3 Return parameters
| Parameter | Type | Description |
|---|---|---|
| qrCodeData | String | Unlock QR code content, in the format SCIE:hexadecimal string, ending with a line break |
