Add API for list of vehicle names #2936
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Settings -
API -
Came to mind in #2921, just wrote it since was straightforward to implement
The keys contain an empty string, coming from it being used to refer to the default vehicle, see ApiProvider.hpp being called from SimModeBase.cpp
A simple way is to just remove the empty string ourselves, which is being done right now.
However, the API could also mean - return a list of valid vehicle names which can be passed to APIs, in which case empty string is valid. But it could also introduce more complexity to the client code, such as removing the empty string if data of each vehicle is required only once, and having an empty string will duplicate calls for one vehicle.
I'm leaning towards removing the empty string, and will add that behaviour in the PR. But do comment if the second behaviour makes more sense.
Could be particularly useful if #2390 goes in (which I hope to update in the next few days)
Not much of an use-case otherwise, just allows the user to avoid parsing the settings for getting the vehicle names