Pass other navigation parameters

This commit is contained in:
Yannick Ulrich 2022-10-21 23:08:15 +01:00
parent 912ccd14b3
commit ba3169d1d0

View File

@ -753,6 +753,17 @@ func (i *Device) Notify(title, body string) error {
// Navigation sends a NavigationEvent to the watch
func (i *Device) Navigation(flag string, narrative string, dist string, progress uint8) error {
if flag != i.navigationEv.flag {
log.Debug().Str("func", "Navigation").
Msg("Sending flag")
if err := i.checkStatus(i.navflagsChar, NavFlagsChar); err != nil {
return err
}
if err := i.navflagsChar.WriteValue([]byte(flag), nil); err != nil {
return err
}
i.navigationEv.flag = flag
}
if narrative != i.navigationEv.narrative {
log.Debug().Str("func", "Navigation").
@ -766,6 +777,32 @@ func (i *Device) Navigation(flag string, narrative string, dist string, progress
i.navigationEv.narrative = narrative
}
if dist != i.navigationEv.dist {
log.Debug().Str("func", "Navigation").
Msg("Sending mandist")
if err := i.checkStatus(i.navmandistChar, NavManDistChar); err != nil {
return err
}
if err := i.navmandistChar.WriteValue([]byte(dist), nil); err != nil {
return err
}
i.navigationEv.dist = dist
}
if progress != i.navigationEv.progress {
log.Debug().Str("func", "Navigation").
Msg("Sending progress")
if err := i.checkStatus(i.navprogressChar, NavProgressChar); err != nil {
return err
}
buf := &bytes.Buffer{}
binary.Write(buf, binary.LittleEndian, progress)
if err := i.navprogressChar.WriteValue(buf.Bytes(), nil); err != nil {
return err
}
i.navigationEv.progress = progress
}
return nil
}