mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-10 15:44:32 +00:00
daemon: move examples from example/daemon to platform/daemon/example. fix mtk compile
This commit is contained in:
parent
3e8ca98812
commit
2531c97e16
@ -2,7 +2,7 @@
|
||||
|
||||
The examples in this folder demonstrate how various Bluetooth profiles can be used with BTstack.
|
||||
|
||||
All contain a btstack_main() function that is called after the Bluetooth stack has been configured.
|
||||
Each contains a btstack_main() function that is called after the Bluetooth stack has been configured.
|
||||
|
||||
By this, the examples are linked in by various ports in the port/ directory.
|
||||
Please go to one of the subfolders of port/ to compile for a specific BTstack port.
|
||||
|
@ -170,7 +170,9 @@ typedef struct btstack_linked_list_gatt_client_helper{
|
||||
// MARK: prototypes
|
||||
static void handle_sdp_rfcomm_service_result(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||
static void handle_sdp_client_query_result(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||
#ifdef ENABLE_BLE
|
||||
static void handle_gatt_client_event(uint8_t packet_type, uint16_t channel, uint8_t * packet, uint16_t size);
|
||||
#endif
|
||||
static void dummy_bluetooth_status_handler(BLUETOOTH_STATE state);
|
||||
static client_state_t * client_for_connection(connection_t *connection);
|
||||
static int clients_require_power_on(void);
|
58
platform/daemon/src/rfcomm_service_db_hash.c
Normal file
58
platform/daemon/src/rfcomm_service_db_hash.c
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2014 BlueKitchen GmbH
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holders nor the names of
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* 4. Any redistribution, use, or modification is done solely for
|
||||
* personal benefit and not for any commercial purpose or for
|
||||
* monetary gain.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
|
||||
* RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* Please inquire about commercial licensing options at
|
||||
* contact@bluekitchen-gmbh.com
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "rfcomm_service_db.h"
|
||||
#include "btstack_memory.h"
|
||||
#include "btstack_debug.h"
|
||||
|
||||
#include "btstack_util.h"
|
||||
#include "btstack_linked_list.h"
|
||||
|
||||
// MARK: PERSISTENT RFCOMM CHANNEL ALLOCATION
|
||||
uint8_t rfcomm_service_db_channel_for_service(const char *serviceName){
|
||||
// quick hack: use sum over service name, map 0 to 1
|
||||
int sum = 0;
|
||||
while (*serviceName){
|
||||
sum += serviceName;
|
||||
}
|
||||
int channel = sum & 0x0f;
|
||||
if (channel == 0) return 1;
|
||||
return channel;
|
||||
}
|
@ -48,13 +48,6 @@
|
||||
// This lists should be only accessed by tests.
|
||||
static btstack_linked_list_t db_mem_services = NULL;
|
||||
|
||||
// Device info
|
||||
static void db_open(void){
|
||||
}
|
||||
|
||||
static void db_close(void){
|
||||
}
|
||||
|
||||
// MARK: PERSISTENT RFCOMM CHANNEL ALLOCATION
|
||||
uint8_t rfcomm_service_db_channel_for_service(const char *serviceName){
|
||||
|
@ -5,7 +5,7 @@
|
||||
DIR=.
|
||||
BTSTACK_ROOT=${DIR}/../..
|
||||
DUMMY=$(shell )
|
||||
VERSION=`sed -n -e 's/^.*BTSTACK_VERSION \"\(.*\)\"/\1/p' ${BTSTACK_ROOT}/platform/daemon/btstack_version.h`
|
||||
VERSION=`sed -n -e 's/^.*BTSTACK_VERSION \"\(.*\)\"/\1/p' ${BTSTACK_ROOT}/platform/daemon/src/btstack_version.h`
|
||||
BTSTACK_PACKAGE=/tmp/btstack
|
||||
ARCHIVE=btstack-arduino-${VERSION}.zip
|
||||
|
||||
|
@ -9,7 +9,7 @@ CFLAGS = @CFLAGS@ \
|
||||
-I..
|
||||
prefix = @prefix@
|
||||
|
||||
VPATH += ${BTSTACK_ROOT}/example/daemon
|
||||
VPATH += ${BTSTACK_ROOT}/platform/daemon/example
|
||||
|
||||
all: test rfcomm_cat rfcomm_echo rfcomm_test inquiry l2cap_server l2cap_throughput le_scan
|
||||
|
||||
|
@ -5,7 +5,7 @@ prefix = @prefix@
|
||||
CC = @CC@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
CFLAGS = @CFLAGS@ \
|
||||
-I $(BTSTACK_ROOT)/platform/daemon \
|
||||
-I $(BTSTACK_ROOT)/platform/daemon/src \
|
||||
-I $(BTSTACK_ROOT)/platform/posix \
|
||||
-I $(BTSTACK_ROOT)/src \
|
||||
-I..
|
||||
@ -14,7 +14,7 @@ BTSTACK_LIB_EXTENSION = @BTSTACK_LIB_EXTENSION@
|
||||
LIBUSB_CFLAGS = @LIBUSB_CFLAGS@
|
||||
LIBUSB_LDFLAGS = @LIBUSB_LDFLAGS@
|
||||
|
||||
VPATH += ${BTSTACK_ROOT}/platform/daemon
|
||||
VPATH += ${BTSTACK_ROOT}/platform/daemon/src
|
||||
VPATH += ${BTSTACK_ROOT}/platform/posix
|
||||
VPATH += ${BTSTACK_ROOT}/platform/cocoa
|
||||
VPATH += ${BTSTACK_ROOT}/src
|
||||
|
@ -13,7 +13,7 @@ BTstack_INSTALL_PATH = /Library/PreferenceBundles
|
||||
BTstack_FRAMEWORKS = UIKit
|
||||
BTstack_CFLAGS = -g -I.. \
|
||||
-I$(BTSTACK_ROOT)/src \
|
||||
-I$(BTSTACK_ROOT)/platform/daemon \
|
||||
-I$(BTSTACK_ROOT)/platform/daemon/src \
|
||||
-I$(BTSTACK_ROOT)/platform/cocoa \
|
||||
|
||||
BTstack_LDFLAGS = -L../src/.theos/obj -lBTstack
|
||||
|
@ -8,11 +8,11 @@ TARGET_IPHONEOS_DEPLOYMENT_VERSION_arm64 = 7.0
|
||||
ARCHS = armv6 arm64
|
||||
|
||||
BTSTACK_ROOT=../../..
|
||||
VPATH += $(BTSTACK_ROOT)/example/daemon
|
||||
VPATH += $(BTSTACK_ROOT)/platform/daemon/example
|
||||
|
||||
ADDITIONAL_CFLAGS = -I.. \
|
||||
-I$(BTSTACK_ROOT)/src \
|
||||
-I$(BTSTACK_ROOT)/platform/daemon \
|
||||
-I$(BTSTACK_ROOT)/platform/daemon/src \
|
||||
-I$(BTSTACK_ROOT)/platform/posix \
|
||||
|
||||
ADDITIONAL_LDFLAGS = -L../src/.theos/obj -lBTstack
|
||||
|
@ -11,7 +11,7 @@ BTSTACK_ROOT=../../..
|
||||
VPATH += $(BTSTACK_ROOT)/src \
|
||||
$(BTSTACK_ROOT)/src/classic \
|
||||
$(BTSTACK_ROOT)/platform/posix \
|
||||
$(BTSTACK_ROOT)/platform/daemon \
|
||||
$(BTSTACK_ROOT)/platform/daemon/src \
|
||||
$(BTSTACK_ROOT)/platform/cocoa \
|
||||
$(BTSTACK_ROOT)/port/ios/SpringBoardAccess
|
||||
|
||||
@ -55,7 +55,7 @@ BTdaemon_FILES = \
|
||||
BTdaemon_CFLAGS = \
|
||||
-I$(BTSTACK_ROOT)/src \
|
||||
-I$(BTSTACK_ROOT)/platform/posix \
|
||||
-I$(BTSTACK_ROOT)/platform/daemon \
|
||||
-I$(BTSTACK_ROOT)/platform/daemon/src \
|
||||
-I..
|
||||
BTdaemon_PRIVATE_FRAMEWORKS = IOKIT
|
||||
|
||||
|
@ -13,7 +13,7 @@ BTSTACK_ROOT = ../..
|
||||
CFLAGS += -I$(BTSTACK_ROOT)/include
|
||||
CFLAGS += -I$(BTSTACK_ROOT)/src/
|
||||
CFLAGS += -I$(BTSTACK_ROOT)/ble
|
||||
CFLAGS += -I$(BTSTACK_ROOT)/platform/daemon
|
||||
CFLAGS += -I$(BTSTACK_ROOT)/platform/daemon/src
|
||||
CFLAGS += -I$(BTSTACK_ROOT)/platform/posix
|
||||
CFLAGS += -I.
|
||||
|
||||
@ -21,39 +21,41 @@ VPATH += $(BTSTACK_ROOT)/src
|
||||
VPATH += $(BTSTACK_ROOT)/src/ble
|
||||
VPATH += $(BTSTACK_ROOT)/src/classic
|
||||
VPATH += $(BTSTACK_ROOT)/platform/posix
|
||||
VPATH += $(BTSTACK_ROOT)/platform/daemon
|
||||
VPATH += $(BTSTACK_ROOT)/example/daemon
|
||||
VPATH += $(BTSTACK_ROOT)/platform/daemon/src
|
||||
VPATH += $(BTSTACK_ROOT)/platform/daemon/example
|
||||
|
||||
libBTstack_OBJS = \
|
||||
btstack.o \
|
||||
btstack_linked_list.o \
|
||||
btstack_run_loop.o \
|
||||
btstack_run_loop_posix.o \
|
||||
hci_cmd.o \
|
||||
hci_dump.o \
|
||||
sdp_util.o \
|
||||
socket_connection.o \
|
||||
utils.o \
|
||||
libBTstack_OBJS = \
|
||||
btstack.o \
|
||||
btstack_linked_list.o \
|
||||
btstack_run_loop.o \
|
||||
btstack_run_loop_posix.o \
|
||||
btstack_util.o \
|
||||
hci_cmd.o \
|
||||
daemon_cmds.o \
|
||||
hci_dump.o \
|
||||
sdp_util.o \
|
||||
socket_connection.o \
|
||||
|
||||
BTdaemon_OBJS = $(libBTstack_OBJS) \
|
||||
att_dispatch.o \
|
||||
le_device_db_memory.o \
|
||||
att.o \
|
||||
att_server.o \
|
||||
gatt_client.o \
|
||||
sm.o \
|
||||
btstack_memory.o \
|
||||
hci.o \
|
||||
l2cap.o \
|
||||
l2cap_signaling.o \
|
||||
memory_pool.o \
|
||||
remote_device_db_memory.o \
|
||||
rfcomm.o \
|
||||
sdp.o \
|
||||
sdp_client.o \
|
||||
sdp_query_rfcomm.o \
|
||||
daemon.o \
|
||||
hci_transport_h4_mtk.o \
|
||||
BTdaemon_OBJS = $(libBTstack_OBJS) \
|
||||
att_dispatch.o \
|
||||
btstack_link_key_db_memory.o \
|
||||
btstack_memory.o \
|
||||
btstack_memory_pool.o \
|
||||
daemon.o \
|
||||
gatt_client.o \
|
||||
hci.o \
|
||||
hci_transport_h4_mtk.o \
|
||||
l2cap.o \
|
||||
l2cap_signaling.o \
|
||||
le_device_db_memory.o \
|
||||
rfcomm.o \
|
||||
rfcomm_service_db_hash.o \
|
||||
sdp_server.o \
|
||||
sm.o \
|
||||
att_db.o \
|
||||
att_server.o \
|
||||
sdp_client.o \
|
||||
sdp_query_rfcomm.o \
|
||||
|
||||
all: $(TOOLCHAIN) version BTstackDaemon libBTstack.so BTstackDaemonRespawn inquiry le_scan rfcomm_echo dist
|
||||
|
||||
@ -83,7 +85,7 @@ shell:
|
||||
|
||||
version:
|
||||
$(BTSTACK_ROOT)/tool/get_version.sh
|
||||
grep BTSTACK_DATE $(BTSTACK_ROOT)/src/btstack_version.h
|
||||
grep BTSTACK_DATE $(BTSTACK_ROOT)/platform/daemon/src/btstack_version.h
|
||||
|
||||
BTstackDaemon: $(BTdaemon_OBJS) libbluetoothdrv.so
|
||||
$(GCC) $(LDFLAGS) -o $@ libbluetoothdrv.so $^
|
||||
|
@ -73,7 +73,7 @@ static void (*packet_handler)(uint8_t packet_type, uint8_t *packet, uint16_t si
|
||||
static uint8_t hci_packet_out[1+HCI_PACKET_BUFFER_SIZE]; // packet type + max(acl header + acl payload, event header + event data)
|
||||
static uint8_t hci_packet_in[1+HCI_PACKET_BUFFER_SIZE]; // packet type + max(acl header + acl payload, event header + event data)
|
||||
|
||||
static int h4_open(const void *transport_config){
|
||||
static int h4_open(void){
|
||||
int fd = mtk_bt_enable();
|
||||
|
||||
if (fd < 0) {
|
||||
@ -90,7 +90,7 @@ static int h4_open(const void *transport_config){
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int h4_close(const void *transport_config){
|
||||
static int h4_close(void){
|
||||
|
||||
mtk_bt_disable(hci_transport_h4->ds->fd);
|
||||
|
||||
@ -152,25 +152,19 @@ static int h4_process(struct btstack_data_source *ds) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char * h4_get_transport_name(void){
|
||||
return "H4 MTK";
|
||||
}
|
||||
|
||||
static void dummy_handler(uint8_t packet_type, uint8_t *packet, uint16_t size){
|
||||
}
|
||||
|
||||
// get h4 singleton
|
||||
hci_transport_t * hci_transport_h4_instance(void){
|
||||
const hci_transport_t * hci_transport_h4_instance(void){
|
||||
if (hci_transport_h4 == NULL) {
|
||||
hci_transport_h4 = (hci_transport_h4_t*)malloc( sizeof(hci_transport_h4_t));
|
||||
hci_transport_h4->ds = NULL;
|
||||
memset(hci_transport_h4, 0, sizeof(hci_transport_h4_t));
|
||||
hci_transport_h4->transport.name = "H4 MTK";
|
||||
hci_transport_h4->transport.open = h4_open;
|
||||
hci_transport_h4->transport.close = h4_close;
|
||||
hci_transport_h4->transport.send_packet = h4_send_packet;
|
||||
hci_transport_h4->transport.register_packet_handler = h4_register_packet_handler;
|
||||
hci_transport_h4->transport.get_transport_name = h4_get_transport_name;
|
||||
hci_transport_h4->transport.set_baudrate = NULL;
|
||||
hci_transport_h4->transport.can_send_packet_now = NULL;
|
||||
}
|
||||
return (hci_transport_t *) hci_transport_h4;
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ popd
|
||||
|
||||
pushd .
|
||||
cd $DIR/../..
|
||||
VERSION=`sed -n -e 's/^.*BTSTACK_VERSION \"\(.*\)\"/\1/p' platform/daemon/btstack_version.h`
|
||||
VERSION=`sed -n -e 's/^.*BTSTACK_VERSION \"\(.*\)\"/\1/p' platform/daemon/src/btstack_version.h`
|
||||
ARCHIVE=btstack-android-mtk-$VERSION.tar.gz
|
||||
echo "Create Archive $ARCHIVE"
|
||||
rm -f $ARCHIVE
|
||||
|
@ -8,7 +8,7 @@ import os
|
||||
# paths
|
||||
bluetooth_h_path = 'src/bluetooth.h'
|
||||
btstack_defines_h_path = 'src/btstack_defines.h'
|
||||
daemon_cmds_c_path = 'platform/daemon/daemon_cmds.c'
|
||||
daemon_cmds_c_path = 'platform/daemon/src/daemon_cmds.c'
|
||||
hci_cmds_c_path = 'src/hci_cmd.c'
|
||||
hci_cmds_h_path = 'src/hci_cmd.h'
|
||||
hci_h_path = 'src/hci.h'
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
DIR=`dirname $0`
|
||||
FILE=$DIR/../platform/daemon/btstack_version.h
|
||||
FILE=$DIR/../platform/daemon/src/btstack_version.h
|
||||
COMMIT=`git log -1 --pretty=format:%h`
|
||||
MAJOR=0
|
||||
MINOR=9
|
||||
|
Loading…
x
Reference in New Issue
Block a user