Package org.javabluetooth.stack.l2cap

Examples of org.javabluetooth.stack.l2cap.L2CAPLink


        super.receive_HCI_Event_Remote_Name_Request_Complete(eventPacket);
    }

    /** @see org.javabluetooth.stack.BluetoothStack#open_L2CAPChannel(long, short) */
    public void connectL2CAPChannel(L2CAPChannel channel, RemoteDevice remoteDevice, short psm) throws HCIException {
        L2CAPLink link = hciTransport.getL2CAPLink(remoteDevice.bdAddrLong, remoteDevice.pageScanRepMode,
            remoteDevice.pageScanMode, remoteDevice.clockOffset);
        link.connectL2CAPChannel(channel, psm);
    }
View Full Code Here


        short clockOffset                = (short)((((short)packet[15]) & 0xff) | (((short)packet[16]) & 0xff) << 8);
        BluetoothTCPChannel l2capChannel = new BluetoothTCPChannel(this, channelHandel);
        if (channels[channelHandel] != null) channels[channelHandel].close();
        channels[channelHandel] = l2capChannel;
        try {
            L2CAPLink link = hciTransport.getL2CAPLink(remoteAddress, pageScanRepMode, pageScanMode, clockOffset);
            link.connectL2CAPChannel(l2capChannel, psm);
        }
        catch (HCIException e) {
            l2capChannel.channelState = L2CAPChannel.FAILED;
            System.err.println("BluetoothTCPServerThread: Failed to Connect L2CAP Channel. " + e);
        }
View Full Code Here

    }

    public L2CAPLink getL2CAPLink(long remoteAddress, byte pageScanRepMode, byte pageScanMode,
        short clockOffset) throws HCIException {
            Long remoteAddressLong = new Long(remoteAddress);
            L2CAPLink link = (L2CAPLink)remoteAddresses.get(remoteAddressLong);
            if (link == null) {
                byte connResult = send_HCI_LC_Create_Connection(remoteAddress, (short)0x8000, pageScanRepMode, pageScanMode,
                    clockOffset, (byte)0x01);
                if (connResult != 0) throw new HCIException("Create Connection failed. (" + connResult + ")");
                short timeout = 0;
View Full Code Here

    }

    private void receive_HCI_Event_Connection_Complete(byte[] eventPacket) {
        if (eventPacket[3] == 0) //is connected
        {
            L2CAPLink conn = new L2CAPLink(this, eventPacket);
            Debug.println(1, "HCI: Received Connection Complete Event: " + conn.remoteAddress);
        }
        else Debug.println(1, "HCI: Received Connection Complete Event: Create Connection failed.");
    }
View Full Code Here

        else Debug.println(1, "HCI: Received Connection Complete Event: Create Connection failed.");
    }

    private void receive_HCI_Event_Disconnection_Complete(byte[] eventPacket) {
        short connectionHandle = (short)(((short)eventPacket[5] & 0x0f) << 8 | ((short)eventPacket[4] & 0xff));
        L2CAPLink link = (L2CAPLink)connectionHandels.remove(new Short(connectionHandle));
        if (link != null) {
            Debug.println(1, "HCI: Received Disconnection Complete Event: " + link.remoteAddress);
            link.wasDisconnected();
        }
        else Debug.println(1, "HCI: Received Disconnection Complete Event.");
    }
View Full Code Here

        if (opCode == commandResponseOpCode) { commandResponse = packetData; }
    }

    private void receive_HCI_Data_Packet(byte[] data) {
        short handle = (short)(((short)data[2] & 0x0f) << 8 | ((short)data[1] & 0xff));
        L2CAPLink link = (L2CAPLink)connectionHandels.get(new Short(handle));
        if (link != null) {
            link.receiveData(data);
            Debug.println(1, "HCI: Received Data Packet from " + link.remoteAddress);
        }
        else System.err.println("HCI: Unable to deliver Data Packet. No open link with handle " + handle + ". : " +
                Debug.printByteArray(data));
    }
View Full Code Here

TOP

Related Classes of org.javabluetooth.stack.l2cap.L2CAPLink

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.