internal BluetopiaSocketException(BluetopiaError bluetopiaError, int socketErr) : base(socketErr) { int iError = (int)bluetopiaError; Set(iError); }
internal static void CheckAndThrow(BluetopiaError ret, string descr) { if (ret >= 0) { return; } Throw(ret, descr); }
internal static void CheckAndThrowZeroIsIllegal(BluetopiaError ret, string descr) { Debug.Assert(ret != 0 || TestUtilities.IsUnderTestHarness(), "Zero is also invalid per the docs."); if (ret > 0) { return; } Throw(ret, descr); }
internal static void WriteLineIfError(BluetopiaError ret, string descr) { if (!IsSuccess(ret)) { Utils.MiscUtils.Trace_WriteLine("Bluetopia error: " + ErrorToString(ret) + ", at: " + descr); } }
private void ExpectQueryRemoteName(StuffStackBluetopia stuff, BluetoothAddress expectedAddr, BluetopiaError whatRet) { Int64 expectedAddrBytes = expectedAddr.ToInt64(); Expect.Once.On(stuff.MockedApi) .Method("GAP_Query_Remote_Device_Name") .With(stuff.StackId, expectedAddrBytes, Is.Anything, Is.Anything) .Will(Return.Value(whatRet)); }
}//class internal IAsyncResult BeginInquiry(int maxDevices, TimeSpan inquiryLength, AsyncCallback callback, object state, BluetoothClient.LiveDiscoveryCallback liveDiscoHandler, object liveDiscoState, DiscoDevsParams args) { CancelAllQueryNames(); return(_inquiryHandler.BeginInquiry(maxDevices, inquiryLength, callback, state, liveDiscoHandler, liveDiscoState, delegate() { BluetopiaError ret = Api.GAP_Perform_Inquiry(StackId, StackConsts.GAP_Inquiry_Type.GeneralInquiry, 0, 0, checked ((uint)inquiryLength.Seconds), checked ((uint)maxDevices), _inquiryEventCallback, 0); BluetopiaUtils.CheckAndThrow(ret, "Btsdk_StartDeviceDiscovery"); }, args)); }
internal BluetopiaSocketException(BluetopiaError bluetopiaError, SocketError socketErr) : this(bluetopiaError, (int)socketErr) { }
internal static void Throw(BluetopiaError ret, string descr) { //default to NotSocket unless match specific error below SocketError err = SocketError.NotSocket; switch (ret) { // TODO ! Match BlueSoleil error codes to SocketExceptions. // Note need different errors for GetServiceRecords, handle here or in GSR itself? case BluetopiaError.INVALID_PARAMETER: case BluetopiaError.INVALID_BLUETOOTH_STACK_ID: err = SocketError.InvalidArgument; break; case BluetopiaError.DLL_INITIALIZATION_ERROR: case BluetopiaError.HCI_INITIALIZATION_ERROR: case BluetopiaError.GAP_INITIALIZATION_ERROR: case BluetopiaError.SCO_INITIALIZATION_ERROR: case BluetopiaError.L2CAP_INITIALIZATION_ERROR: case BluetopiaError.RFCOMM_INITIALIZATION_ERROR: case BluetopiaError.SDP_INITIALIZATION_ERROR: case BluetopiaError.SPP_INITIALIZATION_ERROR: case BluetopiaError.GOEP_INITIALIZATION_ERROR: case BluetopiaError.OTP_INITIALIZATION_ERROR: err = SocketError.SystemNotReady; break; case BluetopiaError.UNSUPPORTED_HCI_VERSION: err = SocketError.VersionNotSupported; break; case BluetopiaError.ATTEMPTING_CONNECTION_TO_DEVICE: err = SocketError.ConnectionRefused; break; case BluetopiaError.INVALID_CONNECTION_STATE: err = SocketError.NotConnected; break; case BluetopiaError.CONNECTION_TO_DEVICE_LOST: err = SocketError.ConnectionAborted; break; case BluetopiaError.INTERNAL_ERROR: err = SocketError.Fault; break; case BluetopiaError.INSUFFICIENT_BUFFER_SPACE: case BluetopiaError.SPP_BUFFER_FULL: err = SocketError.NoBufferSpaceAvailable; break; case BluetopiaError.UNSUPPORTED_PLATFORM_ERROR: err = SocketError.OperationNotSupported; break; case BluetopiaError.RFCOMM_UNABLE_TO_ADD_CONNECTION_INFORMATION: err = SocketError.AddressAlreadyInUse; break; } Debug.WriteLine("Bluetopia Throw " + ret + ", at: " + descr + ", (" + err + ")"); throw new BluetopiaSocketException(ret, (int)err); }
internal static string ErrorToString(BluetopiaError ret) { return(ret + "=(" + ((int)ret).ToString(CultureInfo.InvariantCulture) + ")"); }
internal static void Assert(BluetopiaError ret, string descr) { Debug.Assert(IsSuccess(ret), "Bluetopia error: " + ErrorToString(ret) + ", at: " + descr); }
internal static bool IsSuccessZeroIsIllegal(BluetopiaError ret) { return(ret > 0); }
internal static bool IsSuccess(BluetopiaError ret) { return(ret >= 0); }