ant: replace usb.GetDevice with direct gousb usage Remove dependency on antgo/driver/usb to fix libusb context leaks on device-not-found errors. The previous code called usb.GetDevice which creates a gousb.Context via libusb_init but leaks it on every error path (device not found, interface claim failure, etc.). Calling ListenForTrainer repeatedly (e.g. starting with no dongle and plugging it in later) triggered a libusb assertion in pthread_key_create because the leaked contexts were never torn down. Replace with direct gousb calls in ListenForTrainer, managing the gousb.Context lifecycle explicitly. Cleanup is ordered correctly on all paths: release interface, close device, close context, cancel the ANT message goroutine context. Also convert panics to returned errors for graceful retry. |
||
|---|---|---|
| .. | ||
| ant.go | ||
| bluetooth.go | ||
| cli.go | ||
| event.go | ||
| log.go | ||