From 2d5d8e4c7c53be4efcb9bd931815400c985512d6 Mon Sep 17 00:00:00 2001 From: "matthias.ringwald@gmail.com" Date: Fri, 5 Sep 2014 10:33:09 +0000 Subject: [PATCH] added support for hci command event return parameters - variable size data until end of packet --- java/generate.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/java/generate.py b/java/generate.py index 11d4c499d..b936c9d63 100755 --- a/java/generate.py +++ b/java/generate.py @@ -107,6 +107,12 @@ java_event_getter_data = \ System.arraycopy(data, {1}, result, 0, len); return result;''' +java_event_getter_remaining_data = \ +'''int len = getPayloadLen() - {0}; + byte[] result = new byte[len]; + System.arraycopy(data, {0}, result, 0, len); + return result;''' + java_event_to_string = \ ''' public String toString(){{ @@ -119,6 +125,7 @@ java_event_to_string = \ }} ''' + # global variables/defines package='com.bluekitchen.btstack' gen_path = 'gen/' + package.replace('.', '/') @@ -162,7 +169,8 @@ def read_defines(infile): def java_type_for_btstack_type(type): param_types = { '1' : 'int', '2' : 'int', '3' : 'int', '4' : 'long', 'H' : 'int', 'B' : 'BD_ADDR', - 'D' : 'byte []', 'E' : 'byte [] ', 'N' : 'String' , 'P' : 'byte []', 'A' : 'byte []', 'S' : 'byte []', + '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' } return param_types[type] @@ -341,7 +349,11 @@ def create_event(event_name, format, args): # just remember name if f in ['L','J']: length_name = camel_case(arg) - if f == 'V': + if f == 'R': + # remaining data + access = java_event_getter_remaining_data.format(offset) + size = 0 + elif f == 'V': access = java_event_getter_data.format(length_name, offset) size = 0 else: