Coder Social home page Coder Social logo

sweetbit-io / sweetbit Goto Github PK

View Code? Open in Web Editor NEW
49.0 5.0 10.0 3.02 MB

๐Ÿ”Œ Sweet daemon for pairing and control of the Bitcoin-enabled candy dispenser

Home Page: https://sweetbit.io

License: MIT License

Go 64.68% Makefile 0.55% JavaScript 31.44% HTML 0.20% BitBake 2.02% Shell 1.11%
bitcoin candy lightning network dispenser hardware sweetbit

sweetbit's Introduction

๐Ÿ”Œ sweetd

license release

Sweet daemon for pairing and control of the Bitcoin-enabled candy dispenser

Intro

sweetd is the daemon process running on the Bitcoin-enabled candy dispenser. It manages pairing and control, which is used by the Candy Dispenser app:

The sweetd program offers the following features:

  • ๐Ÿฌ Control of the motor for dispensing candy
  • ๐Ÿ“ณ Control of the buzzer for user feedback
  • โ˜๏ธ React on events from the touch sensor
  • ๐Ÿ”ต Pair through Bluetooth
  • ๐ŸŒ Set up Wi-Fi on candy dispenser
  • โšก Dispense candy on payments from remote lnd node
  • ๐Ÿ’… Customize name of your dispenser
  • ๐Ÿ”„ Update itself through app
  • โš™๏ธ Ensure all system configs are made

Download

Download the pre-built binary for your system from the GitHub releases page.

Extract and open the downloaded archive, then run sweetd.

Structure

The sweetd program's source code is split into small modules:

  • ๐Ÿ”Œ api - REST api for remote management of the dispenser
  • โš™๏ธ app - website for managing the dispenser
  • ๐Ÿฌ dispenser - orchestrator for everything the dispenser does
  • โšก๏ธ lightning - controller for configured Lightning nodes, remote and local
  • ๐Ÿ”ฉ๏ธ machine - hardware controller for the touch sensor, motor and buzzer
  • ๐Ÿ“ถ network - network subsystem that handles Wi-Fi discovery and connectivity
  • ๐Ÿคนโ€ nodeman - node manager
  • ๐Ÿง… onion - Tor onion service conveniences and .onion address generation
  • ๐Ÿ“ฒ pairing - pairing controller for BLE pairing
  • ๐Ÿ’ต pos - point-of-sale website that creates invoices
  • ๐Ÿ›‘ reboot - methods for rebooting and shutting down the system
  • ๐Ÿ“ sweetdb - persistent database manager
  • ๐Ÿ“ƒ sweetlog - logging middleware for intercepting logs
  • ๐Ÿ”– sysid - methods for determining a system-specific id
  • ๐Ÿ”„ updater - update subsystem that controls system updates

Configure data directory

By default, sweetd stores all data to ./data. You can easily override this location:

sweetd --datadir=/data/sweetd

Configure machine access

Currently, the sweetd program is only tested and executed on a Raspberry Pi. Running the executable with no options is the same as providing the following options:

sweetd \
  --machine=raspberry \
  --raspberry.touchpin=25 \
  --raspberry.motorpin=23 \
  --raspberry.buzzerpin=24

You can also mock the underlying machine with the following option:

sweetd \
  --machine=mock \
  --mock.listen=localhost:5000

With this option, you can fake touches by sending simple HTTP requests to the mock machine:

curl http://localhost:5000/touch/on
curl http://localhost:5000/touch/off

Configure the sweetd API server

sweetd exposes a gRPC API. It can be used to configure the Wi-Fi network that the candy dispenser connects to, personalize it and change settings.

By default, the API server listens on 0.0.0.0:9000. This can be changed with the following option:

sweetd --listen=localhost:9000

It's also possible to specify multiple --listen options and listen to multiple interfaces at once.

Enable Wi-Fi hotspot pairing

At the moment, the only app pairing mechanism is through a Wi-Fi hotspot that is created by the sweetd program.

This feature needs to be activated first:

sweetd --ap

Make sure that the following dependencies are installed when running the access point mode:

hostapd wireless-tools wpasupplicant dnsmasq iw

The access point is configured with the below defaults. Any of these can be changed to your needs.

sweetd \
  --ap \
  --ap.ip=192.168.27.1/24 \
  --ap.interface=uap0 \
  --ap.ssid=candy \
  --ap.passphrase=reckless \
  --ap.dhcprange=192.168.27.100,192.168.27.150,1h

This will create a Wi-Fi network called candy with the passphrase reckless. An app will connect to that network for pairing and use the gRPC api that is provided by the sweetd program.

Development

go get -d github.com/the-lightning-land/sweetd

cd $GOPATH/src/github.com/the-lightning-land/sweetd

go build

./sweetd

Releasing using goreleaser

The tool goreleaser can automatically sign the release and upload it to GitHub.

git tag -a v0.1.0 -m "Release name"

git push origin v0.1.0

goreleaser --rm-dist

sweetbit's People

Contributors

davidknezic avatar guggero avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar

sweetbit's Issues

Remove node from image

Apparently node is bundled into the image even though it is only supposed to be a build time dependency for building the pos and app frontends.

Root go.mod interferes during build of go-native-1.12.9-r0

During the bitbake build the go-native-1.12.9-r0 compile step fails with following error:

Log data follows:
| DEBUG: Executing shell function do_compile
| Building Go cmd/dist using /workdir/sweetbit/yocto/build/tmp/work/x86_64-linux/go-native/1.12.9-r0/go1.4/go.
| Building Go toolchain1 using /workdir/sweetbit/yocto/build/tmp/work/x86_64-linux/go-native/1.12.9-r0/go1.4/go.
| Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
| Building Go toolchain2 using go_bootstrap and Go toolchain1.
| go: golang.org/x/[email protected]: unrecognized import path "golang.org/x/net" (https fetch: no http in bootstrap go command)
| go: go.etcd.io/[email protected]: unrecognized import path "go.etcd.io/bbolt" (https fetch: no http in bootstrap go command)
| go: golang.org/x/[email protected]: unrecognized import path "golang.org/x/sys" (https fetch: no http in bootstrap go command)
| go: golang.org/x/[email protected]: unrecognized import path "golang.org/x/text" (https fetch: no http in bootstrap go command)
| go: google.golang.org/[email protected]: unrecognized import path "google.golang.org/appengine" (https fetch: no http in bootstrap go command)
| go: periph.io/x/[email protected]+incompatible: unrecognized import path "periph.io/x/periph" (https fetch: no http in bootstrap go command)
| go: google.golang.org/[email protected]: unrecognized import path "google.golang.org/grpc" (https fetch: no http in bootstrap go command)
| go: google.golang.org/[email protected]: unrecognized import path "google.golang.org/genproto" (https fetch: no http in bootstrap go command)
| go: golang.org/x/[email protected]: unrecognized import path "golang.org/x/crypto" (https fetch: no http in bootstrap go command)
| go: error loading module requirements
| go tool dist: FAILED: /workdir/sweetbit/yocto/build/tmp/work/x86_64-linux/go-native/1.12.9-r0/go/pkg/tool/linux_amd64/go_bootstrap install -gcflags=all= -ldflags=all= -i cmd/asm cmd/cgo cmd/compile cmd/link: exit status 1
| WARNING: exit code 2 from a shell command.
| ERROR: Function failed: do_compile (log file is located at /workdir/sweetbit/yocto/build/tmp/work/x86_64-linux/go-native/1.12.9-r0/temp/log.do_compile.84199)

This happens since the yocto files are part of the sweetd repository, which has a go.mod file in its root that is being pulled during compilation. Possible solutions:

  • Move build directory out of project tree
  • Temporarily move go.mod before and after compilation of go-native
  • Nest sweetd Go project in src
  • Set GO111MODULE=off in go-native build

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.