Added Navigation service #5
@ -753,6 +753,17 @@ func (i *Device) Notify(title, body string) error {
|
|||||||
|
|
||||||
// Navigation sends a NavigationEvent to the watch
|
// Navigation sends a NavigationEvent to the watch
|
||||||
func (i *Device) Navigation(flag string, narrative string, dist string, progress uint8) error {
|
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 {
|
if narrative != i.navigationEv.narrative {
|
||||||
log.Debug().Str("func", "Navigation").
|
log.Debug().Str("func", "Navigation").
|
||||||
@ -766,6 +777,32 @@ func (i *Device) Navigation(flag string, narrative string, dist string, progress
|
|||||||
i.navigationEv.narrative = narrative
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user