Commit Graph

27 Commits

Author SHA1 Message Date
31f4c51a61 Improve navigation API 2022-11-06 20:08:13 -08:00
e6fb402c0c Remove check for unchanged values and refactor code 2022-11-05 20:33:30 -07:00
1f5301f5de 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>
2022-11-03 19:09:06 +00:00
9ed74726c4 Add contexts and improve error handling 2022-05-11 13:22:57 -07:00
2def4b13ac Add debug logging 2022-04-23 19:58:00 -07:00
2f51bde597 Use log level provided in options 2022-04-23 19:07:41 -07:00
bebd1017c5 Ensure that done signals for Watch functions are handled properly and restart notifications if they stop unexpectedly 2022-04-23 18:40:25 -07:00
b7a50271be Log when too many disconnects occur rather than removing the device (Arsen6331/itd#10) 2022-04-16 04:24:21 -07:00
e82981e3fc Rewrite connect/reconnect code 2022-02-21 02:46:20 -08:00
738e140bfb Create custom BlueZ agent 2021-12-16 21:30:29 -08:00
a2ff29ce84 Add weather service 2021-12-12 12:43:43 -08:00
522c10a9c0 Set connected property to true in all connecting functions 2021-11-25 20:33:06 -08:00
bd057815cf Fix checkStatus call in (*Device).FS() 2021-11-25 13:35:58 -08:00
58d5036f20 Allow multiple call notification responses and improve error handling 2021-11-25 12:39:43 -08:00
e9a92bac46 Implement BLE filesystem (experimental and will change in the future) 2021-11-22 21:19:30 -08:00
75942bdb0c Add whitelist to pair() and make case insensitive 2021-10-26 21:42:41 -07:00
53aa6f8a0c Add cancel functions to battery level and heart rate 2021-10-22 21:26:33 -07:00
45baea1048 Implement Motion Service 2021-10-22 12:59:51 -07:00
c101249d3e Add call notification support 2021-10-15 00:23:54 -07:00
745b4bd37c Return intial values in watch functions 2021-08-24 22:17:34 -07:00
0430ddcd30 Add watch function for battery level 2021-08-24 21:55:03 -07:00
9553844896 Remove pair timeout entirely 2021-08-22 13:12:16 -07:00
47293f04bc Fix bug where Connect blocked forever after 10 seconds 2021-08-22 13:09:56 -07:00
d228b6cf60 Fix segfault due to using wrong opts struct 2021-08-21 20:27:31 -07:00
91fbe718e5 Add error handling to connect call 2021-08-21 20:25:09 -07:00
7f19dfb354 Allow configuration of pair timeout 2021-08-21 20:24:56 -07:00
21078996c1 Initial Commit 2021-08-19 17:41:09 -07:00