Пример #1
0
 /// <summary>
 /// OBEX协议服务
 /// </summary>
 public static ObexService GetObexInstance()
 {
     if (BlueToothDevice != null)
     {
         return(ObexService.GetDefaultForBluetoothDevice(BlueToothDevice));
     }
     else
     {
         return(null);
     }
 }
Пример #2
0
 public async void StartService(BluetoothDevice BTDevice)
 {
     BtDevice                            = BTDevice;
     obexService                         = ObexService.GetDefaultForBluetoothDevice(BtDevice);
     obexService.Aborted                += obexService_Aborted;
     obexService.ConnectionFailed       += obexService_ConnectionFailed;
     obexService.DataTransferFailed     += obexService_DataTransferFailed;
     obexService.DataTransferProgressed += obexService_DataTransferProgressed;
     obexService.DataTransferSucceeded  += obexService_DataTransferSucceeded;
     obexService.DeviceConnected        += obexService_DeviceConnected;
     obexService.Disconnected           += obexService_Disconnected;
     obexService.Disconnecting          += obexService_Disconnecting;
     obexService.ServiceConnected       += obexService_ServiceConnected;
     await obexService.ConnectAsync();
 }
Пример #3
0
        async void obexService_Disconnected(object sender, EventArgs e)
        {
            obexService.Aborted                -= obexService_Aborted;
            obexService.ConnectionFailed       -= obexService_ConnectionFailed;
            obexService.DataTransferFailed     -= obexService_DataTransferFailed;
            obexService.DataTransferProgressed -= obexService_DataTransferProgressed;
            obexService.DataTransferSucceeded  -= obexService_DataTransferSucceeded;
            obexService.DeviceConnected        -= obexService_DeviceConnected;
            obexService.Disconnected           -= obexService_Disconnected;
            obexService.Disconnecting          -= obexService_Disconnecting;
            obexService.ServiceConnected       -= obexService_ServiceConnected;
            obexService = null;

            if (filesToShare.Count.Equals(0))
            {
                OnTransferCompleted(AppConstants.FilesSharedOK);
            }
            else if (this.filesToShare[0].ShareStatus.Equals(FileShareStatus.Error) || this.filesToShare[0].ShareStatus.Equals(FileShareStatus.Cancelled))
            {
                OnTransferCompleted(AppConstants.FilesSharedError);
            }
            else
            {
                obexService = ObexService.GetDefaultForBluetoothDevice(BtDevice);
                obexService.DeviceConnected        += obexService_DeviceConnected;
                obexService.ServiceConnected       += obexService_ServiceConnected;
                obexService.ConnectionFailed       += obexService_ConnectionFailed;
                obexService.DataTransferProgressed += obexService_DataTransferProgressed;
                obexService.DataTransferSucceeded  += obexService_DataTransferSucceeded;
                obexService.DataTransferFailed     += obexService_DataTransferFailed;
                obexService.Disconnecting          += obexService_Disconnecting;
                obexService.Disconnected           += obexService_Disconnected;
                obexService.Aborted += obexService_Aborted;
                await obexService.ConnectAsync();
            }
        }
Пример #4
0
 /// <summary>
 /// OBEX协议服务
 /// </summary>
 public static ObexService GetObexNewInstance()
 {
     return(BlueToothDevice != null?ObexService.GetDefaultForBluetoothDevice(BlueToothDevice) : null);
 }