Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

.net search for all available sensors

RankRank

Total Posts: 33

Joined 0

PM

Hi,

I developped a program with functionality to choose the wanted sensors.
Now i open an channel with specific data (e.g. heartrate, speed, cadence, SandC or Power).
But when there are e.g. 10 SandC , 4 speed, 5 heart, 2 power sensors in the neighbourhood, how can i detect them all by showing the deviceid so the user must choose the wanted sensored to be paired with in the program.

No i must set specific channels to search, but my ant+ usb has only 8 channels.

Is there way to use the .net api of ant to detect all available sensors without paring direct?

I hope you understand what i mean, otherwise ask me for more details.

Best Regards,
Klaasjan      
RankRankRankRank

Total Posts: 156

Joined 2013-01-07

PM

Hi Klaasjan,

The best implementation for your requirement would be to open a background scanning channel with all channel ID parameters configured to perform a wildcard search (0).
(Refer to Section 8.2 of Application Note 11 - ANT Channel Search and Background Scanning Channel).

If you configure the RF frequency of the background scanning channel to 2457MHz, you will be able to receive messages from all transmitting ANT+ devices in range. To receive the channel ID's of the transmitting devices you will have to enable extended messages so you can associate each received message with a specific master. (Refer to Section 7.1.1 of the ANT Message Protocol and Usage document).

If you have access to a C7 ANT module you can try out the ANT+ RSSI demo which will display all of the ANT+ devices in range along with their received signal strength.

ANT document and software resources can be found at: http://www.thisisant.com/developer/resources/downloads/      
RankRank

Total Posts: 33

Joined 0

PM

Hi Usamak,

I downloaded the RSSI demo but my usb stick is not regonized.

But what i understand i need to open a channel with de specs from the document.
As a reply i got messagetype 0x40 back.

Best Regards,
Klaasjan      
RankRankRankRank

Total Posts: 156

Joined 2013-01-07

PM

Yes, you would need to use a C7 ANT module for the RSSI demo, your ANT USB stick will not work.

To decode messagetype 0x40 refer to section 9.5.6 of the ANT Message Protocol and Usage document. (http://www.thisisant.com/resources/ant-message-protocol-and-usage/)      
RankRank

Total Posts: 33

Joined 0

PM

Ok clear,,
but is it possible using an ant+ usb stick of detecting al devices in the neighbourhood?

Best Regards,
Klaasjan      
RankRankRankRank

Total Posts: 156

Joined 2013-01-07

PM

Yes, you will have to create an application that opens a background scanning channel (that searches for all ANT+ channel IDs) with extended messages enabled.

The background scanning channel will be able to receive messages from all transmitting sensors without pairing to just one. Extended messages will allow your application to access the channel ID associated with each received message, enabling your application to determine what kind of ANT+ sensor it is receiving from (Device Type) and also its ID (Device Number).

     
RankRank

Total Posts: 33

Joined 0

PM

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

     
RankRankRankRank

Total Posts: 156

Joined 2013-01-07

PM

Hi Klaasjan,

For enabling extended messages refer to Section 7.1.1 of the ANT Message Protocol and Usage document.
Section 9.5.2.19 describes the Lib Config (0x6E) message which can be used to enable extended messages. Lib Config can be used to enable channel ID, RSSI and timestamp information in the extended bytes.

If you only wish to enable channel ID information in the extended bytes (your use case) you may also use the Enable Extended Messages (0x66) message, Section 9.5.2.16.