goralb

package module
v0.0.0-...-32ec79c Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2021 License: MIT Imports: 11 Imported by: 0

README

Goral-B

A WIP Go library for connecting to and getting data from (Braun) Oral-B Bluetooth enabled electric toothbrushes.

Todo

  • Parsing BLE advertisements
  • Connecting to brush
  • Reading/Writing new right light colors
  • Enabling/Disabling ring light
  • Change mode order / activate hidden modes
Debugging

Using gatttool it is possible to manually send commands to the brush.

Connecting to the brush: gatttool --device=<ADDR> -I

Examples

Setting the color to green (#00ff00)

connect                         # Connect to the brush
char-write-req 0x0071 00ff0000  # Set color to 00ff00
char-write-req 0x0052 372f      # "Configure" color
char-write-req 0x0052 1031      # "Control" color enable
char-write-req 0x0052 1032      # "Control" color enable

Documentation

Index

Constants

View Source
const (
	ExtendConnection  statusConfigure = 0x00
	ReadParam         statusConfigure = 0x01
	ReadData          statusConfigure = 0x02
	CalibrationRead   statusConfigure = 0x04
	ReadMetadata      statusConfigure = 0x05
	RTC               statusConfigure = 0x26
	BrushTimer        statusConfigure = 0x28
	BrushModes        statusConfigure = 0x29
	QuadrantTimers    statusConfigure = 0x2a
	TongueTime        statusConfigure = 0x2b
	MyColor           statusConfigure = 0x2f
	Dashboard         statusConfigure = 0x30
	RefillReminder    statusConfigure = 0x31
	FactoryReset      statusConfigure = 0x32
	SmartGuideDisable statusConfigure = 0x50
	SmartGuideEnable  statusConfigure = 0x51
)
View Source
const (
	SetMode          statusControl = 0x01
	StopTimerSignal  statusControl = 0x20
	ResetMemoryTimer statusControl = 0x29
	MyColorDisable   statusControl = 0x30
	MyColorEnable    statusControl = 0x31
	MotionDisable    statusControl = 0x40
	MotionEnable     statusControl = 0x41
)
View Source
const PGCompanyID = 0xDC

Variables

This section is empty.

Functions

func NewScanner

func NewScanner() (*brushScanner, error)

Types

type Brush

type Brush interface {
	Connect(timeout context.Context) error
	Disconnect() error
	SetRingEnabled(enabled bool) error
	SetMotionEnabled(enabled bool) error
	GetColor() (color.RGBA, error)
	SetColor(rgba color.RGBA) error
	Info() *BrushInfo
	String() string
}

func NewBrush

func NewBrush(dev *device.Device1) Brush

type BrushInfo

type BrushInfo struct {
	ProtocolVersion      int
	TypeID               int
	FirmwareVersion      int
	State                BrushState
	PressureDetected     bool
	HasReducedMotorSpeed bool
	HasProfessionalTimer bool
	BrushTime            time.Duration
	Mode                 BrushMode
	Quadrant             BrushQuadrant
	Smiley               int
}

type BrushMode

type BrushMode int
const (
	ModeOff            BrushMode = 0x00 // Off
	ModeDailyClean     BrushMode = 0x01 // Daily
	ModeSensitive      BrushMode = 0x02 // Sensitive
	ModeMassage        BrushMode = 0x03 // Massage
	ModeWhitening      BrushMode = 0x04 // Whitening
	ModeDeepClean      BrushMode = 0x05 // Deep Clean
	ModeTongueCleaning BrushMode = 0x06 // Tongue Cleaning
	ModeTurbo          BrushMode = 0x07 // Turbo
	ModeUnknown        BrushMode = 0xFF // Unknown
)

func (BrushMode) String

func (i BrushMode) String() string

type BrushQuadrant

type BrushQuadrant int
const (
	Sector1 BrushQuadrant = 0x01
	Sector2 BrushQuadrant = 0x02
	Sector3 BrushQuadrant = 0x03
	Sector4 BrushQuadrant = 0x04
	Sector5 BrushQuadrant = 0x05
	Sector6 BrushQuadrant = 0x06
	Sector7 BrushQuadrant = 0x07
	Sector8 BrushQuadrant = 0x08
)

func (BrushQuadrant) String

func (b BrushQuadrant) String() string

type BrushScanner

type BrushScanner interface {
	FindBrush(ctx context.Context) (Brush, error)
	FindBrushes(ctx context.Context, count int) ([]Brush, error)
	Close() error
}

type BrushState

type BrushState int
const (
	StateUnknown BrushState = 0x00 // Unknown
	StateIdle    BrushState = 0x02 // Idle
	StateRun     BrushState = 0x03 // Run
	StateCharge  BrushState = 0x04 // Charge
)

func (BrushState) String

func (i BrushState) String() string

type Color

type Color int

func (Color) String

func (c Color) String() string

Directories

Path Synopsis
_example

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳