draft example of ble client

This commit is contained in:
mila@ringwald.ch 2013-11-28 10:54:41 +00:00
parent 9ecc3e1772
commit 7d0f8f4b07
4 changed files with 20 additions and 13 deletions

View File

@ -29,16 +29,19 @@ COMMON = \
${BTSTACK_ROOT}/src/sdp_query_util.c \
${BTSTACK_ROOT}/src/sdp_query_rfcomm.c \
${BTSTACK_ROOT}/ble/att.c \
# ${BTSTACK_ROOT}/chipset-cc256x/bt_control_cc256x.c \
# ${BTSTACK_ROOT}/chipset-cc256x/bluetooth_init_cc2560A_2.1.c \
CC2564 = \
${BTSTACK_ROOT}/chipset-cc256x/bt_control_cc256x.c \
${BTSTACK_ROOT}/chipset-cc256x/bluetooth_init_cc2564_2.5.c \
CORE_OBJ = $(CORE:.c=.o)
COMMON_OBJ = $(COMMON:.c=.o)
CC2564_OBJ = $(CC2564:.c=.o)
# create firmware image from common objects and example source file
all: ../../include/btstack/version.h sdp_rfcomm_query sdp_general_query spp_counter ble_server ble_client
all: ../../include/btstack/version.h ble_client ble_client_uart sdp_rfcomm_query sdp_general_query spp_counter ble_server ble_client
#spp-usb l2cap-server-usb l2cap-client-usb l2cap-server-uart l2cap-client-uart
@ -64,8 +67,11 @@ profile.h: profile.gatt
ble_server: ${CORE_OBJ} ${COMMON_OBJ} rijndael.c ble_server.c profile.h
${CC} ${CORE_OBJ} ${COMMON_OBJ} rijndael.c ble_server.c ${CFLAGS} ${LDFLAGS} -o $@
ble_client: ${CORE_OBJ} ${COMMON_OBJ} rijndael.c ble_client.c profile.h
${CC} ${CORE_OBJ} ${COMMON_OBJ} rijndael.c ble_client.c ${CFLAGS} ${LDFLAGS} -o $@
ble_client: ${CORE_OBJ} ${COMMON_OBJ} rijndael.c ble_client.c ad_parser.c
${CC} ${CORE_OBJ} ${COMMON_OBJ} ad_parser.c rijndael.c ble_client.c ${CFLAGS} ${LDFLAGS} -o $@
ble_client_uart: ${CORE_OBJ} ${COMMON_OBJ} ${CC2564_OBJ} rijndael.c ble_client.c ad_parser.c
${CC} -DHAVE_UART_CC2564 ${CORE_OBJ} ${COMMON_OBJ} ${CC2564_OBJ} ad_parser.c rijndael.c ble_client.c ${CFLAGS} ${LDFLAGS} -o $@
clean:
rm -f spp_counter sdp_rfcomm_query sdp_general_query spp_counter_ssp ble_server ble_client

View File

@ -42,6 +42,7 @@
#include <stdlib.h>
#include <string.h>
#include <btstack/utils.h>
#include <btstack/sdp_util.h>
#include <btstack/hci_cmds.h>

View File

@ -41,8 +41,6 @@
#include "config.h"
#include <btstack/utils.h>
#if defined __cplusplus
extern "C" {
#endif

View File

@ -83,7 +83,9 @@ typedef enum {
typedef enum {
BLE_PERIPHERAL_OK = 0,
BLE_PERIPHERAL_IN_WRONG_STATE,
BLE_PERIPHERAL_DIFFERENT_CONTEXT_FOR_ADDRESS_ALREADY_EXISTS
BLE_PERIPHERAL_DIFFERENT_CONTEXT_FOR_ADDRESS_ALREADY_EXISTS,
BLE_PERIPHERAL_NOT_CONNECTED,
BLE_PERIPHERAL_BUSY
} le_command_status_t;
@ -115,17 +117,17 @@ typedef struct le_characteristic{
void le_central_init();
void le_central_register_handler(void (*le_callback)(le_central_event_t * event));
void le_central_start_scan();
le_command_status_t le_central_start_scan();
// creates one event per found peripheral device
// { type (8), addr_type (8), addr(48), rssi(8), ad_len(8), ad_data(ad_len*8) }
void le_central_stop_scan();
le_command_status_t le_central_stop_scan();
le_command_status_t le_central_connect(le_peripheral_t *context, uint8_t addr_type, bd_addr_t addr);
le_command_status_t le_central_disconnect(le_peripheral_t *context);
void le_central_get_services(le_peripheral_t *context);
void le_central_get_services_with_uuid16(le_peripheral_t *context, uint16_t uuid16);
void le_central_get_services_with_uuid128(le_peripheral_t *context, uint8_t * uuid128);
le_command_status_t le_central_get_services(le_peripheral_t *context);
le_command_status_t le_central_get_services_with_uuid16(le_peripheral_t *context, uint16_t uuid16);
le_command_status_t le_central_get_services_with_uuid128(le_peripheral_t *context, uint8_t * uuid128);
// { type (8), le_peripheral_t *context, service_handle }
void le_central_get_characteristics_for_service(le_peripheral_t *context, uint16_t service_handle);