public Lovense(IButtplugLogManager aLogManager, IBluetoothDeviceInterface aInterface, IBluetoothDeviceInfo aInfo) : base(aLogManager, $"Lovense Device ({FriendlyNames[aInterface.Name]})", aInterface, aInfo) { if (FriendlyNames[aInterface.Name] == "Edge") { _vibratorCount++; } MsgFuncs.Add(typeof(SingleMotorVibrateCmd), new ButtplugDeviceWrapper(HandleSingleMotorVibrateCmd)); MsgFuncs.Add(typeof(VibrateCmd), new ButtplugDeviceWrapper(HandleVibrateCmd, new MessageAttributes() { FeatureCount = _vibratorCount })); MsgFuncs.Add(typeof(StopDeviceCmd), new ButtplugDeviceWrapper(HandleStopDeviceCmd)); if (FriendlyNames[aInterface.Name] == "Nora") { MsgFuncs.Add(typeof(RotateCmd), new ButtplugDeviceWrapper(HandleRotateCmd, new MessageAttributes() { FeatureCount = 1 })); } }
//---------- public List_IBluetoothDeviceInfo GetKnownRemoteDeviceEntries() { List <REM_DEV_INFO> list = new List <REM_DEV_INFO>(); REM_DEV_INFO info = new REM_DEV_INFO(); int cb = System.Runtime.InteropServices.Marshal.SizeOf(typeof(REM_DEV_INFO)); IntPtr pBuf = System.Runtime.InteropServices.Marshal.AllocHGlobal(cb); try { REM_DEV_INFO_RETURN_CODE ret = m_btIf.GetRemoteDeviceInfo(ref info, pBuf, cb); Utils.MiscUtils.Trace_WriteLine("GRDI: ret: {0}=0x{0:X}", ret); while (ret == REM_DEV_INFO_RETURN_CODE.SUCCESS) { list.Add(info); // COPY it into the list ret = m_btIf.GetNextRemoteDeviceInfo(ref info, pBuf, cb); Utils.MiscUtils.Trace_WriteLine("GnRDI: ret: {0}=0x{0:X}", ret); }//while if (ret != REM_DEV_INFO_RETURN_CODE.EOF) { throw WidcommSocketExceptions.Create(ret, "Get[Next]RemoteDeviceInfo"); } // List_IBluetoothDeviceInfo bdiList = new List_IBluetoothDeviceInfo(list.Count); foreach (REM_DEV_INFO cur in list) { IBluetoothDeviceInfo bdi = WidcommBluetoothDeviceInfo.CreateFromStoredRemoteDeviceInfo(cur, m_factory); bdiList.Add(bdi); } return(bdiList); } finally { System.Runtime.InteropServices.Marshal.FreeHGlobal(pBuf); } }
public VorzeSA(IButtplugLogManager aLogManager, IBluetoothDeviceInterface aInterface, IBluetoothDeviceInfo aInfo) : base(aLogManager, "Vorze SA Unknown", aInterface, aInfo) { if (aInterface.Name == "CycSA") { _deviceType = DeviceType.CycloneOrUnknown; Name = "Vorze A10 Cyclone SA"; } else if (aInterface.Name == "UFOSA") { _deviceType = DeviceType.UFO; Name = "Vorze UFO SA"; } else { // If the device doesn't identify, warn and try sending it Cyclone packets. BpLogger.Warn($"Vorze product with unrecognized name ({Name}) found. This product may not work with B******g. Contact the developers for more info."); } MsgFuncs.Add(typeof(VorzeA10CycloneCmd), new ButtplugDeviceWrapper(HandleVorzeA10CycloneCmd)); MsgFuncs.Add(typeof(RotateCmd), new ButtplugDeviceWrapper(HandleRotateCmd, new MessageAttributes() { FeatureCount = 1 })); MsgFuncs.Add(typeof(StopDeviceCmd), new ButtplugDeviceWrapper(HandleStopDeviceCmd)); }
public UWPBluetoothDeviceFactory([NotNull] IButtplugLogManager aLogManager, [NotNull] IBluetoothDeviceInfo aInfo) { _buttplugLogManager = aLogManager; _bpLogger = _buttplugLogManager.GetLogger(GetType()); _bpLogger.Trace($"Creating {GetType().Name}"); _deviceInfo = aInfo; }
//---- public void HandleInquiryResultInd(TInquiryEventItemType item) { IBluetoothDeviceInfo bdi = CreateDeviceInfo(item); BluetoothClient.LiveDiscoveryCallback liveDiscoHandler; object liveDiscoState; lock (_lockInquiry) { if (_inquiryDevices == null) { //Debug.Assert(TestUtilities.IsUnderTestHarness(), "HandleDeviceResponded without DD i.e. m_inquiryDevices == null."); return; } liveDiscoHandler = _liveDiscoHandler; liveDiscoState = _liveDiscoState; // DateTime t0 = _inquiryAr.BeginParameters.discoTime; bdi.SetDiscoveryTime(t0); // BluetoothDeviceInfo.AddUniqueDevice(_inquiryDevices, bdi); } if (liveDiscoHandler != null) { WaitCallback dlgt = delegate { OnDeviceResponded(liveDiscoHandler, bdi, liveDiscoState); }; ThreadPool.QueueUserWorkItem(dlgt); } }
public KiirooGen2Vibe([NotNull] IButtplugLogManager aLogManager, [NotNull] IBluetoothDeviceInterface aInterface, [NotNull] IBluetoothDeviceInfo aInfo) : base(aLogManager, "Kiiroo Unknown", aInterface, aInfo) { if (DevInfos.ContainsKey(aInterface.Name)) { Name = $"{DevInfos[aInterface.Name].Brand} {aInterface.Name}"; _devInfo = DevInfos[aInterface.Name]; } else { BpLogger.Warn($"Cannot identify device {Name}, defaulting to Pearl2 settings."); _devInfo = DevInfos["Unknown"]; } AddMessageHandler <StopDeviceCmd>(HandleStopDeviceCmd); AddMessageHandler <VibrateCmd>(HandleVibrateCmd, new MessageAttributes { FeatureCount = _devInfo.VibeCount }); AddMessageHandler <SingleMotorVibrateCmd>(HandleSingleMotorVibrateCmd); }
private IObservable <bool> ActionDevice(string actionName, IBluetoothDeviceInfo device, Func <BluetoothAddress, bool> action) { return(Observable.Create <bool>(o => { _logger.Info("Request to {0} Bluetooth device {1} ({2})", actionName, device.DeviceName, device.DeviceType.Name); if (!IsSupported) { o.OnError(new InvalidOperationException("Bluetooth not currently supported on this device.")); return Disposable.Empty; } try { var btAddress = new BluetoothAddress(device.DeviceAddress); var successful = action(btAddress); LogDeviceAction(actionName, device, successful); RefreshDevice(device); o.OnNext(successful); o.OnCompleted(); } catch (Exception ex) { _logger.Warn(ex, "Request to {0} Bluetooth device '{1}' ({2}) caused an error", actionName, device.DeviceName, device.DeviceType.Name); o.OnNext(false); o.OnCompleted(); } //Cancellation not supported by BluetoothSecurity api. return Disposable.Empty; })); }
internal static List_IBluetoothDeviceInfo ReadKnownDevicesFromRegistry( string deviceListPath, Func <BluetoothAddress, string, uint, bool, IBluetoothDeviceInfo> makeDev) { List_IBluetoothDeviceInfo known = new List_IBluetoothDeviceInfo(); //open bluetooth device key RegistryKey devkey = Registry.LocalMachine.OpenSubKey(deviceListPath); //bool addFromRegistry = authenticated || remembered; if (devkey != null) { //enumerate the keys foreach (string devid in devkey.GetSubKeyNames()) { BluetoothAddress address; if (BluetoothAddress.TryParse(devid, out address)) { //get friendly name RegistryKey thisdevkey = devkey.OpenSubKey(devid); string name = thisdevkey.GetValue(DevicesValueNames.DeviceName, "").ToString(); uint classOfDevice = Convert.ToUInt32(thisdevkey.GetValue(DevicesValueNames.ClassOfDevice, 0)); thisdevkey.Close(); //add to collection IBluetoothDeviceInfo thisdevice = makeDev(address, name, classOfDevice, true); known.Add(thisdevice); } } devkey.Close(); } return(known); }
public override string GetRemoteMachineName(BluetoothAddress device) { // This is what we do on Win32. Good enough?? IBluetoothDeviceInfo bdi = _fcty.DoGetBluetoothDeviceInfo(device); return(bdi.DeviceName); }
public Kiiroo([NotNull] IButtplugLogManager aLogManager, [NotNull] IBluetoothDeviceInterface aInterface, [NotNull] IBluetoothDeviceInfo aInfo) : base(aLogManager, $"Kiiroo {aInterface.Name}", aInterface, aInfo) { AddMessageHandler <KiirooCmd>(HandleKiirooRawCmd); AddMessageHandler <StopDeviceCmd>(HandleStopDeviceCmd); // ReSharper disable once ConvertIfStatementToSwitchStatement if (aInterface.Name == "PEARL") { AddMessageHandler <VibrateCmd>(HandleVibrateCmd, new MessageAttributes() { FeatureCount = 1 }); AddMessageHandler <SingleMotorVibrateCmd>(HandleSingleMotorVibrateCmd); } else if (aInterface.Name == "ONYX") { AddMessageHandler <LinearCmd>(HandleLinearCmd, new MessageAttributes() { FeatureCount = 1 }); AddMessageHandler <FleshlightLaunchFW12Cmd>(HandleFleshlightLaunchFW12Cmd); } }
public MagicMotion(IButtplugLogManager aLogManager, IBluetoothDeviceInterface aInterface, IBluetoothDeviceInfo aInfo) : base(aLogManager, $"Unknown MagicMotion Device ({aInterface.Name})", aInterface, aInfo) { if (DevInfos.ContainsKey(aInterface.Name)) { Name = $"MagicMotion {DevInfos[aInterface.Name].Name}"; _devInfo = DevInfos[aInterface.Name]; } else { BpLogger.Warn($"Cannot identify device {Name}, defaulting to Smart Mini Vibe settings."); _devInfo = DevInfos["Smart Mini Vibe"]; } AddMessageHandler <SingleMotorVibrateCmd>(HandleSingleMotorVibrateCmd); AddMessageHandler <VibrateCmd>(HandleVibrateCmd, new MessageAttributes { FeatureCount = _devInfo.VibeCount }); AddMessageHandler <StopDeviceCmd>(HandleStopDeviceCmd); }
internal static bool AddUniqueDevice(List <IBluetoothDeviceInfo> list, IBluetoothDeviceInfo bdi) { int idx = BluetoothDeviceInfo.ListIndexOf(list, bdi); AssertManualExistsIf(idx, list, bdi); if (idx == -1) { list.Add(bdi); return(true); } else { Debug.WriteLine("Replace device"); // Check the new info versus the previously discovered device. IBluetoothDeviceInfo bdiOld = list[idx]; Debug.Assert(bdiOld.DeviceAddress.Equals(bdi.DeviceAddress)); //Debug.Assert(deviceName != null); //Debug.Assert(deviceName.Length != 0); //Debug.Assert(bdiOld.ClassOfDevice.Equals(bdi.ClassOfDevice)); // Replace list[idx] = bdi; return(false); } }
public VorzeSA(IButtplugLogManager aLogManager, IBluetoothDeviceInterface aInterface, IBluetoothDeviceInfo aInfo) : base(aLogManager, "Vorze SA Unknown", aInterface, aInfo) { switch (aInterface.Name) { case "CycSA": _deviceType = DeviceType.CycloneOrUnknown; _commandType = CommandType.Rotate; Name = "Vorze A10 Cyclone SA"; break; case "UFOSA": _deviceType = DeviceType.UFO; _commandType = CommandType.Rotate; Name = "Vorze UFO SA"; break; case "Bach smart": _deviceType = DeviceType.Bach; _commandType = CommandType.Vibrate; Name = "Vorze Bach"; break; default: // If the device doesn't identify, warn and try sending it Cyclone packets. BpLogger.Warn($"Vorze product with unrecognized name ({Name}) found. This product may not work with B******g. Contact the developers for more info."); break; } switch (_commandType) { case CommandType.Rotate: AddMessageHandler <VorzeA10CycloneCmd>(HandleVorzeA10CycloneCmd); AddMessageHandler <RotateCmd>(HandleRotateCmd, new MessageAttributes() { FeatureCount = 1 }); break; case CommandType.Vibrate: AddMessageHandler <SingleMotorVibrateCmd>(HandleSingleMotorVibrateCmd); AddMessageHandler <VibrateCmd>(HandleVibrateCmd, new MessageAttributes() { FeatureCount = 1 }); break; default: BpLogger.Error("Unhandled command type."); break; } AddMessageHandler <StopDeviceCmd>(HandleStopDeviceCmd); }
private void LogDeviceAction(string action, IBluetoothDeviceInfo device, bool successful) { _logger.Info("Request to {0} Bluetooth device '{1}' ({2}) was {3}successful", action, device.DeviceName, device.DeviceType.Name, successful ? string.Empty : "un"); }
public BluetoothDevice(IBluetoothDeviceInfo deviceInfo, IBluetoothService bluetoothService, ISchedulerProvider schedulerProvider) { _deviceInfo = deviceInfo; _bluetoothService = bluetoothService; _schedulerProvider = schedulerProvider; _pairDeviceCommand = new DelegateCommand(PairDevice, () => !Status.IsProcessing && !IsAuthenticated); _removeDeviceCommand = new DelegateCommand(RemoveDevice, () => !Status.IsProcessing && _deviceInfo.IsAuthenticated); }
public BluetoothDevice(IBluetoothDeviceInfo deviceInfo, IBluetoothService bluetoothService, ISchedulerProvider schedulerProvider) { _deviceInfo = deviceInfo; _bluetoothService = bluetoothService; _schedulerProvider = schedulerProvider; _pairDeviceCommand = new DelegateCommand(PairDevice, () => !Status.IsProcessing && !IsAuthenticated); _removeDeviceCommand = new DelegateCommand(RemoveDevice, () => !Status.IsProcessing && _deviceInfo.IsAuthenticated); }
public UWPBluetoothDeviceInterface( [NotNull] IButtplugLogManager aLogManager, [NotNull] IBluetoothDeviceInfo aInfo, [NotNull] BluetoothLEDevice aDevice, [NotNull] GattCharacteristic[] aChars) { _bpLogger = aLogManager.GetLogger(GetType()); _bleDevice = aDevice; if (aInfo.Characteristics.Count > 0) { foreach (var item in aInfo.Characteristics) { var c = (from x in aChars where x.Uuid == item.Value select x).ToArray(); if (c.Length != 1) { var err = $"Cannot find characteristic ${item.Value} for device {Name}"; _bpLogger.Error(err); throw new Exception(err); } if (_indexedChars == null) { _indexedChars = new Dictionary <uint, GattCharacteristic>(); } _indexedChars.Add(item.Key, c[0]); } } else { foreach (var c in aChars) { if (c.CharacteristicProperties.HasFlag(GattCharacteristicProperties.Read) || c.CharacteristicProperties.HasFlag(GattCharacteristicProperties.Notify) || c.CharacteristicProperties.HasFlag(GattCharacteristicProperties.Indicate)) { _rxChar = c; } else if (c.CharacteristicProperties.HasFlag(GattCharacteristicProperties.WriteWithoutResponse) || c.CharacteristicProperties.HasFlag(GattCharacteristicProperties.Write)) { _txChar = c; } } } if (_rxChar == null && _txChar == null && _indexedChars == null) { var err = $"No characteristics to connect to for device {Name}"; _bpLogger.Error(err); throw new Exception(err); } _bleDevice.ConnectionStatusChanged += ConnectionStatusChangedHandler; }
private void RefreshDevice(IBluetoothDeviceInfo device) { _logger.Debug("Refreshing Bluetooth device '{0}' ({1}) state", device.DeviceName, device.DeviceType); device.Refresh(); _logger.Debug("Bluetooth device '{0}' ({1}) is {2} connected", device.DeviceName, device.DeviceType, device.IsConnected ? "now" : "not"); }
public Lovense(IButtplugLogManager aLogManager, IBluetoothDeviceInterface aInterface, IBluetoothDeviceInfo aInfo) : base(aLogManager, "Lovense Unknown Device", aInterface, aInfo) { AddMessageHandler <StopDeviceCmd>(HandleStopDeviceCmd); }
public VorzeA10Cyclone(IButtplugLogManager aLogManager, IBluetoothDeviceInterface aInterface, IBluetoothDeviceInfo aInfo) : base(aLogManager, "Vorze A10 Cyclone", aInterface, aInfo) { MsgFuncs.Add(typeof(VorzeA10CycloneCmd), HandleVorzeA10CycloneCmd); MsgFuncs.Add(typeof(StopDeviceCmd), HandleStopDeviceCmd); }
internal static List <IBluetoothDeviceInfo> CreateFromInquiryHandles(List <uint> discoverableHandles, BluesoleilFactory factory) { List <IBluetoothDeviceInfo> result = new List <IBluetoothDeviceInfo>(discoverableHandles.Count); foreach (var hCur in discoverableHandles) { IBluetoothDeviceInfo bdi = CreateFromHandleFromInquiry(hCur, factory); result.Add(bdi); } return(result); }
public Youcups(IButtplugLogManager aLogManager, IBluetoothDeviceInterface aInterface, IBluetoothDeviceInfo aInfo) : base(aLogManager, $"Youcups Device ({friendlyNames[aInterface.Name]})", aInterface, aInfo) { MsgFuncs.Add(typeof(SingleMotorVibrateCmd), HandleSingleMotorVibrateCmd); MsgFuncs.Add(typeof(StopDeviceCmd), HandleStopDeviceCmd); }
public WeVibe(IButtplugLogManager aLogManager, IBluetoothDeviceInterface aInterface, IBluetoothDeviceInfo aInfo) : base(aLogManager, $"WeVibe Device ({aInterface.Name})", aInterface, aInfo) { MsgFuncs.Add(typeof(SingleMotorVibrateCmd), HandleSingleMotorVibrateCmd); MsgFuncs.Add(typeof(StopDeviceCmd), HandleStopDeviceCmd); }
public Kiiroo([NotNull] IButtplugLogManager aLogManager, [NotNull] IBluetoothDeviceInterface aInterface, [NotNull] IBluetoothDeviceInfo aInfo) : base(aLogManager, $"Kiiroo {aInterface.Name}", aInterface, aInfo) { MsgFuncs.Add(typeof(KiirooCmd), HandleKiirooRawCmd); MsgFuncs.Add(typeof(StopDeviceCmd), HandleStopDeviceCmd); }
//-------- public override bool Equals(object obj) { Debug.Fail("who calls this????"); IBluetoothDeviceInfo bdiO = obj as IBluetoothDeviceInfo; Debug.Assert(bdiO != null, "CHANGED/-ING Bdi->IBdi"); if (bdiO != null) { return(this.DeviceAddress.Equals(bdiO.DeviceAddress)); } return(base.Equals(obj)); }
protected ButtplugBluetoothDevice([NotNull] IButtplugLogManager aLogManager, [NotNull] string aName, [NotNull] IBluetoothDeviceInterface aInterface, [NotNull] IBluetoothDeviceInfo aInfo) : base(aLogManager, aName, aInterface.Address.ToString()) { Interface = aInterface; Info = aInfo; Interface.DeviceRemoved += DeviceRemovedHandler; }
private IBluetoothDeviceInfo GetEntryOrThrow(List_IBluetoothDeviceInfo result, BluetoothAddress address) { IBluetoothDeviceInfo bdi = result.Find(delegate(IBluetoothDeviceInfo cur) { return(cur.DeviceAddress == address); }); if (bdi == null) { throw new KeyNotFoundException("No BDI for " + address + "."); } return(bdi); }
public FleshlightLaunch([NotNull] IButtplugLogManager aLogManager, [NotNull] IBluetoothDeviceInterface aInterface, [NotNull] IBluetoothDeviceInfo aInfo) : base(aLogManager, "Fleshlight Launch", aInterface, aInfo) { // Setup message function array MsgFuncs.Add(typeof(FleshlightLaunchFW12Cmd), HandleFleshlightLaunchRawCmd); MsgFuncs.Add(typeof(StopDeviceCmd), HandleStopDeviceCmd); }
//---- public void Merge(IBluetoothDeviceInfo other) { _paired = other.Authenticated; Debug.Assert(this._cod.Equals(other.ClassOfDevice), "ClassOfDevice " + this._cod + " <> " + other.ClassOfDevice); Debug.Assert(this._connected == other.Connected, "Connected " + this._connected + " <> " + other.Connected); Debug.Assert(this._addr == other.DeviceAddress, "DeviceAddress " + this._addr + " <> " + other.DeviceAddress); //Debug.Assert(this._cachedName == other.DeviceName, "DeviceName '" + this._cachedName + "' <> '" + other.DeviceName + "'"); if (this._cachedName == null) { this._cachedName = other.DeviceName; } _remembered = other.Remembered; }
internal static bool EqualsIBDI(IBluetoothDeviceInfo x, object obj) { IBluetoothDeviceInfo y = obj as IBluetoothDeviceInfo; if (y != null) { return(EqualsIBDI(x, y)); } Debug.Fail("Who's comparing " + (obj == null ? "<null>" : "'" + obj.GetType().FullName + "'") + " to BDI!"); return(object.Equals(x, obj)); }
//---- void IBluetoothDeviceInfo.Merge(IBluetoothDeviceInfo other) { _authd = other.Authenticated; Debug.Assert(this._cod.Equals(other.ClassOfDevice), "ClassOfDevice " + this._cod + " <> " + other.ClassOfDevice); //Debug.Assert(this._connd == other.Connected, "Connected " + this._connd + " <> " + other.Connected); Debug.Assert(this._addr == other.DeviceAddress, "DeviceAddress " + this._addr + " <> " + other.DeviceAddress); //Debug.Assert(this._cachedName == other.DeviceName, "DeviceName '" + this._cachedName + "' <> '" + other.DeviceName + "'"); //if (this._name == null || !_hasDeviceName) { // this._name = other.DeviceName; // //TODO this._hasDeviceName = other.HasDeviceName; //} _rmbd = other.Remembered; }
private IObservable<bool> ActionDevice(string actionName, IBluetoothDeviceInfo device, Func<BluetoothAddress, bool> action) { return Observable.Create<bool>(o => { _logger.Info("Request to {0} Bluetooth device {1} ({2})", actionName, device.DeviceName, device.DeviceType.Name); if (!IsSupported) { o.OnError(new InvalidOperationException("Bluetooth not currently supported on this device.")); return Disposable.Empty; } try { var btAddress = new BluetoothAddress(device.DeviceAddress); var successful = action(btAddress); LogDeviceAction(actionName, device, successful); RefreshDevice(device); o.OnNext(successful); o.OnCompleted(); } catch (Exception ex) { _logger.Warn(ex, "Request to {0} Bluetooth device '{1}' ({2}) caused an error", actionName, device.DeviceName, device.DeviceType.Name); o.OnNext(false); o.OnCompleted(); } //Cancellation not supported by BluetoothSecurity api. return Disposable.Empty; }); }
private void RefreshDevice(IBluetoothDeviceInfo device) { _logger.Debug("Refreshing Bluetooth device '{0}' ({1}) state", device.DeviceName, device.DeviceType); device.Refresh(); _logger.Debug("Bluetooth device '{0}' ({1}) is {2} connected", device.DeviceName, device.DeviceType, device.IsConnected ? "now" : "not"); }
public IObservable<bool> PairDevice(IBluetoothDeviceInfo device) { return ActionDevice("pair", device, btAddress => BluetoothSecurity.PairRequest(btAddress, Pin)); }
public IObservable<bool> RemoveDevice(IBluetoothDeviceInfo device) { return ActionDevice("remove", device, BluetoothSecurity.RemoveDevice); }
private void LogDeviceAction(string action, IBluetoothDeviceInfo device, bool successful) { _logger.Info("Request to {0} Bluetooth device '{1}' ({2}) was {3}successful", action, device.DeviceName, device.DeviceType.Name, successful ? string.Empty : "un"); }