mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-20 18:40:31 +00:00
annotate/update api, handle multiline function def
This commit is contained in:
parent
99e736a0a8
commit
c4350632cc
@ -50,6 +50,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* API_START */
|
||||
|
||||
typedef struct ad_context {
|
||||
uint8_t * data;
|
||||
uint8_t offset;
|
||||
@ -70,6 +72,7 @@ uint8_t * ad_iterator_get_data(ad_context_t * context);
|
||||
int ad_data_contains_uuid16(uint8_t ad_len, uint8_t * ad_data, uint16_t uuid);
|
||||
int ad_data_contains_uuid128(uint8_t ad_len, uint8_t * ad_data, uint8_t * uuid128);
|
||||
|
||||
/* API_END */
|
||||
|
||||
#if defined __cplusplus
|
||||
}
|
||||
|
@ -44,6 +44,8 @@ extern "C" {
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/* API_START */
|
||||
|
||||
typedef struct ancs_event{
|
||||
uint8_t type;
|
||||
uint16_t handle;
|
||||
@ -56,6 +58,8 @@ void ancs_client_hci_event_handler (uint8_t packet_type, uint16_t channel, uint8
|
||||
void ancs_client_register_callback(void (*handler)(ancs_event_t * event));
|
||||
const char * ancs_client_attribute_name_for_id(int id);
|
||||
|
||||
/* API_END */
|
||||
|
||||
#if defined __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
66
ble/att.h
66
ble/att.h
@ -185,58 +185,58 @@ typedef int (*att_write_callback_t)(uint16_t con_handle, uint16_t attribute_hand
|
||||
|
||||
// MARK: ATT Operations
|
||||
|
||||
/*
|
||||
* @brief setup ATT database
|
||||
*/
|
||||
/*
|
||||
* @brief setup ATT database
|
||||
*/
|
||||
void att_set_db(uint8_t const * db);
|
||||
|
||||
/*
|
||||
* @brief set callback for read of dynamic attributes
|
||||
* @param callback
|
||||
*/
|
||||
/*
|
||||
* @brief set callback for read of dynamic attributes
|
||||
* @param callback
|
||||
*/
|
||||
void att_set_read_callback(att_read_callback_t callback);
|
||||
|
||||
/*
|
||||
* @brief set callback for write of dynamic attributes
|
||||
* @param callback
|
||||
*/
|
||||
/*
|
||||
* @brief set callback for write of dynamic attributes
|
||||
* @param callback
|
||||
*/
|
||||
void att_set_write_callback(att_write_callback_t callback);
|
||||
|
||||
/*
|
||||
* @brief debug helper, dump ATT database to stdout using log_info
|
||||
*/
|
||||
/*
|
||||
* @brief debug helper, dump ATT database to stdout using log_info
|
||||
*/
|
||||
void att_dump_attributes(void);
|
||||
|
||||
/*
|
||||
* @brief process ATT request against database and put response into response buffer
|
||||
* @param att_connection used for mtu and security properties
|
||||
* @param request_buffer, request_len: ATT request from clinet
|
||||
* @param response_buffer for result
|
||||
* @returns len of data in response buffer. 0 = no response
|
||||
*/
|
||||
/*
|
||||
* @brief process ATT request against database and put response into response buffer
|
||||
* @param att_connection used for mtu and security properties
|
||||
* @param request_buffer, request_len: ATT request from clinet
|
||||
* @param response_buffer for result
|
||||
* @returns len of data in response buffer. 0 = no response
|
||||
*/
|
||||
uint16_t att_handle_request(att_connection_t * att_connection,
|
||||
uint8_t * request_buffer,
|
||||
uint16_t request_len,
|
||||
uint8_t * response_buffer);
|
||||
|
||||
/*
|
||||
* @brief setup value notification in response buffer for a given handle and value
|
||||
* @param att_connection
|
||||
* @param value, value_len: new attribute value
|
||||
* @param response_buffer for notification
|
||||
*/
|
||||
/*
|
||||
* @brief setup value notification in response buffer for a given handle and value
|
||||
* @param att_connection
|
||||
* @param value, value_len: new attribute value
|
||||
* @param response_buffer for notification
|
||||
*/
|
||||
uint16_t att_prepare_handle_value_notification(att_connection_t * att_connection,
|
||||
uint16_t handle,
|
||||
uint8_t *value,
|
||||
uint16_t value_len,
|
||||
uint8_t * response_buffer);
|
||||
|
||||
/*
|
||||
* @brief setup value indication in response buffer for a given handle and value
|
||||
* @param att_connection
|
||||
* @param value, value_len: new attribute value
|
||||
* @param response_buffer for indication
|
||||
*/
|
||||
/*
|
||||
* @brief setup value indication in response buffer for a given handle and value
|
||||
* @param att_connection
|
||||
* @param value, value_len: new attribute value
|
||||
* @param response_buffer for indication
|
||||
*/
|
||||
uint16_t att_prepare_handle_value_indication(att_connection_t * att_connection,
|
||||
uint16_t handle,
|
||||
uint8_t *value,
|
||||
|
@ -55,6 +55,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* API_START */
|
||||
|
||||
/**
|
||||
* @brief Init ATT DB storage
|
||||
*/
|
||||
@ -94,6 +96,8 @@ uint8_t * att_db_util_get_address(void);
|
||||
*/
|
||||
uint16_t att_db_util_get_size(void);
|
||||
|
||||
/* API_END */
|
||||
|
||||
#if defined __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -45,12 +45,13 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* @brief setup ATT server
|
||||
* @param db attribute database created by compile-gatt.ph
|
||||
* @param read_callback, see att.h, can be NULL
|
||||
* @param write_callback, see attl.h, can be NULL
|
||||
*/
|
||||
/* API_START */
|
||||
/*
|
||||
* @brief setup ATT server
|
||||
* @param db attribute database created by compile-gatt.ph
|
||||
* @param read_callback, see att.h, can be NULL
|
||||
* @param write_callback, see attl.h, can be NULL
|
||||
*/
|
||||
void att_server_init(uint8_t const * db, att_read_callback_t read_callback, att_write_callback_t write_callback);
|
||||
|
||||
/*
|
||||
@ -67,16 +68,18 @@ int att_server_can_send(void);
|
||||
|
||||
/*
|
||||
* @brief notify client about attribute value change
|
||||
* @ereturns 0 if ok, error otherwise
|
||||
* @return 0 if ok, error otherwise
|
||||
*/
|
||||
int att_server_notify(uint16_t handle, uint8_t *value, uint16_t value_len);
|
||||
|
||||
/*
|
||||
* @brief indicate value change to client. client is supposed to reply with an indication_response
|
||||
* @ereturns 0 if ok, error otherwise
|
||||
* @return 0 if ok, error otherwise
|
||||
*/
|
||||
int att_server_indicate(uint16_t handle, uint8_t *value, uint16_t value_len);
|
||||
|
||||
/* API_END */
|
||||
|
||||
#if defined __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -44,6 +44,8 @@ extern "C" {
|
||||
|
||||
#include <btstack/utils.h>
|
||||
|
||||
/* API_START */
|
||||
|
||||
typedef enum {
|
||||
GAP_RANDOM_ADDRESS_TYPE_OFF = 0,
|
||||
GAP_RANDOM_ADDRESS_NON_RESOLVABLE,
|
||||
@ -96,10 +98,8 @@ void gap_advertisements_set_data(uint8_t advertising_data_length, uint8_t * adve
|
||||
* @param direct_address
|
||||
* @param channel_map
|
||||
* @param filter_policy
|
||||
*
|
||||
* @note own_address_type is used from gap_random_address_set_mode
|
||||
*/
|
||||
|
||||
void gap_advertisements_set_params(uint16_t adv_int_min, uint16_t adv_int_max, uint8_t adv_type,
|
||||
uint8_t direct_address_typ, bd_addr_t direct_address, uint8_t channel_map, uint8_t filter_policy);
|
||||
|
||||
@ -109,6 +109,8 @@ void gap_advertisements_set_params(uint16_t adv_int_min, uint16_t adv_int_max, u
|
||||
*/
|
||||
void gap_advertisements_enable(int enabled);
|
||||
|
||||
/* API_END */
|
||||
|
||||
#if defined __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -60,6 +60,7 @@ extern "C" {
|
||||
|
||||
// LE Device db interface
|
||||
|
||||
/* API_START */
|
||||
|
||||
/**
|
||||
* @brief init
|
||||
@ -155,6 +156,8 @@ void le_device_db_local_counter_set(int index, uint32_t counter);
|
||||
*/
|
||||
void le_device_db_remove(int index);
|
||||
|
||||
/* API_END */
|
||||
|
||||
#if defined __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
2
ble/sm.c
2
ble/sm.c
@ -2205,7 +2205,7 @@ void gap_random_address_set_update_period(int period_ms){
|
||||
gap_random_address_update_start();
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* @brief Set Advertisement Paramters
|
||||
* @param adv_int_min
|
||||
* @param adv_int_max
|
||||
|
@ -8,24 +8,30 @@ class State:
|
||||
|
||||
# [file_name, api_title, api_lable]
|
||||
apis = [
|
||||
["ble/ad_parser.h", "BLE Advertisements Parser", "advParser"],
|
||||
["ble/ancs_client_lib.h", "BLE ANCS Client", "ancsClient"],
|
||||
["ble/att_db_util.h", "BLE ATT Database", "attDb"],
|
||||
["ble/att_server.h", "BLE ATT Server", "attServer"],
|
||||
["ble/gap_le.h", "BLE GAP", "gapLE"],
|
||||
["ble/gatt_client.h", "BLE GATT Client", "gattClient"],
|
||||
["ble/le_device_db.h", "BLE Device Database", "leDeviceDb"],
|
||||
["ble/sm.h", "BLE Security Manager", "sm"],
|
||||
["src/bnep.h", "BNEP", "bnep"],
|
||||
["src/btstack_memory.h","Memory Management","btMemory"],
|
||||
["src/btstack_memory.h","BTstack Memory Management","btMemory"],
|
||||
["src/gap.h", "GAP", "gap"],
|
||||
["ble/gatt_client.h", "GATT Client", "gattClient"],
|
||||
["src/hci.h", "HCI", "hci"],
|
||||
["src/hci_dump.h","Logging","hciTrace"],
|
||||
["src/hci_dump.h","HCI Logging","hciTrace"],
|
||||
["src/hci_transport.h","HCI Transport","hciTransport"],
|
||||
["src/l2cap.h", "L2CAP", "l2cap"],
|
||||
["src/pan.h", "PAN", "pan"],
|
||||
["src/remote_device_db.h","Remote Device DB","rdevDb"],
|
||||
["src/rfcomm.h", "RFCOMM", "rfcomm"],
|
||||
["include/btstack/run_loop.h", "Run Loop", "runLoop"],
|
||||
["ble/sm.h", "SM", "sm"],
|
||||
["src/sdp.h", "SDP", "sdp"],
|
||||
["src/sdp_client.h", "SDP Client", "sdpClient"],
|
||||
["src/sdp_parser.h","SDP Parser","sdpParser"],
|
||||
["src/sdp_query_rfcomm.h", "SDP RFCOMM Query", "sdpQueries"],
|
||||
["src/sdp_query_util.h","SDP Query Util","sdpQueryUtil"],
|
||||
["src/sdp_query_util.h","SDP Query Utils","sdpQueryUtil"],
|
||||
["include/btstack/sdp_util.h","SDP Utils", "sdpUtil"]
|
||||
]
|
||||
|
||||
@ -82,7 +88,7 @@ def writeAPI(apifile, btstackfolder, apis, mk_codeidentation):
|
||||
|
||||
def createIndex(btstackfolder, apis, githubfolder):
|
||||
global typedefs, functions
|
||||
|
||||
|
||||
for api_tuple in apis:
|
||||
api_filename = btstackfolder + api_tuple[0]
|
||||
api_title = api_tuple[1]
|
||||
@ -91,16 +97,49 @@ def createIndex(btstackfolder, apis, githubfolder):
|
||||
linenr = 0
|
||||
with open(api_filename, 'rb') as fin:
|
||||
typedefFound = 0
|
||||
|
||||
multiline_function_def = 0
|
||||
state = State.SearchStartAPI
|
||||
|
||||
for line in fin:
|
||||
if state == State.DoneAPI:
|
||||
continue
|
||||
|
||||
linenr = linenr + 1
|
||||
|
||||
if state == State.SearchStartAPI:
|
||||
parts = re.match('.*API_START.*',line)
|
||||
if parts:
|
||||
state = State.SearchEndAPI
|
||||
continue
|
||||
|
||||
if state == State.SearchEndAPI:
|
||||
parts = re.match('.*API_END.*',line)
|
||||
if parts:
|
||||
state = State.DoneAPI
|
||||
continue
|
||||
|
||||
if multiline_function_def:
|
||||
function_end = re.match('.*;\n', line)
|
||||
if function_end:
|
||||
multiline_function_def = 0
|
||||
continue
|
||||
|
||||
param = re.match(".*@brief.*", line)
|
||||
if param:
|
||||
continue
|
||||
param = re.match(".*@param.*", line)
|
||||
if param:
|
||||
continue
|
||||
param = re.match(".*@return.*", line)
|
||||
if param:
|
||||
continue
|
||||
|
||||
# search typedef struct begin
|
||||
typedef = re.match('.*typedef\s+struct.*', line)
|
||||
if typedef:
|
||||
typedefFound = 1
|
||||
|
||||
# search typedef struct begin
|
||||
# search typedef struct end
|
||||
if typedefFound:
|
||||
typedef = re.match('}\s*(.*);\n', line)
|
||||
if typedef:
|
||||
@ -108,16 +147,20 @@ def createIndex(btstackfolder, apis, githubfolder):
|
||||
typedefs[typedef.group(1)] = codeReference(typedef.group(1), githubfolder, api_tuple[0], linenr)
|
||||
continue
|
||||
|
||||
function = re.match('.*typedef\s+void\s+\(\s*\*\s*(.*?)\)\(.*', line)
|
||||
ref_function = re.match('.*typedef\s+void\s+\(\s*\*\s*(.*?)\)\(.*', line)
|
||||
if ref_function:
|
||||
functions[ref_function.group(1)] = codeReference(ref_function.group(1), githubfolder, api_tuple[0], linenr)
|
||||
continue
|
||||
|
||||
function = re.match('.*?\s+\*?\s*(.*?)\(.*\(*.*;\n', line)
|
||||
if function:
|
||||
functions[function.group(1)] = codeReference(function.group(1), githubfolder, api_tuple[0], linenr)
|
||||
continue
|
||||
|
||||
function = re.match('.*?\s+\*?\s*(.*?)\(.*\(*.*;', line)
|
||||
function = re.match('.*?\s+\*?\s*(.*?)\(.*\(*.*', line)
|
||||
if function:
|
||||
multiline_function_def = 1
|
||||
functions[function.group(1)] = codeReference(function.group(1), githubfolder, api_tuple[0], linenr)
|
||||
continue
|
||||
|
||||
|
||||
|
||||
def main(argv):
|
||||
@ -162,10 +205,8 @@ def main(argv):
|
||||
with open(indexfile, 'w') as fout:
|
||||
for function, reference in references.items():
|
||||
fout.write("[" + function + "](" + reference + ")\n")
|
||||
|
||||
|
||||
|
||||
pickle.dump(references, open( "tmp/references.p", "wb" ) )
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv[1:])
|
||||
|
@ -111,7 +111,6 @@ static void le_counter_setup(void){
|
||||
|
||||
// setup ATT server
|
||||
att_server_init(profile_data, att_read_callback, att_write_callback);
|
||||
att_dump_attributes();
|
||||
|
||||
// setup advertisements
|
||||
uint16_t adv_int_min = 0x0030;
|
||||
|
@ -115,8 +115,7 @@ static void le_streamer_setup(void){
|
||||
// setup ATT server
|
||||
att_server_init(profile_data, NULL, att_write_callback);
|
||||
att_server_register_packet_handler(packet_handler);
|
||||
att_dump_attributes();
|
||||
|
||||
|
||||
// setup advertisements
|
||||
uint16_t adv_int_min = 0x0030;
|
||||
uint16_t adv_int_max = 0x0030;
|
||||
|
@ -282,7 +282,7 @@ int btstack_main(void)
|
||||
|
||||
// setup ATT server
|
||||
att_server_init(profile_data, att_read_callback, att_write_callback);
|
||||
att_dump_attributes();
|
||||
|
||||
// set one-shot timer
|
||||
heartbeat.process = &heartbeat_handler;
|
||||
run_loop_set_timer(&heartbeat, HEARTBEAT_PERIOD_MS);
|
||||
|
Loading…
x
Reference in New Issue
Block a user