Git Product home page Git Product logo

banglecli's Introduction

banglecli

Introduction

I use my Bangle.js as general input / output device, not only for typical "smartwatch use-cases". This repository collects CLI-based tools to interact with a Bangle.js over Bluetooth Low Energy I've written. Currently, banglebang is the only one.

Tool Overview

banglebang ๐Ÿ””

Ever ran a wget in background, switched to your browser, and then forgot that you were downloading something at all? Or hate switching windows just to check if it's finished? This has come to an end with banglebang. It will take input from stdin (e.g by using a pipe, | ) and display it as notification on your Bangle.js.

curl -s https://example.com/file.zip | banglebang

If there is no message specified by stdin, the Bangle.js will display "* BAM *". Please also notify that banglebang will only parse the first line of stdin, so you should filter (e.g by using an intermediate grep)

Requirements

  • A working bluetooth low energy stack (e.g. BlueZ) as described in the Espruino Wiki
    • Rule of thumb: if you can use the Espruino Web IDE, you can use banglecli tools without any problems!
  • A working Python 3 installation in #!/usr/bin/python3, also a working pip3 to install the bluetooth library
  • A Bangle.js with the Gadgetbridge App installed (required to display notifications)

Installation

By executing setup.sh`` banglecli will be installed to /usr/local/bin and it's executables under /apps like banglebang will be symlinked to /usr/local/bin/$appname so you can easily call them by bangleapps.

The install script needs root permissions to run, due to /usr/local/bin/ permissions and because BLE access requires a kernel capability that will be set during the install (cap_net_raw,cap_net_admin+eip); Please review the script before executing with sudo setup.sh.

Setup

The only additional required step is to set the BCLI_MAC environment variable to your Bangle.js's MAC address. It should be very easy to find out by running sudo hcitool lescan. I suggest setting this in your shell's .rc file (e.g .bashrc)

Configuration

Besides the already mentioned environment variable BCLI_MAC, there are some more configuration variables. See this table.

Name Description Default
BCLI_MAC MAC address of the Bangle.js to connect to [Required]
BCLI_RETRIES Number of retries when connecting to Bangle.js 3
BCLI_SOURCE Source that will be used for notifications "bcli"
BCLI_TITLE Title that will be used for notifications [Command Output]
BCLI_MSG Fallback message when no input from stdin is detected "Command finished"

Contribution

I tried maintain a certain level of modularity and put the generic functions into bcli.py. If you want to write a new banglecli tool, you can start by importing this file. Connection setup can be copied from banglebang. Don't get confused by BTLE Characteristics, just get the TX and RX objects and write to them. Also, never forget to send your messages through packByteArray since send BLE packet size limit is 20 bytes, at least for the Nordic Semiconductor chip the Bangle is using.

banglecli's People

Contributors

ziehmon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

banglecli's Issues

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.