service

package
v0.0.0-...-a6e383f Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2022 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateCertificate

func CreateCertificate(organizationalUnit, organization, country, commonName string) (tls.Certificate, error)

Create a ship compatible self signed certificate organizationalUnit is the OU of the certificate organization is the O of the certificate country is the C of the certificate commonName is the CN of the certificate Example for commonName: "deviceModel-deviceSerialNumber"

Types

type EEBUSService

type EEBUSService struct {
	ServiceDescription *ServiceDescription

	// The local service details
	LocalService *ServiceDetails
	// contains filtered or unexported fields
}

A service is the central element of an EEBUS service including its websocket server and a zeroconf service.

func NewEEBUSService

func NewEEBUSService(ServiceDescription *ServiceDescription, serviceHandler EEBUSServiceHandler) *EEBUSService

creates a new EEBUS service

func (*EEBUSService) AddEntity

func (s *EEBUSService) AddEntity(entity *spine.EntityLocalImpl)

Add a new entity, used for connected EVs Only for EVSE implementations

func (*EEBUSService) DisconnectSKI

func (s *EEBUSService) DisconnectSKI(ski string, reason string)

Close a connection to a remote SKI

func (*EEBUSService) IsRemoteServiceForSKIPaired

func (s *EEBUSService) IsRemoteServiceForSKIPaired(ski string) bool

Returns if the provided SKI is from a registered service

func (*EEBUSService) LocalDevice

func (s *EEBUSService) LocalDevice() *spine.DeviceLocalImpl

func (*EEBUSService) LocalEntity

func (s *EEBUSService) LocalEntity() *spine.EntityLocalImpl

return the local entity 1

func (*EEBUSService) PairRemoteService

func (s *EEBUSService) PairRemoteService(service ServiceDetails)

Adds a new device to the list of known devices which can be connected to and connect it if it is currently not connected

func (*EEBUSService) RemoteDeviceForSki

func (s *EEBUSService) RemoteDeviceForSki(ski string) *spine.DeviceRemoteImpl

func (*EEBUSService) RemoteDeviceOfType

func (s *EEBUSService) RemoteDeviceOfType(deviceType model.DeviceTypeType) *spine.DeviceRemoteImpl

return a specific remote device of a given DeviceType

func (*EEBUSService) RemoteDevices

func (s *EEBUSService) RemoteDevices() []*spine.DeviceRemoteImpl

return all remote devices

func (*EEBUSService) RemoteSKIConnected

func (s *EEBUSService) RemoteSKIConnected(ski string)

report a connection to a SKI

func (*EEBUSService) RemoteSKIDisconnected

func (s *EEBUSService) RemoteSKIDisconnected(ski string)

report a disconnection to a SKI

func (*EEBUSService) RemoveEntity

func (s *EEBUSService) RemoveEntity(entity *spine.EntityLocalImpl)

Remove an entity, used for disconnected EVs Only for EVSE implementations

func (*EEBUSService) ReportServiceShipID

func (s *EEBUSService) ReportServiceShipID(ski string, shipdID string)

Provides the SHIP ID the remote service reported during the handshake process

func (*EEBUSService) SetLogging

func (s *EEBUSService) SetLogging(logger logging.Logging)

Sets a custom logging implementation By default NoLogging is used, so no logs are printed

func (*EEBUSService) Setup

func (s *EEBUSService) Setup() error

Starts the service by initializeing mDNS and the server.

func (*EEBUSService) Shutdown

func (s *EEBUSService) Shutdown()

Shutdown all services and stop the server.

func (*EEBUSService) Start

func (s *EEBUSService) Start()

Starts the service

func (*EEBUSService) UnpairRemoteService

func (s *EEBUSService) UnpairRemoteService(ski string) error

Remove a device from the list of known devices which can be connected to and disconnect it if it is currently connected

type EEBUSServiceHandler

type EEBUSServiceHandler interface {

	// report a connection to a SKI
	RemoteSKIConnected(service *EEBUSService, ski string)

	// report a disconnection to a SKI
	RemoteSKIDisconnected(service *EEBUSService, ski string)

	// Provides the SHIP ID the remote service reported during the handshake process
	// This needs to be persisted and passed on for future remote service connections
	// when using `PairRemoteService`
	ReportServiceShipID(ski string, shipdID string)
}

interface for receiving data for specific events

type MdnsEntry

type MdnsEntry struct {
	Name       string
	Identifier string   // mandatory
	Path       string   // mandatory
	Register   bool     // mandatory
	Brand      string   // optional
	Type       string   // optional
	Model      string   // optional
	Host       string   // mandatory
	Port       int      // mandatory
	Addresses  []net.IP // mandatory
}

type MdnsSearch

type MdnsSearch interface {
	ReportMdnsEntries(entries map[string]MdnsEntry)
}

type ServiceDescription

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

defines requires meta information about this service

func NewServiceDescription

func NewServiceDescription(
	vendorCode,
	deviceBrand,
	deviceModel,
	serialNumber string,
	deviceType model.DeviceTypeType,
	port int,
	certificate tls.Certificate,
) (*ServiceDescription, error)

Setup a ServiceDescription with the required parameters

func (*ServiceDescription) Identifier

func (s *ServiceDescription) Identifier() string

return the identifier to be used for mDNS and SHIP ID returns in this order: - alternateIdentifier - generateIdentifier

func (*ServiceDescription) MdnsServiceName

func (s *ServiceDescription) MdnsServiceName() string

return the name to be used as the mDNS service name returns in this order: - alternateMdnsServiceName - generateIdentifier

func (*ServiceDescription) SetAlternateIdentifier

func (s *ServiceDescription) SetAlternateIdentifier(identifier string)

define an alternative mDNS and SHIP identifier usually this is only used when no deviceCode is available or identical to the brand if this is not set, generated identifier is used

func (*ServiceDescription) SetAlternateMdnsServiceName

func (s *ServiceDescription) SetAlternateMdnsServiceName(name string)

define an alternative mDNS service name this is normally not needed or used

func (*ServiceDescription) SetInterfaces

func (s *ServiceDescription) SetInterfaces(ifaces []string)

define which network interfaces should be considered instead of all existing expects a list of network interface names

func (*ServiceDescription) SetRegisterAutoAccept

func (s *ServiceDescription) SetRegisterAutoAccept(auto bool)

define wether this service should announce auto accept TODO: this needs to be redesigned!

type ServiceDetails

type ServiceDetails struct {
	// This is the SKI of the service
	// This needs to be persisted
	SKI string

	// This is the IPv4 address of the device running the service
	// This is optional only needed when this runs with
	// zeroconf as mDNS and the remote device is using the latest
	// avahi version and thus zeroconf can sometimes not detect
	// the IPv4 address and not initiate a connection
	IPv4 string

	// ShipID is the ship identifier of the service
	// This needs to be persisted
	ShipID string
	// contains filtered or unexported fields
}

generic service details about the local or any remote service

Jump to

Keyboard shortcuts

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