I'm trying to develop an Android-based ANT-FS application and am running into some difficulty sending acknowledged messages from the host to the client to step through the connection states.
While it is highly likely there is something else I'm not setting up properly I would like to see if someone can verify that I'm implementing the ANTSendAcknowledgedData function in the AntInterface class properly. Or point out what I'm doing wrong if not. I'm getting the sense that I'm not sending any data from the host to the client.
I'm confident that I have the channel set up properly since I can search and see the client beacon messages. The host channel parameters are:
- Channel type = AntDefine.PARAMETER_RX_NOT_TX
- Network number = 2 (ANT-FS)
- Device number = 0
- Device type = 1
- Period = 4096 (Used for ANT-FS)
- Frequency = 57
- Transmission type = 5
- Channel number = 3
The client parameters are:
- Device number = 0
- Device type = 22
- Authentication = passkey
- Manufacturing ID = 2
The host searches the channel and sees the client beacon come in as:
[09][4E][03][43][2C][00][03][16][00][02][00]
which is correct based on the client settings
When I receive the beacon, I call the ANTSendAcknowledgedData(chn#, txBuffer[]) function via the AntInterface class with the following byte array (in this order as well):
- byte _fsCmnd = (byte)0x43; (I've also tried 0x44 here)
- byte _link = (byte)0x02;
- byte _chFreq = (byte)0x32;
- byte _chPeriod = (byte)0x04;
- byte _snByte0 = (byte)0x01;
- byte _snByte1 = (byte)0x00;
- byte _snByte2 = (byte)0x00;
- byte _snByte3 = (byte)0x00;
I then change the host frequency to 0x32 (50 decimal) and wait for the client to beacon there with its status bit indicating that it's in the authentication state. I never see it get there. In fact, if I don't change the host frequency, I continue to see the client beacon on the previous frequency with no changes to its bytes.
Questions:
- Does the ANTSendAcknowledgedData function handle the acknowledgment in the background and throw an exception if it doesn't receive it? Thus, do I simply have to call it and not wait for a receive event?
- Is there some positive indicator that I can see (wait for) at the ANTPlusManager or higher level to confirm that the message was received or not? Do I need to wait for a period of time watching for an exception using its timed out absence as a negative indicator that the message was acknowledged?
- In case the message was sporatically missed by the client, I've tried looping with a pause to send the acknowledged message several times. Still no success.
- Do I need to add the length, channel numner, sync byte, or checksum byte in the byte array. I tried adding the length and channel number bytes to the front of it with no difference. What does a proper txBuffer[] look like?
- I also noticed that the Windows ANT-FS application sends 0x44 for the _sfCmd byte. I tried that as well but with no success.
- Maybe I'm not actually moving to the new channel frequency. I change it on the fly. Do I need to close the channel and then reopen it with the new frequency? However, as noted above, when I don't issue the new frequency command, I continue to see the client beacon; whereas, when I issue it, I don't see the beacon anymore. That pretty much tells me that I'm changing frequency properly.
- My understanding is that the client's beacon after it receives the link command is identical to that before the command except that the authenticate state is set. Does it come in to the broadcast receiver with a different message value that I'm not trapping or does it continue to come in with a 0x4E message ID?
Any advice anyone can provide with this or other settings I need to put in place to get this to work is greatly appreciated.
Thanks!