Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

Backgrounad scanning Channel Finding Only 1 device. 

Rank

Total Posts: 14

Joined 2017-11-26

PM

Hello

I am using the ANT_Managed_library c#. Its fine. However, I have implemented background Scanning using the ANT RSSI_DEMO . It also works, thanks!!

However, the RSSI demo seems to be able to get a list of devices, but I cannot. I havent copied the code verbatim, but used the demo as part of my project. But regardless of what I do, I can only ever get 1 device.

Im using SIMULANT+ and also a physical device to try and get the DeviceIDs to list. But only ever get 1..

What am I missing.

kind regards

Anthony      
Rank

Total Posts: 16

Joined 2022-04-10

PM

Hi Anthony,

I'm not sure why you are having problems with your app, but maybe my open source project on github can provide you some guidance - https://github.com/StephenHidem/AntPlus.

See the Examples folder. AntUsbStick in particular uses the ANT+ libraries; see the InitializeContinuousScanMode method.

I also have some NuGet packages. Go to NuGet and search on smallearthtech.

Best regards,
Stephen Hidem      
Rank

Total Posts: 14

Joined 2017-11-26

PM

cheers, I will look at your github. I thought I had send the necessary messages to get continous scanning, but it only every produces 1 device id, despite me having 1 on SimulANT and also a physical device.

     
Rank

Total Posts: 14

Joined 2017-11-26

PM

yeah, your Github didnt help me at all thanks.

I cant see any evidence where you get 2 devices or more listed. There is no allocation in your code, that I can see where you list out DeviceIDs successfully.

Im clearly not as advances at C# as you, but I understand Inferfaces well enough to work through your project, its just not providing me with a clear method of Creating a new ANT_DEVICE and then retrieving multiple DEVICEIDs from a channel scan      
Rank

Total Posts: 16

Joined 2022-04-10

PM

Hi Anthony,

I suggest cloning the Github AntPlus solution. Build it and run the WpfUsbStickApp project in the Examples folder. You should see all active ANT devices.

The WPF application uses the AntDeviceCollection class (in the AntPlus project) to instantiate all ANT devices, including unknown devices.

The AntUsbStick is a concrete implementation of the interfaces defined in AntRadioInterface. AntPlus is an implementation that provides ANT device classes you can work with; it uses the interfaces implemented by AntUsbStick.

Hope that clarifies your issue. I'm more than happy to answer any questions you may have.

Best regards,
Stephen      
Rank

Total Posts: 14

Joined 2017-11-26

PM

I see.Thanks.

I cloned your work and got it working, pefectly. Just as you said it would. Congrats on some really impressive work there.

There is alot there to work through, as your implementations seem a bit different to the ANT_MANGED_LIBRARY I have been using and your work if so extensive it may take me some time to look through and figure how, you ended up with some of it.

Thanks I will continue to see if I have time to look through and it if it assists me with what I need. Im vaguely familiar with Maui, but its not a requirement for my protoype, I am looking at running a x86 console app in the background of my Unity App (x64), likely using Pipes to send data to my Unity Scene.

     
Rank

Total Posts: 16

Joined 2022-04-10

PM

Hi Anthony,

Thanks for the congratulations! I just made a note to myself to better explain the architecture and motivation behind my code.

MAUI is interesting but it still has issues, so don't devote too much attention to the example. I was more interested in how gRPC (google remote procedure call) worked. gRPC is the way to go when you want to communicate over networks to devices like my Android phone from my PC.

I looked at Unity about a year ago; it looks like a good fit for running simulations like bike tracks and interfacing with bike trainers. My Unity version may be a little dated. I've got version 2022.3.13f1 installed.

Give me a couple of days to dig in and see if I can help. I'll post to this thread.

Best regards,
Stephen      
Rank

Total Posts: 14

Joined 2017-11-26

PM

Cheers, never heard of gPRC. Thanks, I'll look, Im more on desktop rather than Android. But my experience is with Xamarin, recently, not Maui

I'll plug away at your example. But I have mostly coded up my own console app using the ANT_MANAGED_LIBRARY, and get data from Data pages and sadly, can only ever get 1 device, which is my only issue right now......oh, AND the ANT_MANGED_LIBRARY is x86 and my Unity Version is x64, so I can't get these libraries into Unity.

Obviously, I am trying to do something interesting with it ANT+ and Unity, probably like everyone does? But my last 5yrs has been working with XR-Tech, so I kind need x64 for that.

Anyway, cheers again. My only way at the minute to get ANT+ working with newer Versions of Unity is to use Pipes and send the data from my windowless Console app, to Unity's Monobeahviour's scripting.      
Rank

Total Posts: 16

Joined 2022-04-10

PM

Hi Anthony,

At last some progress! I'm new to Unity, so had to learn the mechanics, mostly by trial and error.

Your requirements as I understand it are:
1. An AntUsbStick (x86) that runs as a server in a console window. Prefer windowless - I'll turn this into a Windows Service a little later.
2. Unity project is x64 or AnyCpu. Can connect to server and communicate with stick.

I've got the basics down - running my AntGrpcServer. The benefit is the server does not need to run on the same PC as the Unity project, although they can. Next steps are to use the AntPlus class library, create the device collection, and interact with a device.

You will need NuGetForUnity to grab some packages to support gRPC. Google it and add it to your project player.

I'll soldier on. This is looking more like a blog post in order to provide comprehensive instructions.

Best regards,
Stephen      
Rank

Total Posts: 14

Joined 2017-11-26

PM

Hi ..

Thank you for looking at Unity. Yesterday I treid to use your Nuget Libraries to try and make a simple conole app as I dont need the windows presentation layer, or perhaps even the observable collection which the devicecollection uses.

So yes my plan really, because it of unity being 64/any cpu and ANT_PLUS.dll is to indeed try and run a console app in the background. I cant see another way. Which I am fine with, like you say a service was on my mind.

     
Rank

Total Posts: 14

Joined 2017-11-26

PM

Does anyone else on here, know or be able to help?

Im currently Setting up my Device, setting my getChannel(0)..... then I set the other paramters like StLibConfigs, then the enableRxExtendedmessages.... and the regular ChannelID as 0.

I then use the
channelScan.channelResponse += new dChannelResponseHandler(ScanResponse); 


which process the responses..... BUT Im only getting 1 line/data page, always for 1 device.....in an endless repeat. Whereas when I use ANTWare II to test, I get all the devices in my room.

What am I missing.

I feel as if Im missing a concept. I vaguely remember that Extended messages are asynchronous? Do I somehow need to offset my settings, I feel like the Hz is constantly just picking up the same page.........occassionally on restart it picks up a different device, BUT always one.

Im kinda stuck, and as I work alone, Its becoming an issue.

If anyone could lend a hand please.Im going around in circles.

     
Rank

Total Posts: 16

Joined 2022-04-10

PM

Hi Anthony,

I don't have any suggestions about your last post, but I did want to give you an update on what I have been working on. I have created a Windows service that uses the ANT USB stick along with gRPC for communication over a network. Runs in the background as all Windows services do. My MAUI client application works on Windows, Android, Android emulator (all running at the same time!). I also created a Unity project, loaded some asset packages, then loaded some NuGet packages, and got my simple implementation talking to the Windows service.

I've got some work to do documenting my Windows service and installation. Then on to bulking up the Unity client and figure out how disseminate the Unity example for other to use.

Best regards,
Steve      
Rank

Total Posts: 14

Joined 2017-11-26

PM

Hi Stephen.

I got it all working.... and by using the Windows Service..... However, I'll look at yours, because my programming isnt as sophisticated as yours. So I might learn something.

I havent managed to have a continued back ground scan on one channel AND have the other channels access devices, its either one or the other, but thats fine by me.

Unity, I got it sorted using MemoryMapped files and a config file and also NamedPipes to sent serialised XML strings for setup in the service. I also import the microsoft dll (cant remember now which one) which controls the windows service and uses the Service Controller Class.

I will take a look, its like you have done a much better job than me. Im a mid level C# programmer at best. but I've got data passing into unity and able to pass back data to the service for things like controlling Smart Trainers and Config parameters as per the device profile pages from ANT...... Its been a very interesting prototype, finally next week Im hopeful to get onto terrain and some basic testing after.



     
Rank

Total Posts: 1

Joined 2024-03-11

PM

JackoNottinhham - 07 March 2024 04:10 PM
Hi Stephen.

I got it all working.... and by using the Windows Service..... However, I'll look at yours, because my programming isnt as sophisticated as yours. So I might learn something.

I havent managed to have a continued back ground scan on one channel AND have the other channels access devices, its either one or the other, but thats fine by x trench run.

Unity, I got it sorted using MemoryMapped files and a config file and also NamedPipes to sent serialised XML strings for setup in the service. I also import the microsoft dll (cant remember now which one) which controls the windows service and uses the Service Controller Class.

I will take a look, its like you have done a much better job than me. Im a mid level C# programmer at best. but I've got data passing into unity and able to pass back data to the service for things like controlling Smart Trainers and Config parameters as per the device profile pages from ANT...... Its been a very interesting prototype, finally next week Im hopeful to get onto terrain and some basic testing after.




Hello! It's wonderful to see that you've successfully implemented your solution using a Windows Service. Your approach with MemoryMapped files, a config file, and NamedPipes for setup in the service demonstrates a thoughtful design. Integrating the Microsoft DLL and utilizing the Service Controller Class for Unity adds an extra layer of sophistication to your project. It's impressive that you've achieved data passing between Unity and the service, enabling control of Smart Trainers and configuration of parameters.      
Rank

Total Posts: 14

Joined 2017-11-26

PM

Cheers. Its all working quite well now. I absolutely know there is a more sophisticated way of pgramming this, and also maybe using .NET core, rather than .NET 4.8, but leveraging .NET core in Unity is just not worth it, for what I want.

My issue is now, still the Data Pages and different types of Power Meters, there are 3 types:

Crank Torque
Wheel Torque
Power Only

Each of these will use different data pages and calculate power differently, I can't see an efficient way of understanding which Device will use which data page.

The only way I can see it being done is via Manu ID, and then making an assumption based on the Manu Name like Garmin or Assioma (Favero).

There is a guide on how to determine which pages to use, based on TX rates of certain pages, but its seems like, by the time my code makes the decision on what data page to use, it will be too slow for the User to happy.