Hello vb.ne use to read your heart rate with ant-usb (GARMIN) and range (Garmin). Using this code, you connect na not read the heartbeat, I'm new to VB.NET, someone could correct the code?Thanks to all for the help.
sorry for the bad english
Rino.
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports ANT_Managed_Library
Namespace ANT__Sample_Application
Friend Class Program
Private Shared device As ANT_Device
'Private Shared ReadOnly networkKey() As Byte = {&H0;, &H0;, &H0;, &H0;, &H0;, &H0;, &H0;, &H0;}
Private Shared ReadOnly networkKey() As Byte = {0, 0, 0, 0, 0, 0, 0, 0}
Private Shared ReadOnly deviceType As Byte = 120 ' Device type
Private Shared transType As Byte = 0 ' Transmission type
Private Shared ReadOnly radioFreq As Byte = 57 ' RF Frequency + 2400 MHz
Private Shared ReadOnly channelPeriod As UShort = 8070 ' Message period possible values 8070 = 4.06 Hz, 16140 = 2.03Hz, 32280 = 1.02Hz
Private Shared channelType As ANT_ReferenceLibrary.ChannelType = ANT_ReferenceLibrary.ChannelType.BASE_Master_Transmit_0x10
Private Shared lastRunNo As Integer = 0
Public Shared Sub Main(ByVal args() As String)
Console.WriteLine("Connecting to HRM, PRESS ENTER TO TERMINATE PROGRAM")
device = New ANT_Device()
device.setNetworkKey(0, networkKey, 500)
Dim Channel As ANT_Channel = device.getChannel(0)
Channel.assignChannel(channelType, 0, 500)
Channel.setChannelID(0, False, deviceType, transType, 500)
Channel.setChannelFreq(radioFreq, 500)
Channel.setChannelPeriod(channelPeriod, 500)
AddHandler Channel.channelResponse, AddressOf HandleHeartRateTest
Channel.setProximitySearch(3) ' Is set to limit the search range
Channel.openChannel(500)
Console.ReadLine()
Channel.closeChannel()
End Sub
Public Shared Sub HandleHeartRateTest(ByVal response As ANT_Response)
Select Case CType(response.responseID, ANT_ReferenceLibrary.ANTMessageID)
Case ANT_ReferenceLibrary.ANTMessageID.BROADCAST_DATA_0x4E
Console.WriteLine("Message: ")
Case ANT_ReferenceLibrary.ANTMessageID.ACKNOWLEDGED_DATA_0x4F
Console.WriteLine("Message: ")
Case ANT_ReferenceLibrary.ANTMessageID.BURST_DATA_0x50
Case ANT_ReferenceLibrary.ANTMessageID.EVENT_0x01
Dim runNo As Integer = response.messageContents(7)
If runNo <> lastRunNo Then
lastRunNo = runNo
'Console.WriteLine("Message: " & BitConverter.ToString(response.messageContents))
Console.WriteLine(" Beat count: " & lastRunNo.ToString() & " HR: " & response.messageContents(8).ToString())
End If
Exit Select
Case ANT_ReferenceLibrary.ANTMessageID.RESPONSE_EVENT_0x40
Console.WriteLine("Message: " & ANT_ReferenceLibrary.ANTMessageID.RESPONSE_EVENT_0x40)
Console.WriteLine(response.messageContents(8).ToString())
Case ANT_ReferenceLibrary.ANTMessageID.CHANNEL_MESG_PERIOD_0x43
Console.WriteLine("Message: 0x4F")
Case Else
Console.WriteLine("Message: 0x4F")
End Select
End Sub
End Class