service

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2023 License: MIT Imports: 30 Imported by: 13

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 Configuration added in v0.1.1

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

defines requires meta information about this service

func NewConfiguration added in v0.1.1

func NewConfiguration(
	vendorCode,
	deviceBrand,
	deviceModel,
	serialNumber string,
	deviceType model.DeviceTypeType,
	port int,
	certificate tls.Certificate,
	voltage float64,
) (*Configuration, error)

Setup a Configuration with the required parameters

func (*Configuration) Identifier added in v0.1.1

func (s *Configuration) Identifier() string

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

func (*Configuration) MdnsServiceName added in v0.1.1

func (s *Configuration) MdnsServiceName() string

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

func (*Configuration) SetAlternateIdentifier added in v0.1.1

func (s *Configuration) 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 (*Configuration) SetAlternateMdnsServiceName added in v0.1.1

func (s *Configuration) SetAlternateMdnsServiceName(name string)

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

func (*Configuration) SetInterfaces added in v0.1.1

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

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

func (*Configuration) SetRegisterAutoAccept added in v0.1.1

func (s *Configuration) SetRegisterAutoAccept(auto bool)

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

func (*Configuration) Voltage added in v0.1.1

func (s *Configuration) Voltage() float64

return the sites predefined grid voltage

type EEBUSService

type EEBUSService struct {
	Configuration *Configuration

	// 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(configuration *Configuration, 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)
}

implemented by hubConnection, used by mdns

type MdnsService added in v0.1.2

type MdnsService interface {
	SetupMdnsService() error
	ShutdownMdnsService()
	AnnounceMdnsEntry() error
	UnannounceMdnsEntry()
	RegisterMdnsSearch(cb MdnsSearch)
	UnregisterMdnsSearch(cb MdnsSearch)
}

implemented by mdns, used by hubConnection

type ServiceDetails

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

generic service details about the local or any remote service

func NewServiceDetails added in v0.1.2

func NewServiceDetails(ski string) *ServiceDetails

create a new ServiceDetails record with a SKI

func (*ServiceDetails) DeviceType added in v0.1.2

func (s *ServiceDetails) DeviceType() model.DeviceTypeType

func (*ServiceDetails) IPv4

func (s *ServiceDetails) IPv4() string

func (*ServiceDetails) RegisterAutoAccept added in v0.1.2

func (s *ServiceDetails) RegisterAutoAccept() bool

func (*ServiceDetails) SKI

func (s *ServiceDetails) SKI() string

return the services SKI

func (*ServiceDetails) SetDeviceType added in v0.1.2

func (s *ServiceDetails) SetDeviceType(deviceType model.DeviceTypeType)

func (*ServiceDetails) SetIPv4 added in v0.1.2

func (s *ServiceDetails) SetIPv4(ipv4 string)

func (*ServiceDetails) SetRegisterAutoAccept added in v0.1.2

func (s *ServiceDetails) SetRegisterAutoAccept(auto bool)

func (*ServiceDetails) SetShipID added in v0.1.2

func (s *ServiceDetails) SetShipID(shipId string)

SHIP ID is the ship identifier of the service

func (*ServiceDetails) ShipID

func (s *ServiceDetails) ShipID() string

Return the services SHIP ID

Jump to

Keyboard shortcuts

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