Initial cloud-services repo - gateway service + pkg modules

This commit is contained in:
Chris Rai
2026-01-30 23:14:52 -05:00
commit fbb820d7b3
1037 changed files with 171318 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
package vod_decoder
import (
"encoding/hex"
"log"
)
// VOD coding information
// https://fiskerinc-my.sharepoint.com/:x:/p/bdoan/EQCJFiYi3dlIgyQ9ZhXgHC4BTW6r_f677rTa2zSxgBkUmg?email=aandrews%40fiskerinc.com&wdOrigin=TEAMS-MAGLEV.p2p_ns.rwc&wdExp=TEAMS-TREATMENT&wdhostclicktime=1704913173133&web=1
// The coding information is 2 bytes off of what the cloud has, as we do not have a starting DID.
// Given a VOD, going to return either Right hand drive, or left hand drive
func GetDriverSideFromVOD(vod string)(driverSide string, ok bool){
hexVOD := decodeVOD(vod)
if len(hexVOD) < 8 {
return "INVALID", false
}
b := hexVOD[7]
switch b{
case 0x00:
return "LEFT", true
case 0x01:
return "RIGHT", true
default:
badHexValue := hex.EncodeToString([]byte{b})
log.Printf("Received an invalid left/right side drive value from vod: %s", badHexValue)
return "INVALID", false
}
}
func decodeVOD(vod string)(hexVOD []byte){
hexVOD, _ = hex.DecodeString(vod)
return
}