From df33c7a6dc495cf85196cca3b51121d0ff393a23 Mon Sep 17 00:00:00 2001 From: "matthias.ringwald" Date: Sun, 8 Aug 2010 18:17:48 +0000 Subject: [PATCH] add const to hci_cmd_t for bt_send_cmd, too. Add C++ link protection to public headers --- include/btstack/btstack.h | 10 +++++++++- include/btstack/hci_cmds.h | 7 +++++++ include/btstack/linked_list.h | 10 +++++++++- include/btstack/run_loop.h | 9 +++++++++ include/btstack/sdp_util.h | 10 +++++++++- include/btstack/utils.h | 9 +++++++++ src/btstack.c | 2 +- src/hci.h | 4 ++-- 8 files changed, 55 insertions(+), 6 deletions(-) diff --git a/include/btstack/btstack.h b/include/btstack/btstack.h index f11de4fa1..1d7951c2b 100644 --- a/include/btstack/btstack.h +++ b/include/btstack/btstack.h @@ -46,6 +46,10 @@ #include +#if defined __cplusplus +extern "C" { +#endif + // Default TCP port for BTstack daemon #define BTSTACK_PORT 13333 @@ -66,7 +70,7 @@ int bt_open(); int bt_close(); // send hci cmd packet -int bt_send_cmd(hci_cmd_t *cmd, ...); +int bt_send_cmd(const hci_cmd_t *cmd, ...); // register packet handler -- channel only valid for l2cap and rfcomm packets // @returns old packet handler @@ -75,3 +79,7 @@ btstack_packet_handler_t bt_register_packet_handler(btstack_packet_handler_t han void bt_send_acl(uint8_t * data, uint16_t len); void bt_send_l2cap(uint16_t local_cid, uint8_t *data, uint16_t len); + +#if defined __cplusplus +} +#endif diff --git a/include/btstack/hci_cmds.h b/include/btstack/hci_cmds.h index 8b000705a..106a42bdf 100644 --- a/include/btstack/hci_cmds.h +++ b/include/btstack/hci_cmds.h @@ -39,6 +39,10 @@ #include +#if defined __cplusplus +extern "C" { +#endif + /** * packet types - used in BTstack and over the H4 UART interface */ @@ -243,3 +247,6 @@ extern const hci_cmd_t sdp_register_service_record; extern const hci_cmd_t sdp_unregister_service_record; +#if defined __cplusplus +} +#endif diff --git a/include/btstack/linked_list.h b/include/btstack/linked_list.h index 8ee711d45..251809487 100644 --- a/include/btstack/linked_list.h +++ b/include/btstack/linked_list.h @@ -37,6 +37,10 @@ #pragma once +#if defined __cplusplus +extern "C" { +#endif + typedef struct linked_item { struct linked_item *next; // <-- next element in list, or NULL void *user_data; // <-- pointer to struct base @@ -51,4 +55,8 @@ void linked_list_add(linked_list_t * list, linked_item_t *item); // <-- a void linked_list_add_tail(linked_list_t * list, linked_item_t *item); // <-- add item to list as last element int linked_list_remove(linked_list_t * list, linked_item_t *item); // <-- remove item from list -void test_linked_list(); \ No newline at end of file +void test_linked_list(); + +#if defined __cplusplus +} +#endif diff --git a/include/btstack/run_loop.h b/include/btstack/run_loop.h index 94fd8912c..c6e9d6b30 100644 --- a/include/btstack/run_loop.h +++ b/include/btstack/run_loop.h @@ -41,6 +41,10 @@ #include +#if defined __cplusplus +extern "C" { +#endif + typedef enum { RUN_LOOP_POSIX = 1, RUN_LOOP_COCOA, @@ -75,3 +79,8 @@ int run_loop_remove_timer(timer_source_t *timer); // execute configured run_loop void run_loop_execute(); + +#if defined __cplusplus +} +#endif + diff --git a/include/btstack/sdp_util.h b/include/btstack/sdp_util.h index d762dc734..fb91038f2 100644 --- a/include/btstack/sdp_util.h +++ b/include/btstack/sdp_util.h @@ -37,6 +37,10 @@ #include +#if defined __cplusplus +extern "C" { +#endif + typedef enum { DE_NIL = 0, DE_UINT, @@ -98,4 +102,8 @@ int de_get_data_size(uint8_t * header); #pragma mark SDP int sdp_append_attributes_in_attributeIDList(uint8_t *record, uint8_t *attributeIDList, uint16_t startIndex, uint16_t maxBytes, uint8_t *buffer); uint8_t * sdp_get_attribute_value_for_attribute_id(uint8_t * record, uint16_t attributeID); -int sdp_record_matches_service_search_pattern(uint8_t *record, uint8_t *serviceSearchPattern); \ No newline at end of file +int sdp_record_matches_service_search_pattern(uint8_t *record, uint8_t *serviceSearchPattern); + +#if defined __cplusplus +} +#endif diff --git a/include/btstack/utils.h b/include/btstack/utils.h index 6ee6a8563..39064f370 100644 --- a/include/btstack/utils.h +++ b/include/btstack/utils.h @@ -41,6 +41,10 @@ #include +#if defined __cplusplus +extern "C" { +#endif + /** * @brief hci connection handle type */ @@ -104,3 +108,8 @@ uint8_t crc8_calc(uint8_t *data, uint16_t len); #ifdef EMBEDDED void bzero(void *s, uint32_t n); #endif + +#if defined __cplusplus +} +#endif + diff --git a/src/btstack.c b/src/btstack.c index cfdd4dfb4..fc56962e9 100644 --- a/src/btstack.c +++ b/src/btstack.c @@ -92,7 +92,7 @@ int bt_close(){ } // send hci cmd packet -int bt_send_cmd(hci_cmd_t *cmd, ...){ +int bt_send_cmd(const hci_cmd_t *cmd, ...){ va_list argptr; va_start(argptr, cmd); uint16_t len = hci_create_cmd_internal(hci_cmd_buffer, cmd, argptr); diff --git a/src/hci.h b/src/hci.h index 1ca29e15b..999878546 100644 --- a/src/hci.h +++ b/src/hci.h @@ -208,7 +208,7 @@ typedef struct { // create and send hci command packets based on a template and a list of parameters uint16_t hci_create_cmd(uint8_t *hci_cmd_buffer, hci_cmd_t *cmd, ...); -uint16_t hci_create_cmd_internal(uint8_t *hci_cmd_buffer, hci_cmd_t *cmd, va_list argptr); +uint16_t hci_create_cmd_internal(uint8_t *hci_cmd_buffer, const hci_cmd_t *cmd, va_list argptr); // set up HCI void hci_init(hci_transport_t *transport, void *config, bt_control_t *control); @@ -223,7 +223,7 @@ int hci_power_control(HCI_POWER_MODE mode); void hci_run(); // create and send hci command packets based on a template and a list of parameters -int hci_send_cmd(hci_cmd_t *cmd, ...); +int hci_send_cmd(const hci_cmd_t *cmd, ...); // send complete CMD packet int hci_send_cmd_packet(uint8_t *packet, int size);