Passcode
KK Smart Lock API Documentation
This article will explain how to integrate TTLock passcode into your system, for example how to get random passcode, create custom passcode, delete passcode, modify passcode, etc.
1、About the two passcode schemes of TTLock
1.1、Random passcode:
An accordant passcode algorithm and passcode key data will be generated in both the KK Smart lock and cloud server when the KK Smart lock is initialized. Developers can Get a random passcode by cloud API, the length of the passcode is basically decided by the passcode type and valid period and will be 6-9 digits,the passcodes are randomly generated and can’t be cutomized. When the passcode is inputed on the keypad of the KK Smart lock, the KK Smart lock will check if it’s valid by the the algorithm and passcode key data.
Random passcodes’s valid period can only be accruate to Hours.
There are five types of random passcodes: One-time, Permanent, Timed, Delete and Recurring.
One-time passcode can only be used once in 6 hours after the it’s start time. With the same start time, there are 200 different One-time passcodes for a KK Smart lock.
Permanent passcode will be valid forever after it’s start time,but it must be used at least once within 24 hours from it’s start time, or it will be suspended for security reasons. With the same start time, there are 20 different Permanent passcodes for a KK Smart lock.
Timed passcode will be valid from it’s start time to end time,but it must be used at least once within 24 hours from it’s start time, or it will be suspended for security reasons. With the same start time and end time, there is only one Timed passcode for a KK Smart lock, you have to adjust the start time and end time to get a different Timed passcode.
All used passcodes will be deleted and become invalid if a Delete passcode is used on the KK Smart lock.
1.2、Custom passcode:
With this scheme you can write up to 150 records of 4-9 digits passcodes into the KK Smart lock‘s memory.
There are only two types of Custom passcode: Timed and Permanent,it’s valid period can be accruate to MINUTES.
There are two ways of adding custom passcodes:
(1)Add by APP nearby the KK Smart lock via bluetooth:
You can develop your own APP based on our APP SDK,call Add passccode method to wirte a passcode into the KK Smart lock,then request cloud API: Add custom passcode ( with addType=1) to add it to the cloud to facilitate follow-up management。
(2)Add by cloud API via gateway or WiFi lock:
If the KK Smart lock is a WiFi model or it’s connected to a gateway, you can add custom passcode remotely,just request cloud API Add custom passcode ( with addType=2) , the gateway will write the passcode into the KK Smart lock.
Random passcode does not support cusomized passcodes, but more passcodes type are supported,and do not rely on gateways, you can get a random passcode by just requesting the cloud API.
Custom passcodes rely on gateway, if the KK Smart lock is not connected to any gateway,you have to be nearby the KK Smart lock to add a custom passcode by APP.
2、How to delete and modify a passcode?
All the generated random passcodes and custom passcodes of a KK Smart lock can be list by cloud API: Get all created passcodes of a lock.
No matter it’s random passcode or custom passcode,if you want to delete or modify the passcode remotely via cloud apis, the KK Smart lock need to be connected to a gateway, otherwise you have to be nearby the KK Smart lock to operate by APP.
If you want to Change passcode or Delete one passcode via cloud API and gateway,changeType or deleteType parameter should be set to 2.
3、How to reset all the passcodes of a KK Smart lock?
There are two ways to make all the passcode of a KK Smart lock to become invalid,you can get a Random passcode of Delete type,all used passcodes will become invalid if a Delete passcode is used on the KK Smart lock.
The second way is to reset the KK Smart lock‘s passcodes, all the passcodes will be cleared from the KK Smart lock and cloud server,and a new key data for random passcode scheme will be gernerated for the KK Smart lock.
Reset of passcodes can only be done via APP SDK near by the KK Smart lock, you can’t do it by gateway,after you successfully reseted passcodes by APP SDK, you will get a newlockData from it’s callback function, request the cloud api: Update lock data with the new lockData to renew the passcode key data of the cloud server,then you can get random passcodes based on the new passcode key data.
4、Passcode FAQ
please refer to : Q&AEn