First steps with FlexLib

  • 2
  • Question
  • Updated 2 months ago
Hi guys.

Steve and Eric sent me source for FlexLib. I spent a couple of days trying to read and and understand it, but it is too difficult to do without having it well commented and documented. One good news is that it has successfully compiled to DLLs.
So now I need to figure out where to start using it. I have made a couple (unsuccessful so far) attempts to at least discover the radio, using FlexLib and feel myself stuck. Did anybody walk this route and can please help? 

Also, a request to Flex guys. Is it possible to share some pieces of complete and usable code, which will show how different pieces of FlexLib work? Nothing fancy, just examples in C# Console, with a bit of explanations on input and output params and entry point. Sort of Flex analog to MSDN :)

Any advise is highly appreciated!

Paul RN3A
Photo of Paul RN3A

Paul RN3A

  • 56 Posts
  • 6 Reply Likes

Posted 6 years ago

  • 2
Photo of Eric - KE5DTO

Eric - KE5DTO, Official Rep

  • 912 Posts
  • 343 Reply Likes
Official Response
Great question.  Here's the basics:

Step 1: Attach to the RadioAdded/RadioRemoved event handlers in the API class.  This will allow you to be notified when a radio shows up/goes away.

Example Code:
API.RadioAdded += new API.RadioAddedEventHandler(API_RadioAdded);            API.RadioRemoved += new API.RadioRemovedEventHandler(API_RadioRemoved);

Step 2: Set the API.ProgramName to your programs name.

Example Code:
API.ProgramName = "My Program";

Step 3: Call API.Init().  This initializes the Discovery objects to listen for radios that are broadcasting their info over the network.

Example Code:

At this point, you should begin getting RadioAdded/Removed events as the discovery packets are passed through the network.

Once you have a reference to a radio with which you would like to connect, you will want to attach to the event handlers that tell you about the objects within a radio (Panadapters, Slices, etc).

Step 4: Attach to the Radio.SliceAdded/SliceRemoved/PanadapterAdded/PanadapterRemoved/PropertyChanged events.

Example Code:
radio.SliceAdded += new Radio.SliceAddedEventHandler(radio_SliceAdded);                radio.SliceRemoved += new Radio.SliceRemovedEventHandler(radio_SliceRemoved);
radio.PanadapterAdded += new Radio.PanadapterAddedEventHandler(radio_PanadapterAdded);
radio.PanadapterRemoved += new Radio.PanadapterRemovedEventHandler(radio_PanadapterRemoved);

Step 5: Connect to the radio by calling the Connect function in the radio class on the radio object (received in the RadioAdded event handler).

Example Code:

Once a Slice or Panadapter object arrives that you would like to control (they will show up in the SliceAdded or PanadapterAdded events), you can attach to the PropertyChanged event to get notifications about various parameters within that object.  For a Slice, this might be the Frequency, the Demodulation Mode, the Filter Cuts, etc.  For a Panadapter this would be the Center Frequency, the Bandwidth, the low/high dBm display levels, etc.

Example Code:
slice.PropertyChanged += new PropertyChangedEventHandler(slice_PropertyChanged);
panadapter.PropertyChanged += new PropertyChangedEventHandler(panadapter_PropertyChanged);

At this point you should have references to Radio, Slice and Panadapter objects that you can use to manipulate the various pieces of the radio.