mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-14 01:27:41 +00:00
drop void * connection param from l2cap packet handlers
This commit is contained in:
parent
02f83142d4
commit
ffbf82013e
@ -234,7 +234,7 @@ static void fill_advertising_report_from_packet(advertising_report_t * report, u
|
||||
dump_advertising_report(report);
|
||||
}
|
||||
|
||||
static void handle_hci_event(void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
static void handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
if (packet_type != HCI_EVENT_PACKET) return;
|
||||
advertising_report_t report;
|
||||
uint8_t event = packet[0];
|
||||
|
@ -105,7 +105,7 @@ static uint16_t gc_id;
|
||||
|
||||
// Handles connect, disconnect, and advertising report events,
|
||||
// starts the GATT client, and sends the first query.
|
||||
static void handle_hci_event(void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||
static void handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||
|
||||
// Handles GATT client query results, sends queries and the
|
||||
// GAP disconnect command when the querying is done.
|
||||
@ -180,7 +180,7 @@ static void fill_advertising_report_from_packet(advertising_report_t * report, u
|
||||
*/
|
||||
|
||||
/* LISTING_START(GATTBrowserHCIPacketHandler): Connecting and disconnecting from the GATT client */
|
||||
static void handle_hci_event(void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
static void handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
if (packet_type != HCI_EVENT_PACKET) return;
|
||||
advertising_report_t report;
|
||||
|
||||
|
@ -86,7 +86,7 @@
|
||||
static int le_notification_enabled;
|
||||
static timer_source_t heartbeat;
|
||||
|
||||
static void packet_handler (void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||
static uint16_t att_read_callback(uint16_t con_handle, uint16_t att_handle, uint16_t offset, uint8_t * buffer, uint16_t buffer_size);
|
||||
static int att_write_callback(uint16_t con_handle, uint16_t att_handle, uint16_t transaction_mode, uint16_t offset, uint8_t *buffer, uint16_t buffer_size);
|
||||
static void heartbeat_handler(struct timer *ts);
|
||||
@ -136,7 +136,7 @@ static void le_counter_setup(void){
|
||||
*/
|
||||
|
||||
/* LISTING_START(packetHandler): Packet Handler */
|
||||
static void packet_handler (void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
switch (packet_type) {
|
||||
case HCI_EVENT_PACKET:
|
||||
switch (packet[0]) {
|
||||
|
@ -133,7 +133,7 @@ static data_source_t tap_dev_ds;
|
||||
*/
|
||||
|
||||
/* LISTING_START(PanuSetup): Panu setup */
|
||||
static void packet_handler (void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||
static void handle_sdp_client_query_result(sdp_query_event_t *event);
|
||||
|
||||
static void panu_setup(void){
|
||||
@ -428,7 +428,7 @@ static void handle_sdp_client_query_result(sdp_query_event_t *event)
|
||||
|
||||
|
||||
/* LISTING_START(packetHandler): Packet Handler */
|
||||
static void packet_handler (void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size)
|
||||
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size)
|
||||
{
|
||||
/* LISTING_PAUSE */
|
||||
int rc;
|
||||
|
@ -90,7 +90,7 @@ static void assertBuffer(int size){
|
||||
*/
|
||||
|
||||
/* LISTING_START(SDPClientInit): SDP client setup */
|
||||
static void packet_handler (void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||
static void handle_sdp_client_query_result(sdp_query_event_t * event);
|
||||
|
||||
static void sdp_client_init(void){
|
||||
@ -113,7 +113,7 @@ static void sdp_client_init(void){
|
||||
*/
|
||||
|
||||
/* LISTING_START(SDPQueryUUID): Querying the a list of service records on a remote device. */
|
||||
static void packet_handler (void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
if (packet_type != HCI_EVENT_PACKET) return;
|
||||
uint8_t event = packet[0];
|
||||
|
||||
|
@ -79,7 +79,7 @@ static const int attribute_value_buffer_size = sizeof(attribute_value);
|
||||
*/
|
||||
|
||||
/* LISTING_START(SDPClientInit): SDP client setup */
|
||||
static void packet_handler (void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||
static void handle_sdp_client_query_result(sdp_query_event_t * event);
|
||||
|
||||
static void sdp_client_init(void){
|
||||
@ -107,7 +107,7 @@ static bd_addr_t remote = {0x04,0x0C,0xCE,0xE4,0x85,0xD3};
|
||||
/* LISTING_END */
|
||||
|
||||
/* LISTING_START(SDPQueryUUID): Querying a list of service records on a remote device. */
|
||||
static void packet_handler (void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
// printf("packet_handler type %u, packet[0] %x\n", packet_type, packet[0]);
|
||||
|
||||
if (packet_type != HCI_EVENT_PACKET) return;
|
||||
|
@ -66,7 +66,7 @@ static uint8_t channel_nr[10];
|
||||
static char* service_name[10];
|
||||
|
||||
|
||||
static void packet_handler (void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
// printf("packet_handler type %u, packet[0] %x\n", packet_type, packet[0]);
|
||||
|
||||
if (packet_type != HCI_EVENT_PACKET) return;
|
||||
|
@ -111,7 +111,7 @@ uint8_t adv_data_len = sizeof(adv_data);
|
||||
* @text The packet handler of the combined example is just the combination of the individual packet handlers.
|
||||
*/
|
||||
|
||||
static void packet_handler (void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
bd_addr_t event_addr;
|
||||
uint8_t rfcomm_channel_nr;
|
||||
uint16_t mtu;
|
||||
@ -180,6 +180,10 @@ static void packet_handler (void * connection, uint8_t packet_type, uint16_t cha
|
||||
}
|
||||
}
|
||||
|
||||
static void rfcomm_packet_handler (void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
packet_handler(packet_type, channel, packet, size);
|
||||
}
|
||||
|
||||
// ATT Client Read Callback for Dynamic Data
|
||||
// - if buffer == NULL, don't copy data, just return size of value
|
||||
// - if buffer != NULL, copy data and return number bytes copied
|
||||
@ -213,7 +217,7 @@ static int att_write_callback(uint16_t con_handle, uint16_t att_handle, uint16_t
|
||||
*/
|
||||
|
||||
/* LISTING_START(heartbeat): Combined Heartbeat handler */
|
||||
static void heartbeat_handler(struct timer *ts){
|
||||
static void heartbeat_handler(struct timer *ts){
|
||||
|
||||
counter++;
|
||||
counter_string_len = sprintf(counter_string, "BTstack counter %04u\n", counter);
|
||||
@ -255,7 +259,7 @@ int btstack_main(void)
|
||||
l2cap_register_packet_handler(packet_handler);
|
||||
|
||||
rfcomm_init();
|
||||
rfcomm_register_packet_handler(packet_handler);
|
||||
rfcomm_register_packet_handler(rfcomm_packet_handler);
|
||||
rfcomm_register_service_internal(NULL, RFCOMM_SERVER_CHANNEL, 0xffff);
|
||||
|
||||
// init SDP, create record for SPP and register with SDP
|
||||
|
@ -68,11 +68,14 @@
|
||||
#define RFCOMM_SERVER_CHANNEL 1
|
||||
#define HEARTBEAT_PERIOD_MS 1000
|
||||
|
||||
static void packet_handler (void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||
|
||||
static uint16_t rfcomm_channel_id;
|
||||
static uint32_t spp_service_buffer[150/4]; // implicit alignment to 4-byte memory address
|
||||
|
||||
static void rfcomm_packet_handler (void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
packet_handler(packet_type, channel, packet, size);
|
||||
}
|
||||
|
||||
/* @section SPP Service Setup
|
||||
*s
|
||||
@ -94,7 +97,7 @@ static void spp_service_setup(void){
|
||||
l2cap_register_packet_handler(packet_handler);
|
||||
|
||||
rfcomm_init();
|
||||
rfcomm_register_packet_handler(packet_handler);
|
||||
rfcomm_register_packet_handler(rfcomm_packet_handler);
|
||||
rfcomm_register_service_internal(NULL, RFCOMM_SERVER_CHANNEL, 0xffff); // reserved channel, mtu limited by l2cap
|
||||
|
||||
// init SDP, create record for SPP and register with SDP
|
||||
@ -188,7 +191,7 @@ static void one_shot_timer_setup(void){
|
||||
*/
|
||||
|
||||
/* LISTING_START(SppServerPacketHandler): SPP Server - Heartbeat Counter over RFCOMM */
|
||||
static void packet_handler (void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
/* LISTING_PAUSE */
|
||||
bd_addr_t event_addr;
|
||||
uint8_t rfcomm_channel_nr;
|
||||
|
@ -62,7 +62,7 @@
|
||||
|
||||
#define HEARTBEAT_PERIOD_MS 500
|
||||
|
||||
static void packet_handler (void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||
|
||||
static uint8_t rfcomm_channel_nr = 1;
|
||||
static uint16_t rfcomm_channel_id;
|
||||
@ -133,7 +133,7 @@ static void one_shot_timer_setup(void){
|
||||
|
||||
/* LISTING_START(phManual): Packet handler with manual credit management */
|
||||
// Bluetooth logic
|
||||
static void packet_handler (void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
/* LISTING_PAUSE */
|
||||
bd_addr_t event_addr;
|
||||
uint8_t rfcomm_channel_nr;
|
||||
|
@ -112,7 +112,7 @@ static void send_packet(void){
|
||||
data_to_send -= test_data_len;
|
||||
}
|
||||
|
||||
static void packet_handler (void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
// printf("packet_handler type %u, packet[0] %x\n", packet_type, packet[0]);
|
||||
|
||||
if (packet_type != HCI_EVENT_PACKET) return;
|
||||
@ -150,6 +150,10 @@ static void packet_handler (void * connection, uint8_t packet_type, uint16_t cha
|
||||
}
|
||||
}
|
||||
|
||||
static void rfcomm_packet_handler (void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
packet_handler(packet_type, channel, packet, size);
|
||||
}
|
||||
|
||||
static void handle_found_service(char * name, uint8_t port){
|
||||
printf("APP: Service name: '%s', RFCOMM port %u\n", name, port);
|
||||
|
||||
@ -194,7 +198,7 @@ int btstack_main(int argc, const char * argv[]){
|
||||
l2cap_init();
|
||||
l2cap_register_packet_handler(packet_handler);
|
||||
|
||||
rfcomm_register_packet_handler(packet_handler);
|
||||
rfcomm_register_packet_handler(rfcomm_packet_handler);
|
||||
|
||||
sdp_query_rfcomm_register_callback(handle_query_rfcomm_event, NULL);
|
||||
|
||||
|
@ -835,6 +835,7 @@ static int btstack_command_handler(connection_t *connection, uint8_t *packet, ui
|
||||
psm = READ_BT_16(packet, 3);
|
||||
mtu = READ_BT_16(packet, 5);
|
||||
status = l2cap_register_service(NULL, psm, mtu, LEVEL_0);
|
||||
daemon_add_client_l2cap_service(connection, READ_BT_16(packet, 3));
|
||||
l2cap_emit_service_registered(connection, status, psm);
|
||||
break;
|
||||
case L2CAP_UNREGISTER_SERVICE:
|
||||
@ -1361,6 +1362,7 @@ static void daemon_packet_handler(void * connection, uint8_t packet_type, uint16
|
||||
daemon_add_client_rfcomm_service(connection, packet[3]);
|
||||
break;
|
||||
case L2CAP_EVENT_CHANNEL_OPENED:
|
||||
// TODO: connection == NULL, lookup via l2cap_cid needed
|
||||
if (packet[2]) {
|
||||
daemon_remove_client_l2cap_channel(connection, READ_BT_16(packet, 13));
|
||||
} else {
|
||||
@ -1368,12 +1370,9 @@ static void daemon_packet_handler(void * connection, uint8_t packet_type, uint16
|
||||
}
|
||||
break;
|
||||
case L2CAP_EVENT_CHANNEL_CLOSED:
|
||||
// TODO: connection == NULL, lookup via l2cap_cid needed
|
||||
daemon_remove_client_l2cap_channel(connection, READ_BT_16(packet, 2));
|
||||
break;
|
||||
case L2CAP_EVENT_SERVICE_REGISTERED:
|
||||
if (packet[2]) break;
|
||||
daemon_add_client_l2cap_service(connection, READ_BT_16(packet, 3));
|
||||
break;
|
||||
#if defined(HAVE_BLE) && defined(HAVE_MALLOC)
|
||||
case HCI_EVENT_DISCONNECTION_COMPLETE:
|
||||
log_info("daemon : ignore HCI_EVENT_DISCONNECTION_COMPLETE ingnoring.");
|
||||
@ -1402,6 +1401,10 @@ static void daemon_packet_handler(void * connection, uint8_t packet_type, uint16
|
||||
}
|
||||
}
|
||||
|
||||
static void l2cap_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t * packet, uint16_t size){
|
||||
daemon_packet_handler(NULL, packet_type, channel, packet, size);
|
||||
}
|
||||
|
||||
static void handle_sdp_rfcomm_service_result(sdp_query_event_t * rfcomm_event, void * context){
|
||||
switch (rfcomm_event->type){
|
||||
case SDP_QUERY_RFCOMM_SERVICE: {
|
||||
@ -1838,7 +1841,7 @@ int main (int argc, char * const * argv){
|
||||
#endif
|
||||
// init L2CAP
|
||||
l2cap_init();
|
||||
l2cap_register_packet_handler(&daemon_packet_handler);
|
||||
l2cap_register_packet_handler(&l2cap_packet_handler);
|
||||
timeout.process = daemon_no_connections_timeout;
|
||||
|
||||
#ifdef HAVE_RFCOMM
|
||||
|
@ -78,7 +78,7 @@ static uint8_t spp_service_buffer[100];
|
||||
|
||||
|
||||
// Bluetooth logic
|
||||
static void packet_handler (void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
bd_addr_t event_addr;
|
||||
uint8_t rfcomm_channel_nr;
|
||||
uint16_t mtu;
|
||||
|
@ -121,7 +121,7 @@ static void send_packet(void){
|
||||
}
|
||||
|
||||
// Bluetooth logic
|
||||
static void packet_handler (void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
bd_addr_t event_addr;
|
||||
uint8_t rfcomm_channel_nr;
|
||||
uint16_t mtu;
|
||||
|
@ -78,7 +78,7 @@ static uint8_t spp_service_buffer[100];
|
||||
|
||||
|
||||
// Bluetooth logic
|
||||
static void packet_handler (void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
bd_addr_t event_addr;
|
||||
uint8_t rfcomm_channel_nr;
|
||||
uint16_t mtu;
|
||||
|
@ -271,7 +271,7 @@ static void l2cap_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t
|
||||
}
|
||||
}
|
||||
|
||||
static void packet_handler (void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
int i,j;
|
||||
switch (packet_type) {
|
||||
case HCI_EVENT_PACKET:
|
||||
|
@ -121,7 +121,7 @@ static void send_packet(void){
|
||||
}
|
||||
|
||||
// Bluetooth logic
|
||||
static void packet_handler (void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
bd_addr_t event_addr;
|
||||
uint8_t rfcomm_channel_nr;
|
||||
uint16_t mtu;
|
||||
|
@ -73,7 +73,7 @@ static int hfp_ag_call_hold_services_nr = 0;
|
||||
static char *hfp_ag_call_hold_services[6];
|
||||
static hfp_callback_t hfp_callback;
|
||||
|
||||
static void packet_handler(void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||
static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||
|
||||
hfp_generic_status_indicator_t * get_hfp_generic_status_indicators();
|
||||
int get_hfp_generic_status_indicators_nr();
|
||||
@ -740,7 +740,7 @@ static void hfp_run(){
|
||||
}
|
||||
}
|
||||
|
||||
static void packet_handler(void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
switch (packet_type){
|
||||
case RFCOMM_DATA_PACKET:
|
||||
hfp_handle_rfcomm_event(packet_type, channel, packet, size);
|
||||
|
@ -108,7 +108,7 @@ static int has_hf_indicators_feature(hfp_connection_t * connection){
|
||||
return hf && ag;
|
||||
}
|
||||
|
||||
static void packet_handler(void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||
static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||
|
||||
void hfp_hf_create_sdp_record(uint8_t * service, int rfcomm_channel_nr, const char * name, uint16_t supported_features){
|
||||
if (!name){
|
||||
@ -650,7 +650,7 @@ static void hfp_run(){
|
||||
}
|
||||
}
|
||||
|
||||
static void packet_handler(void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
switch (packet_type){
|
||||
case RFCOMM_DATA_PACKET:
|
||||
hfp_handle_rfcomm_event(packet_type, channel, packet, size);
|
||||
|
@ -363,8 +363,6 @@ typedef struct {
|
||||
|
||||
} rfcomm_channel_t;
|
||||
|
||||
void rfcomm_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||
|
||||
/* API_START */
|
||||
|
||||
/**
|
||||
|
22
src/l2cap.c
22
src/l2cap.c
@ -66,7 +66,7 @@
|
||||
#define L2CAP_SIGNALING_COMMAND_LENGTH_OFFSET 2
|
||||
#define L2CAP_SIGNALING_COMMAND_DATA_OFFSET 4
|
||||
|
||||
static void null_packet_handler(void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||
static void null_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||
static void l2cap_packet_handler(uint8_t packet_type, uint8_t *packet, uint16_t size);
|
||||
|
||||
// used to cache l2cap rejects, echo, and informational requests
|
||||
@ -77,7 +77,7 @@ static linked_list_t l2cap_channels;
|
||||
static linked_list_t l2cap_services;
|
||||
static linked_list_t l2cap_le_channels;
|
||||
static linked_list_t l2cap_le_services;
|
||||
static void (*packet_handler) (void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size) = null_packet_handler;
|
||||
static void (*packet_handler) (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size) = null_packet_handler;
|
||||
static int new_credits_blocked = 0;
|
||||
|
||||
static btstack_packet_handler_t attribute_protocol_packet_handler;
|
||||
@ -119,9 +119,9 @@ void l2cap_init(void){
|
||||
|
||||
|
||||
/** Register L2CAP packet handlers */
|
||||
static void null_packet_handler(void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
static void null_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
}
|
||||
void l2cap_register_packet_handler(void (*handler)(void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size)){
|
||||
void l2cap_register_packet_handler(void (*handler)(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size)){
|
||||
packet_handler = handler;
|
||||
}
|
||||
|
||||
@ -130,7 +130,7 @@ static void l2cap_dispatch(l2cap_channel_t *channel, uint8_t type, uint8_t * dat
|
||||
if (channel->packet_handler) {
|
||||
(* (channel->packet_handler))(type, channel->local_cid, data, size);
|
||||
} else {
|
||||
(*packet_handler)(channel->connection, type, channel->local_cid, data, size);
|
||||
(*packet_handler)(type, channel->local_cid, data, size);
|
||||
}
|
||||
}
|
||||
|
||||
@ -186,7 +186,7 @@ static void l2cap_emit_connection_parameter_update_response(uint16_t handle, uin
|
||||
bt_store_16(event, 2, handle);
|
||||
bt_store_16(event, 4, result);
|
||||
hci_dump_packet( HCI_EVENT_PACKET, 0, event, sizeof(event));
|
||||
(*packet_handler)(NULL, HCI_EVENT_PACKET, 0, event, sizeof(event));
|
||||
(*packet_handler)(HCI_EVENT_PACKET, 0, event, sizeof(event));
|
||||
}
|
||||
|
||||
static void l2cap_emit_credits(l2cap_channel_t *channel, uint8_t credits) {
|
||||
@ -1015,7 +1015,7 @@ static void l2cap_event_handler(uint8_t *packet, uint16_t size){
|
||||
}
|
||||
|
||||
// pass on: main packet handler, att and sm packet handlers
|
||||
(*packet_handler)(NULL, HCI_EVENT_PACKET, 0, packet, size);
|
||||
(*packet_handler)(HCI_EVENT_PACKET, 0, packet, size);
|
||||
if (attribute_protocol_packet_handler){
|
||||
(*attribute_protocol_packet_handler)(HCI_EVENT_PACKET, 0, packet, size);
|
||||
}
|
||||
@ -1078,7 +1078,6 @@ static void l2cap_handle_connection_request(hci_con_handle_t handle, uint8_t sig
|
||||
BD_ADDR_COPY(channel->address, hci_connection->address);
|
||||
channel->psm = psm;
|
||||
channel->handle = handle;
|
||||
channel->connection = service->connection;
|
||||
channel->packet_handler = service->packet_handler;
|
||||
channel->local_cid = l2cap_next_local_cid();
|
||||
channel->remote_cid = source_cid;
|
||||
@ -1460,7 +1459,7 @@ static void l2cap_acl_handler( uint8_t *packet, uint16_t size ){
|
||||
}
|
||||
|
||||
hci_dump_packet( HCI_EVENT_PACKET, 0, event, sizeof(event));
|
||||
(*packet_handler)(NULL, HCI_EVENT_PACKET, 0, event, sizeof(event));
|
||||
(*packet_handler)( HCI_EVENT_PACKET, 0, event, sizeof(event));
|
||||
|
||||
break;
|
||||
}
|
||||
@ -1600,7 +1599,7 @@ static inline l2cap_service_t * l2cap_le_get_service(uint16_t psm){
|
||||
* @brief Regster L2CAP LE Credit Based Flow Control Mode service
|
||||
* @param
|
||||
*/
|
||||
void l2cap_le_register_service_internal(void * connection, btstack_packet_handler_t packet_handler, uint16_t psm,
|
||||
void l2cap_le_register_service(btstack_packet_handler_t packet_handler, uint16_t psm,
|
||||
uint16_t mtu, uint16_t mps, uint16_t initial_credits, gap_security_level_t security_level){
|
||||
|
||||
log_info("L2CAP_LE_REGISTER_SERVICE psm 0x%x mtu %u connection %p", psm, mtu, connection);
|
||||
@ -1627,7 +1626,6 @@ void l2cap_le_register_service_internal(void * connection, btstack_packet_handle
|
||||
service->psm = psm;
|
||||
service->mtu = mtu;
|
||||
service->mps = mps;
|
||||
service->connection = connection;
|
||||
service->packet_handler = packet_handler;
|
||||
service->required_security_level = security_level;
|
||||
|
||||
@ -1638,7 +1636,7 @@ void l2cap_le_register_service_internal(void * connection, btstack_packet_handle
|
||||
l2cap_emit_service_registered(connection, 0, psm);
|
||||
}
|
||||
|
||||
void l2cap_le_unregister_service_internal(void * connection, uint16_t psm) {
|
||||
void l2cap_le_unregister_service(uint16_t psm) {
|
||||
|
||||
log_info("L2CAP_LE_UNREGISTER_SERVICE psm 0x%x", psm);
|
||||
|
||||
|
14
src/l2cap.h
14
src/l2cap.h
@ -161,9 +161,6 @@ typedef struct {
|
||||
|
||||
timer_source_t rtx; // also used for ertx
|
||||
|
||||
// client connection
|
||||
void * connection;
|
||||
|
||||
// internal connection
|
||||
btstack_packet_handler_t packet_handler;
|
||||
|
||||
@ -183,9 +180,6 @@ typedef struct {
|
||||
// incoming MPS
|
||||
uint16_t mps;
|
||||
|
||||
// client connection
|
||||
void * connection;
|
||||
|
||||
// internal connection
|
||||
btstack_packet_handler_t packet_handler;
|
||||
|
||||
@ -223,7 +217,7 @@ void l2cap_init(void);
|
||||
/**
|
||||
* @brief Registers a packet handler that handles HCI and general BTstack events.
|
||||
*/
|
||||
void l2cap_register_packet_handler(void (*handler)(void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size));
|
||||
void l2cap_register_packet_handler(void (*handler)(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size));
|
||||
|
||||
/**
|
||||
* @brief Creates L2CAP channel to the PSM of a remote device with baseband address. A new baseband connection will be initiated if necessary.
|
||||
@ -302,9 +296,9 @@ int l2cap_send_connectionless(uint16_t handle, uint16_t cid, uint8_t *data, uin
|
||||
* @brief Regster L2CAP LE Credit Based Flow Control Mode service
|
||||
* @param
|
||||
*/
|
||||
void l2cap_le_register_service_internal(void * connection, btstack_packet_handler_t packet_handler, uint16_t psm,
|
||||
uint16_t mtu, uint16_t mps, uint16_t initial_credits, gap_security_level_t security_level);
|
||||
void l2cap_le_unregister_service_internal(void * connection, uint16_t psm);
|
||||
void l2cap_le_register_service(btstack_packet_handler_t packet_handler, uint16_t psm,
|
||||
uint16_t mtu, uint16_t mps, uint16_t initial_credits, gap_security_level_t security_level);
|
||||
void l2cap_le_unregister_service(uint16_t psm);
|
||||
#endif
|
||||
|
||||
#if defined __cplusplus
|
||||
|
Loading…
x
Reference in New Issue
Block a user