Code Monkey home page Code Monkey logo

bloop-box-client's Introduction

Bloop Box

ci

Bloop box client written in Rust with Tokio.

Table of Contents

  1. NFC tag support
  2. Run-time configuration
  3. LED status codes
  4. Pre-requisites
  5. Shared data
  6. Development
  7. Deployment
    1. Automatic
    2. Manual
  8. System Setup

NFC tag support

While for reading UIDs any NFC tag supporting Iso14443a with a baud rate of 106 is supported, it is recommended to use tags with a 7-byte UID. Tags with shorter UIDs will be padded with zeroes, while tags with longer UIDs will be truncated.

When it comes to config tags though you have to use either NTAG 213, 215 or 216. Other NTAG formats may work but are not tested.

Run-time configuration

You can change all configuration at run-time via text records on an NTAG tag. A helpful utility to automatically generate the text records is available here. If you prefer to generate the config tags in another way, following is the format for the text record:

Each record begins with a single letter denoting the command. It is followed by a JSON array with zero or more arguments.

Command Description Arguments
w Set WiFi Credentials SSID, Password
c Set Connection Details Host, Port, Client ID, Secret
v Set Max Volume Volume (0.0 - 0.1)
u Add additional config tag
r Remove all but current config tag
s Shut down system

LED status codes

The status RGB LED will display the current status of the Bloop Box. If no user interaction is required, you'll get a static light, otherwise a blinking one.

Static

  • Green: Ready to read attendee tags
  • Yellow: Processing tag
  • Cyan: Config tag accepted
  • Red: Config tag denied (malformed data)

Blinking

  • Magenta: Awaiting new config tag
  • Yellow: Awaiting connection config
  • Blue: Connecting to server
  • Red: Invalid server credentials

Pre-requisites

Before you can deploy the Bloop Box client you need to set up the Raspberry Pi of course, including audio and NFC. If you are using our reference design for the hardware, the steps to take are documented in the System setup section.

Shared data

You'll need to have a data package for the bloop box installed. For more information about this, please check the Bloop Box Data Example

Development

If you are testing against a locally hosted server with a self-signed certificate, you have to disable certificate verification in order to connect to that server. You can do so through the following call:

bloop-box --dangerous-disable-cert-verification

Be really careful to only use this flag in development. If you use this in production, the client will not know if the server certificate is genuine and be open to man-in-the-middle attacks!

Deployment

Automatic

You can find pre-compiled .deb files in the release section. These will automatically set everything up for you.

Manual

Cross compilation

In order to compile Bloop Box for the Raspberry Zero W, run the following command:

cross build --target arm-unknown-linux-gnueabihf

This will generate a debug build. In order to create a release build, add --release to the command.

Copy the resulting binary from the target folder to /usr/bin/bloop-box.

User setup

Apart from the shared data, you'll need to set up the bloop-box user and its lib directory:

adduser --system --home /nonexistent --gecos "bloop-box" \
        --no-create-home --disabled-password \
        --quiet bloop-box
usermod -a -G gpio,spi,i2c,audio,netdev bloop-box
mkdir -p /var/lib/bloop-box
chown bloop-box:nogroup /var/lib/bloop-box

On a development system, you might want to give the bloop-box user a login shell and a home directory.

Allow bloop-box user to shut down system

The bloop box client has the capability to shut down the system when it receives the right config command. In order to do so it needs sudo privilege to call the shutdown binary. You can accomplish this by copying the 011_bloop-box-shutdown file from the etc directory to /etc/sudoers.d and change its permissions ot 440.

Hardware config

In order to configure the Bloop Box for your specific hardware, you need to copy the etc/bloop-box.conf file to via SSH to /etc/bloop-box. If you are using our open hardware motherboard, you can leave all values in it as is, otherwise you need to adjust it to match your hardware.

Systemd

To have the bloop box automatically start when the system boots, create a systemd file in /lib/systemd/system/bloop-box.service:

[Unit]
Description=BloopBox
After=network.target

[Service]
Type=simple
User=bloop-box
ExecStart=/usr/bin/bloop-box
Environment="RUST_LOG=error,bloop_box=info"
Restart=always

[Install]
WantedBy=multi-user.target

Then run the following two commands to register and start the daemon:

sudo systemctl daemon-reload
sudo systemctl start bloop-box

System setup

  • Flash an SD card with the latest Raspian Lite image.
  • Create an empty file /boot/ssh.

Create a file /boot/wpa_supplicant.conf with the following contents and adjust SSID and PSK:

country=DE
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
    ssid="NETWORK-NAME"
    psk="NETWORK-PASSWORD"
}

Then insert the SD card into the Bloop Box and boot it up. After that, connect to it via SSH (pi:raspberry). The first thing you should do is to add your public key to ./.ssh/authorized_keys. Then you should disable password authentication for security reasons.

To do so, edit /etc/ssh/sshd_config, uncomment PasswordAuthentication and set the value to no. Then you can reload the SSH daemon: sudo systemctl reload sshd.

Then install the audio driver according to these instructions: https://learn.adafruit.com/adafruit-max98357-i2s-class-d-mono-amp/raspberry-pi-usage

Next you need to enable SPI for the MFRC522 NFC reader:

sudo raspi-config nonint do_spi 0

bloop-box-client's People

Contributors

dasprid avatar semantic-release-bot avatar maticsulc 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.