This example project was created by the Tedee team to show you how to operate the Tedee Lock using Bluetooth Low Energy communication protocol. This project is developed using the Kotlin language and is designed to run on Android devices. It utilizes our Tedee Lock SDK, which can be accessed via the following link: LINK TO SDK.
In example app navigate to the build.gradle file located in the Module: app directory. Within this file, locate the dependencies section where you'll find the dependency for the Tedee Lock SDK. implementation('com.github.tedee-com:tedee-mobile-sdk-android:1.0.0@aar') { transitive = true }
The purpose of this project is to demonstrate how you can integrate the Tedee Lock SDK into your own app. It provides you with the capability to:
- Add Tedee Lock to your account LINK TO DOCUMENTATION
- Establish a Bluetooth connection with a Tedee Lock by providing necessary data such as the Lock's Serial Number, Certificate, Mobile Public Key, Device ID and Device Name.
- Disconnect the connection from the lock.
- Send commands to the lock based on the BLE documentation.
- Receive callbacks when the connection status changes.
- Receive callbacks when indication messages are received.
- Receive callbacks when notification messages are received.
- Handle errors that occur during lock connection.
App uses RxAndroidBle library and custom implementation of secure BLE session (All from Tedee Lock SDK). It is not using any Tedee services and works only locally within the range of BLE. The example app uses an API to create a certificate right from the app itself. When setting up, you will need to manually obtain the Personal Access Key.
With the SDK, you will be able to operate only one lock at a time.
⚠️ This is just a simplified example of how to connect and send commands to lock. It omits security concerns, error handling, and best practices. This is not production-ready code.
- Tedee Lock - you can order it in our online store
- Android (not emulator) with Android 8.0+ and installed Tedee app
- Any PC/Mac able to run Android Studio
- USB cable (to connect the phone to PC)
- Tedee account created in Tedee app
- Lock added and calibrated in Tedee app
- Clone this repository, unpack the archive
- Select File > Open in Android Studio and click on the downloaded folder
- The project will be imported and configured automatically. Android Studio will prompt you with any needed updates.
- Enable
Developer Optionson your phone How to enable - Enable
USB debugginginDeveloper Options - Open Android Studio, connect the phone via USB
- Your phone may display a popup asking about trusting PC, approve the connection.
- Now you should see your Android device in top bar
⚠️ USB debugging allows to control your phone from any connected computer. Make sure to disable it after finishing working on the project.
Now you are ready to build the project and upload it to your device.
Click on "Run 'app'" button or use Shift + F10 to build project and run it on connected device.
On first launch app will ask you for permission to use Location and Bluetooth. Both are needed for Android app to access Bluetooth module.
When you first open the app, it will generate a Mobile Public Key. This key is necessary for creating a lock certificate, which will be covered in the following steps. To find this key, check the Logcat at the bottom of Android Studio and look for the entry marked !!! Public key to register mobile:. The app will save this key after its initial creation. In future app launches, it will retrieve the key from its stored location.
Please keep an eye on the Logcat as it will display the sequence of actions the app performs to the lock. These actions include connecting to the lock, starting an encrypted session, sending any commands, and receiving a response.
- Log in to Tedee Portal with credentials from created Tedee account
- Click on your initials in top right corner
- Click on Personal Access Keys and generate new access key with at least Device certificates - Read scope. Remember to save this key, as it will be needed for the following step.
- In the project navigator, open the
Constants.ktfile (located within tedee.mobile.demo). - Replace the
PERSONAL_ACCESS_KEYvalue with the one obtained in the previous step. - Compile and run app again with
Run 'app'button or useShift + F10.
⚠️ Before you can generate a certificate and connect to the lock, ensure all necessary information is entered
Serial Number: Enter the serial number of your Tedee lock. This is essential for connecting to the lock. You can find it in the Tedee app under Lock > Settings > Information > Serial number.Lock Name: Input the name of your Tedee lock. This is necessary to generate a certificate for the lock. Locate this in the Tedee app under Lock > Settings > Lock name.Device ID: Enter the device ID of your Tedee lock. This is required to generate a certificate for the lock. Find this information in the Tedee app under Lock > Settings > Information > Device ID.
- Ensure you have an internet connection and all data from the previous step has been filled in.
- The
Personal Access Keyis required for creating aMobileIDand generating acertificate. Click theGenerate certificatebutton to proceed. If successful, you will seeCertificate: Generate certificate request successfulbelow theKeep Connectionswitch. If the request fails, you will seeCertificate: [ERROR MESSAGE]. If there will be an error, ensure you have an internet connection, and that the Serial Number, Lock Name, and Device ID are correctly entered and match those from the Tedee app. - If you continue to encounter issues with certificate generation, refer to the additional troubleshooting step (
Step 8). - The Certificate, Device Public Key, and Mobile Public Key are saved in the device's cache. For future app launches, you won't need to regenerate the token; you can skip directly to (
Step 10)
⚠️ The generated certificate has an expiration date included in the response. Once expired, you will not be able to operate the lock and will need to acquire a new one. In this case, simply clickGenerate token.
- Go to Tedee API and authorize yourself with created
Personal Access Key(from Step 4) - Click "Authorize" button
- Proper format is
PersonalKey [YOUR PERSONAL ACCESS KEY] - Confirm with
Authorize
ℹ️ You can also use one-time token by signing in after clicking "Azure B2C Login Page" on top of Swagger website. Paste returned token similarly as in step 6. in
Bearer [TOKEN]format
- Go to
Mobilesection and usePOST /api/[api version]/my/mobileroute and click onTry it outbutton
- Enter
name(lock name from Tedee app),operatingSystemset to3andpublicKeythe one that was copied in "First launch" step - Response will return
idthat is required in next step (asMobileID) - Go to
DeviceCertificatesection and use/api/[api version]/my/devicecertificate/getformobile
- Click on
Try it out - Fill
MobileIDgathered from previous request response - Fill
DeviceIdgathered from Tedee app (click: Lock > Settings > Information > Device ID) - Click
Execute, store somewhere response result, you will need it in next step
⚠️ Generated certificate has expiration date, which is attached to the response with certificate. After certificate expiration you will not be able to operate the lock and you need to get new one.
- Open MainActivity.kt in project navigator
- Replace value of
certificatewithresult.certificateof API request - Replace value of
devicePublicKeywithresult.devicePublicKeyof API request - Comment out the
setupCertificateDatamethod call to prevent its execution. - Compile and run app again with
Run 'app'button or useShift + F10. You won't need to clickGenerate certificateagain, as you now have the necessary information.
⚠️ By default, the connection method from the Tedee Lock SDK has the keepConnection parameter set to false.
- To modify the keepConnection setting, use the switch found directly below the
Connectbutton. - Turning the switch on allows the app to maintain the connection indefinitely.
- Turning the switch off sets the app to keep the connection for a limited time only.
- Click the
Connectbutton. - During the connection process, the status will display
Connecting. Once the connection is successfully established, it will change toSecure session established. If any issues occurs, the status will showDisconnected.
⚠️ If you are unable to connect to lock, please check if your mobile certificate did not change or was not expired. It is deleted after every app uninstall. If it changes, repeat step 7
- Once the app is connected to the lock, you'll see two fields and a
SENDbutton. In the first EditText, you can input theLOCK COMMAND(e.g., 0x51 to open the lock). The second EditText is optional and allows you to input parameters to be sent with the command (e.g., 0x02 to force unlock). You can input multiple values in the params field by separating them with spaces (e.g., 0x02 0x04). For BLE commands documentation, refer to Tedee Lock BLE API Documentation and navigate to theCOMMANDSsection from the right menu. - The app should execute the command, and you can observe the Logcat or history of the commands/notifications/errors at the bottom of the example app screen. Messages tagged with
MESSAGE:indicate BT messages sent by the mobile device, while messages tagged withLOCK LISTENER message:indicate BT responses from the lock. For instance, the unlock command has a value of 51. The response may contain additional parameters. If the parameter is 00, the lock successfully initiated the operation. For more information, refer to Tedee Lock BLE API Documentation.
- The app listens for notifications from the lock. Check the Logcat for notifications tagged with
NOTIFICATION:. For example, after sending the unlock command (0x51), the app listens for notifications and receives lock state changes if the operation is successful. The first state is opening state (0x04), followed by opened state (0x02). The logcat line will appear as: [NOTIFICATION: BA 04 00] for a state change to opening. Refer to Tedee Lock BLE API Documentation and navigate to theNOTIFICATIONSsection from the right menu for more information about notifications. - To close the BT connection between the app and the lock, simply click the
Disconnectbutton.






