/// <summary> /// Opens RX Scan mode without extended packets /// </summary> public void RxScanMode() { state++; switch (state) { case 1: callFunc = new ContinuationCallback(this.RxScanMode); needsResponse = true; SendCommand(ANTCommands.Reset()); break; case 2: SendCommand(ANTCommands.AssignChannel()); break; case 3: SendCommand(ANTCommands.SetChannelId()); break; case 4: SendCommand(ANTCommands.RxExtMessageEnable()); break; case 5: SendCommand(ANTCommands.OpenRxScanMode()); break; case 6: channelOpen = true; callFunc = null; parent.OnChannelOpened(); state = 0; break; } }
/// <summary> /// Initialized sychronous ANT communication in receive mode /// Default settings used /// </summary> public void InitializeAntSyncronous() { state++; switch (state) { case 1: callFunc = new ContinuationCallback(this.InitializeAntSyncronous); SendCommand(ANTCommands.Reset()); //no response on AP1 needsResponse = true; //waitTimer.Start(); break; case 2: needsResponse = true; SendCommand(ANTCommands.AssignChannel()); break; case 3: SendCommand(ANTCommands.SetChannelId()); break; case 4: SendCommand(ANTCommands.SetChannelPeriod()); break; case 5: //startTime = System.DateTime.Now.ToFileTimeUtc(); SendCommand(ANTCommands.OpenChannel()); break; case 6: //long stopTime = System.DateTime.Now.ToFileTimeUtc(); channelOpen = true; callFunc = null; parent.OnChannelOpened(); state = 0; break; } }
/// <summary> /// Reopens a channel that has been previously initialized /// </summary> public void OpenChannel() { state++; if (state == 1) { callFunc = new ContinuationCallback(this.OpenChannel); SendCommand(ANTCommands.OpenChannel()); } else if (state == 2) { channelOpen = true; callFunc = null; parent.OnChannelOpened(); state = 0; } }
/// <summary> /// Closes the channel and waits for a response /// </summary> public void CloseChannel() { state++; if (state == 1) { callFunc = new ContinuationCallback(this.CloseChannel); SendCommand(ANTCommands.CloseChannel()); } else if (state == 2) //gets back an EVENT_CHANNEL_CLOSED as well { channelOpen = false; callFunc = null; parent.OnChannelClosed(); state = 0; } }