Skip to content

Local Radio Information

Peter Foot edited this page Apr 14, 2018 · 1 revision

Local Radio Information

Local Bluetooth Radios are represented by the BluetoothRadio class, and an instance representing the primary radio can be accessed via the BluetoothRadio.PrimaryRadio static (Shared in Visual Basic) property. The class provides various information about the radio: the Bluetooth Address, the Class of Devices bits and the manufacturer, etc. The radio mode can be configured be setting the Mode property: it can be enabled, disabled, and put in discoverable mode. See the example below.

Public Shared Sub DisplayBluetoothRadio()
    Dim myRadio As BluetoothRadio = BluetoothRadio.PrimaryRadio
    If myRadio Is Nothing Then
        Console.WriteLine("No radio hardware or unsupported software stack")
        Return
    End If
    Dim mode As RadioMode = myRadio.Mode
    ' Warning: LocalAddress is null if the radio is powered-off.
    Console.WriteLine("* Radio, address: {0:C}", myRadio.LocalAddress) 
    Console.WriteLine("Mode: " & mode.ToString())
    Console.WriteLine("Name: " & myRadio.Name)
    Console.WriteLine("HCI Version: " & myRadio.HciVersion _
        & ", Revision: " & myRadio.HciRevision)
    Console.WriteLine("LMP Version: " & myRadio.LmpVersion _
        & ", Subversion: " & myRadio.LmpSubversion)
    Console.WriteLine("ClassOfDevice: " & myRadio.ClassOfDevice.ToString() _
        & ", device: " & myRadio.ClassOfDevice.Device.ToString() _
        & " / service: " & myRadio.ClassOfDevice.Service.ToString())
    '
    '
    ' Enable discoverable mode
    Console.WriteLine()
    myRadio.Mode = RadioMode.Discoverable
    Console.WriteLine("Radio Mode now: " & myRadio.Mode.ToString())
End Sub
void DisplayBluetoothRadio()
{
    BluetoothRadio myRadio = BluetoothRadio.PrimaryRadio;
    if (myRadio == null) {
        Console.WriteLine("No radio hardware or unsupported software stack");
        return;
    }
    RadioMode mode = myRadio.Mode;
    // Warning: LocalAddress is null if the radio is powered-off.
    Console.WriteLine("* Radio, address: {0:C}", myRadio.LocalAddress);
    Console.WriteLine("Mode: " + mode.ToString());
    Console.WriteLine("Name: " + myRadio.Name);
    Console.WriteLine("HCI Version: " + myRadio.HciVersion
        + ", Revision: " + myRadio.HciRevision);
    Console.WriteLine("LMP Version: " + myRadio.LmpVersion
        + ", Subversion: " + myRadio.LmpSubversion);
    Console.WriteLine("ClassOfDevice: " + myRadio.ClassOfDevice.ToString()
        + ", device: " + myRadio.ClassOfDevice.Device.ToString()
        + " / service: " + myRadio.ClassOfDevice.Service.ToString());
    //
    //
    // Enable discoverable mode
    Console.WriteLine();
    myRadio.Mode = RadioMode.Discoverable;
    Console.WriteLine("Radio Mode now: " + myRadio.Mode.ToString());
}

There is also a static property BluetoothRadio.AllRadios to fetch all the local radios. However the supported Bluetooth stack software (Microsoft and Widcomm) each support one radio. Note, if there is no supported local radio then BluetoothRadio.PrimaryRadio will return null, as shown in the sample; and BluetoothRadio.AllRadios will return an empty array. Also BluetoothRadio.LocalAddress can be null on the instance returned when the radio is powered-off.

Clone this wiki locally