internal void SetWriteResult(PORT_RETURN_CODE result) { lock (_lock) { m_writeResult = result; m_writeAcceptLength = null; } }
public PORT_RETURN_CODE OpenServer(int scn__) { PORT_RETURN_CODE ret = ConvertResult(WidcommL2CapClient.NativeMethods.L2CapConn_Listen(m_pPort, _intf.PObject)); Utils.MiscUtils.Trace_WriteLine("WidcommL2CapClient.NativeMethods.L2CapConn_OpenServer ret: {0}=0x{0:X}", ret); return(ret); }
PORT_RETURN_CODE BackgroundWrite(byte[] p_data, UInt16 len_to_write, out UInt16 p_len_written, Thread callerThread) { Debug.Assert(Thread.CurrentThread != callerThread, "Same thread!!! " + Thread.CurrentThread.ManagedThreadId + " =?= " + callerThread.ManagedThreadId); PORT_RETURN_CODE ret = m_port.Write(p_data, len_to_write, out p_len_written); return(ret); }
public PORT_RETURN_CODE OpenClient(int scn__, byte[] address) { if (address == null || address.Length != 6) { throw new ArgumentException("Parameter 'address' must be non-null and six-bytes long."); } PORT_RETURN_CODE ret = ConvertResult(WidcommL2CapClient.NativeMethods.L2CapConn_Connect(m_pPort, _intf.PObject, address)); Utils.MiscUtils.Trace_WriteLine("WidcommL2CapClient.NativeMethods.L2CapConn_OpenClient ret: {0}=0x{0:X}", ret); return(ret); }
protected override bool TryBondingIf_inLock(BluetoothAddress addressToConnect, int ocScn, out Exception error) { const bool Retrying = true; const bool NotRetrying = false; // /* * if(havePin) * if(Bond success) * if(OpenClient success) * return Retrying; * return NotRetrying; */ try { // Mustn't die on this thread, need to report all exceptions back!! // if (m_passcodeToTry != null) { if (addressToConnect == null) { Debug.Fail("In retry, have passcode, but looks like Server mode!!"); error = null; return(NotRetrying); } // string passcodeToTry = m_passcodeToTry; m_passcodeToTry = null; Debug.Assert(addressToConnect != null, "addressToConnect != null"); bool didPair = Bond(addressToConnect, passcodeToTry); if (didPair) { //TODO Destroy old port! SetPort(m_factory.GetWidcommRfcommPort()); PORT_RETURN_CODE ret = m_port.OpenClient(ocScn, WidcommUtils.FromBluetoothAddress(addressToConnect)); Utils.MiscUtils.Trace_WriteLine("OpenClient/AB ret: {0}=0x{0:X}", ret); if (ret == PORT_RETURN_CODE.SUCCESS) { error = null; return(Retrying); } else { error = WidcommSocketExceptions.Create(ret, "OpenClient/AB"); return(NotRetrying); } } } // error = null; } catch (Exception ex) { error = ex; } return(NotRetrying); }
public PORT_RETURN_CODE OpenServer(int scn) { var scnB = checked ((byte)scn); if (scnB < BluetoothEndPoint.MinScn || scnB == 0xFF || scnB > BluetoothEndPoint.MaxScn) { throw new ArgumentOutOfRangeException("scn", "Should be >0 and <31, is: " + scnB + "."); } PORT_RETURN_CODE ret = NativeMethods.RfcommPort_OpenServer(m_pRfcommPort, scnB); Utils.MiscUtils.Trace_WriteLine("NativeMethods.RfcommPort_OpenServer ret: {0}=0x{0:X}", ret); return(ret); }
public PORT_RETURN_CODE OpenClient(int scn, byte[] address) { var scnB = checked ((byte)scn); if (scnB < BluetoothEndPoint.MinScn || scnB == 0xFF || scnB > BluetoothEndPoint.MaxScn) { throw new ArgumentOutOfRangeException("scn", "Should be >0 and <31, is: " + scnB + "."); } if (address == null || address.Length != 6) { throw new ArgumentException("Parameter 'address' must be non-null and six-bytes long."); } PORT_RETURN_CODE ret = NativeMethods.RfcommPort_OpenClient(m_pRfcommPort, scnB, address); Utils.MiscUtils.Trace_WriteLine("NativeMethods.RfcommPort_OpenClient ret: {0}=0x{0:X}", ret); return(ret); }
private static TestLsnrRfcommPort AddACreatablePort(TestWcLsnrBluetoothFactory f, PORT_RETURN_CODE result) { TestLsnrRfcommPort port1 = new TestLsnrRfcommPort(); port1.SetOpenServerResult(result); // now begun immediately f.queueIRfCommPort.Enqueue(port1); return(port1); }
protected override void ActionCore() { _result = Port.Close(); }
protected override void ActionCore() { _result = Port.OpenClient(_scn, _address); }
protected override void ActionCore() { _result = Port.OpenServer(_scn); }
protected override void ActionCore() { _result = Port.Write(_data, _lenToWrite, out _lenWritten); }
public void SetOpenServerResult(PORT_RETURN_CODE ret) { m_OpenServerResult = ret; }
public void SetOpenClientResult(PORT_RETURN_CODE ret) { m_OpenClientResult = ret; }
internal static SocketException Create(PORT_RETURN_CODE result, string location) { return(new PORT_RETURN_CODE_WidcommSocketException(CommonSocketExceptions.SocketError_StartDiscovery_Failed, result, location)); }