void blueT_DeviceInquired(GT.Bluetooth sender, string macAddress, string name) { Debug.Print("inquired"); if (name.IndexOf("HomeSecurity") > -1) { blueT.HostMode.InputPinCode("1234"); Debug.Print("Conectado a un dispositivo!!!"); blueT.HostMode.Connect(macAddress); } }
public Devices(Button button, Wifi wifi) { this.wifi = wifi; blueT = new Gadgeteer.Bluetooth(8); this.button = button; t = new GT.Timer(100); t.Tick += new GT.Timer.TickEventHandler(start); t.Start(); Debug.Print("devices"); }
void blueT_DataReceived(GT.Bluetooth sender, string data) { if (!Scheduler.Instance().canContinue()) { return; } int index = data.IndexOf(bluetoothMessage); if (index > -1) { wifi.SendData("device", data.Substring(index + bluetoothMessage.Length, data.Length - (index + bluetoothMessage.Length + 1)), "sendMovement"); } }
internal Host(Bluetooth bluetooth) { Debug.Print("Host mode"); this.bluetooth = bluetooth; bluetooth.serialPort.Write("\r\n+STWMOD=1\r\n"); }
internal Client(Bluetooth bluetooth) { Debug.Print("Client Mode"); this.bluetooth = bluetooth; bluetooth.serialPort.Write("\r\n+STWMOD=0\r\n"); }
/// <summary> /// Raises the <see cref="PinRequested"/> event. /// </summary> /// <param name="sender">The object that raised the event.</param> protected virtual void OnPinRequested(Bluetooth sender) { if (onPinRequested == null) onPinRequested = new PinRequestedHandler(OnPinRequested); if (Program.CheckAndInvoke(PinRequested, onPinRequested, sender)) { PinRequested(sender); } }
/// <summary> /// Raises the <see cref="PinRequested"/> event. /// </summary> /// <param name="sender">The object that raised the event.</param> /// <param name="macAddress">MAC Address of the inquired device</param> /// <param name="name">Name of the inquired device</param> protected virtual void OnDeviceInquired(Bluetooth sender, string macAddress, string name) { if (onDeviceInquired == null) onDeviceInquired = new DeviceInquiredHandler(OnDeviceInquired); if (Program.CheckAndInvoke(DeviceInquired, onDeviceInquired, sender, macAddress, name)) { DeviceInquired(sender, macAddress, name); } }
/// <summary> /// Raises the <see cref="DataReceived"/> event. /// </summary> /// <param name="sender">The object that raised the event.</param> /// <param name="data">Data string received by the Bluetooth module</param> protected virtual void OnDataReceived(Bluetooth sender, string data) { if (onDataReceived == null) onDataReceived = new DataReceivedHandler(OnDataReceived); if (Program.CheckAndInvoke(DataReceived, onDataReceived, sender, data)) { DataReceived(sender, data); } }
/// <summary> /// Raises the <see cref="BluetoothStateChanged"/> event. /// </summary> /// <param name="sender">The object that raised the event.</param> /// <param name="btState">Current state of the Bluetooth module</param> protected virtual void OnBluetoothStateChanged(Bluetooth sender, BluetoothState btState) { if (onBluetoothStateChanged == null) onBluetoothStateChanged = new BluetoothStateChangedHandler(OnBluetoothStateChanged); if (Program.CheckAndInvoke(BluetoothStateChanged, onBluetoothStateChanged, sender, btState)) { BluetoothStateChanged(sender, btState); } }
private void blueT_BluetoothStateChanged(GT.Bluetooth sender, GT.Bluetooth.BluetoothState btState) { Debug.Print(btState.ToString()); }
void bluetooth_DataReceived(Bluetooth sender, string data) { Debug.Print(data); sender.ClientMode.SendLine(data); //echoes the data back to the device. }
void bluetooth_BluetoothStateChanged(Bluetooth sender, Bluetooth.BluetoothState btState) { Debug.Print(btState.ToString()); }