This commit is contained in:
Matthias Ringwald 2015-07-01 16:25:36 +02:00
commit 386bc99d83
15 changed files with 268 additions and 102 deletions

View File

@ -1,4 +1,6 @@
all:
rm -rf tmp
mkdir tmp
./update_apis.py
./update_listings.py
rm -rf docs_tmp
@ -8,13 +10,14 @@ all:
./markdown2mkdocs.py
rm -rf docs_tmp
mkdocs build --clean
./mkdocs2html.py
mkdir -p latex
cp -r docs/picts latex
./markdown2pdf.py
cp btstack_gettingstarted.tex latex
cd latex && pdflatex btstack_gettingstarted.tex && pdflatex btstack_gettingstarted.tex
mv latex/btstack_gettingstarted.pdf btstack.pdf
rm -rf latex
rm -rf latex tmp

View File

@ -71,7 +71,7 @@ setups, toolchains, programmers, and init scripts.
The quickest way to try BTstack is on a Linux or OS X system with an
additional USB Bluetooth module. The Makefile [platforms/libusb]() in requires
[pkg-config](http://www.freedesktop.org/wiki/Software/pkg-config/)
and [libusb-1.0](www.libusb.org) or higher to be
and [libusb-1.0](http://libusb.info) or higher to be
installed.
On Linux, its usually necessary to run the examples as root as the

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python
import sys, yaml
import os, re
import sys, os, shutil
import re, yaml
def insert_anchor(mdout, reference):
mdout.write("<a name=\"" + reference + "\"></a>\n\n")
@ -9,12 +9,6 @@ def insert_anchor(mdout, reference):
def insert_reference(mdout, text, link):
mdout.write("")
def fcopy(source_file, dest_file):
with open(dest_file, 'w') as mdout:
with open(source_file, 'r') as mdin:
for line in mdin:
mdout.write(line)
def process_sections(temp_file, dest_file):
with open(dest_file, 'w') as mdout:
with open(temp_file, 'r') as mdin:
@ -26,7 +20,7 @@ def process_sections(temp_file, dest_file):
else:
mdout.write(line)
fcopy(dest_file, temp_file)
shutil.copyfile(dest_file, temp_file)
return
def process_figures(temp_file, dest_file):
@ -44,7 +38,7 @@ def process_figures(temp_file, dest_file):
md_reference = "[below](#"+figure_ref.group(2)+")"
line = line.replace(figure_ref.group(1), md_reference)
mdout.write(line)
fcopy(dest_file, temp_file)
shutil.copyfile(dest_file, temp_file)
return
def process_tables(temp_file, dest_file):
@ -62,7 +56,7 @@ def process_tables(temp_file, dest_file):
md_reference = "[below](#"+table_ref.group(2)+")"
line = line.replace(table_ref.group(1), md_reference)
mdout.write(line)
fcopy(dest_file, temp_file)
shutil.copyfile(dest_file, temp_file)
return
@ -78,7 +72,7 @@ def process_listings(temp_file, dest_file):
mdout.write("\n")
else:
mdout.write(line)
fcopy(dest_file, temp_file)
shutil.copyfile(dest_file, temp_file)
return

46
docs/manual/mkdocs2html.py Executable file
View File

@ -0,0 +1,46 @@
#!/usr/bin/env python
import os, sys, shutil, re, pickle
def writeCodeBlock(aout, code, references):
for function_name, url in references.items():
html_link = '<a href="' + url + '">' + function_name + '</a>'
#print "before:" + code + "\n\n"
code = code.replace(function_name, html_link)
aout.write(code)
def main(argv):
html_path = "btstack/examples/examples/"
html_tmppath = html_path + "tmp/"
html_in = html_path + "index.html"
html_tmp = html_tmppath + "index.html"
references = pickle.load(open( "tmp/references.p", "rb" ))
os.mkdir(html_tmppath)
codeblock = 0
codeblock_end = 0
with open(html_in, 'r') as fin:
with open(html_tmp, 'w') as fout:
for line in fin:
if not codeblock:
fout.write(line)
if re.match('.*<pre><code>.*',line):
codeblock = 1
continue
writeCodeBlock(fout,line, references)
# check if codeblock ended
if re.match('.*</code></pre>.*',line):
codeblock = 0
shutil.copyfile(html_tmp, html_in)
shutil.rmtree(html_tmppath)
if __name__ == "__main__":
main(sys.argv[1:])

View File

@ -1,26 +1,32 @@
#!/usr/bin/env python
import os, sys, getopt, re
import os, sys, getopt, re, pickle
class State:
SearchStartAPI = 0
RemoveEmptyLinesAfterAPIStart = 1
SearchEndAPI = 2
DoneAPI = 3
SearchEndAPI = 1
DoneAPI = 2
# [file_name, api_title, api_lable]
apis = [
["include/btstack/run_loop.h", "Run Loop", "runLoop"],
["src/bnep.h", "BNEP", "bnep"],
["src/btstack_memory.h","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_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"],
["ble/gatt_client.h", "GATT Client", "gattClient"],
["src/pan.h", "PAN", "pan"],
["src/bnep.h", "BNEP", "bnep"],
["src/gap.h", "GAP", "gap"],
["ble/sm.h", "SM", "sm"]
["src/sdp_query_util.h","SDP Query Util","sdpQueryUtil"],
["include/btstack/sdp_util.h","SDP Utils", "sdpUtil"]
]
functions = {}
@ -35,12 +41,12 @@ api_header = """
api_ending = """
"""
code_ref = """[FNAME](GITHUBFPATH#LLINENR)"""
code_ref = """GITHUBFPATH#LLINENR"""
def codeReference(fname, githubfolder, filepath, linenr):
global code_ref
ref = code_ref.replace("FNAME",fname)
ref = ref.replace("GITHUB", githubfolder)
ref = code_ref.replace("GITHUB", githubfolder)
ref = ref.replace("FPATH", filepath)
ref = ref.replace("LINENR", str(linenr))
return ref
@ -60,19 +66,13 @@ def writeAPI(apifile, btstackfolder, apis, mk_codeidentation):
with open(api_filename, 'rb') as fin:
for line in fin:
if state == State.SearchStartAPI:
parts = re.match('\s*(/\*).*API_START.*(\*/)',line)
parts = re.match('.*API_START.*',line)
if parts:
state = State.RemoveEmptyLinesAfterAPIStart
state = State.SearchEndAPI
continue
if state == State.RemoveEmptyLinesAfterAPIStart:
if line == "" or line == "\n":
continue
state = State.SearchEndAPI
continue
if state == State.SearchEndAPI:
parts = re.match('\s*(/\*).*API_END.*(\*/)',line)
parts = re.match('.*API_END.*',line)
if parts:
state = State.DoneAPI
continue
@ -80,47 +80,44 @@ def writeAPI(apifile, btstackfolder, apis, mk_codeidentation):
continue
def writeIndex(indexfile, btstackfolder, apis, githubfolder):
def createIndex(btstackfolder, apis, githubfolder):
global typedefs, functions
with open(indexfile, 'w') as fout:
for api_tuple in apis:
api_filename = btstackfolder + api_tuple[0]
api_title = api_tuple[1]
api_lable = api_tuple[2]
for api_tuple in apis:
api_filename = btstackfolder + api_tuple[0]
api_title = api_tuple[1]
api_lable = api_tuple[2]
linenr = 0
with open(api_filename, 'rb') as fin:
typedefFound = 0
linenr = 0
with open(api_filename, 'rb') as fin:
typedefFound = 0
for line in fin:
linenr = linenr + 1
typedef = re.match('.*typedef\s+struct.*', line)
for line in fin:
linenr = linenr + 1
# search typedef struct begin
typedef = re.match('.*typedef\s+struct.*', line)
if typedef:
typedefFound = 1
# search typedef struct begin
if typedefFound:
typedef = re.match('}\s*(.*);\n', line)
if typedef:
typedefFound = 1
continue
typedefFound = 0
typedefs[typedef.group(1)] = codeReference(typedef.group(1), githubfolder, api_tuple[0], linenr)
continue
if typedefFound:
typedef = re.match('}\s*(.*);\n', line)
if typedef:
typedefFound = 0
typedefs[typedef.group(1)] = codeReference(typedef.group(1), githubfolder, api_tuple[0], linenr)
fout.write(typedefs[typedef.group(1)]+"\n")
continue
function = re.match('.*typedef\s+void\s+\(\s*\*\s*(.*?)\)\(.*', line)
if function:
functions[function.group(1)] = codeReference(function.group(1), githubfolder, api_tuple[0], linenr)
continue
function = re.match('.*typedef\s+void\s+\(\s*\*\s*(.*?)\)\(.*', line)
if function:
functions[function.group(1)] = codeReference(function.group(1), githubfolder, api_tuple[0], linenr)
fout.write(functions[function.group(1)]+"\n")
continue
function = re.match('.*?\s+\*?\s*(.*?)\(.*\(*.*;', line)
if function:
functions[function.group(1)] = codeReference(function.group(1), githubfolder, api_tuple[0], linenr)
continue
function = re.match('.*?\s+\*?\s*(.*?)\(.*\(*.*;', line)
if function:
functions[function.group(1)] = codeReference(function.group(1), githubfolder, api_tuple[0], linenr)
fout.write(functions[function.group(1)]+"\n")
continue
def main(argv):
@ -157,7 +154,17 @@ def main(argv):
print 'Index file is :', indexfile
writeAPI(apifile, btstackfolder, apis, mk_codeidentation)
# writeIndex(indexfile, btstackfolder, apis, githubfolder)
createIndex(btstackfolder, apis, githubfolder)
references = functions.copy()
references.update(typedefs)
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__":

View File

@ -252,8 +252,8 @@ int btstack_main(int argc, const char * argv[]) {
hci_register_packet_handler(packet_handler);
// turn on!
hci_power_control(HCI_POWER_ON);
hci_power_control(HCI_POWER_ON);
return 0;
}
/* LISTING_END */

View File

@ -47,29 +47,8 @@
#if defined __cplusplus
extern "C" {
#endif
typedef enum {
DE_NIL = 0,
DE_UINT,
DE_INT,
DE_UUID,
DE_STRING,
DE_BOOL,
DE_DES,
DE_DEA,
DE_URL
} de_type_t;
typedef enum {
DE_SIZE_8 = 0,
DE_SIZE_16,
DE_SIZE_32,
DE_SIZE_64,
DE_SIZE_128,
DE_SIZE_VAR_8,
DE_SIZE_VAR_16,
DE_SIZE_VAR_32
} de_size_t;
/* API_START */
// UNIVERSAL ATTRIBUTE DEFINITIONS
#define SDP_ServiceRecordHandle 0x0000
@ -126,6 +105,30 @@ typedef enum {
#define SDP_vMessage 0x06
#define SDP_OBEXFileTypeAny 0xFF
typedef enum {
DE_NIL = 0,
DE_UINT,
DE_INT,
DE_UUID,
DE_STRING,
DE_BOOL,
DE_DES,
DE_DEA,
DE_URL
} de_type_t;
typedef enum {
DE_SIZE_8 = 0,
DE_SIZE_16,
DE_SIZE_32,
DE_SIZE_64,
DE_SIZE_128,
DE_SIZE_VAR_8,
DE_SIZE_VAR_16,
DE_SIZE_VAR_32
} de_size_t;
// MARK: DateElement
void de_dump_data_element(uint8_t * record);
int de_get_len(uint8_t *header);
@ -171,6 +174,8 @@ void sdp_create_spp_service(uint8_t *service, int service_id, const char *n
void sdp_normalize_uuid(uint8_t *uuid, uint32_t shortUUID);
int sdp_has_blueooth_base_uuid(uint8_t * uuid128);
/* API_END */
#if defined __cplusplus
}
#endif

View File

@ -36,7 +36,6 @@
*/
/*
* btstsack_memory.h
*

View File

@ -37,7 +37,6 @@
/*
* btstsack_memory.h
*
@ -64,8 +63,15 @@ extern "C" {
#include "gatt_client.h"
#endif
/* API_START */
/**
* @brief Initializes BTstack memory pools.
*/
void btstack_memory_init(void);
/* API_END */
// hci_connection
hci_connection_t * btstack_memory_hci_connection_get(void);
void btstack_memory_hci_connection_free(hci_connection_t *hci_connection);

View File

@ -60,19 +60,46 @@ extern "C" {
#define LOG_LEVEL_INFO 1
#define LOG_LEVEL_ERROR 2
/* API_START */
typedef enum {
HCI_DUMP_BLUEZ = 0,
HCI_DUMP_PACKETLOGGER,
HCI_DUMP_STDOUT
} hci_dump_format_t;
/*
* @brief
*/
void hci_dump_open(const char *filename, hci_dump_format_t format);
/*
* @brief
*/
void hci_dump_set_max_packets(int packets); // -1 for unlimited
/*
* @brief
*/
void hci_dump_packet(uint8_t packet_type, uint8_t in, uint8_t *packet, uint16_t len);
/*
* @brief
*/
void hci_dump_log(int log_level, const char * format, ...);
/*
* @brief
*/
void hci_dump_enable_log_level(int log_level, int enable);
/*
* @brief
*/
void hci_dump_close(void);
/* API_END */
#ifdef __AVR__
void hci_dump_log_P(int log_level, PGM_P format, ...);
#endif

View File

@ -52,7 +52,9 @@
#if defined __cplusplus
extern "C" {
#endif
/* API_START */
/* HCI packet types */
typedef struct {
int (*open)(void *transport_config);
@ -75,12 +77,34 @@ typedef struct {
// inline various hci_transport_X.h files
/*
* @brief
*/
extern hci_transport_t * hci_transport_h4_instance(void);
/*
* @brief
*/
extern hci_transport_t * hci_transport_h4_dma_instance(void);
/*
* @brief
*/
extern hci_transport_t * hci_transport_h4_iphone_instance(void);
/*
* @brief
*/
extern hci_transport_t * hci_transport_h5_instance(void);
/*
* @brief
*/
extern hci_transport_t * hci_transport_usb_instance(void);
/* API_END */
// support for "enforece wake device" in h4 - used by iOS power management
extern void hci_transport_h4_iphone_set_enforce_wake_device(char *path);

View File

@ -49,6 +49,8 @@
extern "C" {
#endif
/* API_START */
typedef struct {
// management
@ -70,11 +72,24 @@ typedef struct {
} remote_device_db_t;
/*
* @brief
*/
extern remote_device_db_t remote_device_db_iphone;
/*
* @brief
*/
extern const remote_device_db_t remote_device_db_memory;
/*
* @brief
*/
extern const remote_device_db_t remote_device_db_fs;
// MARK: non-persisten implementation
/* API_END */
// MARK: non-persistent implementation
#include <btstack/linked_list.h>
#define MAX_NAME_LEN 32
typedef struct {

View File

@ -68,6 +68,8 @@ typedef struct de_state {
void de_state_init(de_state_t * state);
int de_state_size(uint8_t eventByte, de_state_t *de_state);
/* API_START */
// SDP Parser
// Basic SDP Query event type
typedef struct sdp_query_event {
@ -100,20 +102,42 @@ typedef struct sdp_query_service_record_handle_event {
} sdp_query_service_record_handle_event_t;
#endif
/*
* @brief
*/
void sdp_parser_init(void);
/*
* @brief
*/
void sdp_parser_handle_chunk(uint8_t * data, uint16_t size);
#ifdef HAVE_SDP_EXTRA_QUERIES
/*
* @brief
*/
void sdp_parser_init_service_attribute_search(void);
/*
* @brief
*/
void sdp_parser_init_service_search(void);
/*
* @brief
*/
void sdp_parser_handle_service_search(uint8_t * data, uint16_t total_count, uint16_t record_handle_count);
#endif
void sdp_parser_handle_done(uint8_t status);
// Registers a callback to receive attribute value data and parse complete event.
/*
* @brief Registers a callback to receive attribute value data and parse complete event.
*/
void sdp_parser_register_callback(void (*sdp_callback)(sdp_query_event_t * event));
/* API_END */
#if defined __cplusplus
}

View File

@ -47,16 +47,25 @@
extern "C" {
#endif
/* API_START */
// Returns service search pattern for given UUID
/*
* @brief Returns service search pattern for given UUID
*/
uint8_t* create_service_search_pattern_for_uuid(uint16_t uuid);
// Searches SDP records on a remote device for all services with
// a given UUID.
/*
* @brief Searches SDP records on a remote device for all services with a given UUID.
*/
void sdp_general_query_for_uuid(bd_addr_t remote, uint16_t uuid);
/*
* @brief
*/
void sdp_general_query_for_uuid128(bd_addr_t remote, uint8_t* uuid);
/* API_END */
#if defined __cplusplus
}
#endif

View File

@ -66,7 +66,14 @@ extern "C" {
#include "gatt_client.h"
#endif
/* API_START */
/**
* @brief Initializes BTstack memory pools.
*/
void btstack_memory_init(void);
/* API_END */
"""
hfile_header_end = """