initial version.
This commit is contained in:
parent
c37fde8cf6
commit
2bbca6f082
32
Makefile
Normal file
32
Makefile
Normal file
@ -0,0 +1,32 @@
|
||||
.DEFAULT_GOAL := all
|
||||
|
||||
.PHONY: fmt vet build clean tools
|
||||
|
||||
tools:
|
||||
GOPROXY=direct go install git.wamblee.org/public/gotools/cmd/go2junit@main
|
||||
go install github.com/a-h/templ/cmd/templ@v0.3.977
|
||||
|
||||
fmt:
|
||||
go fmt ./...
|
||||
|
||||
vet: fmt
|
||||
go vet ./...
|
||||
|
||||
|
||||
build: vet
|
||||
mkdir -p bin
|
||||
go build -ldflags "-X main.Version=$(shell git rev-parse HEAD ) -X main.BuildTime=$(shell date +'%Y-%m-%dT%H:%M:%S')" -o bin ./cmd/...
|
||||
|
||||
install: build
|
||||
go install ./...
|
||||
|
||||
test: build
|
||||
go test -count=1 -coverprofile=testout/coverage.out -json ${TESTFLAGS} ./... | go2junit testout
|
||||
|
||||
clean:
|
||||
rm -rf bin
|
||||
rm -f pkg/server/ui/LICENSE*
|
||||
rm -rf testout
|
||||
|
||||
all: build
|
||||
|
||||
47
cmd/bridge/main.go
Normal file
47
cmd/bridge/main.go
Normal file
@ -0,0 +1,47 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/half2me/antgo/ant"
|
||||
"github.com/half2me/antgo/device"
|
||||
"github.com/half2me/antgo/driver/usb"
|
||||
)
|
||||
|
||||
func main() {
|
||||
drv, err := usb.GetDevice(0x0fcf, 0x1008)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer drv.Close()
|
||||
|
||||
fmt.Println("device opened")
|
||||
|
||||
if err := device.ResetWait(drv); err != nil {
|
||||
panic(fmt.Sprintf("reset failed: %v", err))
|
||||
}
|
||||
fmt.Println("reset ok")
|
||||
|
||||
if err := device.StartRxScanModeWait(drv); err != nil {
|
||||
panic(fmt.Sprintf("scan mode failed: %v", err))
|
||||
}
|
||||
fmt.Println("scan mode started")
|
||||
|
||||
msgs := make(chan ant.BroadcastMessage, 100)
|
||||
go device.DumpBroadcastMessages(context.Background(), drv, msgs)
|
||||
|
||||
fmt.Println("listening...")
|
||||
for msg := range msgs {
|
||||
//fmt.Printf("raw msg: device type=0x%02x device number=%d content=%x\n",
|
||||
// msg.DeviceType(), msg.DeviceNumber(), msg.Content())
|
||||
|
||||
switch msg.DeviceType() {
|
||||
case ant.DEVICE_TYPE_POWER:
|
||||
cur := ant.PowerMessage(msg)
|
||||
fmt.Printf("power: %dW cadence: %d rpm\n", cur.InstantaneousPower(), cur.InstantaneousCadence())
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Println("channel closed")
|
||||
}
|
||||
7
go.mod
Normal file
7
go.mod
Normal file
@ -0,0 +1,7 @@
|
||||
module git.wamblee.org/antplusbridge
|
||||
|
||||
go 1.26.2
|
||||
|
||||
require github.com/half2me/antgo v0.0.0-20240825222428-e6b9ddc9c32f
|
||||
|
||||
require github.com/google/gousb v1.1.3 // indirect
|
||||
4
go.sum
Normal file
4
go.sum
Normal file
@ -0,0 +1,4 @@
|
||||
github.com/google/gousb v1.1.3 h1:xt6M5TDsGSZ+rlomz5Si5Hmd/Fvbmo2YCJHN+yGaK4o=
|
||||
github.com/google/gousb v1.1.3/go.mod h1:GGWUkK0gAXDzxhwrzetW592aOmkkqSGcj5KLEgmCVUg=
|
||||
github.com/half2me/antgo v0.0.0-20240825222428-e6b9ddc9c32f h1:T1EVnxPi3CqwmJdOs/s76vplnG8t0MEFmwo3bvHrZAo=
|
||||
github.com/half2me/antgo v0.0.0-20240825222428-e6b9ddc9c32f/go.mod h1:BXp/M+7//3V0GY2ytRJw4vcxZve8mQ0zRVuow+fANkE=
|
||||
31
setup.md
Normal file
31
setup.md
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
# dmesg
|
||||
|
||||
Make sure usbserial does not handle this device
|
||||
|
||||
```
|
||||
cat > /etc/udev/rules.d/99-ant-usb.rules <<EOF
|
||||
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fcf", ATTRS{idProduct}=="1008", ENV{MODALIAS}="ignore"
|
||||
EOF
|
||||
|
||||
```
|
||||
|
||||
Reload the rules
|
||||
```
|
||||
# remove dongle
|
||||
sudo modprobe -r usb_serial_simple
|
||||
sudo udevadm control --reload-rules
|
||||
sudo udevadm trigger
|
||||
|
||||
```
|
||||
|
||||
Output of dmesg
|
||||
```
|
||||
[20167.459968] usb 3-2.2.1: new full-speed USB device number 16 using xhci_hcd
|
||||
[20167.550486] usb 3-2.2.1: New USB device found, idVendor=0fcf, idProduct=1008, bcdDevice= 1.00
|
||||
[20167.550497] usb 3-2.2.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
|
||||
[20167.550501] usb 3-2.2.1: Product: ANT USBStick2
|
||||
[20167.550503] usb 3-2.2.1: Manufacturer: CYCPLUS
|
||||
[20167.550506] usb 3-2.2.1: SerialNumber: 123
|
||||
|
||||
```
|
||||
Loading…
Reference in New Issue
Block a user