35 lines
948 B
Go
35 lines
948 B
Go
// Package vehicleprotocol owns the canonical protocol identifiers shared by
|
|
// the vehicle data platform, statistics services and the open platform API.
|
|
package vehicleprotocol
|
|
|
|
import "strings"
|
|
|
|
const (
|
|
GB32960 = "GB32960"
|
|
YutongMQTT = "YUTONG_MQTT"
|
|
JT808 = "JT808"
|
|
)
|
|
|
|
// All returns a copy so callers cannot mutate the platform-wide catalog.
|
|
func All() []string {
|
|
return []string{GB32960, JT808, YutongMQTT}
|
|
}
|
|
|
|
// MileagePriority is the source-selection order for total mileage.
|
|
func MileagePriority() []string {
|
|
return []string{GB32960, YutongMQTT, JT808}
|
|
}
|
|
|
|
// Canonical accepts only the identifiers persisted by ingestion and
|
|
// statistics. Public aliases are deliberately rejected to avoid a second
|
|
// protocol vocabulary at the API boundary.
|
|
func Canonical(value string) (string, bool) {
|
|
value = strings.TrimSpace(value)
|
|
switch value {
|
|
case GB32960, YutongMQTT, JT808:
|
|
return value, true
|
|
default:
|
|
return "", false
|
|
}
|
|
}
|