Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register


Peer-to-Peer Communication (HCI packets)


Total Posts: 524

Joined 2012-11-15



I'm working on a simple proof of concept for communication across two mobile phones.

The idea is:
If two phones can see each other they exchange information, for example a number or a string.

The string will be bigger than the 8 bytes in a normal broadcast so I need to use Burst mode to send it.

Sending "Hello World!" via ANTSendBurstTransfer will result in this log
01-08 03:22:20.012INFO/ANTManager(1649): ANTTransmitBurst1
-08 03:22:20.012INFO/ANTManager(1649): ANTTransmitBurstSending 12 bytesin 2 ANT packets.
01-08 03:22:20.012INFO/ANTManager(1649): ANTTransmitBurstCombining 2 ANT packets inside 1 HCI packet
-08 03:22:20.012DEBUG/ANTManager(1649): ANTTransmitBurstSending HCI packet 1 

But how do I receive a HCI packet? Using the Demo code i only get "Hello Wo" (the first 8 bytes)
01-08 03:23:11.448DEBUG/AntSender RECEIVER(6879): enter onReceivecom.dsi.ant.intent.action.ANT_RX_MESSAGE_ACTION
-08 03:23:11.448DEBUG/AntSender RECEIVER(6879): Rx:[9][4e][1][48][65][6c][6c][6f][20][57][6f] {Hello Wo} 

Sometimes I get what looks like a burst:
01-08 03:23:12.448DEBUG/AntSender RECEIVER(6879): Rx:[9][50][1][48][65][6c][6c][6f][20][57][6f] {Hello Wo}
-08 03:23:12.448DEBUG/AntSender RECEIVER(6879): Rx:[9][50][a1][72][6c][64][21][6f][20][57][6f] {rld!o Wo} 

And any tips on how to setup peer-to-peer would also be appreciated. Currently using sAntReceiver.ANTAssignChannel(channelNumber, AntDefine.PARAMETER_TX_NOT_RX, networkNumber) and PARAMETER_RX_NOT_TX.

Using PARAMETER_SHARED_CHANNEL on both devices results in no data.      

Total Posts: 662

Joined 2012-10-09


Please have a look at the section "Getting Started with the ANT Protocol" section on this post

The first few sections of the "ANT Message Protocol and Usage Document", the ANT Basics video, and ANTware will greatly help you understand the basic principles of ANT channels. In order for two nodes to communicate with each other, their channel parameters need to match, and one of them needs to be configured as the master and the other as the slave. If both nodes are to have the same configuration, you may want to consider using two channels (one master, one slave in each) and some sort of application level handshaking to establish a connection.

Bursting is one possibility, but please note that when a burst fails, it will stop immediately. Please refer to the AN04 Burst Transfers and Section of the "ANT Message protocol and usage document" for more details on burst transfers and how to decode burst packets. You do not need to deal directly with the HCI packets; you just need to decode the burst as you receive it, paying attention to the sequence number. Depending on the amount of data you need to send, you might want to look into ANT-FS