Code Monkey home page Code Monkey logo

doorlock's Introduction

Migration done on 2021-11-16

Node bundles TLS root certificates and does not respect system root certificates. Node v8 is too old to has the latest root certificate used by Let's encrypt.

The following changes were done on the raspberry pi.

  • Installed Node 10.24.1 to work around certificate expiration.
  • Installed Node 8.17.0 to replace the existing Node 8.14.0
  • Edited /etc/systemd/system/[email protected] to use node 10.24.1
  • Edited /etc/systemd/system/[email protected] to use node 8.17.0

There was an attempt to also upgrade the Node used by doorlock-ble, but the dependency bleno works on Node 8 exclusively. Therefore, the Node version of doorlock-ble must be fixed at 8.

doorlock

Oursky IoT doorlock system.

System Architecture:

(drawn using GNU Dia)

Hardware

Circuit diagrams are drawn with this Circuit Simulator.
Diagrams are saved as txt files, you can import them under File > Import From Text.

Relay Board:

Connections:

  • Release Button: GPIO0/Ground
  • Release Signal: GPIO1/Ground

Raspberry Pi 3

System: ArchLinux ARM

Enable Watchdog:

[~/]$ pacman -S watchdog
[~/]$ systemctl enable watchdog
[~/]$ systemctl start watchdog
# /etc/watchdog.conf

ping = 127.0.0.1
max-load-1 = 24
watchdog-timeout = 10
watchdog-device = /dev/watchdog
realtime = yes
priority = 1

Doorlock Daemon

Responsible for interacting with hardware connected to the Pi. Exposes a HTTP API listening on 127.0.0.1:8090, any requests sent to this socket will trigger an unlock. An optional header X-Source can be sent to identify the triggering source (e.g. Bluetooth LE). Written in clojure, runs on JVM.

Build Dependencies:

  • leiningen

Build:

[~/]$ git clone ...
[~/doorlock/daemon-doorlock]$ lein uberjar

The compiled JAR is now in daemon-doorlock/target/doorlock-<version>-standalone.jar.

Runtime Dependencies:

  • java
  • wiringpi-git (AUR)

Install as systemd service:

  1. copy the compiled JAR to /home/oursky/doorlock.jar
  2. copy doorlock.service to /etc/systemd/system/
  3. enable and start the service:
[oursky ~/]$ sudo systemctl enable doorlock
[oursky ~/]$ sudo systemctl start doorlock

Note: If your username is not oursky, you need to edit doorlock.service accordingly.

BLE Trigger Daemon

Running this service, the rpi would act as peripheral and advertise. You would need to connect to the device and write a generated time-based token to service 'fff0' characteristic 'fff0' to unlock.

Runtime Dependencies:

  • bluez
  • pi-bluetooth (AUR)
  • nodejs
  • npm

Install as systemd service:

  1. copy index.js and package.json to /home/oursky/ble
  2. copy [email protected] to /etc/systemd/system/
  3. setup, enable and start the service:
[oursky ~/ble]$ npm install
[oursky ~/ble]$ sudo systemctl enable doorlock-ble@<your-secret>
[oursky ~/ble]$ sudo systemctl start doorlock-ble@<your-secret>

Skygear Trigger Daemon

Listen for unlock requests from Skygear ...

Home directory Backup

Backup of user:oursky home directory which contains the compiled code could be found on miniserver /doc/doorlock.tgz

OpenSky App

Allow end users to trigger an unlock from a mobile device. Written using clojurescript on react-native.

Dev Dependencies:

  • leiningen
  • npm
  • re-natal (from npm)
  • react-native-cli (from npm)
  • android SDK (must set env ANDROID_HOME)
  • android platform tools (adb)
  • XCode (with CLI tools)
  • rlwrap (optional, for figwheel REPL)

Android Development:

[~/doorlock/opensky/]$ npm install
[~/doorlock/opensky/]$ npm start                       # start react-native packager
[~/doorlock/opensky/]$ rlwrap lein figwheel android    # start figwheel dev server
[~/doorlock/opensky/]$ react-native run-android        # deploy app
[~/doorlock/opensky/]$ adb reverse tcp:8081 tcp:8081   # connect react-native
[~/doorlock/opensky/]$ adb reverse tcp:3449 tcp:3449   # connect figwheel

doorlock's People

Contributors

akiroz avatar jasonkit avatar louischan-oursky avatar rickmak avatar steven-chan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

doorlock's Issues

Add Confirmation dialog to logout

This issue is about the OpenSky App, not sure if it is the right repo to post at.

The "忘記芝麻" and "花生開門" buttons are too close to each other. And there is no confirmation dialog for "忘記芝麻".
It's very easy for the users to mis-press the wrong button and found themselves logged out, esp on smaller devices like iPhone SE / Mini.

Suggestion: Add a confirmation dialog to "忘記芝麻", this requires the least UI changes

Remove Nanoleaf API key and make it configurable instead of hardcode

A quick change at Hackathon of X'mas 2017, we added Nanoleaf support to the code (at branch nanoleaf), however it hardcode the API key which is the URL to the Nanoleaf, and the theme to open in code. It should be configurable. (And not give up the API key of our office's nanoleaf! To avoid people come to our office / VPN and show red all the time lol)

Tasks:

  • Make Nano Leaf URL (IP, port, API key) and effects name configurable
  • Make daemon-opendoor fire trigger of door unlock / door lock, instead of hard code nanoleaf code in the middle of the code.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.