Frameworks > Bluetooth Framework
Bluetooth adapter not found scenario
TheodorosGR:
I have the following scenario on my application.
Application is starting.The bluetooth adapter is not pluged(i think this is common from a lot users).Show an exception from Enum_Radios() (wcl demo).The exception says what to do(check your adapter....etc).Then if the user plugs the adaptor he will probably hit the refresh button (GetSelectedRadio()).But there i am getting an exception which i cant handle.
My question is if there is any way after the user plugs the adapter and calling GetSelectedRadio() to display the BT adapter without requiring restarting the application.
A little bit confusing question but i think you got the point.
Regards
Thiodor
Mike Petrichenko:
Good day!
WCL Has no GetSelectedRadio function. What does that function do?
Of course, WCL can detect changes in hardware without restarting application.
TheodorosGR:
Here is the code.
--- Code: --- private wclBluetoothRadio GetSelectedRadio()
{
wclBluetoothRadio Result = null;
if (lvRadios.SelectedItems.Count == 0)
{
Result = new wclBluetoothRadio();
try
{
Result.API = wclBluetoothDiscovery.StringToBluetoothAPI(lvRadios.Items[0].SubItems[1].Text);
}
catch (Exception )
{
MessageBoxEx.Show(Resources.PlugAdaptorGR + ".Error code:201", headerMSG);
}
//MessageBox.Show("Select radio", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
{
Result = new wclBluetoothRadio();
try
{
Result.API = wclBluetoothDiscovery.StringToBluetoothAPI(lvRadios.SelectedItems[0].SubItems[1].Text);
}
catch
{
Result = null;
throw;
}
}
return Result;
}
--- End code ---
Mike Petrichenko:
When and how lvRadios items created and inserted in the liist view
TheodorosGR:
I think you need this:
--- Code: --- private void ShowRadio(wclBluetoothRadio Radio)
{
String Address = "";
try
{
Address = Radio.Address;
}
catch (Exception e)
{
Address = e.Message;
}
ListViewItem Item = lvRadios.Items.Add(Address);
Item.SubItems.Add(wclBluetoothDiscovery.BluetoothAPIToString(Radio.API));
try
{
Item.SubItems.Add(Radio.Connectable.ToString());
}
catch (Exception e)
{
Item.SubItems.Add(e.Message);
}
try
{
Item.SubItems.Add(Radio.Discoverable.ToString());
}
catch (Exception e)
{
Item.SubItems.Add(e.Message);
}
try
{
Item.SubItems.Add(Radio.Name);
}
catch (Exception e)
{
Item.SubItems.Add(e.Message);
}
}
--- End code ---
Navigation
[0] Message Index
[#] Next page
Go to full version