Skip to content

Commit

Permalink
add wait and dontcare modes
Browse files Browse the repository at this point in the history
  • Loading branch information
half2me committed Apr 13, 2023
1 parent 882aa8a commit e1701e4
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions device/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func expectMessageClass(driver io.ReadWriter, t byte) (msg ant.Packet, err error
return msg, nil
}

func Reset(driver io.ReadWriter) error {
func ResetWait(driver io.ReadWriter) error {
_, err := driver.Write(ant.SystemResetMessage())
if err != nil {
return err
Expand All @@ -27,7 +27,12 @@ func Reset(driver io.ReadWriter) error {
return err
}

func StartRxScanMode(driver io.ReadWriter) error {
func Reset(driver io.ReadWriter) error {
_, err := driver.Write(ant.SystemResetMessage())
return err
}

func StartRxScanModeWait(driver io.ReadWriter) error {
messages := []ant.Packet{
ant.SetNetworkKeyMessage(0, []byte(ant.ANTPLUS_NETWORK_KEY)),
ant.AssignChannelMessage(0, ant.CHANNEL_TYPE_ONEWAY_RECEIVE),
Expand All @@ -51,6 +56,26 @@ func StartRxScanMode(driver io.ReadWriter) error {
return nil
}

func StartRxScanMode(driver io.ReadWriter) error {
messages := []ant.Packet{
ant.SetNetworkKeyMessage(0, []byte(ant.ANTPLUS_NETWORK_KEY)),
ant.AssignChannelMessage(0, ant.CHANNEL_TYPE_ONEWAY_RECEIVE),
ant.SetChannelIdMessage(0),
ant.SetChannelRfFrequencyMessage(0, 2457),
ant.EnableExtendedMessagesMessage(true),
// message.LibConfigMessage(true, true, true),
ant.OpenRxScanModeMessage(),
}

for _, msg := range messages {
_, err := driver.Write(msg)
if err != nil {
return err
}
}
return nil
}

func DumpBroadcastMessages(ctx context.Context, driver io.ReadWriter, messages chan ant.BroadcastMessage) {
defer close(messages)
for {
Expand Down

0 comments on commit e1701e4

Please sign in to comment.