Coder Social home page Coder Social logo

doorlock's Introduction

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.

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 ...

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 rickmak avatar steven-chan avatar

Watchers

 avatar  avatar

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.