Exemple #1
0
 private void SessionConnect()
 {
     if (session == null)
     {
         session = new ObexClientSession(LocalClient.GetStream(), UInt16.MaxValue);
     }
     session.Connect(new byte[] { 0x79, 0x61, 0x35, 0xf0, 0xf0, 0xc5, 0x11, 0xd8, 0x09, 0x66, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66 });
 }
Exemple #2
0
        protected void SendFileMethod()
        {
            try
            {
                bluetoothClient = new BluetoothClient();

                BluetoothEndPoint remoteEndPoint = new BluetoothEndPoint(device.DeviceAddress, BluetoothService.ObexObjectPush);

                bluetoothClient.Connect(remoteEndPoint);

                session = new ObexClientSession(bluetoothClient.GetStream(), UInt16.MaxValue);
                session.Connect();

                session.PutFile(filePath);

                session.Disconnect();
                session.Dispose();

                bluetoothClient.Dispose();
            }
            catch (PlatformNotSupportedException ex)
            {
                ErrorLog.AddError(ErrorType.Failure, Strings.BT_NoBluetooth);
                Logger.Write(ex);
            }
            catch (ObexResponseException ex)
            {
                ErrorLog.AddError(ErrorType.Failure, Strings.BT_ConnectionRefused);
                Logger.Write(ex);

                if (bluetoothClient != null)
                {
                    bluetoothClient.Dispose();
                }
            }
        }