Smartlock


Smartlock is a multi-door lock controller based on Raspberry Pi (Android Things) with the client for Android smartphones. Personally, it's my way of learning the Android Things platform and exploring Firebase services.

Google announced an update about the Android Things platform. It's discontinued and the console will be shut down on January 5, 2022. That will be for sure a good reason to change the controller implementation, probably with the use of my second project - Jetty. The other parts of this project: Android app and Firebase instance and configuration will remain.

Conception

From the functional point of view, the user of this system should be able to add a virtual lock (or locks) on the Raspberry Pi platform and access it through the admin account on the Android smartphone app. Furthermore, as a lock administrator, the user should be able to give temporary or permanent access to the specific lock for any other registered user on basis of his email address.

Implementation

The Android app and Android Things module communicates through the common real-time database: Firebase Firestore.

Smartlock_scheme

The heart of this database is the table called locks. It contains all key knowledge about the lock: its owner, granted accesses, secure ID, and index of entries about performed actions. The two other tables: logs and users are complementary to the main locks table, storing detailed information.

Smartlock_locks_table

For security reasons, the Android Things module could additionally act as a beacon that emits an encrypted secret key through Bluetooth. When the Android phone with the Smartlock app will show up in the controller Bluetooth range, it'll receive the secret key, which in combination with the user data provides an additional layer of security. If the user is on the access list, the notification will appear that allows changing the lock state.

Code

The app architecture is based on MVVM with slight use of RxJava2 library. Currently I'm working on refactoring and moving controller module out of Android Things platform. The old source code is available on my GitHub page.

Status of the project:

☑ Create authentication process on basis of Firebase Authentication
☑ Create NoSQL cloud database instance and database structure with Cloud Firestore
☑ Configure Android Things for Raspberry Pi 3B with a GPIO LCD screen
☑ Create an app for Android smartphones for accessing the locks, managing accesses, and viewing logs
☑ Create an app for Android Things for controlling the local, virtual locks displayed on the screen

Updates in progress:

☐ Use an alternative for Android Things

Potential updates:

☑ Use the Gradle plugin or NDK for hiding the secret keys in open-source projects. Make the code public
☐ Use BLE encrypted communication to propagate secure ID as an additional layer of system security
☐ Secure the database with Firebase Security Rules
☐ Use servo motor with a real lock instead of virtual locks