private void SetMode(RadioMode value) { switch (value) { case RadioMode.Discoverable: if (Mode == RadioMode.PowerOff) { NativeMethods.BluetoothEnableIncomingConnections(_handle, true); } NativeMethods.BluetoothEnableDiscovery(_handle, true); break; case RadioMode.Connectable: if (Mode == RadioMode.Discoverable) { NativeMethods.BluetoothEnableDiscovery(_handle, false); } else { NativeMethods.BluetoothEnableIncomingConnections(_handle, true); } break; case RadioMode.PowerOff: if (Mode == RadioMode.Discoverable) { NativeMethods.BluetoothEnableDiscovery(_handle, false); } NativeMethods.BluetoothEnableIncomingConnections(_handle, false); break; } }
static void A_GetMode_(StackConsts.GAP_Connectability_Mode conno, StackConsts.GAP_Discoverability_Mode disco, RadioMode expectedMode) { var stuff = Create_Radio_A(new Params { }); // Expect.Once.On(stuff.MockedApi).Method("GAP_Query_Connectability_Mode") .With(stuff.StackId, Is.Out) .Will( new SetIndexedParameterAction(1, conno), Return.Value(BluetopiaError.OK)); if (conno == StackConsts.GAP_Connectability_Mode.ConnectableMode) { // (We don't call GAP_Query_Discoverability_Mode when not conno). Expect.Once.On(stuff.MockedApi).Method("GAP_Query_Discoverability_Mode") .With(stuff.StackId, Is.Out, Is.Out) .Will( new SetIndexedParameterAction(1, disco), new SetIndexedParameterAction(2, (uint)0), Return.Value(BluetopiaError.OK)); } // Assert.AreEqual(expectedMode, stuff.Radio.Mode, "Mode"); // stuff.Mockery_VerifyAllExpectationsHaveBeenMet(); }
private void ChangeRadioMode(string mode) { var command = ""; DJControllerControl note = DJControllerControl.None; DJControllerControl[] switchOff = null; switch (mode) { case "CW": command = "MD3;MD"; _radioMode = RadioMode.CW; note = DJControllerControl.RightPad3; switchOff = new[] { DJControllerControl.RightPad2, DJControllerControl.RightPad1, DJControllerControl.RightPad4 }; break; case "LSB": command = "MD1;MD"; _radioMode = RadioMode.LSB; note = DJControllerControl.RightPad1; switchOff = new[] { DJControllerControl.RightPad2, DJControllerControl.RightPad3, DJControllerControl.RightPad4 }; break; case "USB": command = "MD2;MD"; _radioMode = RadioMode.USB; note = DJControllerControl.RightPad2; switchOff = new[] { DJControllerControl.RightPad1, DJControllerControl.RightPad3, DJControllerControl.RightPad4 }; break; case "FSK": command = "MD6;MD"; _radioMode = RadioMode.FSK; note = DJControllerControl.RightPad4; switchOff = new[] { DJControllerControl.RightPad2, DJControllerControl.RightPad3, DJControllerControl.RightPad1 }; break; } SendToRadio(note, command, switchOff); }
void DisplayBluetoothRadio() { BluetoothRadio myRadio = BluetoothRadio.PrimaryRadio; if (myRadio == null) { Console.WriteLine("No radio hardware or unsupported software stack"); return; } RadioMode mode = myRadio.Mode; /// Warning: LocalAddress can be null if the radio is powered-off. Console.WriteLine("* Radio, address: {0:C}", myRadio.LocalAddress); Console.WriteLine("Mode: " + mode.ToString()); Console.WriteLine("Name: " + myRadio.Name); Console.WriteLine("HCI Version: " + myRadio.HciVersion + ", Revision: " + myRadio.HciRevision); Console.WriteLine("LMP Version: " + myRadio.LmpVersion + ", Subversion: " + myRadio.LmpSubversion); // Too Long: Console.WriteLine("LMP Features: {" + myRadio.LmpFeatures + " }"); ; Console.WriteLine("ClassOfDevice: " + myRadio.ClassOfDevice.ToString() + ", device: " + myRadio.ClassOfDevice.Device.ToString() + " / service: " + myRadio.ClassOfDevice.Service.ToString()); // // // Enable discoverable mode Console.WriteLine(); myRadio.Mode = RadioMode.Discoverable; Console.WriteLine("Radio Mode now: " + myRadio.Mode.ToString()); }
private AudioSource GetNoise(RadioMode mode) { switch (mode) { case RadioMode.F: return(noiseF); case RadioMode.G: return(noiseG); case RadioMode.H: return(noiseH); case RadioMode.J: return(noiseJ); case RadioMode.K: return(noiseK); case RadioMode.L: return(noiseL); default: return(null); } }
void SetRadioMode(RadioMode mode) { try { BluetoothRadio.PrimaryRadio.Mode = mode; } catch (NotSupportedException) { MessageBox.Show("Setting Radio.Mode not supported on this Bluetooth stack."); } }
/// <summary> /// Initialize the status of the Bluetooth stack to connectable /// </summary> /// <returns>True if connected, otherwise false</returns> public override bool Initialize() { try { this.Mode = RadioMode.Connectable; } catch { return(false); } return(true); }
/// <summary> /// Shuts down the bluetooth stack /// </summary> public override bool Dispose() { try { this.Mode = RadioMode.PowerOff; return(true); } catch { return(false); } }
public void SetMode(RadioMode mode) { if (this.mode == mode) { this.mode = null; } else { this.mode = mode; } UpdateRadio(); }
public void Initialize() { WriteRegister(Constants.RX_PW_P0, PacketSize); WriteRegister(Constants.RX_PW_P1, PacketSize); WriteRegister(Constants.EN_AA, 0x00); FlushTransmitBuffer(); FlushReceiveBuffer(); RadioMode = RadioMode.Receive; }
private void SetMode(RadioMode value) { switch (value) { case RadioMode.PowerOff: _adapter.Disable(); break; default: // TODO: Determine if setting ScanMode is possible if (!_adapter.IsEnabled) { _adapter.Enable(); } break; } }
private void SetMode(RadioMode mode) { try { Log.DebugFormat("Setting Crazyradio USB dongle Mode to {0}.", mode); var enableContinuousCarrierMode = (mode == RadioMode.ContinuousCarrierMode) ? 1 : 0; ControlTransferOut(CrazyradioRequest.SetContinuousCarrierMode, (short)enableContinuousCarrierMode, 0, 0, new byte[0]); Log.DebugFormat("Successfully set Crazyradio USB dongle Mode to {0}.", mode); } catch (Exception ex) { var message = string.Format("Failed setting Crazyradio USB dongle mode to {0}.", mode); Log.Error(message); throw new CrazyradioDriverException(message, ex); } }
//--- IBluetoothRadio TestRadioStates(RadioModes expectedModes, RadioMode expectedMode, HardwareStatus expectedStatus, Android.Bluetooth.State state, Android.Bluetooth.ScanMode scanMode) { var values = new AndroidMockValues { Radio_Address = "10:23:45:67:89:ab", Radio_Name = "radio2222", Radio_State = state, Radio_ScanMode = scanMode, }; var f = AndroidTestInfra.Init(values); var r = f.DoGetPrimaryRadio(); // Assert.AreEqual(expectedMode, r.Mode, "r.Mode"); Assert.AreEqual(expectedModes, r.Modes, "r.Modes"); Assert.AreEqual(expectedStatus, r.HardwareStatus, "r.HardwareStatus"); return(r); }
public void SetMode(RadioMode mode, byte filterLevel = 0) { byte[] commandHeader = { (byte)CommandBytes.COMMAND_MODE_SET }; byte[] command; if (Config.RadioID == Radio.IC_R7000 && (mode == RadioMode.MODE_USB || mode == RadioMode.MODE_LSB)) { // Special handling for ICOM 7000R SSB mode byte[] ICR7000SSB = { 0x05, 0x00 }; command = commandHeader.Concat(ICR7000SSB).ToArray(); } else { List <byte> modeSet = new List <byte>(); modeSet.Add((byte)mode); if (filterLevel != 0) { modeSet.Add(filterLevel); } command = commandHeader.Concat(modeSet).ToArray(); } TransmitCommand(command); }
public void TransmitPayload([ReadOnlyArray] byte[] data) { RadioMode = RadioMode.Transmit; _spiDevice.Write(new[] { Constants.W_TX_PAYLOAD, data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[8], data[9] }); ChipEnable(true); ChipEnable(false); RadioMode = RadioMode.Receive; }
private void SetMode(RadioMode value) { var a = _adapter; if (value == RadioMode.PowerOff) { a.SetProperty(BluezRadio.PropertyName.Powered, false); } else if (value == RadioMode.Connectable) { a.SetProperty(BluezRadio.PropertyName.Powered, true); } else if (value == RadioMode.Discoverable) { a.SetProperty(BluezRadio.PropertyName.Powered, true); a.SetProperty(BluezRadio.PropertyName.Discoverable, true); } else { throw new ArgumentException("Unknown enum value: " + value); } Console.WriteLine("DONE SetAdapterMode."); }
/// <summary> /// Initializes a new instance of the <see cref="SenderBluetoothService"/> class. /// </summary> public SenderBluetoothService() { // this guid is random, only need to match in Sender & Receiver // this is like a "key" for the connection! _serviceClassId = new Guid("e0cbf06c-cd8b-4647-bb8a-263b43f0f974"); myRadio = BluetoothRadio.PrimaryRadio; if (myRadio == null) { Console.WriteLine("No radio hardware or unsupported software stack"); //return; } RadioMode mode = myRadio.Mode; // Warning: LocalAddress is null if the radio is powered-off. Console.WriteLine("* Radio, address: {0:C}", myRadio.LocalAddress); // mac is mac address of local bluetooth device localEndpoint = new BluetoothEndPoint(myRadio.LocalAddress, BluetoothService.SerialPort); // client is used to manage connections bluetoothClient = new BluetoothClient(localEndpoint); // component is used to manage device discovery localComponent = new BluetoothComponent(bluetoothClient); }
private static extern int BthGetMode( ref RadioMode dwMode);
// Overload for tune, to include mode public void TuneFrequency(double frequency, RadioMode mode, byte filterLevel = 0) { TuneFrequency(frequency); SetMode(mode, filterLevel); }
/// <summary> /// Shuts down the bluetooth stack /// </summary> public override bool Dispose() { try { this.Mode = RadioMode.PowerOff; return true; } catch { return false; } }
internal static extern int BthGetMode(out RadioMode dwMode);
private void SetMode(RadioMode value) { }
private static extern int BthSetMode( RadioMode dwMode);
public static extern int BthSetMode(RadioMode dwMode);
public static extern int BthGetMode(out RadioMode dwMode);
public static extern int BthGetMode(ref RadioMode dwMode);
private static void SetBluetoothStatus(RadioMode newMode) { BthSetMode(newMode); }
public void SetRadioMode(RadioMode mode) { try { BluetoothRadio.PrimaryRadio.Mode = mode; } catch (NotSupportedException) { System.Windows.MessageBox.Show("Setting Radio.Mode not supported on this Bluetooth stack."); } }
/// <summary> /// Initialize the status of the Bluetooth stack to connectable /// </summary> /// <returns>True if connected, otherwise false</returns> public override bool Initialize() { try { this.Mode = RadioMode.Connectable; } catch { return false; } return true; }
public virtual void ResetDevice() { ModeC = false; Mode = RadioMode.None; }
private void SetSettings() { this.isBluetoothSupported = true; this.radioMode = br.Mode; }
internal static extern int BthSetMode(RadioMode dwMode);
private void SetMode(RadioMode mode) { try { Log.DebugFormat("Setting Crazyradio USB dongle Mode to {0}.", mode); var enableContinuousCarrierMode = (mode == RadioMode.ContinuousCarrierMode) ? 1 : 0; ControlTransferOut(CrazyradioRequest.SetContinuousCarrierMode, (short) enableContinuousCarrierMode, 0, 0, new byte[0]); Log.DebugFormat("Successfully set Crazyradio USB dongle Mode to {0}.", mode); } catch (Exception ex) { var message = string.Format("Failed setting Crazyradio USB dongle mode to {0}.", mode); Log.Error(message); throw new CrazyradioDriverException(message, ex); } }
/// <summary> /// Sends the data to the Receiver. /// </summary> /// <param name="device">The device.</param> /// <param name="content">The content.</param> /// <returns>If was sent or not.</returns> public async Task <bool> Send(Device device, string content) { if (device == null) { throw new ArgumentNullException("device"); } if (string.IsNullOrEmpty(content)) { throw new ArgumentNullException("content"); } // for not block the UI it will run in a different threat var task = Task.Run(() => { using (var bluetoothClient = new BluetoothClient()) { try { BluetoothRadio myRadio = BluetoothRadio.PrimaryRadio; if (myRadio == null) { Console.WriteLine("No radio hardware or unsupported software stack"); //return; } RadioMode mode = myRadio.Mode; // Warning: LocalAddress is null if the radio is powered-off. Console.WriteLine("* Radio, address: {0:C}", myRadio.LocalAddress); // mac is mac address of local bluetooth device BluetoothEndPoint localEndpoint = new BluetoothEndPoint(myRadio.LocalAddress, BluetoothService.SerialPort); // client is used to manage connections BluetoothClient localClient = new BluetoothClient(localEndpoint); // component is used to manage device discovery BluetoothComponent localComponent = new BluetoothComponent(localClient); var ep = new BluetoothEndPoint(device.DeviceInfo.DeviceAddress, _serviceClassId); // get stream for send the data var bluetoothStream = bluetoothClient.GetStream(); // if all is ok to send if (bluetoothClient.Connected && bluetoothStream != null) { // write the data in the stream var buffer = System.Text.Encoding.UTF8.GetBytes(content); bluetoothStream.Write(buffer, 0, buffer.Length); bluetoothStream.Flush(); bluetoothStream.Close(); return(true); } return(false); } catch { // the error will be ignored and the send data will report as not sent // for understood the type of the error, handle the exception } } return(false); }); return(await task); }