Hi Usamak,
Thanks,
One question : in the pdf file AN11 section 8.2 in the scheme they said to enable extended messages. How do i do that. Here the code to setup channel 0 for searching.
Private Sub OpenSearch()
'initialisatie hr parameters
bRFChannel = {&H39;} '57
bDevideTypeID = {0} '0
If Not channel0 Is Nothing Then
channel0.unassignChannel()
channel0.closeChannel()
End If
channel0 = device.getChannel(0)
AddHandler channel0.channelResponse, AddressOf ChannelResponse
channel0.assignChannelExt(ANT_ReferenceLibrary.ChannelType.ADV_TxRx_Only_or_RxAlwaysWildCard_0x40, bAntNetNumber(0), ANT_ReferenceLibrary.ChannelTypeExtended.ADV_AlwaysSearch_0x01)
channel0.setChannelID(device_id, False, bDevideTypeID(0), bantTransType(0))
Thread.Sleep(50)
channel0.setChannelPeriod(8192)
Thread.Sleep(50)
channel0.setChannelFreq(bRFChannel(0))
Thread.Sleep(50)
channel0.setChannelSearchTimeout(&HFF;)
Thread.Sleep(50)
channel0.openChannel()
Thread.Sleep(50)
End Sub
After trying, i recieve the BROADCAST_DATA_0x4E message, but apperently the wrong contect, becase the check of the data is usable failes
Private Sub ChannelResponse(ByVal response As ANT_Response)
Dim message_bytes As Byte() = New Byte(response.messageContents.Length + 2) {}
'Add header bytes as expected by the ProcessMessage function
Select Case (CType(response.responseID, ANT_ReferenceLibrary.ANTMessageID))
Case ANT_ReferenceLibrary.ANTMessageID.ACKNOWLEDGED_DATA_0x4F, ANT_ReferenceLibrary.ANTMessageID.BROADCAST_DATA_0x4E
Try
Dim extMsgOffset As Byte = 10
'Check to make sure that the data received is useable
If ((response.messageContents.Length <= 9) OrElse ((response.messageContents(9) OrElse CType(ANT_ReferenceLibrary.LibConfigFlags.MESG_OUT_INC_DEVICE_ID_0x80, Byte)) = 0)) Then
Exit Select
End If
temp.usDeviceNum = CType((response.messageContents(extMsgOffset) Or (response.messageContents((extMsgOffset + 1)) + 8)), System.UInt16)
temp.ucDeviceType = response.messageContents((extMsgOffset + 2))
temp.ucTransType = response.messageContents((extMsgOffset + 3))
Catch ex As Exception
End Try
End Select
message_bytes(2) = response.responseID
response.messageContents.CopyTo(message_bytes, 3)
Dim d As New ProcessManager(Sub() ProcessMessage(message_bytes))
d.BeginInvoke(Nothing, Nothing)
End Sub