301 Commits

Author SHA1 Message Date
Yannick Ulrich b28c386c4e Used new error conversion routine
ci/woodpecker/pr/woodpecker Pipeline was successful
2023-03-04 09:19:27 +00:00
Yannick Ulrich 4c59561a99 Added error to syscall function
Some of these aren't ideal..
2023-03-04 09:14:49 +00:00
Yannick Ulrich 955e1323ce Send better syscall status codes
ci/woodpecker/pr/woodpecker Pipeline was successful
2023-03-01 19:36:44 +00:00
Yannick Ulrich 3b9690103b Moved starting of fuse
ci/woodpecker/pr/woodpecker Pipeline was successful
2023-03-01 19:07:14 +00:00
Yannick Ulrich b5328ece92 Made logging more consistent 2023-03-01 19:06:32 +00:00
Yannick Ulrich 2396623c73 Formatted interface checks 2023-03-01 18:57:02 +00:00
Yannick Ulrich a54ca7afdf Handle more errors 2023-03-01 18:08:58 +00:00
Yannick Ulrich 673383f795 Stylistic changes 2023-03-01 18:08:18 +00:00
Yannick Ulrich cc6fc3e1dc removed godebug dep
ci/woodpecker/pr/woodpecker Pipeline was successful
2023-03-01 16:45:42 +00:00
Yannick Ulrich c05d4fe951 4. Split converters 2023-03-01 15:15:32 +00:00
Yannick Ulrich 87c78566c1 3. Added builder 2023-03-01 15:14:06 +00:00
Yannick Ulrich 8dd8f3d012 2. added fuse.go in main 2023-03-01 15:13:49 +00:00
Yannick Ulrich bf13b96660 1. moved fuse.go 2023-03-01 15:04:17 +00:00
Yannick Ulrich 2440cb954c Merged two properties lists 2023-02-26 19:11:30 +00:00
Yannick Ulrich 08c8d7e8de Removed device wrapper 2023-02-26 19:09:45 +00:00
Yannick Ulrich 1799c072ff Added one-shot converter for strings 2023-02-26 19:08:35 +00:00
Yannick Ulrich c5ca30cd0a Added format converters 2023-02-26 19:08:10 +00:00
Yannick Ulrich c046c67dbd Turned generator to return []byte 2023-02-26 19:07:09 +00:00
Yannick Ulrich e2bd52b5a0 Implemented Read for watcher 2023-02-26 19:06:11 +00:00
Yannick Ulrich 2c899b4660 Implemented Read for watcher 2023-02-26 19:04:47 +00:00
Yannick Ulrich 083da5b3f0 Used generator instead of function in ITProperty 2023-02-26 19:03:27 +00:00
Yannick Ulrich 4333b83ca2 Added channel reader 2023-02-26 19:02:23 +00:00
Yannick Ulrich d2dbcd8713 Fixed unlink (1a5970a0) 2023-02-26 13:54:57 +00:00
Yannick Ulrich 8f57a0be8d Added fuse to config 2023-02-26 13:40:44 +00:00
Yannick Ulrich 4389609500 Run Readdir during Lookup if necessary 2023-02-26 13:15:09 +00:00
Yannick Ulrich 5fa49adee4 7. Activate fuse 2023-02-26 13:10:03 +00:00
Yannick Ulrich fe43a608d0 6. Used io.Copy to move files 2023-02-26 13:09:41 +00:00
Yannick Ulrich c142d97ee8 5. Use defer for closing file 2023-02-26 13:09:17 +00:00
Yannick Ulrich 9b9ab67217 4. Better error handling 2023-02-26 13:08:14 +00:00
Yannick Ulrich a27cc090dd 3. Interfaced FS 2023-02-26 13:06:58 +00:00
Yannick Ulrich ffe9d43cf8 2. Inherited from infinitime.Device to extend 2023-02-26 13:05:58 +00:00
Yannick Ulrich ec39e649c5 1. Removed main routine 2023-02-26 13:04:44 +00:00
Yannick Ulrich b181785006 Removed mock 2023-02-26 13:03:19 +00:00
Yannick Ulrich 4d3bc1ed40 y 1a5970a 2023-02-21 20:13:44 +00:00
Yannick Ulrich 68f6d20719 x 2023-02-21 20:11:38 +00:00
Yannick Ulrich bfb21ea6a9 Enforced single thread fuse 2023-02-21 20:06:09 +00:00
Yannick Ulrich 83726c9427 Changed the way DirEntry is mocked 2023-02-21 20:05:49 +00:00
Yannick Ulrich afaa5990c4 Ensure Close is always called 2023-02-21 19:58:02 +00:00
Yannick Ulrich 1a5970a041 Improved logging 2023-02-21 19:57:36 +00:00
Yannick Ulrich 5d71ae245c Added Fsync 2023-02-19 20:12:38 +00:00
Yannick Ulrich 9d28a2a1f8 Implementing remove 2023-02-19 20:11:30 +00:00
Yannick Ulrich 82ed906857 Implemented Rename 2023-02-19 19:58:34 +00:00
Yannick Ulrich 9d3fdeb78f Implemented Mkdir 2023-02-19 19:46:38 +00:00
Yannick Ulrich 85b2145aa5 Implemented Create 2023-02-19 19:39:26 +00:00
Yannick Ulrich 74afbc7c20 Implemented Getattr 2023-02-19 19:36:56 +00:00
Yannick Ulrich 2a8de96773 Implemented Write 2023-02-19 19:00:20 +00:00
Yannick Ulrich a8dc017a48 Implemented Read 2023-02-19 16:54:19 +00:00
Yannick Ulrich d04af07dbe Implemented ReadDir 2023-02-19 16:45:51 +00:00
Yannick Ulrich a5d70e373c Implemented mocks 2023-02-19 14:23:04 +00:00
Yannick Ulrich e4f8d0b551 Updated mock interfaces 2023-02-19 13:51:06 +00:00
Yannick Ulrich 4a18622d37 Added functions for variables 2023-02-19 13:01:18 +00:00
Yannick Ulrich 5008cdd4f4 Define reader 2023-02-19 12:23:44 +00:00
Yannick Ulrich eb745def04 Store inode in ITNode 2023-02-19 12:23:18 +00:00
Yannick Ulrich 0e0bfdc1f4 Defined ITProperties 2023-02-19 12:08:56 +00:00
Yannick Ulrich b820d6a674 Used switch instead of if 2023-02-19 12:08:45 +00:00
Yannick Ulrich 3a8888c003 Added FUSE example 2023-02-19 11:50:02 +00:00
Yannick Ulrich 7010dc6b17 Added fuse dep 2023-02-19 11:01:23 +00:00
Elara6331 4cdd47311f Switch from zerolog to go.arsenm.dev/logger in itctl
ci/woodpecker/push/woodpecker Pipeline was successful
2023-01-04 15:17:14 -08:00
Elara6331 520c23b75b Switch from zerolog to go.arsenm.dev/logger
ci/woodpecker/push/woodpecker Pipeline was successful
2023-01-04 15:06:05 -08:00
Elara6331 81840d411d Upgrade go.arsenm.dev/drpc
ci/woodpecker/push/woodpecker Pipeline was successful
2023-01-04 14:25:58 -08:00
Elara6331 0aa89e18b6 Add error handling for RPC registration functions
ci/woodpecker/push/woodpecker Pipeline was successful
2023-01-03 16:47:25 -08:00
Elara6331 c3a61b5893 Move multiplexing code into separate module
ci/woodpecker/push/woodpecker Pipeline was successful
2023-01-03 13:06:38 -08:00
Elara6331 52686fbad0 Update itgui screenshots
ci/woodpecker/push/woodpecker Pipeline was successful
2023-01-03 09:39:21 -08:00
Elara6331 547c79f874 Add doc comments
ci/woodpecker/push/woodpecker Pipeline was successful
2023-01-03 09:30:04 -08:00
Elara6331 de3ce406e7 Use multiplexed connection in NewFromConn()
ci/woodpecker/push/woodpecker Pipeline was successful
2023-01-03 09:24:36 -08:00
Elara6331 27cd275ddb Run formatter
ci/woodpecker/push/woodpecker Pipeline was successful
2023-01-03 09:18:57 -08:00
Elara6331 1ad99fafc4 Use correct paths in README
ci/woodpecker/push/woodpecker Pipeline was successful
2023-01-03 09:16:59 -08:00
Elara6331 0cf36f220d Properly close multiplexed streams
ci/woodpecker/push/woodpecker Pipeline was successful
2023-01-03 09:15:38 -08:00
Elara6331 1cbc2f86fa Start separate goroutine for multiplexed stream handling
ci/woodpecker/push/woodpecker Pipeline was successful
2023-01-03 01:02:48 -08:00
Elara6331 87fdb7a30a Add connection multiplexing, fixing itgui
ci/woodpecker/push/woodpecker Pipeline was successful
2023-01-03 00:54:00 -08:00
Elara6331 7e4720ed6a Fix dependencies
ci/woodpecker/push/woodpecker Pipeline was successful
2023-01-02 23:06:04 -08:00
Elara6331 d7bd94e164 Restructure and revise README
ci/woodpecker/push/woodpecker Pipeline was successful
2023-01-02 22:42:12 -08:00
Elara6331 f9ea55910e Remove itgui CI config
ci/woodpecker/push/woodpecker Pipeline was successful
2023-01-02 22:32:04 -08:00
Elara6331 b757af7fed Switch to autogenerated DRPC framework
ci/woodpecker/push/woodpecker Pipeline was successful
2023-01-02 22:30:17 -08:00
Hunman 5f5c67f7cc Warn when Koanf read fails (#47)
ci/woodpecker/push/woodpecker Pipeline was successful
Figured out the problem in issue #32, the toml file syntax was invalid (I had `'` instead of `"` at some values), but there was nothing in the logs about it.

Moved the config reading (and watching) into the same function, which logs the error as a warning.

I wanted to try moving the whole `if` into a separate function, but I kept getting errors when I tried to extract the `path` from the `File`, so I have that attempt in a separate branch not in this pull request: https://gitea.arsenm.dev/Hunman/itd/commit/5a84bf81489d3dc57f197f5feef5521950645ba5

Reviewed-on: https://gitea.arsenm.dev/Arsen6331/itd/pulls/47
Co-authored-by: Hunman <sanyi.exe@gmail.com>
Co-committed-by: Hunman <sanyi.exe@gmail.com>
2023-01-02 09:05:23 +00:00
Elara6331 248beffa2f Add tests
ci/woodpecker/push/woodpecker Pipeline was successful
2022-12-08 01:16:00 -08:00
Elara6331 73a679d10b Move mpris out of pkg directory and run gofumpt
ci/woodpecker/push/woodpecker Pipeline was successful
2022-11-24 17:36:25 -08:00
Elara6331 d475c6905e Fix goreleaser aur config
ci/woodpecker/push/woodpecker Pipeline was successful
2022-11-24 16:24:45 -08:00
Elara6331 0e6e3848d7 Add archlinux package to goreleaser config
ci/woodpecker/push/woodpecker Pipeline was successful
2022-11-24 16:23:03 -08:00
Elara6331 ceff536e92 Add itgui.desktop to goreleaser and fix itgui permissions 2022-11-24 16:20:11 -08:00
Elara6331 5e24e8aafa Add itgui.desktop
ci/woodpecker/push/woodpecker Pipeline was successful
2022-11-24 16:18:26 -08:00
Elara6331 f4da64a8dd Prepare for itgui cross-compilation
ci/woodpecker/push/woodpecker Pipeline was successful
2022-11-24 16:16:25 -08:00
Elara6331 76320aa813 Switch version.txt target to use go generate
ci/woodpecker/push/woodpecker Pipeline was successful
2022-11-22 03:23:14 +00:00
Elara6331 b64e6d27d4 Merge pull request 'Move mpris implementation from infinitime library to itd, where it really belongs' (#41) from FloralExMachina/itd:master into master
ci/woodpecker/push/woodpecker Pipeline was successful
Reviewed-on: https://gitea.arsenm.dev/Arsen6331/itd/pulls/41
2022-11-22 02:24:51 +00:00
razorkitty f215e4fd90 fixed type in comment about DBus
ci/woodpecker/pr/woodpecker Pipeline was successful
2022-11-22 02:23:03 +00:00
razorkitty 1e8c9484d2 copy mpris implementation from infinitime library to itd, where it really belongs
ci/woodpecker/pr/woodpecker Pipeline was successful
moved dbus.go to an internal utils package
added context function parameter to initMusicCtrl and updated main.go to pass it
updated calls.go, maps.go, music.go, and notifs.go to use utils package for getting a dus connection
2022-11-21 19:59:54 +00:00
Elara6331 b6c47b7383 Remove gitm config as it's no longer needed
ci/woodpecker/push/woodpecker Pipeline was successful
2022-11-19 15:38:23 -08:00
Elara6331 e97c1fef48 Remove pactl dependencies (Arsen6331/infinitime#6)
ci/woodpecker/push/woodpecker Pipeline was successful
2022-11-19 15:29:10 -08:00
Elara6331 3f2bccc40c Merge pull request 'update itctl usage screen to current output' (#39) from mashuptwice/itd:master into master
ci/woodpecker/push/woodpecker Pipeline was successful
Reviewed-on: https://gitea.arsenm.dev/Arsen6331/itd/pulls/39
2022-11-19 04:04:31 +00:00
mashuptwice d80230b9d4 update itctl usage screen to current output
ci/woodpecker/pr/woodpecker Pipeline was successful
2022-11-19 03:55:22 +00:00
Elara6331 c81ac19dda Switch badge to self-hosted CI
ci/woodpecker/push/woodpecker Pipeline was successful
2022-11-18 07:50:21 +00:00
Elara6331 4a397d4c1e Add go generate script for calculating version number
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2022-11-17 21:27:36 -08:00
Elara6331 c5fb3e1a33 Add woodpecker config
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline failed
2022-11-18 05:02:37 +00:00
Elara6331 908bd7d5f3 Add resource loading to ITD FS tab 2022-11-15 19:20:34 -08:00
Elara6331 c97fcaeefb Mention navigation support in README 2022-11-07 12:24:55 -08:00
Elara6331 992eb2e085 Add navigation support via PureMaps 2022-11-07 12:22:14 -08:00
Elara6331 f33b3d2b56 Update infinitime library 2022-10-25 12:38:02 -07:00
Elara6331 03f3968fe1 Update infinitime library 2022-10-20 01:42:23 -07:00
Elara6331 dea92c6404 Update infinitime library 2022-10-17 12:50:51 -07:00
Elara6331 006f245c10 Add warning if current InfiniTime doesn't support BLE FS (#29) 2022-10-17 12:40:51 -07:00
Elara6331 d232340edd Update infinitime library 2022-10-17 12:24:17 -07:00
Elara6331 c6458720e9 Handle error events in itctl res load command (#29) 2022-10-17 12:23:06 -07:00
Elara6331 1e072a3540 Merge pull request 'Add resource loading to ITD' (#28) from resource-loading into master
Reviewed-on: https://gitea.arsenm.dev/Arsen6331/itd/pulls/28
2022-10-16 20:17:49 +00:00
Elara6331 f639fef992 Add resource loading as part of DFU 2022-10-16 13:17:12 -07:00
Elara6331 2d0db1dcf1 Close channel once resource uploading complete 2022-10-16 12:42:59 -07:00
Elara6331 4efa4380c4 Add -r for rm and -p for mkdir 2022-09-03 16:28:25 -07:00
Elara6331 fca64afbf3 Remove example comments from goreleaser config 2022-09-01 15:09:49 -07:00
Elara6331 cf24c5ace8 Fix file extension of Alpine example 2022-09-01 15:02:11 -07:00
Elara6331 a25b2e3e62 Add --allow-untrusted to Alpine example 2022-09-01 15:00:03 -07:00
Elara6331 2d0b64d92f Add installation instructions for major distros 2022-09-01 14:58:33 -07:00
Elara6331 5efafe9be7 Remove download binary badge and add new AUR badge 2022-09-01 14:33:23 -07:00
Elara6331 271510d528 Allow automatic release to the AUR 2022-09-01 11:50:41 -07:00
Elara6331 4d72a063b2 Update CI badge 2022-09-01 03:14:05 -07:00
Elara6331 643245f16c Add GoReleaser config 2022-09-01 01:52:46 -07:00
Elara6331 6f87980d4b Add resource loading to itctl 2022-08-30 13:01:36 -07:00
Elara6331 851f1975d6 Add LoadResources() to API 2022-08-30 12:13:22 -07:00
Elara6331 5e66fe82ac Improve itgui compilation documentation (Fixes #24) 2022-08-29 13:28:52 -07:00
Elara6331 645541e079 Update infinitime library and bluetooth library (Fixes #22) 2022-08-19 14:05:30 -07:00
Elara6331 1012be6e5b Revert #22 bandaid fix 2022-08-19 14:04:08 -07:00
Elara6331 5973290d6c Temporary bandaid fix for #22 2022-08-14 00:05:56 -07:00
Elara6331 19bacf29b2 Fix comment above goroutine code 2022-07-31 02:40:46 -07:00
Elara6331 a78650e526 Fix bug where itctl doesn't exit on SIGINT/SIGTERM 2022-07-31 02:22:33 -07:00
Elara6331 71e9caf0bc Fix bug where help command doesn't show flags/subcommands 2022-07-31 02:15:42 -07:00
Elara6331 1f5a6365bc Remove GOFLAGS from Makefile as the go tool already looks at that variable 2022-07-22 10:36:19 -07:00
Elara6331 958f2af516 Propagate context to lrpc 2022-05-12 17:14:34 -07:00
Elara6331 60f1eedc9a Create and propagate contexts wherever possible 2022-05-11 13:24:12 -07:00
Elara6331 c05147518d Add metrics screenshot 2022-05-11 12:10:50 -07:00
Elara6331 422f844943 Add metrics graphs to itgui 2022-05-10 23:37:58 -07:00
Elara6331 66618e5bf0 Add metrics collection via sqlite 2022-05-10 18:03:37 -07:00
Elara6331 0c2e57ced0 Update lrpc 2022-05-10 02:12:52 -07:00
Elara6331 6d9f6fc6e6 Update Go compiler requirement 2022-05-09 21:46:03 -07:00
Elara6331 0cbd6a48ae Allow API client to be made from connection 2022-05-07 21:23:42 -07:00
Elara6331 b614138f6b Update lrpc library 2022-05-07 15:12:29 -07:00
Elara6331 3a0491f069 Add new itgui screenshots 2022-05-05 14:05:58 -07:00
Elara6331 093a5632c7 Rewrite itgui and add new screenshots 2022-05-05 14:00:49 -07:00
Elara6331 91662e6f38 Update infinitime library 2022-05-05 12:41:51 -07:00
Elara6331 931966bf1e Update lrpc for data race fixes 2022-05-04 16:16:28 -07:00
Elara6331 ed01700e26 Update lrpc 2022-05-03 18:55:37 -07:00
Elara6331 e9269e8eb8 Update infinitime library 2022-05-02 20:21:47 -07:00
Elara6331 52b85ab361 Allow changing bluetooth adapter ID 2022-05-02 20:17:38 -07:00
Elara6331 bc45943bdc Update lrpc 2022-05-02 16:28:25 -07:00
Elara6331 6933f45683 Fix lrpc response line number in README 2022-05-01 23:06:27 -07:00
Elara6331 0f22d67395 Update lrpc 2022-05-01 21:39:58 -07:00
Elara6331 6da03181a9 Remove version.txt on clean 2022-05-01 21:22:15 -07:00
Elara6331 44a25625da Only update version if version.txt does not exist 2022-05-01 21:21:22 -07:00
Elara6331 14a38351e4 Update README to reflect recent changes 2022-05-01 21:16:47 -07:00
Elara6331 4c27f424b2 Remove debug print 2022-05-01 20:56:14 -07:00
Elara6331 86fbef2e8a Remove the no-longer useful none type alias 2022-05-01 20:51:13 -07:00
Elara6331 7b8658e072 Remove version.txt 2022-05-01 20:49:42 -07:00
Elara6331 73c46cfa66 Remove replace directive and fix firmware upgrade error 2022-05-01 20:40:30 -07:00
Elara6331 1e0f1c5b76 Fix bug where itctl could not be killed 2022-05-01 20:32:59 -07:00
Elara6331 78b5ca1de8 Add context support and update lrpc 2022-05-01 15:22:28 -07:00
Elara6331 b0c4574481 Remove now unnecessary DoneMap 2022-05-01 14:00:31 -07:00
Elara6331 01975f207c Upgrade lrpc version 2022-05-01 13:59:40 -07:00
Elara6331 428e7967c1 Use default codec 2022-05-01 11:41:16 -07:00
Elara6331 56dbf0540e Switch to lrpc and use context to handle signals 2022-05-01 11:36:28 -07:00
Elara6331 240e7a5ee4 Use rpcxlite 2022-04-30 03:25:27 -07:00
Elara6331 625805fe96 Add comments 2022-04-24 00:58:39 -07:00
Elara6331 4b6f7d408e Support bidirectional requests over gateway 2022-04-24 00:54:04 -07:00
Elara6331 9034ef7c6b Add debug logs 2022-04-23 20:20:13 -07:00
Elara6331 9939f724c4 Re-add watch commands to itctl 2022-04-23 18:46:49 -07:00
Elara6331 8dce33f7b1 Enable RPCX gateway 2022-04-23 11:29:16 -07:00
Elara6331 563009c44d Merge branch 'master' of ssh://192.168.100.62:2222/Arsen6331/itd 2022-04-22 19:22:32 -07:00
Elara6331 d4a8a9f8c9 Improve error handling 2022-04-22 18:43:13 -07:00
Elara6331 7fd9af3288 Remove old code comment 2022-04-22 17:19:23 -07:00
Elara6331 4508559bfd Update module go version to 1.17 2022-04-22 17:15:41 -07:00
Elara6331 0cdf8a4bed Switch from custom socket API to rpcx 2022-04-22 17:12:30 -07:00
Elara6331 2af6c1887f Fix typo in code (Czeck -> Czech) 2022-04-16 10:15:55 -07:00
Elara6331 3a3f95acdf Fix typo (Czeck -> Czech) 2022-04-16 10:14:18 -07:00
Elara6331 d318c584da Use new changes in infinitime library to stop removing InfiniTime devices (Fixes #10) 2022-04-16 04:28:53 -07:00
Elara6331 c8c617c10a Fix itctl panic when itd is not running (Fixes #14) 2022-04-02 15:20:31 -07:00
Elara6331 365414f951 Merge pull request 'emoji translation: Add my frequently received emojis' (#15) from earboxer/itd:common-emojis into master
Reviewed-on: https://gitea.arsenm.dev/Arsen6331/itd/pulls/15
2022-03-25 17:22:02 -07:00
earboxer 9b04d06560 emoji translation: Add my frequently received emojis
mapped to a common ASCII emoticon, or to the shortcode
2022-03-21 11:58:13 -04:00
Elara6331 23e9195e70 Remove debug code 2022-03-15 19:25:37 -07:00
Elara6331 cd68fbd7f3 Update 'cmd/itctl/main.go' 2022-03-15 16:16:44 -07:00
Elara6331 205a041758 Remove exit error handler because it causes duplicated help text 2022-03-15 16:06:05 -07:00
Elara6331 62597f70ee Transliterate song metadata (Fixes #13) 2022-03-11 13:14:23 -08:00
Elara6331 32bb141244 Merge pull request 'Romanian transliterate' (#12) from eugenr/itd:romanian into master
Reviewed-on: https://gitea.arsenm.dev/Arsen6331/itd/pulls/12
2022-03-11 10:04:26 -08:00
eugenr f28c68438a Add Romanian to README.md 2022-03-11 04:17:12 -08:00
eugenr aa90e9eb26 Romanian translit 2022-03-11 04:15:10 -08:00
Elara6331 553709ce8d Make sure fs is only updated if dev.FS() succeeds (#11) 2022-03-08 08:32:31 -08:00
Elara6331 2ded0d36b1 Update infinitime library for #9 fix 2022-03-04 12:05:58 -08:00
Elara6331 a885eacc70 Rewrite itctl to use urfave/cli instead of spf13/cobra 2022-02-24 21:26:40 -08:00
Elara6331 9e63401db3 Add update weather command to itctl 2022-02-23 21:22:03 -08:00
Elara6331 2f14e70721 Add default version.txt file 2022-02-22 08:44:50 -08:00
Elara6331 614d14e399 Add version flag 2022-02-22 08:43:29 -08:00
Elara6331 c08ddfd810 Add enable switch for weather to config 2022-02-22 08:33:27 -08:00
Elara6331 4bdb82b1bc Add error logging for weather 2022-02-21 16:27:04 -08:00
Elara6331 b4d302caf6 Implement weather via MET Norway 2022-02-21 16:18:52 -08:00
Elara6331 4b2694ee0d Switch from viper to koanf 2022-02-21 11:20:02 -08:00
Elara6331 4c36144b0b Update version of infinitime library for rewritten connection code 2022-02-21 02:47:48 -08:00
Elara6331 e88dea40fb Reorganize and clean code 2021-12-17 00:31:05 -08:00
Elara6331 23b9cfe8a3 Update Infinitime library to use custom agent 2021-12-16 21:32:06 -08:00
Elara6331 518fe74e96 Propagate FS errors on read/write and close files when finished writing 2021-12-13 09:58:34 -08:00
Elara6331 27aabdceba Make paths absolute for firmware upgrades 2021-12-12 17:46:50 -08:00
Elara6331 c019d7523b Implement file transfer progress 2021-12-12 17:08:48 -08:00
Elara6331 03c3c6b22f Remove debug code 2021-12-11 22:23:01 -08:00
Elara6331 69d1027f01 Create absolute directories for ITD to read/write 2021-12-11 22:13:21 -08:00
Elara6331 873df67d1f Directly read/write files from ITD 2021-12-11 22:11:01 -08:00
Elara6331 a9ef386883 Fix comments in filesystem commands 2021-11-27 00:11:37 -08:00
Elara6331 24cfda82d7 Fix and add error messages to fs operations 2021-11-27 00:03:13 -08:00
Elara6331 655af5c446 Ensure that the FS works after a reconnect 2021-11-25 20:35:03 -08:00
Elara6331 b363a20a9d Remove replace directive 2021-11-25 19:49:07 -08:00
Elara6331 f5d326124d Add missing responses to some FS operations 2021-11-25 19:46:04 -08:00
Elara6331 cb8fb2c0bc Add newline for read file command if output is stdout 2021-11-25 19:44:43 -08:00
Elara6331 38119435f1 Get BLE FS once rather than on every connection 2021-11-25 19:41:44 -08:00
Elara6331 034a69c12f Allow multiple call notification responses 2021-11-25 12:41:36 -08:00
Elara6331 70006a3d7b Remove playerctl from depencency list 2021-11-24 16:46:57 -08:00
Elara6331 8aada58d64 Update music control implementation 2021-11-24 16:44:36 -08:00
Elara6331 5d231207cd Remove useless function call 2021-11-24 13:07:48 -08:00
Elara6331 584d9426e6 Make sure modemmanager exists for call notifications 2021-11-24 13:04:20 -08:00
Elara6331 7a772a5458 Add comments 2021-11-24 12:00:44 -08:00
Elara6331 079c733b60 Use clearer variable names 2021-11-24 11:54:16 -08:00
Elara6331 e24a8e9088 Use new helper functions 2021-11-24 11:52:52 -08:00
Elara6331 0b5d777077 Switch calls to use dbus library and add helpers for private connections 2021-11-24 11:36:36 -08:00
Elara6331 75327286ef Switch to private bus connection 2021-11-23 22:03:41 -08:00
Elara6331 099b0cd849 Add filesystem to itctl 2021-11-23 14:14:45 -08:00
Elara6331 c9c00e0072 Allow multiple paths in mkdir and remove 2021-11-23 13:35:18 -08:00
Elara6331 b2ffb2062a Fix write file in api package 2021-11-23 11:19:21 -08:00
Elara6331 2e8c825fff Add BLE FS to API package 2021-11-23 11:12:16 -08:00
Elara6331 7b870950d1 Implement BLE FS 2021-11-22 22:04:09 -08:00
Elara6331 3a877c41a4 Update infinitime library to fix compatibility with BlueZ 5.62 2021-11-22 01:18:40 -08:00
Elara6331 04fb390bee Add reminder to validate firmware to itctl and itgui 2021-11-06 19:06:17 -07:00
Elara6331 50b17d3266 Update default values to reflect new config fields 2021-11-01 11:28:55 -07:00
Elara6331 763d408405 Upgrade infinitime library version 2021-11-01 11:21:37 -07:00
Elara6331 fbb7cd9bc1 Remove config version field 2021-10-27 08:34:10 -07:00
Elara6331 f1b7f70313 Add whitelist support 2021-10-27 07:27:12 -07:00
Elara6331 552f19676b Add motion service to itgui 2021-10-25 09:45:19 -07:00
Elara6331 9d58ea0ae7 Remove debug print and add error handling (itgui) 2021-10-25 00:11:41 -07:00
Elara6331 76875db7ea Use api package in itgui 2021-10-24 13:27:14 -07:00
Elara6331 be5bdc625b Add watch commands to itctl 2021-10-24 11:02:29 -07:00
Elara6331 0d0db949af Handle unknown request type 2021-10-24 01:11:57 -07:00
Elara6331 0d164aef3d Use request type for error response type 2021-10-24 01:09:27 -07:00
Elara6331 28610d9ebb Fix API package 2021-10-24 00:49:48 -07:00
Elara6331 dff34b484d Return request type for response type 2021-10-24 00:45:50 -07:00
Elara6331 2ea9f99db6 Disable firmware updating error once progress channel closed 2021-10-23 22:03:33 -07:00
Elara6331 44dc5f8e47 Use sent bytes to check if transfer complete 2021-10-23 19:36:23 -07:00
Elara6331 4d35912466 Remove test 2021-10-23 18:42:22 -07:00
Elara6331 ef29b9bee4 Update itctl to use api 2021-10-23 18:41:03 -07:00
Elara6331 e198b769f9 Generalize socket cancellation and update API accordingly 2021-10-23 18:03:17 -07:00
Elara6331 ef4bad94b5 Reorganize itctl structure 2021-10-23 15:11:04 -07:00
Elara6331 8cf2b47733 Add cancellation to api package 2021-10-22 22:30:58 -07:00
Elara6331 f20fdcb161 Add responses to cancellation requests 2021-10-22 22:15:35 -07:00
Elara6331 eeba9b2964 Add cancellation to watchable values 2021-10-22 22:14:01 -07:00
Elara6331 d7057e3f9c Add doc comments to api package 2021-10-22 21:01:18 -07:00
Elara6331 80a5867d6b Send response types in socket responses and create api package 2021-10-22 20:47:57 -07:00
Elara6331 f001dd6079 Update readme 2021-10-22 17:12:46 -07:00
Elara6331 b87586ef15 Add MotionValues type 2021-10-22 13:42:33 -07:00
Elara6331 295892c8a8 Add motion service to itctl 2021-10-22 13:40:16 -07:00
Elara6331 1492db7566 Implement motion service 2021-10-22 13:21:14 -07:00
Elara6331 e7de7bd7bb Update infinitime library version to fix intermittent DFU issues 2021-10-21 20:27:58 -07:00
Elara6331 7b849a3fc7 Remove replace directive 2021-10-15 00:27:10 -07:00
Elara6331 21d4964207 Mention call notifications in readme 2021-10-15 00:26:14 -07:00
Elara6331 604ea57c5f Add call notifications for ModemManager 2021-10-15 00:25:34 -07:00
Elara6331 b15cbb6349 Show update file names when selected in itgui 2021-10-07 13:38:13 -07:00
Elara6331 843e369bab Remove replace directive 2021-10-06 17:47:07 -07:00
Elara6331 eec7a3db48 Update infinitime library 2021-10-06 17:15:42 -07:00
Elara6331 c23201e18c Add and fix comments, fix transliteration maps so only first character is capitalized 2021-10-06 13:26:16 -07:00
Elara6331 4bc6eb9d41 Fix chinese transliteration when chinese characters are not followed by non-chinese characters 2021-10-06 13:15:49 -07:00
Elara6331 2a59e74a2c Only do init once for Armenian transliteration 2021-10-06 13:08:25 -07:00
Elara6331 df743cca96 Add init functions to transliterators 2021-10-06 09:41:33 -07:00
Elara6331 01bf493c77 Fix capital letters for Armenian transliteration 2021-10-05 09:09:19 -07:00
Elara6331 b6e9ad6160 Add Chinese transliteration via Pinyin conversion library 2021-10-04 22:26:16 -07:00
Elara6331 c56c0ae198 Update variable names and comments for interface-based transliteration 2021-10-04 20:23:54 -07:00
Elara6331 6b94030b83 Fix Korean transliteration 2021-10-04 20:06:08 -07:00
Elara6331 2bbd722ecd Add korean transliteration 2021-10-04 19:07:54 -07:00
Elara6331 73f16fcfef Use interface to allow for more complex transliteration implementations 2021-10-04 17:45:26 -07:00
Elara6331 9df6531023 Fix German transliteration for Ü and add attribution 2021-10-04 13:17:48 -07:00
Elara6331 1db2ca3395 Add transliteration 2021-10-04 01:05:01 -07:00
Elara6331 419b2f5a79 Break transfer loops after refreshing progress bar 2021-08-27 09:01:46 -07:00
Elara6331 44607ba9e2 Add fatal error dialog 2021-08-27 08:47:24 -07:00
Elara6331 f4d2f4e6eb Mention GUI in README 2021-08-26 09:01:03 -07:00
Elara6331 0721b7f9d4 Add comments to gui 2021-08-26 08:47:17 -07:00
Elara6331 b7bd385c43 Add GUI frontend 2021-08-25 21:18:24 -07:00
Elara6331 cbcefb149e Fix indentation in config 2021-08-24 20:35:25 -07:00
Elara6331 cb8d207249 Switch to iota for request types and move to types package 2021-08-24 20:32:17 -07:00
Elara6331 7786ea1d58 Fix debug config paths 2021-08-24 08:55:22 -07:00
Elara6331 6e16aa7a7a Add config defaults and run go fmt 2021-08-24 08:54:08 -07:00
Elara6331 91f7132d5e Create new config format 2021-08-24 08:33:41 -07:00
Elara6331 b186f77bea Remove replace directive 2021-08-22 15:07:45 -07:00
Elara6331 adb297c6dd Fix find and replace error 2021-08-22 13:53:32 -07:00
Elara6331 b4992cb393 Update infinitime library to fix connection bug 2021-08-22 13:13:37 -07:00
Elara6331 a5490b8364 Use new pair timeout option 2021-08-21 20:35:21 -07:00
Elara6331 44d1f5552b Mention interactive mode in readme 2021-08-21 19:07:59 -07:00
Elara6331 5e34f656b3 Disable completion command 2021-08-21 19:03:18 -07:00
Elara6331 560d19860e Fix binary download link 2021-08-21 18:52:11 -07:00
Elara6331 ea1a7fa9f4 Add badges 2021-08-21 18:48:43 -07:00
Elara6331 81fe634ed8 Add uninstall rule to makefile 2021-08-21 17:17:25 -07:00
Elara6331 281e1dcbac Add CI status to readme 2021-08-21 16:36:10 -07:00
Elara6331 4847eee540 Add GOFLAGS environment variable to makefile 2021-08-21 16:03:54 -07:00
Elara6331 19caa3ee83 Add gitm for mirroring 2021-08-21 15:59:19 -07:00
Elara6331 e523a024ec Specify minimum go version in readme 2021-08-21 15:35:36 -07:00
Elara6331 4a3dff646c Add starting to readme 2021-08-21 15:14:37 -07:00
Elara6331 986d2064a7 Change recoverable errors to warn log level to stop shell from exiting 2021-08-21 14:15:55 -07:00
Elara6331 95cf5bfe6b Add interactive mode to itctl 2021-08-21 12:30:16 -07:00
Elara6331 0d70dd9b11 Prioritize config in home directory over /etc 2021-08-21 10:26:12 -07:00
Elara6331 3cfcdb7a01 Mention getting info from watch in readme 2021-08-21 09:40:29 -07:00
Elara6331 bdf5a099d4 Mention automatic config updates in readme 2021-08-21 09:37:20 -07:00
Elara6331 4a195f8311 Watch config for changes and apply automatically 2021-08-21 03:07:48 -07:00
Elara6331 60d2053894 Remove replace directive and update infinitime library 2021-08-21 01:37:16 -07:00
Elara6331 407a6cb3d7 Initial Commit 2021-08-21 01:19:49 -07:00
40 changed files with 433 additions and 576 deletions
+7 -7
View File
@@ -53,8 +53,8 @@ nfpms:
{{- else }}{{.Arch}} {{- else }}{{.Arch}}
{{- end }} {{- end }}
description: "Companion daemon for the InfiniTime firmware on the PineTime smartwatch" description: "Companion daemon for the InfiniTime firmware on the PineTime smartwatch"
homepage: 'https://gitea.elara.ws/Elara6331/itd' homepage: 'https://gitea.arsenm.dev/Arsen6331/itd'
maintainer: 'Elara Musayelyan <elara@elara.ws>' maintainer: 'Arsen Musyaelyan <arsen@arsenm.dev>'
license: GPLv3 license: GPLv3
formats: formats:
- apk - apk
@@ -74,10 +74,10 @@ nfpms:
mode: 0755 mode: 0755
aurs: aurs:
- name: itd-bin - name: itd-bin
homepage: 'https://gitea.elara.ws/Elara6331/itd' homepage: 'https://gitea.arsenm.dev/Arsen6331/itd'
description: "Companion daemon for the InfiniTime firmware on the PineTime smartwatch" description: "Companion daemon for the InfiniTime firmware on the PineTime smartwatch"
maintainers: maintainers:
- 'Elara Musayelyan <elara@elara.ws>' - 'Arsen Musyaelyan <arsen@arsenm.dev>'
license: GPLv3 license: GPLv3
private_key: '{{ .Env.AUR_KEY }}' private_key: '{{ .Env.AUR_KEY }}'
git_url: 'ssh://aur@aur.archlinux.org/itd-bin.git' git_url: 'ssh://aur@aur.archlinux.org/itd-bin.git'
@@ -105,11 +105,11 @@ aurs:
install -Dm644 "./LICENSE" "${pkgdir}/usr/share/licenses/itd/LICENSE" install -Dm644 "./LICENSE" "${pkgdir}/usr/share/licenses/itd/LICENSE"
release: release:
gitea: gitea:
owner: Elara6331 owner: Arsen6331
name: itd name: itd
gitea_urls: gitea_urls:
api: 'https://gitea.elara.ws/api/v1/' api: 'https://gitea.arsenm.dev/api/v1/'
download: 'https://gitea.elara.ws' download: 'https://gitea.arsenm.dev'
skip_tls_verify: false skip_tls_verify: false
checksum: checksum:
name_template: 'checksums.txt' name_template: 'checksums.txt'
+2 -3
View File
@@ -1,9 +1,9 @@
# ITD # ITD
## InfiniTime Daemon ## InfiniTime Daemon
`itd` is a daemon that uses my infinitime [library](https://go.elara.ws/infinitime) to interact with the [PineTime](https://www.pine64.org/pinetime/) running [InfiniTime](https://infinitime.io). `itd` is a daemon that uses my infinitime [library](https://go.arsenm.dev/infinitime) to interact with the [PineTime](https://www.pine64.org/pinetime/) running [InfiniTime](https://infinitime.io).
[![status-badge](https://ci.elara.ws/api/badges/Elara6331/itd/status.svg)](https://ci.elara.ws/Elara6331/itd) [![status-badge](https://ci.arsenm.dev/api/badges/Arsen6331/itd/status.svg)](https://ci.arsenm.dev/Arsen6331/itd)
[![itd-git AUR package](https://img.shields.io/aur/version/itd-git?label=itd-git&logo=archlinux)](https://aur.archlinux.org/packages/itd-git/) [![itd-git AUR package](https://img.shields.io/aur/version/itd-git?label=itd-git&logo=archlinux)](https://aur.archlinux.org/packages/itd-git/)
[![itd-bin AUR package](https://img.shields.io/aur/version/itd-bin?label=itd-bin&logo=archlinux)](https://aur.archlinux.org/packages/itd-bin/) [![itd-bin AUR package](https://img.shields.io/aur/version/itd-bin?label=itd-bin&logo=archlinux)](https://aur.archlinux.org/packages/itd-bin/)
@@ -22,7 +22,6 @@
- Weather - Weather
- BLE Filesystem - BLE Filesystem
- Navigation (PureMaps) - Navigation (PureMaps)
- FUSE Filesystem
--- ---
+2 -2
View File
@@ -4,8 +4,8 @@ import (
"io" "io"
"net" "net"
"go.elara.ws/drpc/muxconn" "go.arsenm.dev/drpc/muxconn"
"go.elara.ws/itd/internal/rpc" "go.arsenm.dev/itd/internal/rpc"
"storj.io/drpc" "storj.io/drpc"
) )
+1 -1
View File
@@ -3,7 +3,7 @@ package api
import ( import (
"context" "context"
"go.elara.ws/itd/internal/rpc" "go.arsenm.dev/itd/internal/rpc"
) )
type DFUProgress struct { type DFUProgress struct {
+1 -1
View File
@@ -5,7 +5,7 @@ import (
"errors" "errors"
"io" "io"
"go.elara.ws/itd/internal/rpc" "go.arsenm.dev/itd/internal/rpc"
) )
type FSClient struct { type FSClient struct {
+1 -1
View File
@@ -3,7 +3,7 @@ package api
import ( import (
"context" "context"
"go.elara.ws/itd/internal/rpc" "go.arsenm.dev/itd/internal/rpc"
) )
func (c *Client) HeartRate(ctx context.Context) (uint8, error) { func (c *Client) HeartRate(ctx context.Context) (uint8, error) {
+1 -1
View File
@@ -3,7 +3,7 @@ package api
import ( import (
"context" "context"
"go.elara.ws/itd/internal/rpc" "go.arsenm.dev/itd/internal/rpc"
) )
func (c *Client) Notify(ctx context.Context, title, body string) error { func (c *Client) Notify(ctx context.Context, title, body string) error {
+2 -2
View File
@@ -3,8 +3,8 @@ package api
import ( import (
"context" "context"
"go.elara.ws/infinitime" "go.arsenm.dev/infinitime"
"go.elara.ws/itd/internal/rpc" "go.arsenm.dev/itd/internal/rpc"
) )
type ResourceOperation uint8 type ResourceOperation uint8
+1 -1
View File
@@ -4,7 +4,7 @@ import (
"context" "context"
"time" "time"
"go.elara.ws/itd/internal/rpc" "go.arsenm.dev/itd/internal/rpc"
) )
func (c *Client) SetTime(ctx context.Context, t time.Time) error { func (c *Client) SetTime(ctx context.Context, t time.Time) error {
+1 -1
View File
@@ -3,7 +3,7 @@ package api
import ( import (
"context" "context"
"go.elara.ws/itd/internal/rpc" "go.arsenm.dev/itd/internal/rpc"
) )
func (c *Client) WeatherUpdate(ctx context.Context) error { func (c *Client) WeatherUpdate(ctx context.Context) error {
+1 -1
View File
@@ -3,7 +3,7 @@ package api
import ( import (
"context" "context"
"go.elara.ws/itd/internal/rpc" "go.arsenm.dev/itd/internal/rpc"
) )
func (c *Client) WatchHeartRate(ctx context.Context) (<-chan uint8, error) { func (c *Client) WatchHeartRate(ctx context.Context) (<-chan uint8, error) {
+6 -42
View File
@@ -5,12 +5,12 @@ import (
"sync" "sync"
"github.com/godbus/dbus/v5" "github.com/godbus/dbus/v5"
"go.elara.ws/infinitime" "go.arsenm.dev/infinitime"
"go.elara.ws/itd/internal/utils" "go.arsenm.dev/itd/internal/utils"
"go.elara.ws/logger/log" "go.arsenm.dev/logger/log"
) )
func initCallNotifs(ctx context.Context, wg WaitGroup, dev *infinitime.Device) error { func initCallNotifs(ctx context.Context, dev *infinitime.Device) error {
// Connect to system bus. This connection is for method calls. // Connect to system bus. This connection is for method calls.
conn, err := utils.NewSystemBusConn(ctx) conn, err := utils.NewSystemBusConn(ctx)
if err != nil { if err != nil {
@@ -53,12 +53,9 @@ func initCallNotifs(ctx context.Context, wg WaitGroup, dev *infinitime.Device) e
var respHandlerOnce sync.Once var respHandlerOnce sync.Once
var callObj dbus.BusObject var callObj dbus.BusObject
wg.Add(1)
go func() { go func() {
defer wg.Done("callNotifs") // For every message received
for { for event := range callCh {
select {
case event := <-callCh:
// Get path to call object // Get path to call object
callPath := event.Body[0].(dbus.ObjectPath) callPath := event.Body[0].(dbus.ObjectPath)
// Get call object // Get call object
@@ -71,17 +68,6 @@ func initCallNotifs(ctx context.Context, wg WaitGroup, dev *infinitime.Device) e
continue continue
} }
// Get direction of call object using method call connection
direction, err := getDirection(conn, callObj)
if err != nil {
log.Error("Error getting call direction").Err(err).Send()
continue
}
if direction != MMCallDirectionIncoming {
continue
}
// Send call notification to InfiniTime // Send call notification to InfiniTime
resCh, err := dev.NotifyCall(phoneNum) resCh, err := dev.NotifyCall(phoneNum)
if err != nil { if err != nil {
@@ -110,9 +96,6 @@ func initCallNotifs(ctx context.Context, wg WaitGroup, dev *infinitime.Device) e
} }
} }
}) })
case <-ctx.Done():
return
}
} }
}() }()
@@ -142,25 +125,6 @@ func getPhoneNum(conn *dbus.Conn, callObj dbus.BusObject) (string, error) {
return out, nil return out, nil
} }
type MMCallDirection int
const (
MMCallDirectionUnknown MMCallDirection = iota
MMCallDirectionIncoming
MMCallDirectionOutgoing
)
// getDirection gets the direction of a call object using a DBus connection
func getDirection(conn *dbus.Conn, callObj dbus.BusObject) (MMCallDirection, error) {
var out MMCallDirection
// Get number property on DBus object and store return value in out
err := callObj.StoreProperty("org.freedesktop.ModemManager1.Call.Direction", &out)
if err != nil {
return 0, err
}
return out, nil
}
// getPhoneNum accepts a call using a DBus connection // getPhoneNum accepts a call using a DBus connection
func acceptCall(ctx context.Context, conn *dbus.Conn, callObj dbus.BusObject) error { func acceptCall(ctx context.Context, conn *dbus.Conn, callObj dbus.BusObject) error {
// Call Accept() method on DBus object // Call Accept() method on DBus object
+2 -2
View File
@@ -7,8 +7,8 @@ import (
"github.com/cheggaaa/pb/v3" "github.com/cheggaaa/pb/v3"
"github.com/urfave/cli/v2" "github.com/urfave/cli/v2"
"go.elara.ws/itd/api" "go.arsenm.dev/itd/api"
"go.elara.ws/logger/log" "go.arsenm.dev/logger/log"
) )
func fwUpgrade(c *cli.Context) error { func fwUpgrade(c *cli.Context) error {
+3 -3
View File
@@ -8,9 +8,9 @@ import (
"time" "time"
"github.com/urfave/cli/v2" "github.com/urfave/cli/v2"
"go.elara.ws/itd/api" "go.arsenm.dev/itd/api"
"go.elara.ws/logger" "go.arsenm.dev/logger"
"go.elara.ws/logger/log" "go.arsenm.dev/logger/log"
) )
var client *api.Client var client *api.Client
+1 -1
View File
@@ -6,7 +6,7 @@ import (
"github.com/cheggaaa/pb/v3" "github.com/cheggaaa/pb/v3"
"github.com/urfave/cli/v2" "github.com/urfave/cli/v2"
"go.elara.ws/infinitime" "go.arsenm.dev/infinitime"
) )
func resourcesLoad(c *cli.Context) error { func resourcesLoad(c *cli.Context) error {
+1 -1
View File
@@ -9,7 +9,7 @@ import (
"fyne.io/fyne/v2/layout" "fyne.io/fyne/v2/layout"
"fyne.io/fyne/v2/storage" "fyne.io/fyne/v2/storage"
"fyne.io/fyne/v2/widget" "fyne.io/fyne/v2/widget"
"go.elara.ws/itd/api" "go.arsenm.dev/itd/api"
) )
func firmwareTab(ctx context.Context, client *api.Client, w fyne.Window) fyne.CanvasObject { func firmwareTab(ctx context.Context, client *api.Client, w fyne.Window) fyne.CanvasObject {
+2 -2
View File
@@ -11,8 +11,8 @@ import (
"fyne.io/fyne/v2/storage" "fyne.io/fyne/v2/storage"
"fyne.io/fyne/v2/theme" "fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget" "fyne.io/fyne/v2/widget"
"go.elara.ws/infinitime" "go.arsenm.dev/infinitime"
"go.elara.ws/itd/api" "go.arsenm.dev/itd/api"
) )
func fsTab(ctx context.Context, client *api.Client, w fyne.Window, opened chan struct{}) fyne.CanvasObject { func fsTab(ctx context.Context, client *api.Client, w fyne.Window, opened chan struct{}) fyne.CanvasObject {
+1 -1
View File
@@ -11,7 +11,7 @@ import (
"fyne.io/fyne/v2/container" "fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/theme" "fyne.io/fyne/v2/theme"
"fyne.io/x/fyne/widget/charts" "fyne.io/x/fyne/widget/charts"
"go.elara.ws/itd/api" "go.arsenm.dev/itd/api"
_ "modernc.org/sqlite" _ "modernc.org/sqlite"
) )
+1 -1
View File
@@ -6,7 +6,7 @@ import (
"fyne.io/fyne/v2" "fyne.io/fyne/v2"
"fyne.io/fyne/v2/container" "fyne.io/fyne/v2/container"
"go.elara.ws/itd/api" "go.arsenm.dev/itd/api"
) )
func infoTab(ctx context.Context, client *api.Client, w fyne.Window) fyne.CanvasObject { func infoTab(ctx context.Context, client *api.Client, w fyne.Window) fyne.CanvasObject {
+1 -1
View File
@@ -6,7 +6,7 @@ import (
"fyne.io/fyne/v2/app" "fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container" "fyne.io/fyne/v2/container"
"go.elara.ws/itd/api" "go.arsenm.dev/itd/api"
) )
func main() { func main() {
+1 -1
View File
@@ -7,7 +7,7 @@ import (
"fyne.io/fyne/v2" "fyne.io/fyne/v2"
"fyne.io/fyne/v2/container" "fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/widget" "fyne.io/fyne/v2/widget"
"go.elara.ws/itd/api" "go.arsenm.dev/itd/api"
) )
func motionTab(ctx context.Context, client *api.Client, w fyne.Window) fyne.CanvasObject { func motionTab(ctx context.Context, client *api.Client, w fyne.Window) fyne.CanvasObject {
+1 -1
View File
@@ -7,7 +7,7 @@ import (
"fyne.io/fyne/v2/container" "fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/layout" "fyne.io/fyne/v2/layout"
"fyne.io/fyne/v2/widget" "fyne.io/fyne/v2/widget"
"go.elara.ws/itd/api" "go.arsenm.dev/itd/api"
) )
func notifyTab(ctx context.Context, client *api.Client, w fyne.Window) fyne.CanvasObject { func notifyTab(ctx context.Context, client *api.Client, w fyne.Window) fyne.CanvasObject {
+1 -1
View File
@@ -8,7 +8,7 @@ import (
"fyne.io/fyne/v2/container" "fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/layout" "fyne.io/fyne/v2/layout"
"fyne.io/fyne/v2/widget" "fyne.io/fyne/v2/widget"
"go.elara.ws/itd/api" "go.arsenm.dev/itd/api"
) )
func timeTab(ctx context.Context, client *api.Client, w fyne.Window) fyne.CanvasObject { func timeTab(ctx context.Context, client *api.Client, w fyne.Window) fyne.CanvasObject {
+2 -2
View File
@@ -9,8 +9,8 @@ import (
"github.com/knadh/koanf/providers/confmap" "github.com/knadh/koanf/providers/confmap"
"github.com/knadh/koanf/providers/env" "github.com/knadh/koanf/providers/env"
"github.com/knadh/koanf/providers/file" "github.com/knadh/koanf/providers/file"
"go.elara.ws/logger" "go.arsenm.dev/logger"
"go.elara.ws/logger/log" "go.arsenm.dev/logger/log"
) )
var cfgDir string var cfgDir string
+9 -22
View File
@@ -1,32 +1,24 @@
package main package main
import ( import (
"context" "go.arsenm.dev/itd/internal/fusefs"
"os" "os"
"github.com/hanwen/go-fuse/v2/fs" "github.com/hanwen/go-fuse/v2/fs"
"github.com/hanwen/go-fuse/v2/fuse" "github.com/hanwen/go-fuse/v2/fuse"
"go.elara.ws/infinitime" "go.arsenm.dev/logger/log"
"go.elara.ws/itd/internal/fusefs" "context"
"go.elara.ws/logger/log" "go.arsenm.dev/infinitime"
) )
func startFUSE(ctx context.Context, wg WaitGroup, dev *infinitime.Device) error { func startFUSE(ctx context.Context, dev *infinitime.Device) error {
// This is where we'll mount the FS // This is where we'll mount the FS
err := os.MkdirAll(k.String("fuse.mountpoint"), 0o755) os.Mkdir(k.String("fuse.mountpoint"), 0755)
if err != nil && !os.IsExist(err) {
return err
}
// Ignore the error because nothing might be mounted on the mountpoint
_ = fusefs.Unmount(k.String("fuse.mountpoint"))
root, err := fusefs.BuildRootNode(dev) root, err := fusefs.BuildRootNode(dev)
if err != nil { if err != nil {
log.Error("Building root node failed"). log.Error("Building root node failed").
Err(err). Err(err).
Send() Send()
return err return err
return err
} }
server, err := fs.Mount(k.String("fuse.mountpoint"), root, &fs.Options{ server, err := fs.Mount(k.String("fuse.mountpoint"), root, &fs.Options{
@@ -55,12 +47,7 @@ func startFUSE(ctx context.Context, wg WaitGroup, dev *infinitime.Device) error
return err return err
} }
wg.Add(1) // Wait until unmount before exiting
go func() { go server.Serve()
defer wg.Done("fuse")
<-ctx.Done()
server.Unmount()
}()
return nil return nil
} }
+6 -6
View File
@@ -1,4 +1,4 @@
module go.elara.ws/itd module go.arsenm.dev/itd
go 1.18 go 1.18
@@ -10,14 +10,13 @@ require (
github.com/cheggaaa/pb/v3 v3.1.0 github.com/cheggaaa/pb/v3 v3.1.0
github.com/gen2brain/dlgs v0.0.0-20220603100644-40c77870fa8d github.com/gen2brain/dlgs v0.0.0-20220603100644-40c77870fa8d
github.com/godbus/dbus/v5 v5.1.0 github.com/godbus/dbus/v5 v5.1.0
github.com/hanwen/go-fuse/v2 v2.2.0
github.com/knadh/koanf v1.4.4 github.com/knadh/koanf v1.4.4
github.com/mattn/go-isatty v0.0.17 github.com/mattn/go-isatty v0.0.17
github.com/mozillazg/go-pinyin v0.19.0 github.com/mozillazg/go-pinyin v0.19.0
github.com/urfave/cli/v2 v2.23.7 github.com/urfave/cli/v2 v2.23.7
go.elara.ws/drpc v0.0.0-20230421021209-fe4c05460a3d go.arsenm.dev/drpc v0.0.0-20230104221210-aa7525743d98
go.elara.ws/infinitime v0.0.0-20230421025334-f2640203e9e9 go.arsenm.dev/infinitime v0.0.0-20230104230015-512d48bc2469
go.elara.ws/logger v0.0.0-20230421022458-e80700db2090 go.arsenm.dev/logger v0.0.0-20230104225304-d706171ea6df
golang.org/x/text v0.5.0 golang.org/x/text v0.5.0
google.golang.org/protobuf v1.28.1 google.golang.org/protobuf v1.28.1
modernc.org/sqlite v1.20.1 modernc.org/sqlite v1.20.1
@@ -46,6 +45,7 @@ require (
github.com/google/uuid v1.3.0 // indirect github.com/google/uuid v1.3.0 // indirect
github.com/gookit/color v1.5.1 // indirect github.com/gookit/color v1.5.1 // indirect
github.com/gopherjs/gopherjs v1.17.2 // indirect github.com/gopherjs/gopherjs v1.17.2 // indirect
github.com/hanwen/go-fuse/v2 v2.2.0 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect github.com/hashicorp/yamux v0.1.1 // indirect
github.com/jsummers/gobmp v0.0.0-20151104160322-e2ba15ffa76e // indirect github.com/jsummers/gobmp v0.0.0-20151104160322-e2ba15ffa76e // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
@@ -74,7 +74,7 @@ require (
golang.org/x/mobile v0.0.0-20221110043201-43a038452099 // indirect golang.org/x/mobile v0.0.0-20221110043201-43a038452099 // indirect
golang.org/x/mod v0.7.0 // indirect golang.org/x/mod v0.7.0 // indirect
golang.org/x/net v0.4.0 // indirect golang.org/x/net v0.4.0 // indirect
golang.org/x/sys v0.6.0 // indirect golang.org/x/sys v0.3.0 // indirect
golang.org/x/tools v0.4.0 // indirect golang.org/x/tools v0.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect
honnef.co/go/js/dom v0.0.0-20221001195520-26252dedbe70 // indirect honnef.co/go/js/dom v0.0.0-20221001195520-26252dedbe70 // indirect
+7 -10
View File
@@ -341,8 +341,6 @@ github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfn
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 h1:MtvEpTB6LX3vkb4ax0b5D2DHbNAUsen0Gx5wZoq3lV4=
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
github.com/lucor/goinfo v0.0.0-20210802170112-c078a2b0f08b/go.mod h1:PRq09yoB+Q2OJReAmwzKivcYyremnibWGbK7WfftHzc= github.com/lucor/goinfo v0.0.0-20210802170112-c078a2b0f08b/go.mod h1:PRq09yoB+Q2OJReAmwzKivcYyremnibWGbK7WfftHzc=
github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
@@ -529,13 +527,12 @@ github.com/yuin/goldmark v1.5.3/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5ta
github.com/zeebo/assert v1.3.0 h1:g7C04CbJuIDKNPFHmsk4hwZDO5O+kntRxzaUoNXj+IQ= github.com/zeebo/assert v1.3.0 h1:g7C04CbJuIDKNPFHmsk4hwZDO5O+kntRxzaUoNXj+IQ=
github.com/zeebo/errs v1.3.0 h1:hmiaKqgYZzcVgRL1Vkc1Mn2914BbzB0IBxs+ebeutGs= github.com/zeebo/errs v1.3.0 h1:hmiaKqgYZzcVgRL1Vkc1Mn2914BbzB0IBxs+ebeutGs=
github.com/zeebo/errs v1.3.0/go.mod h1:sgbWHsvVuTPHcqJJGQ1WhI5KbWlHYz+2+2C/LSEtCw4= github.com/zeebo/errs v1.3.0/go.mod h1:sgbWHsvVuTPHcqJJGQ1WhI5KbWlHYz+2+2C/LSEtCw4=
go.arsenm.dev/drpc v0.0.0-20230104221210-aa7525743d98 h1:Tt/05IEOeIEfovj8YLxDaZz+SP8eR1uPLtcgD5Pf4EI=
go.arsenm.dev/drpc v0.0.0-20230104221210-aa7525743d98/go.mod h1:K5cFls42m5q1RIphTVojRdXLaoCknq/kBqQt8Ow3XuA=
go.arsenm.dev/infinitime v0.0.0-20230104230015-512d48bc2469 h1:LsJHg+8rQSYnTE1sSCjBCACxUUVMZIOQani8J6wF2/E=
go.arsenm.dev/infinitime v0.0.0-20230104230015-512d48bc2469/go.mod h1:scUyDmLmCHn6CanGbau8yjTjzyhUbLJcsjmDCCKMIII=
go.arsenm.dev/logger v0.0.0-20230104225304-d706171ea6df h1:8mBHvEe7BJmpOeKSMA5YLqrGo9dCpePocTeR0C1+/2w=
go.arsenm.dev/logger v0.0.0-20230104225304-d706171ea6df/go.mod h1:RV2qydKDdoyaRkhAq8JEGvojR8eJ6bjq5WnSIlH7gYw= go.arsenm.dev/logger v0.0.0-20230104225304-d706171ea6df/go.mod h1:RV2qydKDdoyaRkhAq8JEGvojR8eJ6bjq5WnSIlH7gYw=
go.elara.ws/drpc v0.0.0-20230421021209-fe4c05460a3d h1:ANb8YPtcxPipwKgmnW688e5PGpNaLh+22nO2LBpIPOU=
go.elara.ws/drpc v0.0.0-20230421021209-fe4c05460a3d/go.mod h1:NDprjiVqKXQKVGzX7jp2g/jctsUbvOxz1nN15QOBEGk=
go.elara.ws/infinitime v0.0.0-20230421025334-f2640203e9e9 h1:HczkQCAHHmOHHdzTxFC1tEGzBJ7F/fuOWNUGrYQhMOg=
go.elara.ws/infinitime v0.0.0-20230421025334-f2640203e9e9/go.mod h1:fu3+jGNBBtRQ1lcywtdZzoQgDFtqvvxBHvLw+XgPrFg=
go.elara.ws/logger v0.0.0-20230421022458-e80700db2090 h1:RVC8XvWo6Yw4HUshqx4TSzuBDScDghafU6QFRJ4xPZg=
go.elara.ws/logger v0.0.0-20230421022458-e80700db2090/go.mod h1:qng49owViqsW5Aey93lwBXONw20oGbJIoLVscB16mPM=
go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs=
go.etcd.io/etcd/api/v3 v3.5.4/go.mod h1:5GB2vv4A4AOn3yk7MftYGHkUfGtDHnEraIjym4dYz5A= go.etcd.io/etcd/api/v3 v3.5.4/go.mod h1:5GB2vv4A4AOn3yk7MftYGHkUfGtDHnEraIjym4dYz5A=
go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g=
@@ -757,8 +754,8 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+61
View File
@@ -0,0 +1,61 @@
package fusefs
import (
"go.arsenm.dev/infinitime"
"context"
"strconv"
)
func converterU8(ctx context.Context, in <-chan uint8) <-chan []byte {
out := make(chan []byte, 2)
go func() {
for {
select {
case <- ctx.Done():
return
case event := <-in:
out <- []byte(strconv.Itoa(int(event)) + "\n")
}
}
}()
return out
}
func converterU32(ctx context.Context, in <-chan uint32) <-chan []byte {
out := make(chan []byte, 2)
go func() {
for {
select {
case <- ctx.Done():
return
case event := <-in:
out <- []byte(strconv.Itoa(int(event)) + "\n")
}
}
}()
return out
}
func converterMotionValues(ctx context.Context, in <-chan infinitime.MotionValues) <-chan []byte {
out := make(chan []byte, 2)
go func() {
for {
select {
case <- ctx.Done():
return
case event := <-in:
out <- []byte(strconv.Itoa(int(event.X)) + " " + strconv.Itoa(int(event.Y)) + " " + strconv.Itoa(int(event.Z)) + "\n")
}
}
}()
return out
}
func converter1String(ctx context.Context, in string) <-chan []byte {
out := make(chan []byte, 2)
out <- []byte(in + "\n")
close(out)
return out
}
+83 -126
View File
@@ -1,25 +1,24 @@
package fusefs package fusefs
import ( import (
"bytes" "go.arsenm.dev/infinitime"
"go.arsenm.dev/infinitime/blefs"
"go.arsenm.dev/logger/log"
"context" "context"
"io"
"strconv"
"syscall" "syscall"
"github.com/hanwen/go-fuse/v2/fs" "github.com/hanwen/go-fuse/v2/fs"
"github.com/hanwen/go-fuse/v2/fuse" "github.com/hanwen/go-fuse/v2/fuse"
"go.elara.ws/infinitime" "io"
"go.elara.ws/infinitime/blefs" "bytes"
"go.elara.ws/logger/log"
) )
type ITProperty struct { type ITProperty struct {
name string name string
Ino uint64 Ino uint64
gen func() ([]byte, error) gen func(context.Context) (<-chan []byte, error)
} }
type DirEntry struct { type DirEntry struct {
isDir bool isDir bool
modtime uint64 modtime uint64
@@ -29,7 +28,7 @@ type DirEntry struct {
type ITNode struct { type ITNode struct {
fs.Inode fs.Inode
kind nodeKind kind int
Ino uint64 Ino uint64
lst []DirEntry lst []DirEntry
@@ -37,19 +36,8 @@ type ITNode struct {
path string path string
} }
type nodeKind uint8 var myfs *blefs.FS = nil
var inodemap map[string]uint64 = nil
const (
nodeKindRoot = iota
nodeKindInfo
nodeKindFS
nodeKindReadOnly
)
var (
myfs *blefs.FS = nil
inodemap map[string]uint64 = nil
)
func BuildRootNode(dev *infinitime.Device) (*ITNode, error) { func BuildRootNode(dev *infinitime.Device) (*ITNode, error) {
var err error var err error
@@ -60,56 +48,46 @@ func BuildRootNode(dev *infinitime.Device) (*ITNode, error) {
return nil, err return nil, err
} }
return &ITNode{kind: nodeKindRoot}, nil return &ITNode{kind: 0}, nil
} }
var properties = make([]ITProperty, 6) var properties = make([]ITProperty, 6)
func BuildProperties(dev *infinitime.Device) { func BuildProperties(dev *infinitime.Device) {
properties[0] = ITProperty{ properties[0] = ITProperty{"heartrate", 2,
"heartrate", 2, func(ctx context.Context) (<-chan []byte, error) {
func() ([]byte, error) { ans, err := dev.WatchHeartRate(ctx)
ans, err := dev.HeartRate() return converterU8(ctx, ans), err
return []byte(strconv.Itoa(int(ans)) + "\n"), err }}
}, properties[1] = ITProperty{"battery", 3,
} func(ctx context.Context) (<-chan []byte, error) {
properties[1] = ITProperty{ ans, err := dev.WatchBatteryLevel(ctx)
"battery", 3, return converterU8(ctx, ans), err
func() ([]byte, error) { }}
ans, err := dev.BatteryLevel() properties[2] = ITProperty{"motion", 4,
return []byte(strconv.Itoa(int(ans)) + "\n"), err func(ctx context.Context) (<-chan []byte, error) {
}, ans, err := dev.WatchMotion(ctx)
} return converterMotionValues(ctx, ans), err
properties[2] = ITProperty{ }}
"motion", 4, properties[3] = ITProperty{"stepcount", 5,
func() ([]byte, error) { func(ctx context.Context) (<-chan []byte, error) {
ans, err := dev.Motion() ans, err := dev.WatchStepCount(ctx)
return []byte(strconv.Itoa(int(ans.X)) + " " + strconv.Itoa(int(ans.Y)) + " " + strconv.Itoa(int(ans.Z)) + "\n"), err return converterU32(ctx, ans), err
}, }}
} properties[4] = ITProperty{"version", 6,
properties[3] = ITProperty{ func(ctx context.Context) (<-chan []byte, error) {
"stepcount", 6,
func() ([]byte, error) {
ans, err := dev.StepCount()
return []byte(strconv.Itoa(int(ans)) + "\n"), err
},
}
properties[4] = ITProperty{
"version", 7,
func() ([]byte, error) {
ans, err := dev.Version() ans, err := dev.Version()
return []byte(ans + "\n"), err return converter1String(ctx, ans), err
}, }}
} properties[5] = ITProperty{"address", 7,
properties[5] = ITProperty{ func(ctx context.Context) (<-chan []byte, error) {
"address", 8,
func() ([]byte, error) {
ans := dev.Address() ans := dev.Address()
return []byte(ans + "\n"), nil return converter1String(ctx, ans), nil
}, }}
}
} }
var _ fs.NodeReaddirer = (*ITNode)(nil) var _ fs.NodeReaddirer = (*ITNode)(nil)
// Readdir is part of the NodeReaddirer interface // Readdir is part of the NodeReaddirer interface
@@ -119,7 +97,7 @@ func (n *ITNode) Readdir(ctx context.Context) (fs.DirStream, syscall.Errno) {
// root folder // root folder
r := make([]fuse.DirEntry, 2) r := make([]fuse.DirEntry, 2)
r[0] = fuse.DirEntry{ r[0] = fuse.DirEntry{
Name: "info", Name: "device",
Ino: 0, Ino: 0,
Mode: fuse.S_IFDIR, Mode: fuse.S_IFDIR,
} }
@@ -131,7 +109,7 @@ func (n *ITNode) Readdir(ctx context.Context) (fs.DirStream, syscall.Errno) {
return fs.NewListDirStream(r), 0 return fs.NewListDirStream(r), 0
case 1: case 1:
// info folder // device folder
r := make([]fuse.DirEntry, 6) r := make([]fuse.DirEntry, 6)
for ind, value := range properties { for ind, value := range properties {
r[ind] = fuse.DirEntry{ r[ind] = fuse.DirEntry{
@@ -144,7 +122,7 @@ func (n *ITNode) Readdir(ctx context.Context) (fs.DirStream, syscall.Errno) {
return fs.NewListDirStream(r), 0 return fs.NewListDirStream(r), 0
case 2: case 2:
// on info // on device
files, err := myfs.ReadDir(n.path) files, err := myfs.ReadDir(n.path)
if err != nil { if err != nil {
log.Error("FUSE ReadDir failed").Str("path", n.path).Err(err).Send() log.Error("FUSE ReadDir failed").Str("path", n.path).Err(err).Send()
@@ -180,13 +158,13 @@ func (n *ITNode) Readdir(ctx context.Context) (fs.DirStream, syscall.Errno) {
r[ind] = fuse.DirEntry{ r[ind] = fuse.DirEntry{
Name: name, Name: name,
Mode: fuse.S_IFDIR, Mode: fuse.S_IFDIR,
Ino: ino + 10, Ino : ino + 10,
} }
} else { } else {
r[ind] = fuse.DirEntry{ r[ind] = fuse.DirEntry{
Name: name, Name: name,
Mode: fuse.S_IFREG, Mode: fuse.S_IFREG,
Ino: ino + 10, Ino : ino + 10,
} }
} }
} }
@@ -197,17 +175,16 @@ func (n *ITNode) Readdir(ctx context.Context) (fs.DirStream, syscall.Errno) {
} }
var _ fs.NodeLookuper = (*ITNode)(nil) var _ fs.NodeLookuper = (*ITNode)(nil)
func (n *ITNode) Lookup(ctx context.Context, name string, out *fuse.EntryOut) (*fs.Inode, syscall.Errno) { func (n *ITNode) Lookup(ctx context.Context, name string, out *fuse.EntryOut) (*fs.Inode, syscall.Errno) {
switch n.kind { switch n.kind {
case 0: case 0:
// root folder // root folder
if name == "info" { if name == "device" {
stable := fs.StableAttr{ stable := fs.StableAttr{
Mode: fuse.S_IFDIR, Mode: fuse.S_IFDIR,
Ino: uint64(0), Ino: uint64(0),
} }
operations := &ITNode{kind: nodeKindInfo, Ino: 0} operations := &ITNode{kind: 1, Ino: 0}
child := n.NewInode(ctx, operations, stable) child := n.NewInode(ctx, operations, stable)
return child, 0 return child, 0
} else if name == "fs" { } else if name == "fs" {
@@ -215,19 +192,19 @@ func (n *ITNode) Lookup(ctx context.Context, name string, out *fuse.EntryOut) (*
Mode: fuse.S_IFDIR, Mode: fuse.S_IFDIR,
Ino: uint64(1), Ino: uint64(1),
} }
operations := &ITNode{kind: nodeKindFS, Ino: 1, path: ""} operations := &ITNode{kind: 2, Ino: 1, path : ""}
child := n.NewInode(ctx, operations, stable) child := n.NewInode(ctx, operations, stable)
return child, 0 return child, 0
} }
case 1: case 1:
// info folder // device folder
for _, value := range properties { for _, value := range properties {
if value.name == name { if value.name == name {
stable := fs.StableAttr{ stable := fs.StableAttr{
Mode: fuse.S_IFREG, Mode: fuse.S_IFREG,
Ino: uint64(value.Ino), Ino: uint64(value.Ino),
} }
operations := &ITNode{kind: nodeKindReadOnly, Ino: value.Ino} operations := &ITNode{kind: 3, Ino: value.Ino}
child := n.NewInode(ctx, operations, stable) child := n.NewInode(ctx, operations, stable)
return child, 0 return child, 0
} }
@@ -240,7 +217,7 @@ func (n *ITNode) Lookup(ctx context.Context, name string, out *fuse.EntryOut) (*
} }
for _, file := range n.lst { for _, file := range n.lst {
if file.path != n.path+"/"+name { if file.path != n.path + "/" + name {
continue continue
} }
log.Debug("FUSE Lookup successful").Str("path", file.path).Send() log.Debug("FUSE Lookup successful").Str("path", file.path).Send()
@@ -250,7 +227,7 @@ func (n *ITNode) Lookup(ctx context.Context, name string, out *fuse.EntryOut) (*
Mode: fuse.S_IFDIR, Mode: fuse.S_IFDIR,
Ino: inodemap[file.path], Ino: inodemap[file.path],
} }
operations := &ITNode{kind: nodeKindFS, path: file.path} operations := &ITNode{kind: 2, path: file.path}
child := n.NewInode(ctx, operations, stable) child := n.NewInode(ctx, operations, stable)
return child, 0 return child, 0
} else { } else {
@@ -259,14 +236,15 @@ func (n *ITNode) Lookup(ctx context.Context, name string, out *fuse.EntryOut) (*
Ino: inodemap[file.path], Ino: inodemap[file.path],
} }
operations := &ITNode{ operations := &ITNode{
kind: nodeKindFS, path: file.path, kind: 2, path: file.path,
self: file, self: file,
} }
child := n.NewInode(ctx, operations, stable) child := n.NewInode(ctx, operations, stable)
return child, 0 return child, 0
} }
break
} }
log.Warn("FUSE Lookup failed").Str("path", n.path+"/"+name).Send() log.Warn("FUSE Lookup failed").Str("path", n.path + "/" + name).Send()
} }
return nil, syscall.ENOENT return nil, syscall.ENOENT
} }
@@ -276,7 +254,6 @@ type bytesFileReadHandle struct {
} }
var _ fs.FileReader = (*bytesFileReadHandle)(nil) var _ fs.FileReader = (*bytesFileReadHandle)(nil)
func (fh *bytesFileReadHandle) Read(ctx context.Context, dest []byte, off int64) (fuse.ReadResult, syscall.Errno) { func (fh *bytesFileReadHandle) Read(ctx context.Context, dest []byte, off int64) (fuse.ReadResult, syscall.Errno) {
log.Debug("FUSE Executing Read").Int("size", len(fh.content)).Send() log.Debug("FUSE Executing Read").Int("size", len(fh.content)).Send()
end := off + int64(len(dest)) end := off + int64(len(dest))
@@ -287,35 +264,30 @@ func (fh *bytesFileReadHandle) Read(ctx context.Context, dest []byte, off int64)
} }
type sensorFileReadHandle struct { type sensorFileReadHandle struct {
content []byte ch <-chan []byte
cancel context.CancelFunc
} }
var _ fs.FileReader = (*sensorFileReadHandle)(nil) var _ fs.FileReader = (*sensorFileReadHandle)(nil)
func (fh *sensorFileReadHandle) Read(ctx context.Context, dest []byte, off int64) (fuse.ReadResult, syscall.Errno) { func (fh *sensorFileReadHandle) Read(ctx context.Context, dest []byte, off int64) (fuse.ReadResult, syscall.Errno) {
log.Debug("FUSE Executing Read").Int("size", len(fh.content)).Send() content := <-fh.ch
end := off + int64(len(dest)) return fuse.ReadResultData(content), 0
if end > int64(len(fh.content)) {
end = int64(len(fh.content))
}
return fuse.ReadResultData(fh.content[off:end]), 0
} }
var _ fs.FileFlusher = (*sensorFileReadHandle)(nil) var _ fs.FileFlusher = (*sensorFileReadHandle)(nil)
func (fh *sensorFileReadHandle) Flush(ctx context.Context) (errno syscall.Errno) { func (fh *sensorFileReadHandle) Flush(ctx context.Context) (errno syscall.Errno) {
fh.cancel()
return 0 return 0
} }
type bytesFileWriteHandle struct { type bytesFileWriteHandle struct {
content []byte content []byte
path string path string
} }
var _ fs.FileWriter = (*bytesFileWriteHandle)(nil) var _ fs.FileWriter = (*bytesFileWriteHandle)(nil)
func (fh *bytesFileWriteHandle) Write(ctx context.Context, data []byte, off int64) (written uint32, errno syscall.Errno) { func (fh *bytesFileWriteHandle) Write(ctx context.Context, data []byte, off int64) (written uint32, errno syscall.Errno) {
log.Debug("FUSE Executing Write").Str("path", fh.path).Int("prev_size", len(fh.content)).Int("next_size", len(data)).Send() log.Info("Executing Write").Str("path", fh.path).Int("prev_size", len(fh.content)).Int("next_size", len(data)).Send()
if off != int64(len(fh.content)) { if off != int64(len(fh.content)) {
log.Error("FUSE Write file size changed unexpectedly").Int("expect", int(off)).Int("received", len(fh.content)).Send() log.Error("FUSE Write file size changed unexpectedly").Int("expect", int(off)).Int("received", len(fh.content)).Send()
return 0, syscall.ENXIO return 0, syscall.ENXIO
@@ -325,8 +297,11 @@ func (fh *bytesFileWriteHandle) Write(ctx context.Context, data []byte, off int6
} }
var _ fs.FileFlusher = (*bytesFileWriteHandle)(nil) var _ fs.FileFlusher = (*bytesFileWriteHandle)(nil)
func (fh *bytesFileWriteHandle) Flush(ctx context.Context) (errno syscall.Errno) { func (fh *bytesFileWriteHandle) Flush(ctx context.Context) (errno syscall.Errno) {
if len(fh.content) == 0 {
return 0
}
log.Debug("FUSE Attempting flush").Str("path", fh.path).Send() log.Debug("FUSE Attempting flush").Str("path", fh.path).Send()
fp, err := myfs.Create(fh.path, uint32(len(fh.content))) fp, err := myfs.Create(fh.path, uint32(len(fh.content)))
if err != nil { if err != nil {
@@ -334,16 +309,6 @@ func (fh *bytesFileWriteHandle) Flush(ctx context.Context) (errno syscall.Errno)
return syscallErr(err) return syscallErr(err)
} }
if len(fh.content) == 0 {
log.Debug("FUSE Flush no data to write").Str("path", fh.path).Send()
err = fp.Close()
if err != nil {
log.Error("FUSE Flush failed during close").Str("path", fh.path).Err(err).Send()
return syscallErr(err)
}
return 0
}
go func() { go func() {
// For every progress event // For every progress event
for sent := range fp.Progress() { for sent := range fp.Progress() {
@@ -372,15 +337,12 @@ func (fh *bytesFileWriteHandle) Flush(ctx context.Context) (errno syscall.Errno)
return 0 return 0
} }
var _ fs.FileFsyncer = (*bytesFileWriteHandle)(nil) var _ fs.FileFsyncer = (*bytesFileWriteHandle)(nil)
func (fh *bytesFileWriteHandle) Fsync(ctx context.Context, flags uint32) (errno syscall.Errno) { func (fh *bytesFileWriteHandle) Fsync(ctx context.Context, flags uint32) (errno syscall.Errno) {
return fh.Flush(ctx) return fh.Flush(ctx)
} }
var _ fs.NodeGetattrer = (*ITNode)(nil) var _ fs.NodeGetattrer = (*ITNode)(nil)
func (bn *ITNode) Getattr(ctx context.Context, f fs.FileHandle, out *fuse.AttrOut) syscall.Errno { func (bn *ITNode) Getattr(ctx context.Context, f fs.FileHandle, out *fuse.AttrOut) syscall.Errno {
log.Debug("FUSE getattr").Str("path", bn.path).Send() log.Debug("FUSE getattr").Str("path", bn.path).Send()
out.Ino = bn.Ino out.Ino = bn.Ino
@@ -392,7 +354,6 @@ func (bn *ITNode) Getattr(ctx context.Context, f fs.FileHandle, out *fuse.AttrOu
} }
var _ fs.NodeSetattrer = (*ITNode)(nil) var _ fs.NodeSetattrer = (*ITNode)(nil)
func (bn *ITNode) Setattr(ctx context.Context, fh fs.FileHandle, in *fuse.SetAttrIn, out *fuse.AttrOut) syscall.Errno { func (bn *ITNode) Setattr(ctx context.Context, fh fs.FileHandle, in *fuse.SetAttrIn, out *fuse.AttrOut) syscall.Errno {
log.Debug("FUSE setattr").Str("path", bn.path).Send() log.Debug("FUSE setattr").Str("path", bn.path).Send()
out.Size = 0 out.Size = 0
@@ -401,7 +362,6 @@ func (bn *ITNode) Setattr(ctx context.Context, fh fs.FileHandle, in *fuse.SetAtt
} }
var _ fs.NodeOpener = (*ITNode)(nil) var _ fs.NodeOpener = (*ITNode)(nil)
func (f *ITNode) Open(ctx context.Context, openFlags uint32) (fh fs.FileHandle, fuseFlags uint32, errno syscall.Errno) { func (f *ITNode) Open(ctx context.Context, openFlags uint32) (fh fs.FileHandle, fuseFlags uint32, errno syscall.Errno) {
switch f.kind { switch f.kind {
case 2: case 2:
@@ -411,11 +371,11 @@ func (f *ITNode) Open(ctx context.Context, openFlags uint32) (fh fs.FileHandle,
return nil, 0, syscall.EROFS return nil, 0, syscall.EROFS
} }
if openFlags&syscall.O_WRONLY != 0 { if openFlags & syscall.O_WRONLY != 0 {
log.Debug("FUSE Opening for write").Str("path", f.path).Send() log.Debug("FUSE Opening for write").Str("path", f.path).Send()
fh = &bytesFileWriteHandle{ fh = &bytesFileWriteHandle{
path: f.path, path : f.path,
content: make([]byte, 0), content : make([]byte, 0),
} }
return fh, fuse.FOPEN_DIRECT_IO, 0 return fh, fuse.FOPEN_DIRECT_IO, 0
} else { } else {
@@ -460,13 +420,15 @@ func (f *ITNode) Open(ctx context.Context, openFlags uint32) (fh fs.FileHandle,
for _, value := range properties { for _, value := range properties {
if value.Ino == f.Ino { if value.Ino == f.Ino {
ans, err := value.gen() sub_ctx, cancel := context.WithCancel(ctx)
ans, err := value.gen(sub_ctx)
if err != nil { if err != nil {
return nil, 0, syscallErr(err) return nil, 0, syscallErr(err)
} }
fh = &sensorFileReadHandle{ fh = &sensorFileReadHandle{
content: ans, ch: ans,
cancel : cancel,
} }
return fh, fuse.FOPEN_DIRECT_IO, 0 return fh, fuse.FOPEN_DIRECT_IO, 0
} }
@@ -476,7 +438,6 @@ func (f *ITNode) Open(ctx context.Context, openFlags uint32) (fh fs.FileHandle,
} }
var _ fs.NodeCreater = (*ITNode)(nil) var _ fs.NodeCreater = (*ITNode)(nil)
func (f *ITNode) Create(ctx context.Context, name string, flags uint32, mode uint32, out *fuse.EntryOut) (node *fs.Inode, fh fs.FileHandle, fuseFlags uint32, errno syscall.Errno) { func (f *ITNode) Create(ctx context.Context, name string, flags uint32, mode uint32, out *fuse.EntryOut) (node *fs.Inode, fh fs.FileHandle, fuseFlags uint32, errno syscall.Errno) {
if f.kind != 2 { if f.kind != 2 {
return nil, nil, 0, syscall.EROFS return nil, nil, 0, syscall.EROFS
@@ -491,14 +452,14 @@ func (f *ITNode) Create(ctx context.Context, name string, flags uint32, mode uin
Ino: ino, Ino: ino,
} }
operations := &ITNode{ operations := &ITNode{
kind: nodeKindFS, Ino: ino, kind: 2, Ino: ino,
path: path, path : path,
} }
node = f.NewInode(ctx, operations, stable) node = f.NewInode(ctx, operations, stable)
fh = &bytesFileWriteHandle{ fh = &bytesFileWriteHandle{
path: path, path : path,
content: make([]byte, 0), content : make([]byte, 0),
} }
log.Debug("FUSE Creating file").Str("path", path).Send() log.Debug("FUSE Creating file").Str("path", path).Send()
@@ -508,7 +469,6 @@ func (f *ITNode) Create(ctx context.Context, name string, flags uint32, mode uin
} }
var _ fs.NodeMkdirer = (*ITNode)(nil) var _ fs.NodeMkdirer = (*ITNode)(nil)
func (f *ITNode) Mkdir(ctx context.Context, name string, mode uint32, out *fuse.EntryOut) (*fs.Inode, syscall.Errno) { func (f *ITNode) Mkdir(ctx context.Context, name string, mode uint32, out *fuse.EntryOut) (*fs.Inode, syscall.Errno) {
if f.kind != 2 { if f.kind != 2 {
return nil, syscall.EROFS return nil, syscall.EROFS
@@ -532,8 +492,8 @@ func (f *ITNode) Mkdir(ctx context.Context, name string, mode uint32, out *fuse.
Ino: ino, Ino: ino,
} }
operations := &ITNode{ operations := &ITNode{
kind: nodeKindFS, Ino: ino, kind: 2, Ino: ino,
path: path, path : path,
} }
node := f.NewInode(ctx, operations, stable) node := f.NewInode(ctx, operations, stable)
@@ -545,7 +505,6 @@ func (f *ITNode) Mkdir(ctx context.Context, name string, mode uint32, out *fuse.
} }
var _ fs.NodeRenamer = (*ITNode)(nil) var _ fs.NodeRenamer = (*ITNode)(nil)
func (f *ITNode) Rename(ctx context.Context, name string, newParent fs.InodeEmbedder, newName string, flags uint32) syscall.Errno { func (f *ITNode) Rename(ctx context.Context, name string, newParent fs.InodeEmbedder, newName string, flags uint32) syscall.Errno {
if f.kind != 2 { if f.kind != 2 {
return syscall.EROFS return syscall.EROFS
@@ -577,17 +536,16 @@ func (f *ITNode) Rename(ctx context.Context, name string, newParent fs.InodeEmbe
} }
var _ fs.NodeUnlinker = (*ITNode)(nil) var _ fs.NodeUnlinker = (*ITNode)(nil)
func (f *ITNode) Unlink(ctx context.Context, name string) syscall.Errno { func (f *ITNode) Unlink(ctx context.Context, name string) syscall.Errno {
if f.kind != 2 { if f.kind != 2 {
return syscall.EROFS return syscall.EROFS
} }
delete(inodemap, f.path+"/"+name) delete(inodemap, f.path + "/" + name)
err := myfs.Remove(f.path + "/" + name) err := myfs.Remove(f.path + "/" + name)
if err != nil { if err != nil {
log.Error("FUSE Unlink failed"). log.Error("FUSE Unlink failed").
Str("file", f.path+"/"+name). Str("file", f.path + "/" + name).
Err(err). Err(err).
Send() Send()
@@ -595,13 +553,12 @@ func (f *ITNode) Unlink(ctx context.Context, name string) syscall.Errno {
} }
log.Debug("FUSE Unlink success"). log.Debug("FUSE Unlink success").
Str("file", f.path+"/"+name). Str("file", f.path + "/" + name).
Send() Send()
return 0 return 0
} }
var _ fs.NodeRmdirer = (*ITNode)(nil) var _ fs.NodeRmdirer = (*ITNode)(nil)
func (f *ITNode) Rmdir(ctx context.Context, name string) syscall.Errno { func (f *ITNode) Rmdir(ctx context.Context, name string) syscall.Errno {
return f.Unlink(ctx, name) return f.Unlink(ctx, name)
} }
+38 -45
View File
@@ -1,9 +1,7 @@
package fusefs package fusefs
import ( import (
"go.arsenm.dev/infinitime/blefs"
"syscall" "syscall"
"go.elara.ws/infinitime/blefs"
) )
func syscallErr(err error) syscall.Errno { func syscallErr(err error) syscall.Errno {
@@ -11,46 +9,41 @@ func syscallErr(err error) syscall.Errno {
return 0 return 0
} }
switch err := err.(type) {
case blefs.FSError:
switch err.Code {
case 0x02: // filesystem error
return syscall.EIO // TODO
case 0x05: // read-only filesystem
return syscall.EROFS
case 0x03: // no such file
return syscall.ENOENT
case 0x04: // protocol error
return syscall.EPROTO
case -5: // input/output error
return syscall.EIO
case -84: // filesystem is corrupted
return syscall.ENOTRECOVERABLE // TODO
case -2: // no such directory entry
return syscall.ENOENT
case -17: // entry already exists
return syscall.EEXIST
case -20: // entry is not a directory
return syscall.ENOTDIR
case -39: // directory is not empty
return syscall.ENOTEMPTY
case -9: // bad file number
return syscall.EBADF
case -27: // file is too large
return syscall.EFBIG
case -22: // invalid parameter
return syscall.EINVAL
case -28: // no space left on device
return syscall.ENOSPC
case -12: // no more memory available
return syscall.ENOMEM
case -61: // no attr available
return syscall.ENODATA // TODO
case -36: // file name is too long
return syscall.ENAMETOOLONG
}
default:
switch err { switch err {
case blefs.FSError{0x02}: // filesystem error
return syscall.EIO // TODO
case blefs.FSError{0x05}: // read-only filesystem
return syscall.EROFS
case blefs.FSError{0x03}: // no such file
return syscall.ENOENT
case blefs.FSError{0x04}: // protocol error
return syscall.EPROTO
case blefs.FSError{-5}: // input/output error
return syscall.EIO
case blefs.FSError{-84}: // filesystem is corrupted
return syscall.ENOTRECOVERABLE // TODO
case blefs.FSError{-2}: // no such directory entry
return syscall.ENOENT
case blefs.FSError{-17}: // entry already exists
return syscall.EEXIST
case blefs.FSError{-20}: // entry is not a directory
return syscall.ENOTDIR
case blefs.FSError{-39}: // directory is not empty
return syscall.ENOTEMPTY
case blefs.FSError{-9}: // bad file number
return syscall.EBADF
case blefs.FSError{-27}: // file is too large
return syscall.EFBIG
case blefs.FSError{-22}: // invalid parameter
return syscall.EINVAL
case blefs.FSError{-28}: // no space left on device
return syscall.ENOSPC
case blefs.FSError{-12}: // no more memory available
return syscall.ENOMEM
case blefs.FSError{-61}: // no attr available
return syscall.ENODATA // TODO
case blefs.FSError{-36}: // file name is too long
return syscall.ENAMETOOLONG
case blefs.ErrFileNotExists: // file does not exist case blefs.ErrFileNotExists: // file does not exist
return syscall.ENOENT return syscall.ENOENT
case blefs.ErrFileReadOnly: // file is read only case blefs.ErrFileReadOnly: // file is read only
@@ -58,7 +51,7 @@ func syscallErr(err error) syscall.Errno {
case blefs.ErrFileWriteOnly: // file is write only case blefs.ErrFileWriteOnly: // file is write only
return syscall.EACCES return syscall.EACCES
case blefs.ErrInvalidOffset: // invalid file offset case blefs.ErrInvalidOffset: // invalid file offset
return syscall.EINVAL return syscall.EFAULT // TODO
case blefs.ErrOffsetChanged: // offset has already been changed case blefs.ErrOffsetChanged: // offset has already been changed
return syscall.ESPIPE return syscall.ESPIPE
case blefs.ErrReadOpen: // only one file can be opened for reading at a time case blefs.ErrReadOpen: // only one file can be opened for reading at a time
@@ -68,7 +61,7 @@ func syscallErr(err error) syscall.Errno {
case blefs.ErrNoRemoveRoot: // refusing to remove root directory case blefs.ErrNoRemoveRoot: // refusing to remove root directory
return syscall.EPERM return syscall.EPERM
} }
}
return syscall.EIO return syscall.EIO // TODO
} }
-17
View File
@@ -1,17 +0,0 @@
package fusefs
import (
_ "unsafe"
"github.com/hanwen/go-fuse/v2/fuse"
)
func Unmount(mountPoint string) error {
return unmount(mountPoint, &fuse.MountOptions{DirectMount: false})
}
// Unfortunately, the FUSE library does not export its unmount function,
// so this is required until that changes
//
//go:linkname unmount github.com/hanwen/go-fuse/v2/fuse.unmount
func unmount(mountPoint string, opts *fuse.MountOptions) error
+29 -48
View File
@@ -26,17 +26,15 @@ import (
"os" "os"
"os/signal" "os/signal"
"strconv" "strconv"
"sync"
"syscall" "syscall"
"time" "time"
"github.com/gen2brain/dlgs" "github.com/gen2brain/dlgs"
"github.com/knadh/koanf" "github.com/knadh/koanf"
"github.com/mattn/go-isatty" "github.com/mattn/go-isatty"
"go.elara.ws/infinitime" "go.arsenm.dev/infinitime"
"go.elara.ws/logger" "go.arsenm.dev/logger"
"go.elara.ws/logger/log" "go.arsenm.dev/logger/log"
) )
var k = koanf.New(".") var k = koanf.New(".")
@@ -76,7 +74,21 @@ func main() {
LogLevel: level, LogLevel: level,
} }
ctx := context.Background() ctx, cancel := context.WithCancel(context.Background())
defer cancel()
sigCh := make(chan os.Signal, 1)
go func() {
<-sigCh
cancel()
time.Sleep(200 * time.Millisecond)
os.Exit(0)
}()
signal.Notify(
sigCh,
syscall.SIGINT,
syscall.SIGTERM,
)
// Connect to InfiniTime with default options // Connect to InfiniTime with default options
dev, err := infinitime.Connect(ctx, opts) dev, err := infinitime.Connect(ctx, opts)
@@ -133,88 +145,57 @@ func main() {
log.Error("Error setting current time on connected InfiniTime").Err(err).Send() log.Error("Error setting current time on connected InfiniTime").Err(err).Send()
} }
sigCh := make(chan os.Signal, 1)
signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM)
ctx, cancel := context.WithCancel(ctx)
defer cancel()
go func() {
sig := <-sigCh
log.Warn("Signal received, shutting down").Stringer("signal", sig).Send()
cancel()
}()
wg := WaitGroup{&sync.WaitGroup{}}
// Initialize music controls // Initialize music controls
err = initMusicCtrl(ctx, wg, dev) err = initMusicCtrl(ctx, dev)
if err != nil { if err != nil {
log.Error("Error initializing music control").Err(err).Send() log.Error("Error initializing music control").Err(err).Send()
} }
// Start control socket // Start control socket
err = initCallNotifs(ctx, wg, dev) err = initCallNotifs(ctx, dev)
if err != nil { if err != nil {
log.Error("Error initializing call notifications").Err(err).Send() log.Error("Error initializing call notifications").Err(err).Send()
} }
// Initialize notification relay // Initialize notification relay
err = initNotifRelay(ctx, wg, dev) err = initNotifRelay(ctx, dev)
if err != nil { if err != nil {
log.Error("Error initializing notification relay").Err(err).Send() log.Error("Error initializing notification relay").Err(err).Send()
} }
// Initializa weather // Initializa weather
err = initWeather(ctx, wg, dev) err = initWeather(ctx, dev)
if err != nil { if err != nil {
log.Error("Error initializing weather").Err(err).Send() log.Error("Error initializing weather").Err(err).Send()
} }
// Initialize metrics collection // Initialize metrics collection
err = initMetrics(ctx, wg, dev) err = initMetrics(ctx, dev)
if err != nil { if err != nil {
log.Error("Error intializing metrics collection").Err(err).Send() log.Error("Error intializing metrics collection").Err(err).Send()
} }
// Initialize puremaps integration // Initialize metrics collection
err = initPureMaps(ctx, wg, dev) err = initPureMaps(ctx, dev)
if err != nil { if err != nil {
log.Error("Error intializing puremaps integration").Err(err).Send() log.Error("Error intializing puremaps integration").Err(err).Send()
} }
// Start fuse socket // Start fuse socket
if k.Bool("fuse.enabled") { if k.Bool("fuse.enabled") {
err = startFUSE(ctx, wg, dev) err = startFUSE(ctx, dev)
if err != nil { if err != nil {
log.Error("Error starting fuse socket").Err(err).Send() log.Error("Error starting fuse socket").Err(err).Send()
} }
} }
// Start control socket // Start control socket
err = startSocket(ctx, wg, dev) err = startSocket(ctx, dev)
if err != nil { if err != nil {
log.Error("Error starting socket").Err(err).Send() log.Error("Error starting socket").Err(err).Send()
} }
// Block forever
wg.Wait() select {}
}
type x struct {
n int
*sync.WaitGroup
}
func (xy *x) Add(i int) {
xy.n += i
xy.WaitGroup.Add(i)
fmt.Println("add: counter:", xy.n)
}
func (xy *x) Done() {
xy.n -= 1
xy.WaitGroup.Done()
fmt.Println("done: counter:", xy.n)
} }
func onReqPasskey() (uint32, error) { func onReqPasskey() (uint32, error) {
+4 -7
View File
@@ -5,9 +5,9 @@ import (
"strings" "strings"
"github.com/godbus/dbus/v5" "github.com/godbus/dbus/v5"
"go.elara.ws/infinitime" "go.arsenm.dev/infinitime"
"go.elara.ws/itd/internal/utils" "go.arsenm.dev/itd/internal/utils"
"go.elara.ws/logger/log" "go.arsenm.dev/logger/log"
) )
const ( const (
@@ -18,7 +18,7 @@ const (
progressProperty = interfaceName + ".progress" progressProperty = interfaceName + ".progress"
) )
func initPureMaps(ctx context.Context, wg WaitGroup, dev *infinitime.Device) error { func initPureMaps(ctx context.Context, dev *infinitime.Device) error {
// Connect to session bus. This connection is for method calls. // Connect to session bus. This connection is for method calls.
conn, err := utils.NewSessionBusConn(ctx) conn, err := utils.NewSessionBusConn(ctx)
if err != nil { if err != nil {
@@ -59,10 +59,7 @@ func initPureMaps(ctx context.Context, wg WaitGroup, dev *infinitime.Device) err
} }
} }
wg.Add(1)
go func() { go func() {
defer wg.Done("pureMaps")
signalCh := make(chan *dbus.Message, 10) signalCh := make(chan *dbus.Message, 10)
monitorConn.Eavesdrop(signalCh) monitorConn.Eavesdrop(signalCh)
+3 -11
View File
@@ -4,15 +4,14 @@ import (
"context" "context"
"database/sql" "database/sql"
"path/filepath" "path/filepath"
"time" "time"
"go.elara.ws/infinitime" "go.arsenm.dev/infinitime"
"go.elara.ws/logger/log" "go.arsenm.dev/logger/log"
_ "modernc.org/sqlite" _ "modernc.org/sqlite"
) )
func initMetrics(ctx context.Context, wg WaitGroup, dev *infinitime.Device) error { func initMetrics(ctx context.Context, dev *infinitime.Device) error {
// If metrics disabled, return nil // If metrics disabled, return nil
if !k.Bool("metrics.enabled") { if !k.Bool("metrics.enabled") {
return nil return nil
@@ -126,13 +125,6 @@ func initMetrics(ctx context.Context, wg WaitGroup, dev *infinitime.Device) erro
}() }()
} }
wg.Add(1)
go func() {
defer wg.Done("metrics")
<-ctx.Done()
db.Close()
}()
log.Info("Initialized metrics collection").Send() log.Info("Initialized metrics collection").Send()
return nil return nil
+1 -1
View File
@@ -6,7 +6,7 @@ import (
"sync" "sync"
"github.com/godbus/dbus/v5" "github.com/godbus/dbus/v5"
"go.elara.ws/itd/internal/utils" "go.arsenm.dev/itd/internal/utils"
) )
var ( var (
+6 -15
View File
@@ -21,14 +21,13 @@ package main
import ( import (
"context" "context"
"go.arsenm.dev/infinitime"
"go.elara.ws/infinitime" "go.arsenm.dev/itd/mpris"
"go.elara.ws/itd/mpris" "go.arsenm.dev/itd/translit"
"go.elara.ws/itd/translit" "go.arsenm.dev/logger/log"
"go.elara.ws/logger/log"
) )
func initMusicCtrl(ctx context.Context, wg WaitGroup, dev *infinitime.Device) error { func initMusicCtrl(ctx context.Context, dev *infinitime.Device) error {
mpris.Init(ctx) mpris.Init(ctx)
maps := k.Strings("notifs.translit.use") maps := k.Strings("notifs.translit.use")
@@ -55,14 +54,9 @@ func initMusicCtrl(ctx context.Context, wg WaitGroup, dev *infinitime.Device) er
if err != nil { if err != nil {
return err return err
} }
wg.Add(1)
go func() { go func() {
defer wg.Done("musicCtrl")
// For every music event received // For every music event received
for { for musicEvt := range musicEvtCh {
select {
case musicEvt := <-musicEvtCh:
// Perform appropriate action based on event // Perform appropriate action based on event
switch musicEvt { switch musicEvt {
case infinitime.MusicEventPlay: case infinitime.MusicEventPlay:
@@ -78,9 +72,6 @@ func initMusicCtrl(ctx context.Context, wg WaitGroup, dev *infinitime.Device) er
case infinitime.MusicEventVolDown: case infinitime.MusicEventVolDown:
mpris.VolDown(uint(k.Int("music.vol.interval"))) mpris.VolDown(uint(k.Int("music.vol.interval")))
} }
case <-ctx.Done():
return
}
} }
}() }()
+6 -14
View File
@@ -23,13 +23,13 @@ import (
"fmt" "fmt"
"github.com/godbus/dbus/v5" "github.com/godbus/dbus/v5"
"go.elara.ws/infinitime" "go.arsenm.dev/infinitime"
"go.elara.ws/itd/internal/utils" "go.arsenm.dev/itd/internal/utils"
"go.elara.ws/itd/translit" "go.arsenm.dev/itd/translit"
"go.elara.ws/logger/log" "go.arsenm.dev/logger/log"
) )
func initNotifRelay(ctx context.Context, wg WaitGroup, dev *infinitime.Device) error { func initNotifRelay(ctx context.Context, dev *infinitime.Device) error {
// Connect to dbus session bus // Connect to dbus session bus
bus, err := utils.NewSessionBusConn(ctx) bus, err := utils.NewSessionBusConn(ctx)
if err != nil { if err != nil {
@@ -54,13 +54,9 @@ func initNotifRelay(ctx context.Context, wg WaitGroup, dev *infinitime.Device) e
// Send events to channel // Send events to channel
bus.Eavesdrop(notifCh) bus.Eavesdrop(notifCh)
wg.Add(1)
go func() { go func() {
defer wg.Done("notifRelay")
// For every event sent to channel // For every event sent to channel
for { for v := range notifCh {
select {
case v := <-notifCh:
// If firmware is updating, skip // If firmware is updating, skip
if firmwareUpdating { if firmwareUpdating {
continue continue
@@ -95,10 +91,6 @@ func initNotifRelay(ctx context.Context, wg WaitGroup, dev *infinitime.Device) e
} }
dev.Notify(sender, msg) dev.Notify(sender, msg)
case <-ctx.Done():
bus.Close()
return
}
} }
}() }()
+9 -13
View File
@@ -25,14 +25,13 @@ import (
"net" "net"
"os" "os"
"path/filepath" "path/filepath"
"time" "time"
"go.elara.ws/drpc/muxserver" "go.arsenm.dev/drpc/muxserver"
"go.elara.ws/infinitime" "go.arsenm.dev/infinitime"
"go.elara.ws/infinitime/blefs" "go.arsenm.dev/infinitime/blefs"
"go.elara.ws/itd/internal/rpc" "go.arsenm.dev/itd/internal/rpc"
"go.elara.ws/logger/log" "go.arsenm.dev/logger/log"
"storj.io/drpc/drpcmux" "storj.io/drpc/drpcmux"
) )
@@ -42,7 +41,7 @@ var (
ErrDFUInvalidUpgType = errors.New("invalid upgrade type") ErrDFUInvalidUpgType = errors.New("invalid upgrade type")
) )
func startSocket(ctx context.Context, wg WaitGroup, dev *infinitime.Device) error { func startSocket(ctx context.Context, dev *infinitime.Device) error {
// Make socket directory if non-existant // Make socket directory if non-existant
err := os.MkdirAll(filepath.Dir(k.String("socket.path")), 0o755) err := os.MkdirAll(filepath.Dir(k.String("socket.path")), 0o755)
if err != nil { if err != nil {
@@ -78,13 +77,10 @@ func startSocket(ctx context.Context, wg WaitGroup, dev *infinitime.Device) erro
return err return err
} }
log.Info("Starting control socket").Str("path", k.String("socket.path")).Send() go muxserver.New(mux).Serve(ctx, ln)
wg.Add(1) // Log socket start
go func() { log.Info("Started control socket").Str("path", k.String("socket.path")).Send()
defer wg.Done("socket")
muxserver.New(mux).Serve(ctx, ln)
}()
return nil return nil
} }
-16
View File
@@ -1,16 +0,0 @@
package main
import (
"sync"
"go.elara.ws/logger/log"
)
type WaitGroup struct {
*sync.WaitGroup
}
func (wg WaitGroup) Done(c string) {
log.Info("Component stopped").Str("name", c).Send()
wg.WaitGroup.Done()
}
+5 -22
View File
@@ -9,12 +9,11 @@ import (
"net/url" "net/url"
"strconv" "strconv"
"strings" "strings"
"time" "time"
"go.elara.ws/infinitime" "go.arsenm.dev/infinitime"
"go.elara.ws/infinitime/weather" "go.arsenm.dev/infinitime/weather"
"go.elara.ws/logger/log" "go.arsenm.dev/logger/log"
) )
// METResponse represents a response from // METResponse represents a response from
@@ -62,14 +61,7 @@ type OSMData []struct {
var sendWeatherCh = make(chan struct{}, 1) var sendWeatherCh = make(chan struct{}, 1)
func sleepCtx(ctx context.Context, d time.Duration) { func initWeather(ctx context.Context, dev *infinitime.Device) error {
select {
case <-time.After(d):
case <-ctx.Done():
}
}
func initWeather(ctx context.Context, wg WaitGroup, dev *infinitime.Device) error {
if !k.Bool("weather.enabled") { if !k.Bool("weather.enabled") {
return nil return nil
} }
@@ -82,21 +74,14 @@ func initWeather(ctx context.Context, wg WaitGroup, dev *infinitime.Device) erro
timer := time.NewTimer(time.Hour) timer := time.NewTimer(time.Hour)
wg.Add(1)
go func() { go func() {
defer wg.Done("weather")
for { for {
_, ok := <-ctx.Done()
if !ok {
return
}
// Attempt to get weather // Attempt to get weather
data, err := getWeather(ctx, lat, lon) data, err := getWeather(ctx, lat, lon)
if err != nil { if err != nil {
log.Warn("Error getting weather data").Err(err).Send() log.Warn("Error getting weather data").Err(err).Send()
// Wait 15 minutes before retrying // Wait 15 minutes before retrying
sleepCtx(ctx, 15*time.Minute) time.Sleep(15 * time.Minute)
continue continue
} }
@@ -189,8 +174,6 @@ func initWeather(ctx context.Context, wg WaitGroup, dev *infinitime.Device) erro
select { select {
case <-timer.C: case <-timer.C:
case <-sendWeatherCh: case <-sendWeatherCh:
case <-ctx.Done():
return
} }
} }
}() }()