usb

package
v4.8.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2019 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeviceInfos

func DeviceInfos() []hid.DeviceInfo

DeviceInfos returns a slice of all found bitbox devices.

Types

type Communication

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

Communication encodes JSON messages to/from a bitbox. The serialized messages are sent/received as USB packets, following the ISO 7816-4 standard.

func NewCommunication

func NewCommunication(
	device io.ReadWriteCloser,
	usbWriteReportSize,
	usbReadReportSize int,
	usbCMD byte,
	hmac bool) *Communication

NewCommunication creates a new Communication.

func (*Communication) Close

func (communication *Communication) Close()

Close closes the underlying device.

func (*Communication) ReadFrame

func (communication *Communication) ReadFrame() ([]byte, error)

ReadFrame reads one usb message.

func (*Communication) SendBootloader

func (communication *Communication) SendBootloader(msg []byte) ([]byte, error)

SendBootloader sends a message in the format the bootloader expects and fetches the response.

func (*Communication) SendEncrypt

func (communication *Communication) SendEncrypt(msg, password string) (map[string]interface{}, error)

SendEncrypt sends an encrypted message. The response is json-deserialized into a map. If the response contains an error field, it is returned as a DBBErr.

func (*Communication) SendFrame

func (communication *Communication) SendFrame(msg string) error

SendFrame sends one usb message.

func (*Communication) SendPlain

func (communication *Communication) SendPlain(msg string) (map[string]interface{}, error)

SendPlain sends an unecrypted message. The response is json-deserialized into a map.

type CommunicationErr

type CommunicationErr error

CommunicationErr is returned if there was an error with the device IO.

type Manager

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

Manager listens for devices and notifies when a device has been inserted or removed.

func NewManager

func NewManager(
	channelConfigDir string,
	bitbox02ConfigDir string,
	onRegister func(device.Interface) error,
	onUnregister func(string),
	onlyOne bool,
) *Manager

NewManager creates a new Manager. onRegister is called when a device has been inserted. onUnregister is called when the device has been removed.

The channelConfigDir argument is passed to each device during initialization, before onRegister is called.

func (*Manager) Start

func (manager *Manager) Start()

Start listens for inserted/removed devices forever.

Jump to

Keyboard shortcuts

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