public byte[] SetConnectionType(L2CAP.PSM connectionType, byte lsb, byte msb, ushort dcid = 0) { switch (connectionType) { case L2CAP.PSM.HID_Command: _l2CapCommandHandle[0] = new BthHandle(lsb, msb); _l2CapCommandHandle[1] = new BthHandle(Dcid++); return(_l2CapCommandHandle[1].Bytes); case L2CAP.PSM.HID_Interrupt: CanStartService = true; _l2CapInterruptHandle[0] = new BthHandle(lsb, msb); _l2CapInterruptHandle[1] = new BthHandle(Dcid++); return(_l2CapInterruptHandle[1].Bytes); case L2CAP.PSM.HID_Service: IsServiceStarted = true; CanStartService = false; _l2CapServiceHandle[0] = new BthHandle(lsb, msb); _l2CapServiceHandle[1] = new BthHandle(dcid); return(_l2CapServiceHandle[1].Bytes); } throw new ArgumentException("Invalid L2CAP Connection Type"); }
public BthConnection(BthHandle hciHandle) { InitializeComponent(); HciHandle = hciHandle; DeviceAddress = PhysicalAddress.None; }
public int HCI_Disconnect(BthHandle handle) { var buffer = new byte[6]; buffer[3] = handle.Bytes[0]; buffer[4] = (byte)(handle.Bytes[1] ^ 0x20); buffer[5] = 0x13; return(HCI_Command(HCI.Command.HCI_Disconnect, buffer)); }
private int HCI_Set_Connection_Encryption(BthHandle Handle) { var buffer = new byte[6]; buffer[3] = Handle.Bytes[0]; buffer[4] = (byte)(Handle.Bytes[1] ^ 0x20); buffer[5] = 0x01; return(HCI_Command(HCI.Command.HCI_Set_Connection_Encryption, buffer)); }
private void Remove(byte lsb, byte msb) { var connection = new BthHandle(lsb, msb); if (!_connected.ContainsKey(connection)) { return; } _connected[connection].Stop(); _connected.Remove(connection); }
/// <summary> /// Returns an existing Bluetooth connection based on an incoming buffer. /// </summary> /// <param name="lsb">Least significant bit in byte stream.</param> /// <param name="msb">Most significant bit in byte stream.</param> /// <returns>The Bluetooth connection, null if not found.</returns> private BthDevice GetConnection(byte lsb, byte msb) { var hande = new BthHandle(lsb, msb); return((!_connected.Any() | !_connected.ContainsKey(hande)) ? null : _connected[hande]); }
public BthConnection(BthHandle hciHandle) { HciHandle = hciHandle; DeviceAddress = PhysicalAddress.None; }
public L2CapDataPacket(byte[] buffer) { RawBytes = buffer; Handle = new BthHandle(RawBytes[0], RawBytes[1]); }
public BthConnection(BthHandle hciHandle) { InitializeComponent(); HciHandle = hciHandle; }