internal static bool IsInitialize = false;
internal static bool IsAudioInitialize = false;
internal static bool IsHidInitialize = false;
+ internal static bool IsOppServerInitialized = false;
+ internal static bool IsOppClientInitialized = false;
}
internal partial class BluetoothAdapterImpl : IDisposable
}
}
+ internal void Enable()
+ {
+ if (Globals.IsInitialize)
+ {
+ int ret = Interop.Bluetooth.EnableAdapter();
+ if (ret != (int)BluetoothError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to enable adapter, Error - " + (BluetoothError)ret);
+ BluetoothErrorFactory.ThrowBluetoothException(ret);
+ }
+ }
+ else
+ {
+ BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotInitialized);
+ }
+ }
+
+ internal void Disable()
+ {
+ if (IsBluetoothEnabled)
+ {
+ int ret = Interop.Bluetooth.DisableAdapter();
+ if (ret != (int)BluetoothError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to disable adapter, Error - " + (BluetoothError)ret);
+ BluetoothErrorFactory.ThrowBluetoothException(ret);
+ }
+ }
+ else
+ {
+ BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled);
+ }
+ }
+
+ internal void SetVisibility(VisibilityMode mode, int timeout)
+ {
+ if (IsBluetoothEnabled)
+ {
+ int ret = Interop.Bluetooth.SetVisibility(mode, timeout);
+ if (ret != (int)BluetoothError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to set visibility, Error - " + (BluetoothError)ret);
+ BluetoothErrorFactory.ThrowBluetoothException(ret);
+ }
+ }
+ else
+ {
+ BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled);
+ }
+ }
+
internal void StartDiscovery()
{
int ret = Interop.Bluetooth.StartDiscovery();
}
BluetoothDeviceStruct device = (BluetoothDeviceStruct)Marshal.PtrToStructure(deviceInfo, typeof(BluetoothDeviceStruct));
+ Interop.Bluetooth.FreeDeviceInfo(deviceInfo);
return BluetoothUtils.ConvertStructToDeviceClass(device);
}
if (ret != (int)BluetoothError.None)
{
Log.Error (Globals.LogTag, "Failed to deinitialize bluetooth, Error - " + (BluetoothError)ret);
- BluetoothErrorFactory.ThrowBluetoothException (ret);
}
else
{