Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

Emulating ANT+ Sensor

Rank

Total Posts: 4

Joined 2018-10-23

PM

Attempting to create a ANT+ Emulator in Android just to get familiar with the SDK and the ANT/ANT+ Protocol.

I've manager to get the channel up and running ( I think ). Found all necessary settings from the device profile. I've manually setup the page data from the device profile.

I do get the TX callback from the Ant Service, I'm assuming this means that the previous packet was sent ? When I do get the callback I call the sendBroadcast method again to update the data.

But for some reason I cannot get my Garmin Watch to recognize the emulated sensor, anyone tried something similar and perhaps can point me in the right direction ?

Using the following code to open the channel, and set broadcast data,

mAntChannelProvider = mAntRadioService.getChannelProvider();
mChannel = mAntChannelProvider.acquireChannel(getApplicationContext(), PredefinedNetwork.ANT_PLUS);
ChannelId id = new ChannelId(40000, 11, 0x05);
mChannel.setChannelId(id);
mChannel.setRfFrequency(57);
mChannel.setPeriod(8182);
mChannel.setTransmitPower(3);
mChannel.assign(ChannelType.BIDIRECTIONAL_MASTER);
mChannel.setChannelEventHandler(mChannelEventCallback);
sendBroadcast(rnd.nextInt());
mChannel.open();

private void sendBroadcast(int power) throws RemoteException {
acc_power += power;
if(++cnt > 255)
cnt = 0;

page10[0] = 0x10; // Bike power
page10[1] = (byte) cnt;
page10[2] = (byte)0xff; // Not in use
page10[3] = (byte)0xff; // Not in use
page10[4] = (byte)(acc_power);
page10[5] = (byte)(acc_power >> 8);
page10[6] = (byte)power;
page10[7] = (byte)(power >> 8);
mChannel.setBroadcastData(page10);
}


     
Rank

Total Posts: 4

Joined 2018-10-23

PM

Finally managed to figure it out, it appears that the command assign_channel will reset most of the channel properties, thus I had to do this first, before assigning all other settings like frequency, period etc..

Once I did this my watch was able to pick up the emulated sensor.      
Rank

Total Posts: 3

Joined 2018-11-26

PM

Hey Aune,

this is very interesting what you are trying to accomplish here.

I have an older Tacx trainer i-Vortex and would like to try to read data from it and then send it as new ANT+ Sensor (let's say powermeter) to my Garmin Watch.

If I understood correctly - you did this part of sending data and you can read it on the watch?


     
Rank

Total Posts: 4

Joined 2018-10-23

PM

Hello EIPaho

Reason for trying this was that my spinning bike was broadcasting its sensory data using BLE (no connect, just advertising).

I've made two solutions for this now, one is on Android device. Where the app starts listening for BLE advertising packets from a particular spinningbike ( ID is included in the advertising packet ), and then broadcasts this on Ant+ network simulating a bike power sensor. I've also made the same solution using nRF52 from Nordic, running Softdevice S323 for concurrent BLE and Ant.

Both solutions worked great and I can use the "new" power-sensor on my forerunner watch.

How does the Taxc send its data ? If it is already using Ant+ to send sensor data you might have a problem if it uses the same frequency as the sensor you are trying to emulate, you cannot set these frequencies freely since they are defined in the Ant+ device profiles for the different sensor types. If it has Bluetooth/BLE possibilities you should be able to do the same thing I did.      
Avatar
Rank

Total Posts: 16

Joined 2013-10-23

PM

Aune - 12 November 2018 08:17 AM

mAntChannelProvider = mAntRadioService.getChannelProvider();
mChannel = mAntChannelProvider.acquireChannel(getApplicationContext(), PredefinedNetwork.ANT_PLUS);
ChannelId id = new ChannelId(40000, 11, 0x05);
mChannel.setChannelId(id);
mChannel.setRfFrequency(57);
mChannel.setPeriod(8182);
mChannel.setTransmitPower(3);
mChannel.assign(ChannelType.BIDIRECTIONAL_MASTER);
mChannel.setChannelEventHandler(mChannelEventCallback);
sendBroadcast(rnd.nextInt());
mChannel.open();


Great example ! But, I am in trouble with PredefinedNetwork.ANT_PLUS cause in my case I only have the choice of PUBLIC, INVALID or ANT_FS... How do I specify ANT+ network ?

Thanks grin      

Signature

Rank

Total Posts: 4

Joined 2018-10-23

PM

You need access to another SDK to get access to the Ant+ network key, send a request to .(JavaScript must be enabled to view this email address) and you will get a document so sign, once signed and returned you will get access.

Reason for the document to sign is that Ant+ behavior is defined in the device profiles, and you have to follow them to sure compatibility with other Ant+ devices.
     
Avatar
Rank

Total Posts: 16

Joined 2013-10-23

PM

Aune - 11 January 2019 03:30 PM
You need access to another SDK to get access to the Ant+ network key, send a request to .(JavaScript must be enabled to view this email address) and you will get a document so sign, once signed and returned you will get access.

Reason for the document to sign is that Ant+ behavior is defined in the device profiles, and you have to follow them to sure compatibility with other Ant+ devices.


Awesome, thanks Aune for the fast reply.      

Signature

Rank

Total Posts: 1

Joined 2020-09-17

PM

Aune - 12 December 2018 02:58 PM
Hello EIPaho

Reason for trying this was that my spinning bike was broadcasting its sensory data using BLE (no connect, just advertising).

I've made two solutions for this now, one is on Android device. Where the app starts listening for BLE advertising packets from a particular spinningbike ( ID is included in the advertising packet ), and then broadcasts this on Ant+ network simulating a bike power sensor.


Hi Aune. I have a spin bike (Schwinn IC4) and I've been searching for exactly this type of solution. It broadcasts bike power data over BLE and I need to somehow convert that to Ant+ so an app I'm using can utilize this power data.

I know this thread is old but I was wondering if you ever finished or published this Android app?