Open Platform
Skip to content

Gateway Server Client User Manual ​

Contents ​

1 Overview ​

1.1 Introduction ​

The gateway-server-client JAR provides the com.ttlock.gateway.client.GatewayServerClient class. It sends HTTP requests to the on premise gateway server (gateway-server-on-premise) to query connected gateways and operate locks remotely via gateways (unlock, lock, manage passcodes/IC cards/fingerprints/faces/palm veins/QR codes, modify lock settings, etc.).

General notes:

  • The lockData parameter of all methods must be generated by the APP SDK on premise after adding a lock.
  • Before operating a lock remotely, call addLock to add the lock data to the gateway server, and the lock must be within the Bluetooth range of a gateway.
  • All time parameters (startDate, endDate, etc.) are timestamps in milliseconds.
  • Unless otherwise specified, methods have no return value; a call without exception means the operation succeeded. On failure, a GatewayException is thrown (with error code, error message and HTTP status code).
  • Methods with the WithSelectedGateway suffix operate via a specified gateway MAC; methods without the suffix let the server automatically select the gateway with the best RSSI.

1.2 Initialization ​

java
GatewayServerClient client = new GatewayServerClient("192.168.8.178", 8888, "1234abcd");
String lockData = "xxx"; // lockData is obtained from TTLock SDK on premise
client.addLock(lockData); // add lockData to gateway server
client.unlock(2340, lockData); // if no exception is thrown, the unlock is successful

Constructor parameters:

NameTypeDescription
ipStringThe host IP of the gateway server
portIntThe HTTP server port of the gateway server, 8888 by default, can be configured in the gateway server's config.properties by the http_server_port property
secretStringThe secret of the gateway server, 1234abcd by default, can be configured in the gateway server's config.properties by the secret property. The gateway server must be restarted for the new configuration to take effect

1.3 Common Parameters ​

The following parameters are shared by multiple methods and are not repeated in later sections:

NameTypeDescription
lockDataStringLock data, generated by the APP SDK on premise
gatewayMacStringGateway MAC address, e.g. B4:89:1F:9E:D6:D1
uidIntUser ID, identifies the operator / unlock record
startDateLongValid start time, timestamp in milliseconds
endDateLongValid end time, timestamp in milliseconds
cyclicConfigStringRecurring time period, a JSON array, can be null. For example: [{"weekDay":1,"startTime":480,"endTime":1080},{"weekDay":2,"startTime":480,"endTime":1080}] means valid from 8:00 to 18:00 on Mondays and Tuesdays. weekDay ranges from 1-7 for Monday to Sunday; startTime/endTime are minutes of the day (e.g. 480 for 8:00)

1.4 Exceptions and Error Codes ​

All method calls fail with a com.ttlock.gateway.exception.GatewayException (a subclass of RuntimeException). Use getErrorCode(), getErrorMsg() and getHttpStatusCode() to get the error details.

Error codes:

Error CodeDescription
-1Operation failure (or means "no")
-1004MAC format error
-1009Invalid command
-1021The IC card does not exist
-1023The fingerprint does not exist
-2018Permission denied
-3002The lock is not connected to any gateway
-3003Gateway is busy, please try later
-3004Lock info not found
-3005The link between gateway and lock is broken
-3006Passcode length invalid, should be 4-9
-3007Passcode exists
-3008Passcode does not exist
-3009No free memory
-3015This record does not exist
-3036WiFi lock offline
-3049This face exists
-4056Lack of storage space and failure of operation
-4082Auto locking period invalid
-7000Invalid lock data
-7001Invalid client secret, should be the same as the gateway server's secret

2 Gateway Management ​

2.1 List Gateways ​

java
public List<Gateway> listGateway()
public List<Gateway> listGatewayByUid(Integer uid)
public List<Gateway> listGatewayByLock(String lockData)
  • listGateway: list gateways of all users.
  • listGatewayByUid: list gateways of a user.
  • listGatewayByLock: list gateways that can connect to a lock (with connection RSSI).

Parameter Description:

NameTypeDescription
uidIntegerUser ID
lockDataStringLock data

Return: List<Gateway> gateway list, see Appendix A for Gateway fields.

2.2 List Locks Connected to a Gateway ​

java
public List<Lock> listLockByGateway(String gatewayMac)

List locks that connect to a gateway.

Parameter Description:

NameTypeDescription
gatewayMacStringGateway MAC address

Return: List<Lock> lock list, see Appendix A for Lock fields.

2.3 List Lock-Gateway Connections ​

java
public List<DeviceRelation> listDeviceRelation()

List the connect relations of all locks and their best-RSSI gateways. No parameters.

Return: List<DeviceRelation> connection list (lockMac, gatewayMac, rssi), see Appendix A for fields.

2.4 Delete Gateway ​

java
public void deleteGateway(String gatewayMac)

Delete a gateway from the gateway server.

Parameter Description:

NameTypeDescription
gatewayMacStringGateway MAC address

2.5 Transfer Gateway ​

java
public void transferGateway(Integer fromUid, Integer toUid, List<String> gatewayMacList)

Transfer gateways to another user.

Parameter Description:

NameTypeDescription
fromUidIntegerThe original user ID
toUidIntegerThe target user ID
gatewayMacListList<String>List of gateway MACs to be transferred

2.6 Query Gateway Online/Busy Status ​

java
public boolean queryGatewayOnlineStatus(String gatewayMac)
public boolean queryGatewayBusyStatus(String gatewayMac)
  • queryGatewayOnlineStatus: query whether the gateway is online.
  • queryGatewayBusyStatus: query whether the gateway is busy.

Parameter Description:

NameTypeDescription
gatewayMacStringGateway MAC address

Return: Boolean, true-online/busy, false-offline/idle.

2.7 Set Gateway Upgrade Mode ​

java
public void setGatewayUpgradeMode(String gatewayMac)

Set the gateway into firmware upgrade mode.

Parameter Description:

NameTypeDescription
gatewayMacStringGateway MAC address

3 Lock Management ​

3.1 Add Lock ​

java
public void addLock(String lockData)
public void addLock(Integer uid, String lockData)

Add lock data to the gateway server. The lock can be operated remotely via gateways only after being added. The overload with uid also assigns the admin user ID of the lock.

Parameter Description:

NameTypeDescription
uidIntegerThe admin user ID of the lock
lockDataStringLock data

3.2 Transfer Lock ​

java
public void transferLock(Integer fromUid, Integer toUid, List<String> lockMacList)

Transfer locks to another user.

Parameter Description:

NameTypeDescription
fromUidIntegerThe original user ID
toUidIntegerThe target user ID
lockMacListList<String>List of lock MACs to be transferred

3.3 Filter Out Online Locks ​

java
public List<String> filterOutOnlineLocks(List<String> lockMacList)

Filter out online locks from the given lock MAC list. A lock is online if any online gateway discovered it in the last 30 minutes; a WiFi lock is also online if it is connected to the WiFi lock server.

Parameter Description:

NameTypeDescription
lockMacListList<String>List of lock MACs to be checked

Return: List<String> MAC list of online locks.

4 Remote Unlock/Lock ​

4.1 Remote Unlock ​

java
public void unlock(int uid, String lockData)

Unlock the lock remotely via gateway (as a normal user).

Parameter Description:

NameTypeDescription
uidIntUser ID of the user who unlocks the lock, identifies the unlock record
lockDataStringLock data

4.2 Remote Unlock with Selected Gateway ​

java
public void unlockWithSelectedGateway(String gatewayMac, int uid, String lockData)

Unlock the lock remotely with a selected gateway (as a normal user).

Parameter Description:

NameTypeDescription
gatewayMacStringThe selected gateway MAC
uidIntUser ID of the user who unlocks the lock
lockDataStringLock data

4.3 Remote Unlock by Administrator ​

java
public void unlockByAdministrator(int uid, String lockData)

Unlock the lock remotely via gateway as an administrator.

Parameter Description:

NameTypeDescription
uidIntUser ID of the user who unlocks the lock
lockDataStringLock data

4.4 Remote Unlock by Administrator with Selected Gateway ​

java
public void unlockByAdministratorWithSelectedGateway(String gatewayMac, int uid, String lockData)

Unlock the lock remotely with a selected gateway as an administrator.

Parameter Description:

NameTypeDescription
gatewayMacStringThe selected gateway MAC
uidIntUser ID of the user who unlocks the lock
lockDataStringLock data

4.5 Remote Lock ​

java
public void lock(int uid, String lockData)

Lock the lock remotely via gateway.

Parameter Description:

NameTypeDescription
uidIntUser ID of the operator
lockDataStringLock data

4.6 Emergency Unlock ​

java
public void emergencyUnlock(int uid, String lockData)

Unlock the lock remotely for emergency. Auto lock will be disabled after unlocking (the lock remains unlocked).

Parameter Description:

NameTypeDescription
uidIntUser ID of the user who unlocks the lock
lockDataStringLock data

4.7 Emergency Lock ​

java
public void emergencyLock(int uid, String lockData, int seconds)

Lock the lock remotely for emergency. The lock will be locked and auto lock will be turned on.

Parameter Description:

NameTypeDescription
uidIntUser ID of the operator
lockDataStringLock data
secondsIntThe lock will auto relock after the specified seconds; set 0 to turn off auto lock

5 Lock Status Query and Calibration ​

5.1 Query Lock Datetime ​

java
public long queryDatetimeOfLock(String lockData)

Query the current datetime of the lock.

Parameter Description:

NameTypeDescription
lockDataStringLock data

Return: Long, datetime of the lock, Unix timestamp in milliseconds.

5.2 Calibrate Lock Datetime ​

java
public void calibrateDatetimeOfLock(String lockData)

Calibrate the datetime of the lock to the server's current time.

Parameter Description:

NameTypeDescription
lockDataStringLock data

5.3 Query Lock Battery Level ​

java
public int queryElectricQuantityOfLock(String lockData)

Query the battery level of the lock.

Parameter Description:

NameTypeDescription
lockDataStringLock data

Return: Int, battery level percentage, 1-100.

5.4 Query Lock Open State ​

java
public int queryOpenStateOfLock(String lockData)

Query the open state of the lock.

Parameter Description:

NameTypeDescription
lockDataStringLock data

Return: Int, 0-locked, 1-unlocked, 2-unknown.

5.5 Query Open State of Lock and Door ​

java
public JSONObject queryOpenStateOfLockAndDoor(String lockData)

Query the open state of the lock and the door sensor state (the lock must support a door sensor).

Parameter Description:

NameTypeDescription
lockDataStringLock data

Return: JSONObject with the following fields:

FieldTypeDescription
stateIntOpen state of lock: 0-locked, 1-unlocked, 2-unknown
sensorStateIntOpen state of door: 0-open, 1-closed, 2-unknown

5.6 Query Lock Freeze Status ​

java
public int queryFreezeStatusOfLock(String lockData)

Query the freeze status of the lock.

Parameter Description:

NameTypeDescription
lockDataStringLock data

Return: Int, 0-not frozen, 1-frozen.

5.7 Query Accessory Battery Level ​

java
public JSONObject queryAccessoryBatteryLevel(int uid, String lockData, String accessoryMac, int type)
public JSONObject queryAccessoryBatteryLevelWithSelectedGateway(String gatewayMac, int uid, String lockData, String accessoryMac, int type)

Query the battery level of a lock accessory (wireless keypad, remote, door sensor). The overload with the WithSelectedGateway suffix operates via a specified gateway.

Parameter Description:

NameTypeDescription
gatewayMacStringThe selected gateway MAC
uidIntUser ID of the operator
lockDataStringLock data
accessoryMacStringAccessory MAC address
typeIntLock accessory type: 1-wireless keypad, 2-remote, 3-door sensor

Return: JSONObject containing the accessory battery level information.

6 WiFi Lock Status Query ​

6.1 Query WiFi Lock Online Status ​

java
public boolean queryWifiLockOnlineStatus(String lockData)

Query whether the WiFi lock is online (connected to the WiFi lock server).

Parameter Description:

NameTypeDescription
lockDataStringLock data

Return: Boolean, true-online, false-offline.

6.2 Query WiFi Lock Busy Status ​

java
public boolean queryWifiLockBusyStatus(String lockData)

Query whether the WiFi lock is busy. Throws GatewayException (error code -3036) if the lock is offline.

Parameter Description:

NameTypeDescription
lockDataStringLock data

Return: Boolean, true-busy, false-idle.

6.3 Query WiFi Lock RSSI ​

java
public int queryWifiLockRssi(String lockData)

Query the network RSSI of the WiFi lock. Throws GatewayException (error code -3036) if the lock is offline.

Parameter Description:

NameTypeDescription
lockDataStringLock data

Return: Int, network RSSI.

7 Passcode Management ​

7.1 Add Custom Passcode ​

java
public void addPasscode(String lockData, String passcode, Long startDate, Long endDate)
public void addPasscode(String lockData, String passcode, Long startDate, Long endDate, String cyclicConfig)
public void addPasscodeWithSelectedGateway(String gatewayMac, String lockData, String passcode, Long startDate, Long endDate)
public void addPasscodeWithSelectedGateway(String gatewayMac, String lockData, String passcode, Long startDate, Long endDate, String cyclicConfig)

Add a custom passcode to the lock. The overloads with cyclicConfig support recurring time periods; the overloads with the WithSelectedGateway suffix operate via a specified gateway.

Parameter Description:

NameTypeDescription
gatewayMacStringThe selected gateway MAC
lockDataStringLock data
passcodeStringPasscode to be added, 4-9 digits
startDateLongValid start time
endDateLongValid end time
cyclicConfigStringRecurring time period, see 1.3 Common Parameters

7.2 Delete Passcode ​

java
public void deletePasscode(String lockData, String passcode)
public void deletePasscodeWithSelectedGateway(String gatewayMac, String lockData, String passcode)

Delete a passcode from the lock.

Parameter Description:

NameTypeDescription
gatewayMacStringThe selected gateway MAC
lockDataStringLock data
passcodeStringPasscode to be deleted

7.3 Change Passcode ​

java
public void changePasscode(String lockData, String passcode, String newPasscode, Long startDate, Long endDate)
public void changePasscode(String lockData, String passcode, String newPasscode, Long startDate, Long endDate, String cyclicConfig)
public void changePasscodeWithSelectedGateway(String gatewayMac, String lockData, String passcode, String newPasscode, Long startDate, Long endDate)
public void changePasscodeWithSelectedGateway(String gatewayMac, String lockData, String passcode, String newPasscode, Long startDate, Long endDate, String cyclicConfig)

Change an existing passcode of the lock (both the passcode value and the valid period can be changed). The overloads with cyclicConfig support recurring time periods.

Parameter Description:

NameTypeDescription
gatewayMacStringThe selected gateway MAC
lockDataStringLock data
passcodeStringThe passcode to be changed
newPasscodeStringThe new passcode
startDateLongValid start time of the new passcode
endDateLongValid end time of the new passcode
cyclicConfigStringRecurring time period, see 1.3 Common Parameters

7.4 Change Admin Passcode ​

java
public String changeSuperPasscode(String lockData, String newPasscode)

Change the admin passcode of the lock. On success, returns the lock data containing the new admin passcode. The developer's system should save the new lock data for subsequent operations.

Parameter Description:

NameTypeDescription
lockDataStringLock data
newPasscodeStringThe new admin passcode

Return: String, new lockData with the new admin passcode.

8 IC Card Management ​

8.1 Add IC Card ​

java
public void addIdentityCard(String lockData, String cardNumber, Long startDate, Long endDate)
public void addIdentityCard(String lockData, String cardNumber, Long startDate, Long endDate, String cyclicConfig)
public void addIdentityCardWithSelectedGateway(String gatewayMac, String lockData, String cardNumber, Long startDate, Long endDate)
public void addIdentityCardWithSelectedGateway(String gatewayMac, String lockData, String cardNumber, Long startDate, Long endDate, String cyclicConfig)

Add an IC card to the lock. The overloads with cyclicConfig support recurring time periods; the overloads with the WithSelectedGateway suffix operate via a specified gateway.

Parameter Description:

NameTypeDescription
gatewayMacStringThe selected gateway MAC
lockDataStringLock data
cardNumberStringNumber of the card to be added
startDateLongValid start time
endDateLongValid end time
cyclicConfigStringRecurring time period, see 1.3 Common Parameters

8.2 Delete IC Card ​

java
public void deleteIdentityCard(String lockData, String cardNumber)
public void deleteIdentityCardWithSelectedGateway(String gatewayMac, String lockData, String cardNumber)

Delete an IC card from the lock.

Parameter Description:

NameTypeDescription
gatewayMacStringThe selected gateway MAC
lockDataStringLock data
cardNumberStringNumber of the card to be deleted

8.3 Change Valid Period of IC Card ​

java
public void changePeriodOfIdentityCard(String lockData, String cardNumber, Long startDate, Long endDate)
public void changePeriodOfIdentityCard(String lockData, String cardNumber, Long startDate, Long endDate, String cyclicConfig)

Change the valid period of an existing IC card in the lock. The overload with cyclicConfig supports recurring time periods.

Parameter Description:

NameTypeDescription
lockDataStringLock data
cardNumberStringNumber of the card to be changed
startDateLongValid start time
endDateLongValid end time
cyclicConfigStringRecurring time period, see 1.3 Common Parameters

8.4 Compress Card Number ​

java
public static String compressCardNumber(String cardNumber)

Static utility method. Compress an 8-byte card number into a 4-byte card number (the high bytes and low bytes are added together). If the card number is no more than 4 bytes, it is returned unchanged.

Parameter Description:

NameTypeDescription
cardNumberString8-byte card number

Return: String, 4-byte card number.

8.5 Reverse Card Number ​

java
public static String reverseCardNumber(String cardNumber)

Static utility method. Reverse the byte order of a card number. The card numbers read by card readers of different brands may differ because they are displayed in different byte order (big endian or little endian); use this method to convert.

Parameter Description:

NameTypeDescription
cardNumberStringCard number

Return: String, the card number with reversed byte order.

9 Fingerprint Management ​

9.1 Add Fingerprint ​

java
public String addFingerprint(String lockData, String fingerprintData, Long startDate, Long endDate)
public String addFingerprint(String lockData, String fingerprintData, Long startDate, Long endDate, String cyclicConfig)

Add a fingerprint to the lock. The overload with cyclicConfig supports recurring time periods.

Parameter Description:

NameTypeDescription
lockDataStringLock data
fingerprintDataStringFingerprint data (obtained from a fingerprint collector / APP SDK)
startDateLongValid start time
endDateLongValid end time
cyclicConfigStringRecurring time period, see 1.3 Common Parameters

Return: String, the fingerprint number (fingerprintNumber) assigned on success, used for subsequent delete/change operations.

9.2 Delete Fingerprint ​

java
public void deleteFingerprint(String lockData, String fingerprintNumber)

Delete a fingerprint from the lock.

Parameter Description:

NameTypeDescription
lockDataStringLock data
fingerprintNumberStringNumber of the fingerprint to be deleted

9.3 Change Valid Period of Fingerprint ​

java
public void changePeriodOfFingerprint(String lockData, String fingerprintNumber, Long startDate, Long endDate)
public void changePeriodOfFingerprint(String lockData, String fingerprintNumber, Long startDate, Long endDate, String cyclicConfig)

Change the valid period of an existing fingerprint in the lock. The overload with cyclicConfig supports recurring time periods.

Parameter Description:

NameTypeDescription
lockDataStringLock data
fingerprintNumberStringNumber of the fingerprint to be changed
startDateLongValid start time
endDateLongValid end time
cyclicConfigStringRecurring time period, see 1.3 Common Parameters

10 Face Management ​

10.1 Add Face ​

java
public String addFace(String lockData, String featureData, Long startDate, Long endDate)
public String addFace(String lockData, String featureData, Long startDate, Long endDate, String cyclicConfig)

Add face feature data to the lock. The overload with cyclicConfig supports recurring time periods.

Parameter Description:

NameTypeDescription
lockDataStringLock data
featureDataStringFace feature data
startDateLongValid start time
endDateLongValid end time
cyclicConfigStringRecurring time period, see 1.3 Common Parameters

Return: String, the face number (faceNumber) assigned on success, used for subsequent delete/change operations.

10.2 Add Face with Photo URL ​

java
public String addFaceWithPhotoUrl(String lockData, String photoUrl, Long startDate, Long endDate, String cyclicConfig)

Add a face by a face photo URL; the server extracts the face feature. The photo must meet the lock's requirements (size, resolution, format), which can be queried via the faceImageSize, faceImageHeight, faceImageWidth and faceImageType fields returned by TTLockUtil.getLockInfo.

Parameter Description:

NameTypeDescription
lockDataStringLock data
photoUrlStringFace photo URL
startDateLongValid start time
endDateLongValid end time
cyclicConfigStringRecurring time period, see 1.3 Common Parameters

Return: String, the face number (faceNumber) assigned on success.

10.3 Delete Face ​

java
public void deleteFace(String lockData, String faceNumber)

Delete a face from the lock.

Parameter Description:

NameTypeDescription
lockDataStringLock data
faceNumberStringNumber of the face to be deleted

10.4 Change Valid Period of Face ​

java
public void changePeriodOfFace(String lockData, String faceNumber, Long startDate, Long endDate)
public void changePeriodOfFace(String lockData, String faceNumber, Long startDate, Long endDate, String cyclicConfig)

Change the valid period of an existing face in the lock. The overload with cyclicConfig supports recurring time periods.

Parameter Description:

NameTypeDescription
lockDataStringLock data
faceNumberStringNumber of the face to be changed
startDateLongValid start time
endDateLongValid end time
cyclicConfigStringRecurring time period, see 1.3 Common Parameters

11 Palm Vein Management ​

11.1 Clear Palm Veins ​

java
public void clearPalmVein(String lockData)

Clear all palm veins of the lock.

Parameter Description:

NameTypeDescription
lockDataStringLock data

11.2 Delete Palm Vein ​

java
public void deletePalmVein(String lockData, String number)

Delete a palm vein from the lock.

Parameter Description:

NameTypeDescription
lockDataStringLock data
numberStringNumber of the palm vein to be deleted

11.3 Change Valid Period of Palm Vein ​

java
public void changePeriodOfPalmVein(String lockData, String number, Long startDate, Long endDate)
public void changePeriodOfPalmVein(String lockData, String number, Long startDate, Long endDate, String cyclicConfig)

Change the valid period of an existing palm vein in the lock. The overload with cyclicConfig supports recurring time periods.

Parameter Description:

NameTypeDescription
lockDataStringLock data
numberStringNumber of the palm vein to be changed
startDateLongValid start time
endDateLongValid end time
cyclicConfigStringRecurring time period, see 1.3 Common Parameters

12 QR Code Management ​

12.1 Add QR Code ​

java
public void addQrCode(String lockData, String qrCodeNumber, Long startDate, Long endDate, String cyclicConfig)
public void addQrCodeWithSelectedGateway(String gatewayMac, String lockData, String qrCodeNumber, Long startDate, Long endDate, String cyclicConfig)

Add a QR code number to the lock (authorize the QR code of this number to unlock). The QR code content can be generated by TTLockUtil.getQrCodeData. The overload with the WithSelectedGateway suffix operates via a specified gateway.

Parameter Description:

NameTypeDescription
gatewayMacStringThe selected gateway MAC
lockDataStringLock data
qrCodeNumberStringQR code number to be added
startDateLongValid start time
endDateLongValid end time
cyclicConfigStringRecurring time period, see 1.3 Common Parameters

12.2 Delete QR Code ​

java
public void deleteQrCode(String lockData, String qrCodeNumber)
public void deleteQrCodeWithSelectedGateway(String gatewayMac, String lockData, String qrCodeNumber)

Delete a QR code number from the lock.

Parameter Description:

NameTypeDescription
gatewayMacStringThe selected gateway MAC
lockDataStringLock data
qrCodeNumberStringQR code number to be deleted

12.3 Change Valid Period of QR Code ​

java
public void changePeriodOfQrCode(String lockData, String qrCodeNumber, Long startDate, Long endDate, String cyclicConfig)
public void changePeriodOfQrCodeWithSelectedGateway(String gatewayMac, String lockData, String qrCodeNumber, Long startDate, Long endDate, String cyclicConfig)

Change the valid period of an existing QR code number in the lock. The overload with the WithSelectedGateway suffix operates via a specified gateway.

Parameter Description:

NameTypeDescription
gatewayMacStringThe selected gateway MAC
lockDataStringLock data
qrCodeNumberStringQR code number to be changed
startDateLongValid start time
endDateLongValid end time
cyclicConfigStringRecurring time period, see 1.3 Common Parameters

13 Lock Settings ​

13.1 Update Lock Setting ​

java
public void updateSetting(String lockData, int type, int value)

Update lock settings, including privacy lock, tamper alert, reset button, opening direction, double verification, etc.

Parameter Description:

NameTypeDescription
lockDataStringLock data
typeIntSetting item: 2-privacy lock, 3-tamper alert, 4-reset button, 7-opening direction, 12-double verification, 20-secure M1 card, 21-power saving care mode
valueIntSetting value: 1-on, 2-off; opening direction: 1-left, 2-right

13.2 Set Lock Volume ​

java
public void setLockVolume(String lockData, int volume)

Set the volume of the lock's prompt sound.

Parameter Description:

NameTypeDescription
lockDataStringLock data
volumeIntVolume level: 1-5; 0-turn off the prompt sound

13.3 Set Auto Lock Time ​

java
public void setAutoLockTime(String lockData, int seconds)

Set the auto lock delay of the lock.

Parameter Description:

NameTypeDescription
lockDataStringLock data
secondsIntThe lock will auto relock after the specified seconds after unlocking; set 0 to turn off auto lock

13.4 Config Passage Mode ​

java
public void configPassageMode(String lockData, int passageMode, String passageModeConfig)
public void configPassageMode(String lockData, int passageMode, String passageModeConfig, Integer autoUnlock)
public void configPassageMode(String lockData, int passageMode, int startDate, int endDate, int isAllDay, String weekDays)

Configure passage mode. The lock keeps unlocked during the configured time periods until locked manually. The first two overloads support multiple time periods per weekday; the third overload configures a single time period.

Parameter Description:

NameTypeDescription
lockDataStringLock data
passageModeIntPassage mode: 1-on, 2-off
passageModeConfigStringValid time periods for each day of the week, a JSON array, for example: [{"weekDay":1,"startTime":480,"endTime":1080},{"weekDay":2,"startTime":420,"endTime":1020}] means 8:00-18:00 on Mondays and 7:00-17:00 on Tuesdays. startTime/endTime are minutes of the day; both 0 means all day
autoUnlockIntegerAuto unlock: 1-on, 2-off. If on, the lock unlocks automatically when a passage period starts
startDateIntStart time of the period, minutes of the day, e.g. 480 for 8:00
endDateIntEnd time of the period, minutes of the day, e.g. 1080 for 18:00
isAllDayIntWhether all day: 1-yes, 2-no. startDate/endDate are ignored if all day
weekDaysStringEffective weekdays, a JSON array, e.g. [1,7] means Monday and Sunday

13.5 Config Working Mode ​

java
public void configWorkingMode(String lockData, int workingMode, String workingModeList)

Set the working mode of the lock. During working periods the lock can be unlocked by ekey, passcode, etc.; outside working periods the lock automatically enters freeze mode, only the mechanical key works and all other unlock methods are disabled.

Tip: to freeze/unfreeze the lock, use configWorkingMode(lockData, 2, null) / configWorkingMode(lockData, 1, null) instead of the deprecated freezeLock / unfreezeLock methods.

Parameter Description:

NameTypeDescription
lockDataStringLock data
workingModeIntWorking mode: 1-work all day, 2-not work all day, 3-custom
workingModeListStringCustom working time configuration, required when workingMode is 3. A JSON array, element format: {"isAllDay":1-yes 2-no, "startTime":minutes of the day, "endTime":minutes of the day, "weekDays":[1-7]}, for example: [{"isAllDay":2,"startTime":480,"endTime":1080,"weekDays":[1,2,3,4,5]}] means working from 8:00 to 18:00 every Monday to Friday

13.6 Freeze/Unfreeze Lock (Deprecated) ​

java
@Deprecated
public void freezeLock(String lockData)
@Deprecated
public void unfreezeLock(String lockData)

Freeze/unfreeze the lock. Deprecated (@Deprecated), use configWorkingMode(lockData, 2, null) to freeze and configWorkingMode(lockData, 1, null) to unfreeze instead.

Parameter Description:

NameTypeDescription
lockDataStringLock data

13.7 Set Access Name ​

java
public void setAccessName(String lockData, String number, AccessType accessType, String name)

Set a name for an access credential on the lock (card number, face number, etc.), so that the user can be identified in unlock records.

Parameter Description:

NameTypeDescription
lockDataStringLock data
numberStringCredential number (card number, face number, etc.)
accessTypeAccessTypeCredential type enum, see Appendix A
nameStringName

14 Matter Configuration (G6 Gateway) ​

14.1 Configure Matter Lock ​

java
public void configureMatterLockForG6Gateway(int uid, String gatewayMac, String lockData)

Configure the lock into the Matter network of a G6 gateway. After configuration, the lock can be unlocked via Matter.

Parameter Description:

NameTypeDescription
uidIntUser ID used for Matter unlocking
gatewayMacStringG6 gateway MAC address
lockDataStringLock data

14.2 Delete Matter Lock ​

java
public void deleteMatterLockForG6Gateway(String gatewayMac)

Delete the configured Matter lock from the G6 gateway.

Parameter Description:

NameTypeDescription
gatewayMacStringG6 gateway MAC address

14.3 Set Matter Pairing Mode ​

java
public void setMatterPairingMode(String gatewayMac)

Set the G6 gateway into Matter pairing mode.

Parameter Description:

NameTypeDescription
gatewayMacStringG6 gateway MAC address

Appendix A Entity Classes ​

Gateway (com.ttlock.gateway.entity.Gateway) ​

FieldTypeDescription
macStringGateway MAC address
nameStringGateway name
versionIntGateway version
uidIntegerAdmin user ID
aesKeyStringAES key
rssiIntConnection RSSI between the gateway and the lock (returned by listGatewayByLock)
isOnlineBooleanWhether the gateway is online

Lock (com.ttlock.gateway.entity.Lock) ​

FieldTypeDescription
macStringLock MAC address
rssiIntConnection RSSI between the gateway and the lock

DeviceRelation (com.ttlock.gateway.entity.DeviceRelation) ​

FieldTypeDescription
gatewayMacStringGateway MAC address
lockMacStringLock MAC address
rssiIntConnection RSSI between the gateway and the lock

AccessType (com.ttlock.gateway.param.AccessType) ​

Access credential type enum:

EnumCodeDescription
FINGERPRINT1Fingerprint
CARD2IC card
WIRELESS_KEY3Wireless key
FACE4Face
PALM_VEIN5Palm vein
PASSWORD6Passcode
QR_CODE7QR code
CopyRight © 2012-2026 Sciener.All Rights Reserved