connector

package
v0.0.0-...-81a5b18 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package connector defines an interface for datagram transport between clients and Tesla vehicles.

Index

Constants

View Source
const BufferSize = 5

BufferSize is the number of inbound messages that can be queued.

View Source
const MaxResponseLength = 100000

MaxResponseLength caps the maximum byte-length of responses that connectors must support.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthMethod

type AuthMethod int32

AuthMethod enumerates the different mechanisms vehicles use to authenticate clients.

const (
	// AuthMethodNone commnds are unauthenticated. They are typically used for handshake messages.
	AuthMethodNone AuthMethod = iota

	// AuthMethodGCM commands are authenticated and encrypted with AES-GCM-ECDH.
	AuthMethodGCM

	// AuthMethodHMAC commands are authenticated with HMAC-SHA256-ECDH.
	AuthMethodHMAC
)

type Connector

type Connector interface {
	// Receive returns a read-only channel used to receive datagrams sent by the vehicle.
	//
	// Implementations must be thread safe.
	Receive() <-chan []byte

	// Send sends a buffer to the vehicle.
	//
	// Depending on the error, the vehicle may have received and even acted on
	// the message. For some errors, such as network timeouts, the client will
	// not be able to determine if this is the case. If the returned error
	// implements the vehicle.Error interface, then the client may be able
	// to determine if the message was received by using the appropriate
	// methods.
	//
	// Implementations must be thread safe.
	Send(ctx context.Context, buffer []byte) error

	// VIN returns the vehicle identification number of the connected vehicle.
	VIN() string

	// Close terminates the connection a vehicle.
	//
	// Repeated calls to Close() must be idempotent, but the behavior of the interface is otherwise
	// undefined after calling this method.
	Close()

	// PreferredAuthMethod returns the AuthMethod that a Dispatcher should use with this connection.
	// An HTTP-based Connector requires AuthMethodHMAC.
	PreferredAuthMethod() AuthMethod

	// RetryInterval returns the recommended wait time between transmission attempts.
	RetryInterval() time.Duration
}

Connector send and receives raw datagrams ([]byte) from a vehicle.

type FleetAPIConnector

type FleetAPIConnector interface {
	Connector
	SendFleetAPICommand(ctx context.Context, endpoint string, command interface{}) ([]byte, error)
	Wakeup(ctx context.Context) error
}

FleetAPIConnector is a superset of Connector (which sends datagrams to vehicles) that also allows sending commands to Fleet API.

Directories

Path Synopsis
Package ble implements the Connector interface using BLE.
Package ble implements the Connector interface using BLE.
Package inet implements the Connector interface using an HTTP REST API.
Package inet implements the Connector interface using an HTTP REST API.

Jump to

Keyboard shortcuts

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