Added Navigation service (#5)
InfiniTime implements a [Navigation Service](https://github.com/InfiniTimeOrg/InfiniTime/blob/develop/doc/NavigationService.md). This pull request will add it to the go library by defining a function ```go func (i *Device) Navigation(flag string, narrative string, dist string, progress uint8) error { ... } ``` From the InfiniTime manual * `flag`: the graphic instruction as provided by [Pure Maps](https://github.com/rinigus/pure-maps/tree/master/qml/icons/navigation). A list of valid instruction icons can be found [here](https://github.com/rinigus/pure-maps/tree/master/qml/icons/navigation) * `narrative`: the instruction in words, eg. "At the roundabout take the first exit". * `dist`: a short string describing the distance to the upcoming instruction such as "50 m". * `progress`: the percent complete in a `uint8` Adding this to the `itd` daemon is straightforward ```patch diff --git a/api/types.go b/api/types.go index 281a85b..14c84de 100644 --- a/api/types.go +++ b/api/types.go @@ -22,6 +22,13 @@ type FwUpgradeData struct { Files []string } +type NavigationData struct { + Flag string + Narrative string + Dist string + Progress uint8 +} + type NotifyData struct { Title string Body string diff --git a/socket.go b/socket.go index 6fcba5c..91b37c0 100644 --- a/socket.go +++ b/socket.go @@ -204,6 +204,10 @@ func (i *ITD) Address(_ *server.Context) string { return i.dev.Address() } +func (i *ITD) Navigation(_ *server.Context, data api.NavigationData) error { + return i.dev.Navigation(data.Flag, data.Narrative, data.Dist, data.Progress) +} + func (i *ITD) Notify(_ *server.Context, data api.NotifyData) error { return i.dev.Notify(data.Title, data.Body) } ``` Co-authored-by: Yannick Ulrich <yannick.ulrich@durham.ac.uk> Reviewed-on: https://gitea.arsenm.dev/Arsen6331/infinitime/pulls/5 Co-authored-by: yannickulrich <yannick.ulrich@protonmail.com> Co-committed-by: yannickulrich <yannick.ulrich@protonmail.com>
This commit is contained in:
@@ -52,6 +52,10 @@ 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 {
|
||||
@@ -67,10 +71,13 @@ type Device struct {
|
||||
fsVersionChar *gatt.GattCharacteristic1
|
||||
fsTransferChar *gatt.GattCharacteristic1
|
||||
weatherDataChar *gatt.GattCharacteristic1
|
||||
weatherdataChar *gatt.GattCharacteristic1
|
||||
notifEventCh chan uint8
|
||||
notifEventDone bool
|
||||
Music MusicCtrl
|
||||
Navigation NavigationCtrl
|
||||
DFU DFU
|
||||
navigationEv NavigationEvent
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -394,6 +401,14 @@ func (i *Device) resolveChars() error {
|
||||
charResolved := true
|
||||
// Set correct characteristics
|
||||
switch char.Properties.UUID {
|
||||
case NavFlagsChar:
|
||||
i.Navigation.flagsChar = char
|
||||
case NavNarrativeChar:
|
||||
i.Navigation.narrativeChar = char
|
||||
case NavManDistChar:
|
||||
i.Navigation.mandistChar = char
|
||||
case NavProgressChar:
|
||||
i.Navigation.progressChar = char
|
||||
case NewAlertChar:
|
||||
i.newAlertChar = char
|
||||
case NotifEventChar:
|
||||
@@ -723,6 +738,7 @@ func (i *Device) Notify(title, body string) error {
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
// These constants represent the possible call statuses selected by the user
|
||||
const (
|
||||
CallStatusDeclined uint8 = iota
|
||||
|
||||
Reference in New Issue
Block a user