-
Notifications
You must be signed in to change notification settings - Fork 12
[SDL-0293] Enable OEM exclusive apps support #374
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
0496013
c0f1b38
0497c80
a2d7ab1
af981f8
8f4069d
f855ca4
76c5350
cccb753
8317fb6
59ac61a
b874414
a0a9ed0
66edef5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,13 +38,15 @@ import { _FrameType } from './enums/_FrameType.js'; | |
| import { _MessageFrameAssembler } from './_MessageFrameAssembler.js'; | ||
| import { _SdlPacket } from './_SdlPacket.js'; | ||
| import { _ControlFrameTags } from './enums/_ControlFrameTags.js'; | ||
| import { _BitConverter } from './../util/_BitConverter.js'; | ||
| import { _BitConverter } from '../util/_BitConverter.js'; | ||
|
|
||
| import { _SdlPacketFactory } from './_SdlPacketFactory.js'; | ||
| import { RpcCreator } from './../rpc/RpcCreator.js'; | ||
| import { RpcCreator } from '../rpc/RpcCreator.js'; | ||
| import { ImageResolution } from '../rpc/structs/ImageResolution.js'; | ||
| import { VideoStreamingFormat } from '../rpc/structs/VideoStreamingFormat.js'; | ||
|
|
||
| import { VehicleType } from '../rpc/structs/VehicleType.js'; | ||
|
|
||
| /** | ||
| * Base implementation of sdl protocol. | ||
| * Should be able to handle basic control frames and be able to | ||
|
|
@@ -268,6 +270,33 @@ class _SdlProtocolBase { | |
| return this._messageID++; | ||
| } | ||
|
|
||
| /** | ||
| * Gets the Vehicle details received in StartService ACK protocol message | ||
| * @returns {VehicleType|null} - A RPC VehicleType struct received from the packet if exists null otherwise. | ||
| */ | ||
| _getVehicleType(sdlPacket) { | ||
|
||
| const make = sdlPacket.getTag(_ControlFrameTags.RPC.StartServiceACK.VEHICLE_MAKE); | ||
| const model = sdlPacket.getTag(_ControlFrameTags.RPC.StartServiceACK.VEHICLE_MODEL); | ||
| const modelYear = sdlPacket.getTag(_ControlFrameTags.RPC.StartServiceACK.VEHICLE_MODEL_YEAR); | ||
| const trim = sdlPacket.getTag(_ControlFrameTags.RPC.StartServiceACK.VEHICLE_TRIM); | ||
|
|
||
| // TODO: awaiting 0293 revisions to process those fields | ||
| const systemHardwareVersion = sdlPacket.getTag(_ControlFrameTags.RPC.StartServiceACK.VEHICLE_SYSTEM_HARDWARE_VERSION); | ||
| const systemSoftwareVersion = sdlPacket.getTag(_ControlFrameTags.RPC.StartServiceACK.VEHICLE_SYSTEM_SOFTWARE_VERSION); | ||
|
||
|
|
||
| // if no any VehicleType tags in the packet just return null | ||
| if (!make && !model && !modelYear && !trim) { | ||
| return null; | ||
| } | ||
|
|
||
| return new VehicleType({ | ||
| make, | ||
| model, | ||
| modelYear, | ||
| trim, | ||
| }); | ||
| } | ||
|
|
||
| /** | ||
| * Takes an rpc message and sends a single or multi frame packets. | ||
| * @param {RpcMessage} rpcMessage - Converts an RpcMessage into an _SdlPacket and sends it. | ||
|
|
@@ -406,6 +435,23 @@ class _SdlProtocolBase { | |
| const version = sdlPacket.getVersion(); | ||
| const serviceType = sdlPacket.getServiceType(); | ||
| if (version >= 5) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ymalovanyi On line 440, does this need to be
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Our initial implementation was exactly with |
||
| // check if vehicleType data exists then fire onVehicleTypeReceived protocol listener event | ||
| const vehicleType = this._getVehicleType(sdlPacket); | ||
| if ( | ||
| vehicleType | ||
| && this._sdlProtocolListener !== null | ||
| && typeof this._sdlProtocolListener.onVehicleTypeReceived === 'function' | ||
|
||
| ) { | ||
| if (!this._sdlProtocolListener.onVehicleTypeReceived(vehicleType)) { | ||
| console.warn('(ACK) Disconnecting from head unit, the vehicle is not supported'); | ||
| this.endService(serviceType, sdlPacket.getSessionID()); | ||
| if (serviceType === _ServiceType.RPC && this._transportManager !== null) { | ||
| this._transportManager.stop(); | ||
| } | ||
| return; | ||
| } | ||
| } | ||
|
|
||
| let mtuTag = null; | ||
| if (serviceType === _ServiceType.RPC) { | ||
| mtuTag = _ControlFrameTags.RPC.StartServiceACK.MTU; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -72,6 +72,12 @@ _ControlFrameTags.RPC = Object.freeze({ | |
| VIDEO_SERVICE_TRANSPORTS: 'videoServiceTransports', | ||
| /** Auth token to be used for log in into services **/ | ||
| AUTH_TOKEN: 'authToken', | ||
| VEHICLE_MAKE: 'make', | ||
| VEHICLE_MODEL: 'model', | ||
| VEHICLE_MODEL_YEAR: 'modelYear', | ||
|
||
| VEHICLE_TRIM: 'trim', | ||
| VEHICLE_SYSTEM_SOFTWARE_VERSION: 'systemSoftwareVersion', | ||
| VEHICLE_SYSTEM_HARDWARE_VERSION: 'systemHardwareVersion', | ||
| }, StartServiceACKBase, StartServiceProtocolVersion, StartServiceHashId), | ||
|
|
||
| StartServiceNAK: NAKBase, | ||
|
|
@@ -128,4 +134,4 @@ _ControlFrameTags.Video = Object.freeze({ | |
| EndServiceNAK: NAKBase, | ||
| }); | ||
|
|
||
| export { _ControlFrameTags }; | ||
| export { _ControlFrameTags }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,6 +61,7 @@ class _SdlSession { | |
| this._sdlProtocolListener = this._setupSdlProtocolListener(); | ||
|
|
||
| this._sdlProtocol = new _SdlProtocol(baseTransportConfig, this._sdlProtocolListener); | ||
| this._didReceiveVehicleType = false; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -77,6 +78,7 @@ class _SdlSession { | |
| sdlProtocolListener.setOnRpcMessageReceived(this.onRpcMessageReceived.bind(this)); | ||
| sdlProtocolListener.setOnTransportConnected(this.onTransportConnected.bind(this)); | ||
| sdlProtocolListener.setOnAuthTokenReceived(this.onAuthTokenReceived.bind(this)); | ||
| sdlProtocolListener.setOnVehicleTypeReceived(this.onVehicleTypeReceived.bind(this)); | ||
|
|
||
| sdlProtocolListener.setGetDesiredVideoParams(this.getDesiredVideoParams.bind(this)); | ||
| sdlProtocolListener.setSetAcceptedVideoParams(this.setAcceptedVideoParams.bind(this)); | ||
|
|
@@ -168,6 +170,25 @@ class _SdlSession { | |
| this._sdlSessionListener.onAuthTokenReceived(authToken, this._sessionId); | ||
| } | ||
|
|
||
| /** | ||
| * A way to determine if VehicleType already received | ||
| * @returns {Boolean} Return true if received | ||
| */ | ||
| didReceiveVehicleType() { | ||
|
||
| return this._didReceiveVehicleType; | ||
| } | ||
|
|
||
| /** | ||
| * A way to determine if this SDL session should continue to be active while | ||
| * connected to the determined vehicle type. | ||
| * @param {VehicleType} vehicleType - the type of vehicle that this session is currently active on. | ||
| * @returns {Boolean} Return true if this session should continue, false if the session should end | ||
| */ | ||
| onVehicleTypeReceived (vehicleType) { | ||
| // set the flag as this event fires only once if VehicleType was received | ||
| this._didReceiveVehicleType = true; | ||
| return this._sdlSessionListener.onVehicleTypeReceived(vehicleType); | ||
| } | ||
|
|
||
| /** ********************************************************************************************************************************************************************** | ||
| * END: _SdlProtocolListener implemented methods | ||
|
|
@@ -324,4 +345,4 @@ class _SdlSession { | |
| } | ||
| } | ||
|
|
||
| export { _SdlSession }; | ||
| export { _SdlSession }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ymalovanyi @vladmu Do you need unit tests for this? For example, sdl java suite has
SdlProtocolTestsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@santhanamk we don't need the test for this particular line as this is just a shortenest path identical to previous but aligned with the style of other imports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vladmu I meant do you need unit tests overall for the changes made to this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@santhanamk it is hard to define expectations of such tests in the order of the library and this class as we don't have any tests of previous functionality covered here. We appreciate any help in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vladmu Ok no problem. It was an optional request, as these were not existing before.