tilt

package module
v0.0.0-...-3aed0fb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2023 License: MIT Imports: 10 Imported by: 2

README

Tilt API in Go

GoDoc Go Report Card

This package provides a library for reading data from Tilt sensors.

Tilt sensors are devices for brewers that read specific gravity and temperature during fermentation.

Installation

go get github.com/alexhowarth/go-tilt

Usage

s := tilt.NewScanner()
s.Scan(20 * time.Second)

for _, t := range s.Tilts() {
	t.Print()
}

Compatibility

This project currently uses a specific fork of go-ble that is compatible with both Linux and macOS.

Cross compiling

To create a binary for use on a Raspberry Pi, simply build it for ARM and copy the binary (no other dependencies are required).

env GOOS=linux GOARCH=arm go build examples/scanner/scanner.go

Documentation

Overview

Package tilt provides an interface to Tilt Bluetooth devices

Index

Constants

This section is empty.

Variables

View Source
var ErrNotBeacon = errors.New("Not an iBeacon")

ErrNotBeacon - the BLE device is not an iBeacon

View Source
var ErrNotTilt = errors.New("Not a Tilt iBeacon")

ErrNotTilt - the BLE device does not match anything in tiltType

Functions

func IsIBeacon

func IsIBeacon(data []byte) bool

IsIBeacon to determine if data is an iBeacon

func IsTilt

func IsTilt(d []byte) bool

IsTilt tests if the data is from a Tilt

Types

type Colour

type Colour string

Colour of the Tilt

type Devices

type Devices map[Colour]Tilt

Devices stores discovered devices

type IBeacon

type IBeacon struct {
	UUID  string
	Major uint16
	Minor uint16
}

IBeacon data

func NewIBeacon

func NewIBeacon(data []byte) (b *IBeacon, err error)

NewIBeacon creates an iBeacon from a valid BLE event

type Scanner

type Scanner struct {
	// contains filtered or unexported fields
}

Scanner for Tilt devices

func NewScanner

func NewScanner() *Scanner

NewScanner returns a Scanner

func (*Scanner) HandleTilt

func (s *Scanner) HandleTilt(t Tilt)

HandleTilt adds a discovered Tilt to a map

func (*Scanner) Scan

func (s *Scanner) Scan(timeout time.Duration)

Scan finds Tilt devices and times out after a duration

func (*Scanner) Tilts

func (s *Scanner) Tilts() Devices

Tilts contains the found devices

type Tilt

type Tilt struct {
	// contains filtered or unexported fields
}

Tilt struct

func NewTilt

func NewTilt(b *IBeacon) (t Tilt, err error)

NewTilt returns a Tilt from an iBeacon

func (*Tilt) Celsius

func (t *Tilt) Celsius() float64

func (*Tilt) Colour

func (t *Tilt) Colour() Colour

func (*Tilt) Fahrenheit

func (t *Tilt) Fahrenheit() uint16

func (*Tilt) Gravity

func (t *Tilt) Gravity() float64

func (*Tilt) Print

func (t *Tilt) Print()

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL