1
0
mirror of https://github.com/bluekitchen/btstack.git synced 2025-03-19 16:21:06 +00:00

add const to hci_cmd_t for bt_send_cmd, too. Add C++ link protection to public headers

This commit is contained in:
matthias.ringwald 2010-08-08 18:17:48 +00:00
parent fe35119d8a
commit df33c7a6dc
8 changed files with 55 additions and 6 deletions

@ -46,6 +46,10 @@
#include <stdint.h> #include <stdint.h>
#if defined __cplusplus
extern "C" {
#endif
// Default TCP port for BTstack daemon // Default TCP port for BTstack daemon
#define BTSTACK_PORT 13333 #define BTSTACK_PORT 13333
@ -66,7 +70,7 @@ int bt_open();
int bt_close(); int bt_close();
// send hci cmd packet // 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 // register packet handler -- channel only valid for l2cap and rfcomm packets
// @returns old packet handler // @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_acl(uint8_t * data, uint16_t len);
void bt_send_l2cap(uint16_t local_cid, uint8_t *data, uint16_t len); void bt_send_l2cap(uint16_t local_cid, uint8_t *data, uint16_t len);
#if defined __cplusplus
}
#endif

@ -39,6 +39,10 @@
#include <stdint.h> #include <stdint.h>
#if defined __cplusplus
extern "C" {
#endif
/** /**
* packet types - used in BTstack and over the H4 UART interface * 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; extern const hci_cmd_t sdp_unregister_service_record;
#if defined __cplusplus
}
#endif

@ -37,6 +37,10 @@
#pragma once #pragma once
#if defined __cplusplus
extern "C" {
#endif
typedef struct linked_item { typedef struct linked_item {
struct linked_item *next; // <-- next element in list, or NULL struct linked_item *next; // <-- next element in list, or NULL
void *user_data; // <-- pointer to struct base void *user_data; // <-- pointer to struct base
@ -52,3 +56,7 @@ void linked_list_add_tail(linked_list_t * list, linked_item_t *item); // <-- a
int linked_list_remove(linked_list_t * list, linked_item_t *item); // <-- remove item from list int linked_list_remove(linked_list_t * list, linked_item_t *item); // <-- remove item from list
void test_linked_list(); void test_linked_list();
#if defined __cplusplus
}
#endif

@ -41,6 +41,10 @@
#include <sys/time.h> #include <sys/time.h>
#if defined __cplusplus
extern "C" {
#endif
typedef enum { typedef enum {
RUN_LOOP_POSIX = 1, RUN_LOOP_POSIX = 1,
RUN_LOOP_COCOA, RUN_LOOP_COCOA,
@ -75,3 +79,8 @@ int run_loop_remove_timer(timer_source_t *timer);
// execute configured run_loop // execute configured run_loop
void run_loop_execute(); void run_loop_execute();
#if defined __cplusplus
}
#endif

@ -37,6 +37,10 @@
#include <stdint.h> #include <stdint.h>
#if defined __cplusplus
extern "C" {
#endif
typedef enum { typedef enum {
DE_NIL = 0, DE_NIL = 0,
DE_UINT, DE_UINT,
@ -99,3 +103,7 @@ int de_get_data_size(uint8_t * header);
int sdp_append_attributes_in_attributeIDList(uint8_t *record, uint8_t *attributeIDList, uint16_t startIndex, uint16_t maxBytes, uint8_t *buffer); 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); 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); int sdp_record_matches_service_search_pattern(uint8_t *record, uint8_t *serviceSearchPattern);
#if defined __cplusplus
}
#endif

@ -41,6 +41,10 @@
#include <stdint.h> #include <stdint.h>
#if defined __cplusplus
extern "C" {
#endif
/** /**
* @brief hci connection handle type * @brief hci connection handle type
*/ */
@ -104,3 +108,8 @@ uint8_t crc8_calc(uint8_t *data, uint16_t len);
#ifdef EMBEDDED #ifdef EMBEDDED
void bzero(void *s, uint32_t n); void bzero(void *s, uint32_t n);
#endif #endif
#if defined __cplusplus
}
#endif

@ -92,7 +92,7 @@ int bt_close(){
} }
// send hci cmd packet // 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_list argptr;
va_start(argptr, cmd); va_start(argptr, cmd);
uint16_t len = hci_create_cmd_internal(hci_cmd_buffer, cmd, argptr); uint16_t len = hci_create_cmd_internal(hci_cmd_buffer, cmd, argptr);

@ -208,7 +208,7 @@ typedef struct {
// create and send hci command packets based on a template and a list of parameters // 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(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 // set up HCI
void hci_init(hci_transport_t *transport, void *config, bt_control_t *control); 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(); void hci_run();
// create and send hci command packets based on a template and a list of parameters // 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 // send complete CMD packet
int hci_send_cmd_packet(uint8_t *packet, int size); int hci_send_cmd_packet(uint8_t *packet, int size);