aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-12-04 13:54:31 +0100
committerDimitri Sokolyuk <demon@dim13.org>2016-12-04 13:54:31 +0100
commit35de52f34bfabc41f10d595f636ea5f501ba1150 (patch)
tree5e9153d7614714e9a6cedde2798b94e07bdf5d61
Initial import
-rw-r--r--advertisement.go31
-rw-r--r--eir.go1
-rw-r--r--protocol.go111
-rw-r--r--vehicle_gatt.go7
4 files changed, 150 insertions, 0 deletions
diff --git a/advertisement.go b/advertisement.go
new file mode 100644
index 0000000..7bf2e1c
--- /dev/null
+++ b/advertisement.go
@@ -0,0 +1,31 @@
+package anki
+
+const (
+ VehicleStateFullBattery = 1 << 4
+ VehicleStateLowBattery = 1 << 5
+ VehicleStateOnCharger = 1 << 6
+)
+
+type VehicleAdvInfo struct {
+ VehicleAdvState uint8 // Battery
+ Version uint16
+ Reserved [5]uint8
+ Name [13]byte // UTF8: 12 bytes + NULL
+}
+
+type VehicleAdvMfg struct {
+ Identifier uint32
+ ModelID uint8
+ Reserved uint8
+ ProductID uint16
+}
+
+type UUID [16]byte
+
+type VehicleAdv struct {
+ Flags uint8
+ TXPower uint8
+ MfgData VehicleAdvMfg
+ LocalName VehicleAdvInfo
+ UUID UUID
+}
diff --git a/eir.go b/eir.go
new file mode 100644
index 0000000..142bf30
--- /dev/null
+++ b/eir.go
@@ -0,0 +1 @@
+package anki
diff --git a/protocol.go b/protocol.go
new file mode 100644
index 0000000..3f3c05f
--- /dev/null
+++ b/protocol.go
@@ -0,0 +1,111 @@
+package anki
+
+const (
+ // BLE Connection
+ VehicleMsgC2VDisconnect = 0x0d
+
+ // Ping request / response
+ VehicleMsgC2VPingRequest = 0x16
+ VehicleMsgV2CPingResponse = 0x17
+
+ // Messages for checking vehicle version info
+ VehicleMsgC2VVersionRequest = 0x18
+ VehicleMsgV2CVersionResponse = 0x19
+
+ // Baterry level
+ VehicleMsgC2VBatteryLevelRequest = 0x1a
+ VehicleMsgV2CBatteryLevelResponse = 0x1b
+
+ // Lights
+ VehicleMsgC2VSetLights = 0x1d
+
+ // Driving Commands
+ VehicleMsgC2VSetSpeed = 0x24
+ VehicleMsgC2VChangeLane = 0x25
+ VehicleMsgC2VCancelLaneChange = 0x26
+ VehicleMsgC2VTurn = 0x32
+
+ // Vehicle position updates
+ VehicleMsgV2CLocalizationPositionUpdate = 0x27
+ VehcileMsgV2CLocalizationTransitionUpdate = 0x29
+ VehicleMsgV2CLocalizationIntersectionUpdate = 0x2a
+ VehicleMsgV2cVehicleDelocalized = 0x2b
+ VehicleMsgC2VSetOffsetFromRoadCenter = 0x2c
+ VehicleMsgV2COffsetFromRoadCenterUpdate = 0x2d
+
+ // Light Patterns
+ VehicleMsgC2VLightsPattern = 0x33
+
+ // Vehicle Configuration Prameters
+ VehicleMsgC2VSetConfigParams = 0x45
+
+ // SDK Mode
+ VehicleMsgC2VSDKMode = 0x90
+)
+
+const (
+ VehicleTurnNone = iota
+ VehicleTurnLeft
+ VehicleTurnRight
+ VehicleTurnUTurn
+ VehicleTurnUTurnJump
+)
+
+const (
+ VehcileTurnTriggerImmediate = iota // Run immediately
+ VehicleTurnTriggerIntersection // Run at the next intersection
+)
+
+const (
+ Forward = iota
+ Reverse
+)
+
+const (
+ IntersectionCodeEntryFirst = iota
+ IntersectionCodeExitFirst
+ IntersectionCodeEntrySecond
+ IntersectionCodeExitSecond
+)
+
+// Lights
+// The bits in the simple light message corresponding to each type of light
+const (
+ LightHeadlights = 1 << iota
+ LightBrakelights
+ LightFrontlights
+ LightEngine
+)
+
+const (
+ VehcileMaxLightIntensity = 14
+ VehicleMaxLightTime = 11
+)
+
+// LED channel definitions - for RGB engine, front, and tail lights
+const (
+ LightRed = iota
+ LightTail
+ LightBlue
+ LightGreen
+ LightFrontL
+ LightFrontR
+)
+
+const (
+ EffectSteady = iota // Simply set the light intensity to 'start' value
+ EffectFade // Fade intensity from 'start' to 'end'
+ EffectThrob // Fade intensity from 'start' to 'end' and back to 'start'
+ EffectFlash // Tun on LED between time 'start' and time 'end' inclusive
+ EffectRandom // Flash the LED erratically - ignoring start/end
+)
+
+const (
+ TrackMaterialPlastic = iota
+ TrackMaterialVinyl
+)
+
+const (
+ SupercodeNone = iota
+ SupercodeBoostJump
+)
diff --git a/vehicle_gatt.go b/vehicle_gatt.go
new file mode 100644
index 0000000..a4e6bff
--- /dev/null
+++ b/vehicle_gatt.go
@@ -0,0 +1,7 @@
+package anki
+
+const (
+ ServiceUUID = "BE15BEEF-6186-407E-8381-0BD89C4D8DF4"
+ ChrReadUUID = "BE15BEE0-6186-407E-8381-0BD89C4D8DF4"
+ ChrWriteUUID = "BE15BEE1-6186-407E-8381-0BD89C4D8DF4"
+)