Egui based UI + fix for hang when reading serial number of Nothing Ear (2024)
So, this is kinda dirty PR, because UI part of it is not very beautiful (regarding both code style and visual style). But, it solves few problems:
- It allows to build a egui-based UI which can be more familiar for many Rust devs (for me it was easier to start hacking with it)
- It fixes the timeout which occurs when reading response with serial number for Nothing Ear (2024) model and adjusts byte offset from which the number is parsed to string
Few words about serial number response for Nothing Ear (2024) model. I added stderr output which logs all bytes received when reading serial number response in case timeout occurs (the timeout is 1 second for now). On my environment there are 145 bytes instead of expected 146 and these bytes are:
[85, 96, 1, 6, 64, 135, 0, 5, 9, 50, 44, 49, 44, 10, 50, 44, 50, 44, 49, 46, 48, 46, 49, 46, 53, 52, 10, 50, 44, 52, 44, 83, 72, 49, 48, 54, 49, 50, 52, 51, 54, 48, 48, 48, 54, 53, 48, 10, 51, 44, 49, 44, 10, 51, 44, 50, 44, 49, 46, 48, 46, 49, 46, 53, 52, 10, 51, 44, 52, 44, 83, 72, 49, 48, 54, 49, 50, 52, 51, 54, 48, 48, 48, 54, 53, 48, 10, 52, 44, 49, 44, 10, 52, 44, 50, 44, 49, 46, 48, 46, 49, 46, 53, 52, 10, 52, 44, 52, 44, 83, 72, 49, 48, 54, 49, 50, 52, 51, 54, 48, 48, 48, 54, 53, 48, 10, 51, 44, 54, 44, 53, 67, 65, 52, 55, 56, 69, 66, 66, 69, 50, 67, 10, 67, 32]
If I try to parse them as UTF-8 I can notice multiple version strings and serial number strings. Probably, the protocol used in Nothing Ear (2024) is a bit different from Nothing Ear (2). Also, serial number offset differs and acceptable EAR_2024_SERIAL_OFFSET is chosen instead of EAR_2_SERIAL_OFFSET if we detect that parsed serial number contains comma character which is indication for wrong offset used.
Fixes #2
Also, need to find the optimal way to integrate support for Nothing Ear (2024) on the level of the project structure. Almost all constants are matching with Nothing Ear (2), only serial number related stuff differs (size of response packet and serial number byte offset). Please, if you have any ideas, suggest, how should we do that without massive copy-paste of whole Ear2 struct.
I am not very keen on changing UI, I wanted to learn leptos and tauri and they seem to work nice (plus look similar to app). About loading, I think we should use leptos_memo or some delayed action (I started the project when I had never worked on FE). That should load the UI without waiting for backend to load.
You just need to implement traits for your hardware https://github.com/sn99/nothing-linux?tab=readme-ov-file#hardware-abstraction. Anyway you do it works :p..\