diff --git a/include/btstack/hci_cmds.h b/include/btstack/hci_cmds.h index 6e63fc801..7deaedef8 100644 --- a/include/btstack/hci_cmds.h +++ b/include/btstack/hci_cmds.h @@ -402,9 +402,10 @@ extern "C" { // data: event(8), len(8), rfcomm channel(8), name(var) /** - * TODO: format for variable data + * @format 1T * @param rfcomm_channel * @param name + * @brief SDP_QUERY_RFCOMM_SERVICE 0x92 */ #define SDP_QUERY_RFCOMM_SERVICE 0x92 diff --git a/java/src/com/bluekitchen/btstack/Event.java b/java/src/com/bluekitchen/btstack/Event.java index 3d35819ed..575f7e685 100644 --- a/java/src/com/bluekitchen/btstack/Event.java +++ b/java/src/com/bluekitchen/btstack/Event.java @@ -10,6 +10,11 @@ public class Event extends Packet { super(HCI_EVENT_PACKET, 0, packet.getBuffer(), packet.getPayloadLen()); } + /** + * @param + * @return eventType as int + * @brief + */ public final int getEventType(){ return Util.readByte(data, 0); } diff --git a/java/src/com/bluekitchen/btstack/Util.java b/java/src/com/bluekitchen/btstack/Util.java index 5481a26d1..c56b30ffa 100644 --- a/java/src/com/bluekitchen/btstack/Util.java +++ b/java/src/com/bluekitchen/btstack/Util.java @@ -147,4 +147,13 @@ public class Util { public static byte[] serviceSearchPatternForUUID16(int uuid){ return new byte[] {(byte)0x35, (byte)0x03, (byte)0x19, (byte) (uuid >> 8), (byte) (uuid & 0xff)}; } + + public static byte[] getBytes(byte[] buffer, int offset, int length){ + return Arrays.copyOfRange(buffer, offset, offset + length); + } + + public static String getText(byte[] buffer, int offset, int length){ + byte [] byteData = getBytes(buffer, offset, length); + return new String(byteData, "UTF-8"); + } } diff --git a/tools/generate.py b/tools/generate.py index 4224b4719..f5a108b7d 100755 --- a/tools/generate.py +++ b/tools/generate.py @@ -96,6 +96,9 @@ public class {1} extends Event {{ java_event_getter = \ ''' + /** + * @return {1} as {0} + {rest} public {0} get{1}(){{ {2} }} @@ -172,12 +175,13 @@ def java_type_for_btstack_type(type): 'D' : 'byte []', 'E' : 'byte [] ', 'N' : 'String' , 'P' : 'byte []', 'A' : 'byte []', 'R' : 'byte []', 'S' : 'byte []', 'J' : 'int', 'L' : 'int', 'V' : 'byte []', 'U' : 'BT_UUID', - 'X' : 'GATTService', 'Y' : 'GATTCharacteristic', 'Z' : 'GATTCharacteristicDescriptor' } + 'X' : 'GATTService', 'Y' : 'GATTCharacteristic', 'Z' : 'GATTCharacteristicDescriptor', + 'T' : 'String'} return param_types[type] def size_for_type(type): param_sizes = { '1' : 1, '2' : 2, '3' : 3, '4' : 4, 'H' : 2, 'B' : 6, 'D' : 8, 'E' : 240, 'N' : 248, 'P' : 16, - 'A' : 31, 'S' : -1, 'V': -1, 'J' : 1, 'L' : 2, 'U' : 16, 'X' : 20, 'Y' : 24, 'Z' : 18} + 'A' : 31, 'S' : -1, 'V': -1, 'J' : 1, 'L' : 2, 'U' : 16, 'X' : 20, 'Y' : 24, 'Z' : 18, 'T':-1} return param_sizes[type] def create_command_java(fout, name, ogf, ocf, format, params): @@ -331,6 +335,7 @@ def create_event(event_name, format, args): 'X' : 'return Util.readGattService(data, %u);', 'Y' : 'return Util.readGattCharacteristic(data, %u);', 'Z' : 'return Util.readGattCharacteristicDescriptor(data, %u);', + 'T' : 'int offset = %u; \n return Util.getText(data, offset, getPayloadLen()-offset);', # 'D' : 'Util.storeBytes(data, %u, 8);', # 'E' : 'Util.storeBytes(data, %u, 240);', # 'N' : 'Util.storeString(data, %u, 248);',