mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-12 15:47:14 +00:00
pass on connection to sdp register functions, call sdp_unregister_services_for_connection when client disconnects
This commit is contained in:
parent
53dfe610d4
commit
c1b43b8cbf
14
src/daemon.c
14
src/daemon.c
@ -48,13 +48,14 @@
|
||||
|
||||
#include <getopt.h>
|
||||
|
||||
#include "hci.h"
|
||||
#include "hci_dump.h"
|
||||
#include "l2cap.h"
|
||||
#include <btstack/btstack.h>
|
||||
#include <btstack/linked_list.h>
|
||||
#include <btstack/run_loop.h>
|
||||
#include <btstack/sdp.h>
|
||||
|
||||
#include "hci.h"
|
||||
#include "hci_dump.h"
|
||||
#include "l2cap.h"
|
||||
#include "sdp.h"
|
||||
#include "socket_connection.h"
|
||||
|
||||
#ifdef USE_BLUETOOL
|
||||
@ -168,11 +169,11 @@ static int btstack_command_handler(connection_t *connection, uint8_t *packet, ui
|
||||
break;
|
||||
case SDP_REGISTER_SERVICE_RECORD:
|
||||
printf("SDP_REGISTER_SERVICE_RECORD size %u\n", size);
|
||||
sdp_register_service_internal(&packet[3]);
|
||||
sdp_register_service_internal(connection, &packet[3]);
|
||||
break;
|
||||
case SDP_UNREGISTER_SERVICE_RECORD:
|
||||
service_record_handle = READ_BT_32(packet, 3);
|
||||
sdp_unregister_service_internal(service_record_handle);
|
||||
sdp_unregister_service_internal(connection, service_record_handle);
|
||||
break;
|
||||
default:
|
||||
//@TODO: log into hci dump as vendor specific "event"
|
||||
@ -203,6 +204,7 @@ static int daemon_client_handler(connection_t *connection, uint16_t packet_type,
|
||||
case DAEMON_EVENT_PACKET:
|
||||
switch (data[0]) {
|
||||
case DAEMON_EVENT_CONNECTION_CLOSED:
|
||||
sdp_unregister_services_for_connection(connection);
|
||||
l2cap_close_connection(connection);
|
||||
break;
|
||||
case DAEMON_NR_CONNECTIONS_CHANGED:
|
||||
|
12
src/sdp.c
12
src/sdp.c
@ -33,7 +33,7 @@
|
||||
* Implementation of the Service Discovery Protocol Server
|
||||
*/
|
||||
|
||||
#include <btstack/sdp.h>
|
||||
#include "sdp.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@ -61,7 +61,7 @@ static void sdp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *p
|
||||
linked_list_t sdp_service_records;
|
||||
|
||||
// our handles start after the reserved range
|
||||
static uint32_t sdp_next_service_record_handle = maxReservedServiceRecordHandle + 1;
|
||||
static uint32_t sdp_next_service_record_handle = maxReservedServiceRecordHandle + 2;
|
||||
|
||||
// AttributeIDList used to remove ServiceRecordHandle
|
||||
const uint8_t removeServiceRecordHandleAttributeIDList[] = { 0x36, 0x00, 0x05, 0x0A, 0x00, 0x01, 0xFF, 0xFF };
|
||||
@ -103,7 +103,7 @@ uint32_t sdp_create_service_record_handle(){
|
||||
// register service record internally
|
||||
// pre: AttributeIDs are in ascending order => ServiceRecordHandle is first attribute if present
|
||||
// @returns ServiceRecordHandle or 0 if registration failed
|
||||
uint32_t sdp_register_service_internal(uint8_t * record){
|
||||
uint32_t sdp_register_service_internal(connection_t *connection, uint8_t * record){
|
||||
|
||||
// dump for now
|
||||
printf("Register service record\n");
|
||||
@ -160,13 +160,17 @@ uint32_t sdp_register_service_internal(uint8_t * record){
|
||||
}
|
||||
|
||||
// unregister service record internally
|
||||
void sdp_unregister_service_internal(uint32_t service_record_handle){
|
||||
void sdp_unregister_service_internal(connection_t *connection, uint32_t service_record_handle){
|
||||
service_record_item_t * record_item = sdp_get_record_for_handle(service_record_handle);
|
||||
if (record_item) {
|
||||
linked_list_remove(&sdp_service_records, (linked_item_t *) record_item);
|
||||
}
|
||||
}
|
||||
|
||||
// remove all service record for a client
|
||||
void sdp_unregister_services_for_connection(connection_t *connectino){
|
||||
}
|
||||
|
||||
// PDU
|
||||
// PDU ID (1), Transaction ID (2), Param Length (2), Param 1, Param 2, ..
|
||||
|
||||
|
@ -31,6 +31,7 @@
|
||||
#pragma mark once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "socket_connection.h"
|
||||
|
||||
typedef enum {
|
||||
SDP_ErrorResponse = 1,
|
||||
@ -46,7 +47,10 @@ void sdp_init();
|
||||
|
||||
// register service record internally
|
||||
// @returns ServiceRecordHandle or 0 if registration failed
|
||||
uint32_t sdp_register_service_internal(uint8_t * service_record);
|
||||
uint32_t sdp_register_service_internal(connection_t *connection, uint8_t * service_record);
|
||||
|
||||
// unregister service record internally
|
||||
void sdp_unregister_service_internal(uint32_t service_record_handle);
|
||||
void sdp_unregister_service_internal(connection_t *connection, uint32_t service_record_handle);
|
||||
|
||||
//
|
||||
void sdp_unregister_services_for_connection(connection_t *connection);
|
Loading…
Reference in New Issue
Block a user