mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-10 06:44:32 +00:00
update docu, simplify names
This commit is contained in:
parent
54deda6a89
commit
49f1a62f59
@ -102,7 +102,7 @@ typedef struct {
|
|||||||
} client_state_t;
|
} client_state_t;
|
||||||
|
|
||||||
// MARK: prototypes
|
// MARK: prototypes
|
||||||
static void handle_sdp_rfcomm_service_result(sdp_query_rfcomm_event_t * event, void * context);
|
static void handle_sdp_rfcomm_service_result(sdp_query_event_t * event, void * context);
|
||||||
static void dummy_bluetooth_status_handler(BLUETOOTH_STATE state);
|
static void dummy_bluetooth_status_handler(BLUETOOTH_STATE state);
|
||||||
static client_state_t * client_for_connection(connection_t *connection);
|
static client_state_t * client_for_connection(connection_t *connection);
|
||||||
static int clients_require_power_on(void);
|
static int clients_require_power_on(void);
|
||||||
@ -524,7 +524,7 @@ static void daemon_packet_handler(void * connection, uint8_t packet_type, uint16
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_sdp_rfcomm_service_result(sdp_query_rfcomm_event_t * rfcomm_event, void * context){
|
static void handle_sdp_rfcomm_service_result(sdp_query_event_t * rfcomm_event, void * context){
|
||||||
switch (rfcomm_event->type){
|
switch (rfcomm_event->type){
|
||||||
case SDP_QUERY_RFCOMM_SERVICE: {
|
case SDP_QUERY_RFCOMM_SERVICE: {
|
||||||
sdp_query_rfcomm_service_event_t * service_event = (sdp_query_rfcomm_service_event_t*) rfcomm_event;
|
sdp_query_rfcomm_service_event_t * service_event = (sdp_query_rfcomm_service_event_t*) rfcomm_event;
|
||||||
@ -540,7 +540,7 @@ static void handle_sdp_rfcomm_service_result(sdp_query_rfcomm_event_t * rfcomm_e
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDP_QUERY_COMPLETE: {
|
case SDP_QUERY_COMPLETE: {
|
||||||
sdp_query_rfcomm_complete_event_t * complete_event = (sdp_query_rfcomm_complete_event_t*) rfcomm_event;
|
sdp_query_complete_event_t * complete_event = (sdp_query_complete_event_t*) rfcomm_event;
|
||||||
uint8_t event[] = { rfcomm_event->type, 1, complete_event->status};
|
uint8_t event[] = { rfcomm_event->type, 1, complete_event->status};
|
||||||
hci_dump_packet(HCI_EVENT_PACKET, 0, event, sizeof(event));
|
hci_dump_packet(HCI_EVENT_PACKET, 0, event, sizeof(event));
|
||||||
socket_connection_send_packet(context, HCI_EVENT_PACKET, 0, event, sizeof(event));
|
socket_connection_send_packet(context, HCI_EVENT_PACKET, 0, event, sizeof(event));
|
||||||
|
@ -1,10 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2009-2013 by Matthias Ringwald
|
||||||
|
*
|
||||||
|
* 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 MATTHIAS RINGWALD 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 btstack@ringwald.ch
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
//*****************************************************************************
|
/*
|
||||||
//
|
* sdp_client.c
|
||||||
// minimal setup for SDP client over USB or UART
|
*/
|
||||||
//
|
|
||||||
//*****************************************************************************
|
|
||||||
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "sdp_client.h"
|
#include "sdp_client.h"
|
||||||
@ -57,6 +89,10 @@ void hexdump2(void *data, int size){
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Queries the SDP service of the remote device given a service search pattern
|
||||||
|
and a list of attribute IDs. The remote data is handled by the SDP parser. The
|
||||||
|
SDP parser delivers attribute values and done event via a registered callback. */
|
||||||
|
|
||||||
void sdp_client_query(bd_addr_t remote, uint8_t * des_serviceSearchPattern, uint8_t * des_attributeIDList){
|
void sdp_client_query(bd_addr_t remote, uint8_t * des_serviceSearchPattern, uint8_t * des_attributeIDList){
|
||||||
|
|
||||||
serviceSearchPattern = des_serviceSearchPattern;
|
serviceSearchPattern = des_serviceSearchPattern;
|
||||||
|
@ -1,10 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2009-2013 by Matthias Ringwald
|
||||||
|
*
|
||||||
|
* 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 MATTHIAS RINGWALD 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 btstack@ringwald.ch
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
//*****************************************************************************
|
/*
|
||||||
//
|
* sdp_client.h
|
||||||
// minimal setup for SDP client over USB or UART
|
*/
|
||||||
//
|
|
||||||
//*****************************************************************************
|
|
||||||
|
|
||||||
#include <btstack/utils.h>
|
#include <btstack/utils.h>
|
||||||
|
|
||||||
|
/* Queries the SDP service of the remote device given a service search pattern
|
||||||
|
and a list of attribute IDs. The remote data is handled by the SDP parser. The
|
||||||
|
SDP parser delivers attribute values and done event via a registered callback. */
|
||||||
|
|
||||||
void sdp_client_query(bd_addr_t remote, uint8_t * des_serviceSearchPattern, uint8_t * des_attributeIDList);
|
void sdp_client_query(bd_addr_t remote, uint8_t * des_serviceSearchPattern, uint8_t * des_attributeIDList);
|
||||||
|
@ -1,3 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2009-2013 by Matthias Ringwald
|
||||||
|
*
|
||||||
|
* 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 MATTHIAS RINGWALD 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 btstack@ringwald.ch
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* sdp_parser.c
|
||||||
|
*/
|
||||||
|
|
||||||
#include "sdp_parser.h"
|
#include "sdp_parser.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
|
@ -1,9 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2009-2013 by Matthias Ringwald
|
||||||
|
*
|
||||||
|
* 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 MATTHIAS RINGWALD 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 btstack@ringwald.ch
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* sdp_parser.h
|
||||||
|
*/
|
||||||
|
|
||||||
//*****************************************************************************
|
|
||||||
//
|
|
||||||
// minimal setup for SDP client over USB or UART
|
|
||||||
//
|
|
||||||
//*****************************************************************************
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -11,13 +45,20 @@
|
|||||||
|
|
||||||
#include <btstack/sdp_util.h>
|
#include <btstack/sdp_util.h>
|
||||||
|
|
||||||
|
|
||||||
|
// Data Element stream parser helper
|
||||||
typedef struct de_state {
|
typedef struct de_state {
|
||||||
uint8_t in_state_GET_DE_HEADER_LENGTH ;
|
uint8_t in_state_GET_DE_HEADER_LENGTH ;
|
||||||
uint32_t addon_header_bytes;
|
uint32_t addon_header_bytes;
|
||||||
uint32_t de_size;
|
uint32_t de_size;
|
||||||
uint32_t de_offset;
|
uint32_t de_offset;
|
||||||
} de_state_t;
|
} de_state_t;
|
||||||
|
void de_state_init(de_state_t * state);
|
||||||
|
int de_state_size(uint8_t eventByte, de_state_t *de_state);
|
||||||
|
|
||||||
|
// SDP Parser
|
||||||
|
|
||||||
|
// Basic SDP Parser event type
|
||||||
typedef enum sdp_parser_event_type {
|
typedef enum sdp_parser_event_type {
|
||||||
SDP_PARSER_ATTRIBUTE_VALUE = 1,
|
SDP_PARSER_ATTRIBUTE_VALUE = 1,
|
||||||
SDP_PARSER_COMPLETE,
|
SDP_PARSER_COMPLETE,
|
||||||
@ -27,6 +68,7 @@ typedef struct sdp_parser_event {
|
|||||||
uint8_t type;
|
uint8_t type;
|
||||||
} sdp_parser_event_t;
|
} sdp_parser_event_t;
|
||||||
|
|
||||||
|
// SDP Parser event to deliver an attribute value byte by byte
|
||||||
typedef struct sdp_parser_attribute_value_event {
|
typedef struct sdp_parser_attribute_value_event {
|
||||||
uint8_t type;
|
uint8_t type;
|
||||||
int record_id;
|
int record_id;
|
||||||
@ -36,15 +78,16 @@ typedef struct sdp_parser_attribute_value_event {
|
|||||||
uint8_t data;
|
uint8_t data;
|
||||||
} sdp_parser_attribute_value_event_t;
|
} sdp_parser_attribute_value_event_t;
|
||||||
|
|
||||||
|
// SDP Parser event to indicate that processing is complete
|
||||||
typedef struct sdp_parser_complete_event {
|
typedef struct sdp_parser_complete_event {
|
||||||
uint8_t type;
|
uint8_t type;
|
||||||
uint8_t status; // 0 == OK
|
uint8_t status; // 0 == OK
|
||||||
} sdp_parser_complete_event_t;
|
} sdp_parser_complete_event_t;
|
||||||
|
|
||||||
void de_state_init(de_state_t * state);
|
|
||||||
int de_state_size(uint8_t eventByte, de_state_t *de_state);
|
|
||||||
|
|
||||||
void sdp_parser_init();
|
void sdp_parser_init();
|
||||||
void sdp_parser_handle_chunk(uint8_t * data, uint16_t size);
|
void sdp_parser_handle_chunk(uint8_t * data, uint16_t size);
|
||||||
void sdp_parser_handle_done(uint8_t status);
|
void sdp_parser_handle_done(uint8_t status);
|
||||||
|
|
||||||
|
// Registers a callback to receive attribute value data and done event.
|
||||||
void sdp_parser_register_callback(void (*sdp_callback)(sdp_parser_event_t* event));
|
void sdp_parser_register_callback(void (*sdp_callback)(sdp_parser_event_t* event));
|
||||||
|
@ -1,9 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2009-2013 by Matthias Ringwald
|
||||||
|
*
|
||||||
|
* 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 MATTHIAS RINGWALD 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 btstack@ringwald.ch
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
//*****************************************************************************
|
/*
|
||||||
//
|
* sdp_rfcomm_query.c
|
||||||
// minimal setup for SDP client over USB or UART
|
*/
|
||||||
//
|
|
||||||
//*****************************************************************************
|
|
||||||
|
|
||||||
#include "sdp_query_rfcomm.h"
|
#include "sdp_query_rfcomm.h"
|
||||||
|
|
||||||
@ -17,7 +50,7 @@
|
|||||||
|
|
||||||
#include "sdp_client.h"
|
#include "sdp_client.h"
|
||||||
|
|
||||||
static void dummy_notify_app(sdp_query_rfcomm_event_t* event, void * context);
|
static void dummy_notify_app(sdp_query_event_t* event, void * context);
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
GET_PROTOCOL_LIST_LENGTH = 1,
|
GET_PROTOCOL_LIST_LENGTH = 1,
|
||||||
@ -52,13 +85,13 @@ static de_state_t de_header_state;
|
|||||||
static de_state_t sn_de_header_state;
|
static de_state_t sn_de_header_state;
|
||||||
|
|
||||||
static void *sdp_app_context;
|
static void *sdp_app_context;
|
||||||
static void (*sdp_app_callback)(sdp_query_rfcomm_event_t * event, void * context) = dummy_notify_app;
|
static void (*sdp_app_callback)(sdp_query_event_t * event, void * context) = dummy_notify_app;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
static void dummy_notify_app(sdp_query_rfcomm_event_t* event, void * context){}
|
static void dummy_notify_app(sdp_query_event_t* event, void * context){}
|
||||||
|
|
||||||
void sdp_query_rfcomm_register_callback(void (*sdp_callback)(sdp_query_rfcomm_event_t* event, void * context), void * context){
|
void sdp_query_rfcomm_register_callback(void (*sdp_callback)(sdp_query_event_t* event, void * context), void * context){
|
||||||
sdp_app_callback = dummy_notify_app;
|
sdp_app_callback = dummy_notify_app;
|
||||||
if (sdp_callback != NULL){
|
if (sdp_callback != NULL){
|
||||||
sdp_app_callback = sdp_callback;
|
sdp_app_callback = sdp_callback;
|
||||||
@ -201,7 +234,7 @@ void handleServiceNameData(uint32_t attribute_value_length, uint32_t data_offset
|
|||||||
.channel_nr = sdp_rfcom_channel_nr
|
.channel_nr = sdp_rfcom_channel_nr
|
||||||
};
|
};
|
||||||
printf("Service found %s\n", sdp_service_name);
|
printf("Service found %s\n", sdp_service_name);
|
||||||
(*sdp_app_callback)((sdp_query_rfcomm_event_t*)&value_event, sdp_app_context);
|
(*sdp_app_callback)((sdp_query_event_t*)&value_event, sdp_app_context);
|
||||||
sdp_rfcom_channel_nr = 0;
|
sdp_rfcom_channel_nr = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -233,11 +266,11 @@ static void handle_sdp_parser_event(sdp_parser_event_t * event){
|
|||||||
break;
|
break;
|
||||||
case SDP_PARSER_COMPLETE:
|
case SDP_PARSER_COMPLETE:
|
||||||
ce = (sdp_parser_complete_event_t*) event;
|
ce = (sdp_parser_complete_event_t*) event;
|
||||||
sdp_query_rfcomm_complete_event_t c_event = {
|
sdp_query_complete_event_t c_event = {
|
||||||
.type = SDP_QUERY_COMPLETE,
|
.type = SDP_QUERY_COMPLETE,
|
||||||
.status = ce->status
|
.status = ce->status
|
||||||
};
|
};
|
||||||
(*sdp_app_callback)((sdp_query_rfcomm_event_t*)&c_event, sdp_app_context);
|
(*sdp_app_callback)((sdp_query_event_t*)&c_event, sdp_app_context);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// insert higher level code HERE
|
// insert higher level code HERE
|
||||||
|
@ -1,31 +1,72 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2009-2013 by Matthias Ringwald
|
||||||
|
*
|
||||||
|
* 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 MATTHIAS RINGWALD 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 btstack@ringwald.ch
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
//*****************************************************************************
|
/*
|
||||||
//
|
* sdp_rfcomm_query.h
|
||||||
// minimal setup for SDP client over USB or UART
|
*/
|
||||||
//
|
|
||||||
//*****************************************************************************
|
|
||||||
|
|
||||||
#include <btstack/utils.h>
|
#include <btstack/utils.h>
|
||||||
#include "sdp_parser.h"
|
#include "sdp_parser.h"
|
||||||
|
|
||||||
|
// Basic SDP Query event type
|
||||||
typedef struct sdp_query_rfcomm_event {
|
typedef struct sdp_query_event {
|
||||||
uint8_t type;
|
uint8_t type;
|
||||||
} sdp_query_rfcomm_event_t;
|
} sdp_query_event_t;
|
||||||
|
|
||||||
|
// SDP Query event to indicate that query is complete.
|
||||||
|
typedef struct sdp_query_complete_event {
|
||||||
|
uint8_t type;
|
||||||
|
uint8_t status; // 0 == OK
|
||||||
|
} sdp_query_complete_event_t;
|
||||||
|
|
||||||
|
// SDP Query RFCOMM event to deliver channel number and service name byte by byte.
|
||||||
typedef struct sdp_query_rfcomm_service_event {
|
typedef struct sdp_query_rfcomm_service_event {
|
||||||
uint8_t type;
|
uint8_t type;
|
||||||
uint8_t channel_nr;
|
uint8_t channel_nr;
|
||||||
uint8_t * service_name;
|
uint8_t * service_name;
|
||||||
} sdp_query_rfcomm_service_event_t;
|
} sdp_query_rfcomm_service_event_t;
|
||||||
|
|
||||||
typedef struct sdp_query_rfcomm_complete_event {
|
|
||||||
uint8_t type;
|
|
||||||
uint8_t status; // 0 == OK
|
|
||||||
} sdp_query_rfcomm_complete_event_t;
|
|
||||||
|
|
||||||
|
|
||||||
void sdp_query_rfcomm_init(void);
|
void sdp_query_rfcomm_init(void);
|
||||||
|
|
||||||
|
// Searches SDP records on a remote device for RFCOMM services with the given UUID.
|
||||||
void sdp_query_rfcomm_channel_and_name_for_service_with_uuid(bd_addr_t remote, uint16_t uuid);
|
void sdp_query_rfcomm_channel_and_name_for_service_with_uuid(bd_addr_t remote, uint16_t uuid);
|
||||||
|
|
||||||
|
// Searches SDP records on a remote device for RFCOMM services with a given service search pattern.
|
||||||
void sdp_query_rfcomm_channel_and_name_for_service_with_service_search_pattern(bd_addr_t remote, uint8_t * des_serviceSearchPattern);
|
void sdp_query_rfcomm_channel_and_name_for_service_with_service_search_pattern(bd_addr_t remote, uint8_t * des_serviceSearchPattern);
|
||||||
void sdp_query_rfcomm_register_callback(void(*sdp_app_callback)(sdp_query_rfcomm_event_t * event, void * context), void * context);
|
|
||||||
|
// Registers a callback to receive RFCOMM service and done event.
|
||||||
|
void sdp_query_rfcomm_register_callback(void(*sdp_app_callback)(sdp_query_event_t * event, void * context), void * context);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user