Documentation ¶
Index ¶
- func NewSession(private authentication.ECDHPrivateKey, vin string) (*session, error)
- func SessionInfoRequest(domain universal.Domain, publicBytes []byte) *universal.RoutableMessage
- type CacheEntry
- type Dispatcher
- func (d *Dispatcher) Cache() []CacheEntry
- func (d *Dispatcher) LoadCache(entries []CacheEntry) error
- func (d *Dispatcher) RequestSessionInfo(ctx context.Context, domain universal.Domain) (protocol.Receiver, error)
- func (d *Dispatcher) RetryInterval() time.Duration
- func (d *Dispatcher) Send(ctx context.Context, message *universal.RoutableMessage, ...) (protocol.Receiver, error)
- func (d *Dispatcher) SetMaxLatency(latency time.Duration)
- func (d *Dispatcher) Start(ctx context.Context) error
- func (d *Dispatcher) StartSession(ctx context.Context, domain universal.Domain) error
- func (d *Dispatcher) StartSessions(ctx context.Context, domains []universal.Domain) error
- func (d *Dispatcher) Stop()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewSession ¶
func NewSession(private authentication.ECDHPrivateKey, vin string) (*session, error)
NewSession creates a new session object that can authorize commands going to the vehicle and authenticate session info arriving from the vehicle.
func SessionInfoRequest ¶
func SessionInfoRequest(domain universal.Domain, publicBytes []byte) *universal.RoutableMessage
SessionInfoRequest returns a RoutableMesasge that initiates a handshake with a vehicle Domain.
Types ¶
type CacheEntry ¶
type CacheEntry struct { CreatedAt time.Time `json:"created_at"` Domain int `json:"domain"` SessionInfo []byte `json:"data"` }
CacheEntry contains information that allows a vehicle session to be resumed without a handshake mesasge (SessionInfoRequest).
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher objects send (encrypted) messages to a vehicle and route incoming messages to the appropriate receiver object.
func New ¶
func New(conn connector.Connector, privateKey authentication.ECDHPrivateKey) (*Dispatcher, error)
New creates a Dispatcher from a Connector.
func (*Dispatcher) Cache ¶
func (d *Dispatcher) Cache() []CacheEntry
Cache returns a list of CacheEntry objects that contain session state for the authenticated connections to a vehicle's Domains.
func (*Dispatcher) LoadCache ¶
func (d *Dispatcher) LoadCache(entries []CacheEntry) error
LoadCache initializes or overwrites d's sessions. This allows resuming a session with a vehicle without requiring a round trip.
func (*Dispatcher) RequestSessionInfo ¶
func (d *Dispatcher) RequestSessionInfo(ctx context.Context, domain universal.Domain) (protocol.Receiver, error)
RequestSessionInfo sends a handshake request and returns a protocol.Receiver for receiving the response.
func (*Dispatcher) RetryInterval ¶
func (d *Dispatcher) RetryInterval() time.Duration
RetryInterval fetches the transport-layer dependent recommended delay between retry attempts.
func (*Dispatcher) Send ¶
func (d *Dispatcher) Send(ctx context.Context, message *universal.RoutableMessage, auth connector.AuthMethod) (protocol.Receiver, error)
Send a message to a vehicle.
func (*Dispatcher) SetMaxLatency ¶ added in v0.1.0
func (d *Dispatcher) SetMaxLatency(latency time.Duration)
func (*Dispatcher) Start ¶
func (d *Dispatcher) Start(ctx context.Context) error
Start runs d's Listen method in a new goroutine. Returns an error if d does not signal it's ready before ctx expires.
func (*Dispatcher) StartSession ¶
StartSession sends a blocking request start an authenticated session with a universal.Domain.
func (*Dispatcher) StartSessions ¶
StartSessions starts sessions with the provided vehicle domains (or all supported domains, if domains is nil).
If multiple connections fail, only returns the first error.
func (*Dispatcher) Stop ¶
func (d *Dispatcher) Stop()
Stop signals any goroutine running Listen to exit.