diff --git a/doc/manual/docs/how_to.md b/doc/manual/docs/how_to.md index ee4594258..3dafd1d88 100644 --- a/doc/manual/docs/how_to.md +++ b/doc/manual/docs/how_to.md @@ -26,21 +26,36 @@ The file *btstack_config.h* contains three parts: +General features: + +#define | Description +-----------------------------------|------------------------------------- +HAVE_EHCILL | TI CC256x/WL18xx with eHCILL is used +HAVE_MALLOC | Use dynamic memory + + +Embedded platform features: + #define | Platform | Description ------------------------------|-------|------------------------------------ -HAVE_B300_MAPPED_TO_2000000 | posix | Hack to use serial port with 2 mbps -HAVE_B600_MAPPED_TO_3000000 | posix | Hack to use serial port with 3 mpbs -HAVE_EHCILL | cc256x radio | TI CC256x/WL18xx with eHCILL is used -HAVE_MALLOC | | dynamic memory used -HAVE_POSIX_FILE_IO | posix | POSIX File i/o used for hci dump -HAVE_STDIO | | STDIN is available for examples -HAVE_TICK | embedded | System provides tick interrupt -HAVE_TIME | posix | System provides time function -HAVE_TIME_MS | embedded | System provides time in milliseconds +-----------------------------------|--------------|------------------------------------ +HAVE_TIME_MS | embedded | System provides time in milliseconds +HAVE_TICK | embedded | System provides tick interrupt + +POSIX platform features: + +#define | Platform | Description +-----------------------------------|--------------|------------------------------------ +HAVE_POSIX_B300_MAPPED_TO_2000000 | posix | Hack to use serial port with 2 mbps +HAVE_POSIX_B600_MAPPED_TO_3000000 | posix | Hack to use serial port with 3 mpbs +HAVE_POSIX_FILE_IO | posix | POSIX File i/o used for hci dump +HAVE_POSIX_STDIN | | STDIN is available for examples +HAVE_POSIX_TIME | posix | System provides time function +BTstack features: + #define | Description ------------------|--------------------------------------------- ENABLE_CLASSIC | Enable Classic related code in HCI and L2CAP @@ -213,7 +228,7 @@ The data sources are standard File Descriptors. In the run loop execute implemen select() call is used to wait for file descriptors to become ready to read or write, while waiting for the next timeout. -To enable the use of timers, make sure that you defined HAVE_TIME in the config file. +To enable the use of timers, make sure that you defined HAVE_POSIX_TIME in the config file. ### Run loop CoreFoundation (OS X/iOS) @@ -221,7 +236,7 @@ This run loop directly maps BTstack's data source and timer source with CoreFoun It supports ready to read and write similar to the POSIX implementation. The call to *btstack_run_loop_execute()* then just calls *CFRunLoopRun()*. -To enable the use of timers, make sure that you defined HAVE_TIME in the config file. +To enable the use of timers, make sure that you defined HAVE_POSIX_TIME in the config file. ### Run loop WICED diff --git a/example/hfp_ag_demo.c b/example/hfp_ag_demo.c index 6ce600177..3b97fb92b 100644 --- a/example/hfp_ag_demo.c +++ b/example/hfp_ag_demo.c @@ -44,7 +44,7 @@ * * @text This HFP Audio Gateway example demonstrates how to receive * an output from a remote HFP Hands-Free (HF) unit, and, - * if HAVE_STDIO is defined, how to control the HFP HF. + * if HAVE_POSIX_STDIN is defined, how to control the HFP HF. */ // ***************************************************************************** @@ -56,7 +56,7 @@ #include #include "btstack.h" -#ifdef HAVE_STDIO +#ifdef HAVE_POSIX_STDIN #include "stdin_support.h" #endif @@ -126,7 +126,7 @@ static int getDeviceIndexForAddress( bd_addr_t addr){ return -1; } -#ifdef HAVE_STDIO +#ifdef HAVE_POSIX_STDIN static void start_scan(void){ printf("Starting inquiry scan..\n"); hci_send_cmd(&hci_inquiry, HCI_INQUIRY_LAP, INQUIRY_INTERVAL, 0); @@ -252,7 +252,7 @@ static void inquiry_packet_handler (uint8_t packet_type, uint8_t *packet, uint16 } } // GAP INQUIRY END -#ifdef HAVE_STDIO +#ifdef HAVE_POSIX_STDIN // prototypes static void show_usage(void); @@ -671,7 +671,7 @@ int btstack_main(int argc, const char * argv[]){ printf("SDP service record size: %u\n", de_get_len( hfp_service_buffer)); sdp_register_service(hfp_service_buffer); -#ifdef HAVE_STDIO +#ifdef HAVE_POSIX_STDIN btstack_stdin_setup(stdin_process); #endif // turn on! diff --git a/example/hfp_hf_demo.c b/example/hfp_hf_demo.c index 901eeab99..23202f823 100644 --- a/example/hfp_hf_demo.c +++ b/example/hfp_hf_demo.c @@ -45,7 +45,7 @@ * * @text This HFP Hands-Free example demonstrates how to receive * an output from a remote HFP audio gateway (AG), and, - * if HAVE_STDIO is defined, how to control the HFP AG. + * if HAVE_POSIX_STDIN is defined, how to control the HFP AG. */ // ***************************************************************************** @@ -59,7 +59,7 @@ #include #include "btstack.h" -#ifdef HAVE_STDIO +#ifdef HAVE_POSIX_STDIN #include "stdin_support.h" #endif @@ -67,7 +67,7 @@ uint8_t hfp_service_buffer[150]; const uint8_t rfcomm_channel_nr = 1; const char hfp_hf_service_name[] = "BTstack HFP HF Demo"; -#ifdef HAVE_STDIO +#ifdef HAVE_POSIX_STDIN static bd_addr_t device_addr = {0xD8,0xBb,0x2C,0xDf,0xF1,0x08}; // prototypes static void show_usage(void); @@ -78,7 +78,7 @@ static uint16_t indicators[1] = {0x01}; char cmd; -#ifdef HAVE_STDIO +#ifdef HAVE_POSIX_STDIN // Testig User Interface static void show_usage(void){ @@ -534,7 +534,7 @@ int btstack_main(int argc, const char * argv[]){ printf("SDP service record size: %u\n", de_get_len(hfp_service_buffer)); sdp_register_service(hfp_service_buffer); -#ifdef HAVE_STDIO +#ifdef HAVE_POSIX_STDIN btstack_stdin_setup(stdin_process); #endif // turn on! diff --git a/example/hsp_ag_demo.c b/example/hsp_ag_demo.c index 4bc4c7438..c512277e2 100644 --- a/example/hsp_ag_demo.c +++ b/example/hsp_ag_demo.c @@ -45,7 +45,7 @@ * @text This example implements a HSP Audio Gateway device that sends and receives * audio signal over HCI SCO. It demonstrates how to receive * an output from a remote headset (HS), and, - * if HAVE_STDIO is defined, how to control the HS. + * if HAVE_POSIX_STDIN is defined, how to control the HS. */ // ***************************************************************************** @@ -59,7 +59,7 @@ #include #include "btstack.h" -#ifdef HAVE_STDIO +#ifdef HAVE_POSIX_STDIN #include "stdin_support.h" #endif @@ -132,7 +132,7 @@ static void show_usage(void){ printf("---\n"); } -#ifdef HAVE_STDIO +#ifdef HAVE_POSIX_STDIN static void stdin_process(btstack_data_source_t *ds, btstack_data_source_callback_type_t callback_type){ char buffer; read(ds->fd, &buffer, 1); @@ -329,7 +329,7 @@ int btstack_main(int argc, const char * argv[]){ hsp_ag_init(rfcomm_channel_nr); hsp_ag_register_packet_handler(packet_handler); -#ifdef HAVE_STDIO +#ifdef HAVE_POSIX_STDIN btstack_stdin_setup(stdin_process); #endif diff --git a/example/hsp_hs_demo.c b/example/hsp_hs_demo.c index 53f0c369a..e85ed6cb7 100644 --- a/example/hsp_hs_demo.c +++ b/example/hsp_hs_demo.c @@ -45,7 +45,7 @@ * @text This example implements a HSP Headset device that sends and receives * audio signal over HCI SCO. It demonstrates how to receive * an output from a remote audio gateway (AG), and, - * if HAVE_STDIO is defined, how to control the AG. + * if HAVE_POSIX_STDIN is defined, how to control the AG. */ // ***************************************************************************** @@ -59,7 +59,7 @@ #include #include "btstack.h" -#ifdef HAVE_STDIO +#ifdef HAVE_POSIX_STDIN #include "stdin_support.h" #endif @@ -132,7 +132,7 @@ static void show_usage(void){ printf("---\n"); } -#ifdef HAVE_STDIO +#ifdef HAVE_POSIX_STDIN static void stdin_process(btstack_data_source_t *ds, btstack_data_source_callback_type_t callback_type){ char buffer; read(ds->fd, &buffer, 1); @@ -338,7 +338,7 @@ int btstack_main(int argc, const char * argv[]){ hsp_hs_init(rfcomm_channel_nr); hsp_hs_register_packet_handler(packet_handler); -#ifdef HAVE_STDIO +#ifdef HAVE_POSIX_STDIN btstack_stdin_setup(stdin_process); #endif diff --git a/platform/embedded/btstack_run_loop_embedded.h b/platform/embedded/btstack_run_loop_embedded.h index 29cb8a243..eb0c1674f 100644 --- a/platform/embedded/btstack_run_loop_embedded.h +++ b/platform/embedded/btstack_run_loop_embedded.h @@ -47,7 +47,7 @@ #include "btstack_linked_list.h" #include "btstack_run_loop.h" -#ifdef HAVE_TIME +#ifdef HAVE_POSIX_TIME #include #endif #include diff --git a/platform/posix/hci_transport_h4_posix.c b/platform/posix/hci_transport_h4_posix.c index 1bd0b8c58..35800063d 100644 --- a/platform/posix/hci_transport_h4_posix.c +++ b/platform/posix/hci_transport_h4_posix.c @@ -132,10 +132,10 @@ static int h4_set_baudrate(uint32_t baudrate){ #endif // Hacks to switch to 2/3 mbps on FTDI FT232 chipsets // requires special config in Info.plist or Registry -#ifdef HAVE_B300_MAPPED_TO_2000000 +#ifdef HAVE_POSIX_B300_MAPPED_TO_2000000 case 2000000: brate=B300; break; #endif -#ifdef HAVE_B600_MAPPED_TO_3000000 +#ifdef HAVE_POSIX_B600_MAPPED_TO_3000000 case 3000000: brate=B600; break; #endif #ifdef HAVE_B1200_MAPPED_TO_2000000 diff --git a/port/daemon/configure.ac b/port/daemon/configure.ac index dd4d04c6c..e72fcbfd1 100644 --- a/port/daemon/configure.ac +++ b/port/daemon/configure.ac @@ -126,7 +126,7 @@ echo "#define __BTSTACK_CONFIG" >> btstack_config.h echo >> btstack_config.h echo "// Port related features" >> btstack_config.h -echo "#define HAVE_TIME" >> btstack_config.h +echo "#define HAVE_POSIX_TIME" >> btstack_config.h echo "#define HAVE_MALLOC" >> btstack_config.h echo >> btstack_config.h diff --git a/port/ios/btstack_config.h b/port/ios/btstack_config.h index 7dbe37750..f59011dfe 100644 --- a/port/ios/btstack_config.h +++ b/port/ios/btstack_config.h @@ -9,7 +9,7 @@ #define HAVE_MALLOC #define HAVE_PLATFORM_IPHONE_OS #define HAVE_POSIX_FILE_IO -#define HAVE_TIME +#define HAVE_POSIX_TIME // BTstack features that can be enabled #define ENABLE_CLASSIC diff --git a/port/libusb/btstack_config.h b/port/libusb/btstack_config.h index 988603175..c42181cbe 100644 --- a/port/libusb/btstack_config.h +++ b/port/libusb/btstack_config.h @@ -8,8 +8,8 @@ // Port related features #define HAVE_MALLOC #define HAVE_POSIX_FILE_IO -#define HAVE_STDIO -#define HAVE_TIME +#define HAVE_POSIX_STDIN +#define HAVE_POSIX_TIME // BTstack features that can be enabled #define ENABLE_BLE diff --git a/port/mtk/btstack_config.h b/port/mtk/btstack_config.h index 8bd68f6bb..61ea24a50 100644 --- a/port/mtk/btstack_config.h +++ b/port/mtk/btstack_config.h @@ -8,7 +8,7 @@ // Port related features #define HAVE_MALLOC #define HAVE_POSIX_FILE_IO -#define HAVE_TIME +#define HAVE_POSIX_TIME // BTstack features that can be enabled #define ENABLE_BLE diff --git a/port/posix-h4/btstack_config.h b/port/posix-h4/btstack_config.h index a77a43914..1906cc488 100644 --- a/port/posix-h4/btstack_config.h +++ b/port/posix-h4/btstack_config.h @@ -8,8 +8,8 @@ // Port related features #define HAVE_MALLOC #define HAVE_POSIX_FILE_IO -#define HAVE_STDIO -#define HAVE_TIME +#define HAVE_POSIX_STDIN +#define HAVE_POSIX_TIME // BTstack features that can be enabled #define ENABLE_BLE diff --git a/port/posix-h4/main.c b/port/posix-h4/main.c index e6b9c358a..c79dcc6e3 100644 --- a/port/posix-h4/main.c +++ b/port/posix-h4/main.c @@ -98,7 +98,7 @@ static void use_fast_uart(void){ #if defined(HAVE_B1200_MAPPED_TO_3000000) || defined(HAVE_B300_MAPPED_TO_3000000) printf("Using 3000000 baud.\n"); config.baudrate_main = 3000000; -#elif defined(HAVE_B1200_MAPPED_TO_2000000) || defined(HAVE_B300_MAPPED_TO_2000000) +#elif defined(HAVE_B1200_MAPPED_TO_2000000) || defined(HAVE_POSIX_B300_MAPPED_TO_2000000) printf("Using 2000000 baud.\n"); config.baudrate_main = 2000000; #else diff --git a/src/btstack_run_loop.h b/src/btstack_run_loop.h index 2532cccc8..e4b5020d7 100644 --- a/src/btstack_run_loop.h +++ b/src/btstack_run_loop.h @@ -50,7 +50,7 @@ #include -#ifdef HAVE_TIME +#ifdef HAVE_POSIX_TIME #include #endif @@ -81,7 +81,7 @@ typedef struct btstack_data_source { typedef struct btstack_timer_source { btstack_linked_item_t item; -#ifdef HAVE_TIME +#ifdef HAVE_POSIX_TIME struct timeval timeout; // <-- next timeout #endif #if defined(HAVE_TICK) || defined(HAVE_TIME_MS) diff --git a/src/hci.c b/src/hci.c index 91658386f..23606a919 100644 --- a/src/hci.c +++ b/src/hci.c @@ -207,7 +207,7 @@ hci_connection_t * hci_connection_for_bd_addr_and_type(bd_addr_t addr, bd_addr_ static void hci_connection_timeout_handler(btstack_timer_source_t *timer){ hci_connection_t * connection = (hci_connection_t *) btstack_run_loop_get_timer_context(timer); -#ifdef HAVE_TIME +#ifdef HAVE_POSIX_TIME struct timeval tv; gettimeofday(&tv, NULL); if (tv.tv_sec >= connection->timestamp.tv_sec + HCI_CONNECTION_TIMEOUT_MS/1000) { @@ -232,7 +232,7 @@ static void hci_connection_timeout_handler(btstack_timer_source_t *timer){ } static void hci_connection_timestamp(hci_connection_t *connection){ -#ifdef HAVE_TIME +#ifdef HAVE_POSIX_TIME gettimeofday(&connection->timestamp, NULL); #endif #ifdef HAVE_TICK diff --git a/src/hci.h b/src/hci.h index dc0822965..b209b1d81 100644 --- a/src/hci.h +++ b/src/hci.h @@ -386,7 +386,7 @@ typedef struct { btstack_timer_source_t timeout; -#ifdef HAVE_TIME +#ifdef HAVE_POSIX_TIME // timer struct timeval timestamp; #endif diff --git a/test/btstack_config.h b/test/btstack_config.h index 5a9b61dce..b6c0644f9 100644 --- a/test/btstack_config.h +++ b/test/btstack_config.h @@ -7,7 +7,7 @@ // Port related features #define HAVE_INIT_SCRIPT -#define HAVE_TIME +#define HAVE_POSIX_TIME #define HAVE_MALLOC // BTstack features that can be enabled diff --git a/test/btstack_link_key_db/btstack_config.h b/test/btstack_link_key_db/btstack_config.h index f3369627a..6ff70b29b 100644 --- a/test/btstack_link_key_db/btstack_config.h +++ b/test/btstack_link_key_db/btstack_config.h @@ -7,7 +7,7 @@ // Port related features #define HAVE_INIT_SCRIPT -#define HAVE_TIME +#define HAVE_POSIX_TIME // BTstack features that can be enabled #define ENABLE_BLE