diff --git a/java/src/com/bluekitchen/btstack/BTstackClient.java b/java/src/com/bluekitchen/btstack/BTstackClient.java index 84998f8df..ffb25569a 100644 --- a/java/src/com/bluekitchen/btstack/BTstackClient.java +++ b/java/src/com/bluekitchen/btstack/BTstackClient.java @@ -95,6 +95,14 @@ public class BTstackClient { if (socketConnection == null) return false; return socketConnection.sendPacket(packet); } + + public boolean L2CAPSendData(int l2capChannelID, byte[] data){ + return sendPacket(new L2CAPDataPacket(l2capChannelID, data)); + } + + public boolean RFCOMMSendData(int rfcommChannelID, byte[] data){ + return sendPacket(new RFCOMMDataPacket(rfcommChannelID, data)); + } public void disconnect(){ if (socketConnection == null) return; diff --git a/java/src/com/bluekitchen/btstack/L2CAPDataPacket.java b/java/src/com/bluekitchen/btstack/L2CAPDataPacket.java new file mode 100644 index 000000000..85327af27 --- /dev/null +++ b/java/src/com/bluekitchen/btstack/L2CAPDataPacket.java @@ -0,0 +1,12 @@ +package com.bluekitchen.btstack; + +public class L2CAPDataPacket extends Packet { + + public L2CAPDataPacket(int channel, byte data[]){ + super(L2CAP_DATA_PACKET, channel, data, data.length); + } + + public L2CAPDataPacket(Packet packet){ + super(L2CAP_DATA_PACKET, packet.getChannel(), packet.getBuffer(), packet.getPayloadLen()); + } +} \ No newline at end of file diff --git a/java/src/com/bluekitchen/btstack/Packet.java b/java/src/com/bluekitchen/btstack/Packet.java index 868202d42..19e353ec8 100644 --- a/java/src/com/bluekitchen/btstack/Packet.java +++ b/java/src/com/bluekitchen/btstack/Packet.java @@ -4,6 +4,8 @@ public class Packet { public static final int HCI_COMMAND_PACKET = 1; public static final int HCI_EVENT_PACKET = 4; + public static final int L2CAP_DATA_PACKET = 6; + public static final int RFCOMM_DATA_PACKET = 7; protected byte[] data; protected int payloadLen; @@ -31,7 +33,6 @@ public class Packet { this.channel = channel; this.data = new byte[payloadLen]; System.arraycopy(buffer, 0, this.data, 0, payloadLen); - this.data = buffer; this.payloadLen = payloadLen; } diff --git a/java/src/com/bluekitchen/btstack/RFCOMMDataPacket.java b/java/src/com/bluekitchen/btstack/RFCOMMDataPacket.java new file mode 100644 index 000000000..299e7d796 --- /dev/null +++ b/java/src/com/bluekitchen/btstack/RFCOMMDataPacket.java @@ -0,0 +1,13 @@ +package com.bluekitchen.btstack; + +public class RFCOMMDataPacket extends Packet { + + public RFCOMMDataPacket(int channel, byte data[]){ + super(RFCOMM_DATA_PACKET, channel, data, data.length); + } + + public RFCOMMDataPacket(Packet packet){ + super(RFCOMM_DATA_PACKET, packet.getChannel(), packet.getBuffer(), packet.getPayloadLen()); + } +} +