Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

Android application to send ANT+ message to another application on the same device

Rank

Total Posts: 4

Joined 2016-11-07

PM

Hello,

As a bicycle rider, I ran into an issue with my ANT+ devices and applications, and as a software developer with 10 years of experience in JAVA (and a few attempts in Android wink ) I decided that it would be great experience to overcome these difficulties by myself. Problem is that I've never developed anything related to ANT nor ANT+, and I do not even know if such scenario is possible.

I have:
- a bike smile
- an ANT+ cadence and speed sensor,
- an ANT+ heart rate monitor,
- an ANT enabled phone with ANT+ capable, popular, orange application (both sensors work well when connected directly to the application),
- a not ANT capable home trainer machine and its speed-to-power characteristic charts.

What I would like to do is to read data from speed sensor, calculate approximate power output, and feed 3rd party application with this data as if it was provided by power sensor. I've searched the forum, read some threads, downloaded manuals, and what I understood is that I can create an application, which would read data from my speed & cadence sensor with ANT+ SDK on one end, calculate values I need, and then I could probably send calculated data via 'raw' ANT (using ANT SDK), after creating appropriate ANT+ message (Cycling Power device profile) by myself. Is my understanding correct? Would ANT SDK allow me to send messages (as far as I understood, yes) and do I have to undertake any special steps (other than creating well-formed ANT+ message) so 3rd party application could receive them? If I do everything correctly, will my application be visible to fitness applications on the same phone just like another ANT+ sensor? (bonus question, not in scope of the problem, but also interesting: is it possible to receive messages from a sensor, and send messages further to another device via radio ANT?)

I know that I could just write an application that would create FIT/gpx file with data collected from all sensors and upload it manually, but then I would miss all data processing performed by 3rd party app, like data smoothening, etc. That's why I'd like to 'simulate' a sensor if possible.


Thanks,
Maciek


PS. Yes, I am aware that power calculated this way will vary from actual power output. I am more interested in software development aspect of the problem.      
Avatar
RankRankRankRank

Total Posts: 149

Joined 2014-04-02

PM

Hi Maciek,

Correctly formatting the ANT packets to match the ANT+ Bike Power Profile is only one part. Your channel transmitting the power values must also be set to match the channel configuration parameters in the ANT+ Bike Power Profile; including being on the ANT+ Network. The standard ANT API does not allow using the ANT+ Network, as this could cause conflicts with the device connections the ANT+ API is trying to use. In order to access the ANT+ network, you will need to contact the ANT+ team and request it.

Bonus: All ANT channels on the radio operate independently. There is nothing stopping you receiving data on one channel and re-transmitting it on another.

Cheers,
-Rohan      

Signature

blackramlabs.com

Rank

Total Posts: 4

Joined 2016-11-07

PM

Rohan,

Thank you for your reply, I believe it helped me a lot.

What I believe is that I could connect to ANT+ network if I only knew its (128-bit) network key, am I right? All other channel details are described in appropriate document (D00001086_-_ANT+_Device_Profile_-_Bicycle_Power_-_Rev4.2.pdf) and with this information I could connect to ANT+ managed network - is my reasoning correct? To create power message(s) I can also use mentioned document to learn its format and compose it correctly, right?

If I get all of this correctly, I am on my way to ask ANT+ team if they are willing to share network key with me for my not-really-enterprisey use case, and maybe they have some higher level API to compose and send ANT+ messages smile


Thanks for help,
Maciek
     
Avatar
RankRankRankRank

Total Posts: 149

Joined 2014-04-02

PM

Almost correct. It's simpler as there is no 128-bit ANT+ Network Key, as the mobile phone chipsets already have the ANT+ Network predefined. The restriction is that the ANT API provides no way to select that network.

On another note; the title of this thread is misleading. You wouldn't use ANT to communicate between 2 apps on the same phone.

-Rohan      

Signature

blackramlabs.com

Rank

Total Posts: 4

Joined 2016-11-07

PM

Rohan,

I see, I was under (apparently incorrect) impression, that something similar to following code would allow me to connect to ANT+ network:

NetworkKey antPlusNetworkKey = new NetworkKey(new byte[] { /* insert ANT+ key here */  });
AntChannel antChannel channelProvider.acquireChannelOnPrivateNetwork(ctxantPlusNetworkKey);

//Configure with values specified in section 4.2 "Master Channel Configuration"
//of "ANT+ Device_Profile - Bicycle Power" manual
ChannelId channelId = new ChannelId(deviceNo0x0B0x05); 

antChannel.assign(ChannelType.BIDIRECTIONAL_MASTER);
antChannel.setRfFrequency(57);
antChannel.setPeriod(8182);
antChannel.setChannelId(channelId);

antChannel.open(); 


But from your reply I conclude that acquireChannelOnPrivateNetwork does not allow access to managed ANT+ network, or that somewhere there is some better API to achieve this goal.
I've already contacted ANT+ support and maybe my question about network key might seem unreasonable to them, but hopefully they will understand what I want to do smile

About thread title, I tried to update it a little bit as when I created the thread all I knew about ANT is that I want to make an app that could feed ANT data to another app, but with my further investigation and better understanding of the topic, it drifted away from my original description. But basically it is still what I want: an app that sends ANT+ data, and which can be used as an ANT+ data source by fitness apps installed on the same device. And since English is not my first language, my wording may also be a bit off.


Thanks for your help and Best Regards,
Maciek

     
Avatar
RankRankRankRank

Total Posts: 149

Joined 2014-04-02

PM

Hobson - 10 November 2016 09:05 AM
But basically it is still what I want: an app that sends ANT+ data, and which can be used as an ANT+ data source by fitness apps installed on the same device.


This is not possible. You could send the bike power data to a seperate device/display, but it could not be received by apps on the same phone. As each ANT channel on the radio is allocated a unique timeslot, there is no way for receiving data that is transmitted on the same radio.

-Rohan      

Signature

blackramlabs.com

Rank

Total Posts: 4

Joined 2016-11-07

PM

Thank you very much for your help. With your answers, and one mail to ANT support team, I know everything I need for now.

Thanks again!
Maciek      
Rank

Total Posts: 2

Joined 2017-07-10

PM

Hello Maciek,

did you make any progress?
I'm trying to implement a power sensor as well, but I have problems when setting the RF frequency to 57. I get a INVALID_REQUEST respond.

Furthermore I have no idea whether to use
- acquireChannelOnPrivateNetwork
- acquireChannel
- acquireChannelFromAdapter
- acquireChannelOnPrivateNetworkFromAdapter
for my app acting as a sensor.

It would be nice if you can provide me your experience.

KR
Lukas

     
Rank

Total Posts: 2

Joined 2020-10-15

PM

Hello there,

As I understand it is not possible/allowed because there is another business membership for this purposes.
More over, a mobile phone is not a sensor device, it is not the same.

Yes/No? Any comments?

I am adopter and I have Garmin certified application. "Contact support" form is not available for me. But actually for me it is clear. Just need a short answer.
     
RankRankRankRank

Total Posts: 370

Joined 2012-06-27

PM

https://www.thisisant.com/forum/viewthread/7477/ may be what you are looking for to implement mobile functionality which is not supported by the more commonly used plugins method.      

Signature

Ian Haigh