本文整理汇总了C#中InTheHand.Net.Sockets.BluetoothClient.BeginConnect方法的典型用法代码示例。如果您正苦于以下问题:C# BluetoothClient.BeginConnect方法的具体用法?C# BluetoothClient.BeginConnect怎么用?C# BluetoothClient.BeginConnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InTheHand.Net.Sockets.BluetoothClient
的用法示例。
在下文中一共展示了BluetoothClient.BeginConnect方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: connect_to_be
/// <summary>
/// Asynchrones Verbinden zu dem Client.
/// </summary>
/// <param name="dev_name">Der Name des Geräts.</param>
public void connect_to_be(string dev_name)
{
add = get_device_address(dev_name);
BluetoothEndPoint BEP = new BluetoothEndPoint(add, BluetoothUUID);
client = new BluetoothClient();
object connection = false;
try
{
client.BeginConnect(BEP, new AsyncCallback(start_read), client);
}
catch (Exception excep)
{
Debug.WriteLine(excep.ToString());
}
}
示例2: ThreadedSender
public void ThreadedSender()
{
BTClient = new BluetoothClient();
// Connect to a remote device.
try
{
BTClient.BeginConnect(BTAddress, _N2FServiceGUID, new AsyncCallback(ConnectCallback), BTClient);
connectDone.WaitOne();
// Send test data to the remote device.
Send(BTClient, "TagValidationString!<EOF>");
sendDone.WaitOne();
}
catch (Exception ex)
{
KillEmAll();
}
finally
{
KillEmAll();
}
}
示例3: ConnectSocket
/// <summary>
/// If we were not provided with a btClient on creation we need to create one
/// </summary>
private void ConnectSocket()
{
try
{
if (NetworkComms.LoggingEnabled) NetworkComms.Logger.Trace("Connecting bluetooth client with " + ConnectionInfo);
bool connectSuccess = true;
//We now connect to our target
btClient = new BluetoothClient();
//Start the connection using the async version
//This allows us to choose our own connection establish timeout
IAsyncResult ar = btClient.BeginConnect((ConnectionInfo.RemoteEndPoint as BluetoothEndPoint), null, null);
WaitHandle connectionWait = ar.AsyncWaitHandle;
try
{
if (!ar.AsyncWaitHandle.WaitOne(NetworkComms.ConnectionEstablishTimeoutMS, false))
{
btClient.Close();
connectSuccess = false;
}
btClient.EndConnect(ar);
}
finally
{
connectionWait.Close();
}
if (!connectSuccess) throw new ConnectionSetupException("Timeout waiting for remoteEndPoint to accept bluetooth connection.");
}
catch (Exception ex)
{
CloseConnection(true, 17);
throw new ConnectionSetupException("Error during bluetooth connection establish with destination (" + ConnectionInfo + "). Destination may not be listening or connect timed out. " + ex.ToString());
}
}
示例4: conectio
private void conectio()
{
BluetoothClient cliento = new BluetoothClient();
cliento.BeginConnect(dispositivomeromero.DeviceAddress,mUUID,this.callbacko,cliento);
}
示例5: Discovery
private void Discovery(Object sender, DoWorkEventArgs e)
{
InfoMessage("Starting Discovery Round");
var client = new BluetoothClient();
BluetoothDeviceInfo[] availableDevices = client.DiscoverDevicesInRange(); // I've found this to be SLOW!
String deviceList = "";
BluetoothDeviceInfo tmpDI = null;
foreach (BluetoothDeviceInfo device in availableDevices)
{
//ServiceRecord[] devServices = device.GetServiceRecords(OurServiceClassId);
if (!device.Authenticated/* || devServices.Count() == 0*/)
continue;
if (tmpDI == null)
tmpDI = device;
deviceList += device.DeviceName + " : " + device.DeviceAddress + " : " + (device.Authenticated ? "Paired" : "Not Paired") + /*" : " + devServices.Count() + */"\n";
}
UpdateDiscoveryDevices(deviceList);
if (tmpDI != null)
{
var peerclient = new BluetoothClient();
peerclient.BeginConnect(tmpDI.DeviceAddress, OurServiceClassId, DiscoveryDeviceConnectCallback, peerclient);
}
}
示例6: bt_pair
private void bt_pair()
{
BluetoothAddress BtAdress = null;
BluetoothClient _blueToothClient;
bool _beginConnect;
int c = 0;
string selDev = null;
try
{
_blueToothClient = new BluetoothClient();
}
catch { MessageBox.Show("Bluetooth модуль не подключен!"); return; }
button7.BeginInvoke((MethodInvoker)(() => { button7.Text = "Wait..."; button7.Enabled = false; }));
comboBox6.BeginInvoke((MethodInvoker)(() => selDev = comboBox6.SelectedItem.ToString()));
var devices = _blueToothClient.DiscoverDevices();
while (BtAdress == null)
{
foreach (var device in devices.Where(device => device.DeviceName == selDev))
{
BtAdress = device.DeviceAddress;
Console.WriteLine("Device found, Address:" + BtAdress.ToString());
}
if (BtAdress != null)
break;
if (c > 2)
{
MessageBox.Show("Невозможно подключиться к устройству!");
button7.BeginInvoke((MethodInvoker)(() => { button7.Text = "Open"; button7.Enabled = true; }));
return;
}
devices = _blueToothClient.DiscoverDevices();
c++;
}
BluetoothDeviceInfo _bluetoothDevice = null;
try
{
_bluetoothDevice = new BluetoothDeviceInfo(BtAdress);
}
catch (System.ArgumentNullException) { }
if (BluetoothSecurity.PairRequest(_bluetoothDevice.DeviceAddress, "1111"))
{
Console.WriteLine("Pair request result: :D");
if (_bluetoothDevice.Authenticated)
{
Console.WriteLine("Authenticated result: Cool :D");
_blueToothClient.SetPin("1111");
_blueToothClient.BeginConnect(_bluetoothDevice.DeviceAddress, BluetoothService.SerialPort, null, _bluetoothDevice);
_beginConnect = true;
bt_serial(BtAdress.ToString()); // Open Serial port for Bluetooth
if (btSerialPort != null)
{
button7.BeginInvoke((MethodInvoker)(() => button7.Text = "Open"));
button6.BeginInvoke((MethodInvoker)(() => button6.Enabled = true));
groupBox6.BeginInvoke((MethodInvoker)(() => groupBox6.Enabled = true));
}
}
else
{
Console.WriteLine("Authenticated: So sad :(");
bt_pair();
}
}
else
{
Console.WriteLine("PairRequest: Sad :(");
MessageBox.Show("Невозможно подключиться к устройству!");
button7.BeginInvoke((MethodInvoker)(() => { button7.Text = "Open"; button7.Enabled = true; }));
return;
}
}
示例7: ClientconnectThread
private void ClientconnectThread()
{
BluetoothClient client = new BluetoothClient();
updateUI("attempting connect");
client.BeginConnect(deviceInfo.DeviceAddress, mUUID,this.bluetoothClientConnectCallback,client);
}