ServerServiceInstance

class someipy.ServerServiceInstance(daemon, service, instance_id, endpoint_ip, endpoint_port, ttl=0, cyclic_offer_delay_ms=2000)

Server-side representation of a service instance used for offering SOME/IP services.

This class manages the lifecycle of offering a service instance via the Some/IP-SD mechanism and enables sending events to subscribed clients.

Parameters

daemonSomeIpDaemonClient

Daemon client used to communicate with the someipy daemon.

serviceService

Service configuration for this instance.

instance_idint

Instance ID for this service instance.

endpoint_ipstr

IP address of the endpoint on which the service instance is reachable.

endpoint_portint

Port of the endpoint on which the service instance is reachable.

ttlint, optional

TTL used for Service Discovery offers. Default: 0.

cyclic_offer_delay_msint, optional

Delay between cyclic offers in milliseconds. Default: 2000.

property endpoint_ip: str

IP address of the endpoint this instance offers services on.

Returns

str

Endpoint IP address.

property endpoint_port: int

Port of the endpoint this instance offers services on.

Returns

int

Endpoint port number.

property instance_id: int

Instance ID of this server service instance.

Returns

int

The unique identifier for this service instance.

send_event(eventgroup_id, event_id, payload)

Send an event to clients subscribed to the event.

This method validates the specified event group and event within the service definition, encodes the payload in Base64, constructs a UDS message and dispatches it through the daemon.

Parameters

eventgroup_idint

ID of the event group the event belongs to.

event_idint

ID of the event to send.

payloadbytes

Payload of the event to transmit to clients.

Returns

None

Raises

ValueError

If event group ID or event ID is not found within the service.

Parameters:
  • eventgroup_id (int) –

  • event_id (int) –

  • payload (bytes) –

property service: Service

Service associated with this server service instance.

Returns

Service

The service configuration that this instance exposes.

async start_offer()

Start offering the service instance via the service discovery offer entries.

This method gathers the current service methods and event groups and invokes the daemon to advertise the service with the configured endpoint and version information.

Returns

None

async stop_offer()

Stop offering the service instance and send out a stop offer entry.

This stops advertising the service instance to clients via the daemon.

Returns

None

Parameters:
  • daemon (SomeIpDaemonClient) –

  • service (Service) –

  • instance_id (int) –

  • endpoint_ip (str) –

  • endpoint_port (int) –

  • ttl (int) –