mirror of
https://github.com/bluekitchen/btstack.git
synced 2024-12-29 09:26:08 +00:00
added l2cap, rfcomm data packet & send
This commit is contained in:
parent
a8c5ee2406
commit
5600833267
@ -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;
|
||||
|
12
java/src/com/bluekitchen/btstack/L2CAPDataPacket.java
Normal file
12
java/src/com/bluekitchen/btstack/L2CAPDataPacket.java
Normal file
@ -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());
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
|
13
java/src/com/bluekitchen/btstack/RFCOMMDataPacket.java
Normal file
13
java/src/com/bluekitchen/btstack/RFCOMMDataPacket.java
Normal file
@ -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());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user