Added Navigation service #5

Merged
Elara6331 merged 9 commits from yannickulrich/infinitime:navigation-service into master 2022-11-03 19:09:07 +00:00
Showing only changes of commit 2fbd8cb666 - Show all commits

View File

@ -38,6 +38,10 @@ const (
FSTransferChar = "adaf0200-4669-6c65-5472-616e73666572"
FSVersionChar = "adaf0100-4669-6c65-5472-616e73666572"
WeatherDataChar = "00040001-78fc-48fe-8e23-433b3a1942d0"
NavFlagsChar = "00010001-78fc-48fe-8e23-433b3a1942d0"
NavNarrativeChar= "00010002-78fc-48fe-8e23-433b3a1942d0"
NavManDistChar = "00010003-78fc-48fe-8e23-433b3a1942d0"
NavProgressChar = "00010004-78fc-48fe-8e23-433b3a1942d0"
)
var charNames = map[string]string{
@ -52,10 +56,18 @@ var charNames = map[string]string{
FSTransferChar: "Filesystem Transfer",
FSVersionChar: "Filesystem Version",
WeatherDataChar: "Weather Data",
NavFlagsChar: "Navigation Icon",
NavNarrativeChar:"Navigation Instruction",
NavManDistChar: "Navigation Distance to next event",
NavProgressChar: "Navigation Progress",
}
type Device struct {
yannickulrich marked this conversation as resolved Outdated

I think it would be better if these were individual constants rather than a slice. That way, they could have their own type and the compiler can guarantee that they're valid instead of needing a separate function. Since that will add quite a bit of code, I think the navigation service can be moved into a separate file.

I think it would be better if these were individual constants rather than a slice. That way, they could have their own type and the compiler can guarantee that they're valid instead of needing a separate function. Since that will add quite a bit of code, I think the navigation service can be moved into a separate file.

Maybe something like

type NavFlag string

const (
    NavFlagArrive     NavFlag = "arrive"
    NavFlagArriveLeft NavFlag = "arrive-left"
    // ...
)

Then, the NavigationEvent can take a NavFlag instead of string.

Maybe something like ```go type NavFlag string const ( NavFlagArrive NavFlag = "arrive" NavFlagArriveLeft NavFlag = "arrive-left" // ... ) ``` Then, the `NavigationEvent` can take a `NavFlag` instead of `string`.

Taken care of in d46f545

Taken care of in d46f545
device *device.Device1
navflagsChar *gatt.GattCharacteristic1
navnarrativeChar*gatt.GattCharacteristic1
navmandistChar *gatt.GattCharacteristic1
navprogressChar *gatt.GattCharacteristic1
newAlertChar *gatt.GattCharacteristic1
notifEventChar *gatt.GattCharacteristic1
stepCountChar *gatt.GattCharacteristic1
@ -394,6 +406,14 @@ func (i *Device) resolveChars() error {
charResolved := true
// Set correct characteristics
switch char.Properties.UUID {
case NavFlagsChar:
i.navflagsChar = char
case NavNarrativeChar:
i.navnarrativeChar = char
case NavManDistChar:
i.navmandistChar = char
case NavProgressChar:
i.navprogressChar = char
case NewAlertChar:
i.newAlertChar = char
case NotifEventChar: