Snapdragon® Telematics Application Framework (TelAF) Interface Specification
|
The SOME/IP Gateway Server Service supports SOME/IP protocol(http://some-ip.com/) through vsomeip (https://github.com/COVESA/vsomeip) library APIs. It provides TelAF APIs for application to serve as a SOME/IP server which can receive client requests, send responses, produce events and publish the events over SOME/IP-SD message and SOME/IP message in the vehicle network.
The functions of this API are provided by the tafSomeipGWSvc application service.
The following example illustrates how to bind to the SOME/IP Gateway Server Service.
bindings: { clientExe.clientComponent.taf_someipSvr -> tafSomeipGWSvc.taf_someipSvr }
Before using any API of the service, the user needs to configure the system properly Since the SOME/IP Gateway Server Service is built upon vsomeip library, the configuration follows the same JSON format as vsomeip. The user can take the default vsomeip JSON file which locates in /legato/systems/current/appsWriteable/tafSomeipGWSvc/tafSomeipGWSvc.json as a template to make their own specific configuration. The default JSON file is as below:
{ "unicast" : "192.168.225.1", "device" : "bridge0", "logging" : { "level" : "error", "console" : "true", "file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" }, "version" : { "enable" : "false", "interval" : "10" }, "dlt" : "false" }, "applications" : [ { "name" : "tafSomeipGWSvc", "id" : "0x0101" } ], "routing" : "tafSomeipGWSvc", "network" : "tafSomeipGWSvc", "service-discovery" : { "enable" : "true", "multicast" : "224.0.0.1", "port" : "30490", "protocol" : "udp", "initial_delay_min" : "10", "initial_delay_max" : "100", "repetitions_base_delay" : "200", "repetitions_max" : "3", "ttl" : "3", "cyclic_offer_delay" : "2000", "request_response_delay" : "1500" } }
Mandatorily, the unicast and device must be set with the correct IP address and network interface in the system for SOME/IP communications. The id in applications section shall be set with a unique client ID within the given network. Optionally, the SOME/IP-SD parameters (like multicast) in service-discovery section can be changed if needed.
Restart the tafSomeipGWSvc service or reboot the device to make the new configuration take effect after any modifications.
Finally run below command to add a route entry for the SOME/IP-SD multicast address(Suppose the network interface is "bridge0" and the multicast address is "224.0.0.1"):
route add 224.0.0.1 dev bridge0
The default configuration file is only for single network/VLAN which is also the default network. If the user wants to support multiple networks/VLANs in the GW service, they have to create additional configuration files. These configuration files can be someipGWSvc_1.json to tafSomeipGWSvc_7.json, which means a maximum of 8 networks/VLANs can be supported. For example, the user can create below configuration file to support the second network/VLAN in the GW service:
{ "unicast" : "192.168.226.1", "device" : "eth1", "logging" : { "level" : "error", "console" : "true", "file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" }, "version" : { "enable" : "false", "interval" : "10" }, "dlt" : "false" }, "applications" : [ { "name" : "tafSomeipGWSvc_1", "id" : "0x0102" } ], "routing" : "tafSomeipGWSvc_1", "network" : "tafSomeipGWSvc_1", "service-discovery" : { "enable" : "true", "multicast" : "225.0.0.1", "port" : "30490", "protocol" : "udp", "initial_delay_min" : "10", "initial_delay_max" : "100", "repetitions_base_delay" : "200", "repetitions_max" : "3", "ttl" : "3", "cyclic_offer_delay" : "2000", "request_response_delay" : "1500" } }
In this case, a second configuration file tafSomeipGWSvc_1.json is created for network interface "eth1" with its own network address and multicast address.
Before setting up a server-service-instance, application shall first get the service reference by calling taf_someipSvr_GetService() or taf_someipSvr_GetServiceEx() and use the reference returned for subsequent operations.
The following example illustrates how to set up a SOME/IP server-service-instance and offer the service on default network interface.
Application can call taf_someipSvr_StopOfferService() to stop the service after the service is offered successfully.
After the service reference is got, the application can call taf_someipSvr_AddRxMsgHandler() to register a message handler for that service. Once a SOME/IP request message for the service is received, the message handler will be called and a message reference is passed as an input parameter to the application. The application can use this reference to retrieve the message header and payload, and then call taf_someipSvr_SendResponse() with the reference to send back a response. Finally call taf_someipSvr_ReleaseRxMsg() to release the message.
The following example illustrates how to register a message handler, get the message data and send back a response in a handler.
After a service is offered, application can call taf_someipSvr_EnableEvent() to set up an event for the service and then call taf_someipSvr_OfferEvent() to offer the event within the vehicle network, later call taf_someipSvr_Notify() to publish the event with given payload data.
The following example illustrates how to set up an event and publish the event.