mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-14 10:21:49 +00:00
drop connection from rfcomm_register_packet_handler callback
This commit is contained in:
parent
457b5cb16b
commit
e4dd59a7e3
@ -180,10 +180,6 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
@ -259,7 +255,7 @@ int btstack_main(void)
|
||||
l2cap_register_packet_handler(packet_handler);
|
||||
|
||||
rfcomm_init();
|
||||
rfcomm_register_packet_handler(rfcomm_packet_handler);
|
||||
rfcomm_register_packet_handler(packet_handler);
|
||||
rfcomm_register_service(RFCOMM_SERVER_CHANNEL, 0xffff);
|
||||
|
||||
// init SDP, create record for SPP and register with SDP
|
||||
|
@ -73,9 +73,6 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
||||
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
|
||||
@ -97,7 +94,7 @@ static void spp_service_setup(void){
|
||||
l2cap_register_packet_handler(packet_handler);
|
||||
|
||||
rfcomm_init();
|
||||
rfcomm_register_packet_handler(rfcomm_packet_handler);
|
||||
rfcomm_register_packet_handler(packet_handler);
|
||||
rfcomm_register_service(RFCOMM_SERVER_CHANNEL, 0xffff); // reserved channel, mtu limited by l2cap
|
||||
|
||||
// init SDP, create record for SPP and register with SDP
|
||||
|
@ -150,10 +150,6 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@ -198,7 +194,7 @@ int btstack_main(int argc, const char * argv[]){
|
||||
l2cap_init();
|
||||
l2cap_register_packet_handler(packet_handler);
|
||||
|
||||
rfcomm_register_packet_handler(rfcomm_packet_handler);
|
||||
rfcomm_register_packet_handler(packet_handler);
|
||||
|
||||
sdp_query_rfcomm_register_callback(handle_query_rfcomm_event, NULL);
|
||||
|
||||
|
@ -1461,6 +1461,9 @@ 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 rfcomm_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){
|
||||
@ -1904,7 +1907,7 @@ int main (int argc, char * const * argv){
|
||||
#ifdef HAVE_RFCOMM
|
||||
log_info("config.h: HAVE_RFCOMM\n");
|
||||
rfcomm_init();
|
||||
rfcomm_register_packet_handler(&daemon_packet_handler);
|
||||
rfcomm_register_packet_handler(&rfcomm_packet_handler);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SDP
|
||||
|
@ -755,10 +755,6 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
||||
hfp_run();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void hfp_ag_init(uint16_t rfcomm_channel_nr, uint32_t supported_features,
|
||||
uint8_t * codecs, int codecs_nr,
|
||||
hfp_ag_indicator_t * ag_indicators, int ag_indicators_nr,
|
||||
@ -768,7 +764,7 @@ void hfp_ag_init(uint16_t rfcomm_channel_nr, uint32_t supported_features,
|
||||
log_error("hfp_init: codecs_nr (%d) > HFP_MAX_NUM_CODECS (%d)", codecs_nr, HFP_MAX_NUM_CODECS);
|
||||
return;
|
||||
}
|
||||
rfcomm_register_packet_handler(rfcomm_packet_handler);
|
||||
rfcomm_register_packet_handler(packet_handler);
|
||||
hfp_init(rfcomm_channel_nr);
|
||||
|
||||
hfp_supported_features = supported_features;
|
||||
|
@ -663,10 +663,6 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
||||
hfp_run();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void hfp_hf_set_codecs(uint8_t * codecs, int codecs_nr){
|
||||
if (codecs_nr > HFP_MAX_NUM_CODECS){
|
||||
log_error("hfp_hf_set_codecs: codecs_nr (%d) > HFP_MAX_NUM_CODECS (%d)", codecs_nr, HFP_MAX_NUM_CODECS);
|
||||
@ -695,7 +691,7 @@ void hfp_hf_set_codecs(uint8_t * codecs, int codecs_nr){
|
||||
}
|
||||
|
||||
void hfp_hf_init(uint16_t rfcomm_channel_nr, uint32_t supported_features, uint16_t * indicators, int indicators_nr, uint32_t indicators_status){
|
||||
rfcomm_register_packet_handler(rfcomm_packet_handler);
|
||||
rfcomm_register_packet_handler(packet_handler);
|
||||
hfp_init(rfcomm_channel_nr);
|
||||
|
||||
hfp_supported_features = supported_features;
|
||||
|
@ -115,7 +115,7 @@ static linked_list_t rfcomm_services = NULL;
|
||||
|
||||
static gap_security_level_t rfcomm_security_level;
|
||||
|
||||
static void (*app_packet_handler)(void * connection, uint8_t packet_type,
|
||||
static void (*app_packet_handler)(uint8_t packet_type,
|
||||
uint16_t channel, uint8_t *packet, uint16_t size);
|
||||
|
||||
static void rfcomm_run(void);
|
||||
@ -139,7 +139,7 @@ static void rfcomm_emit_connection_request(rfcomm_channel_t *channel) {
|
||||
event[8] = channel->dlci >> 1;
|
||||
bt_store_16(event, 9, channel->rfcomm_cid);
|
||||
hci_dump_packet(HCI_EVENT_PACKET, 0, event, sizeof(event));
|
||||
(*app_packet_handler)(channel->connection, HCI_EVENT_PACKET, 0, (uint8_t *) event, sizeof(event));
|
||||
(*app_packet_handler)(HCI_EVENT_PACKET, 0, (uint8_t *) event, sizeof(event));
|
||||
}
|
||||
|
||||
// API Change: BTstack-0.3.50x uses
|
||||
@ -161,7 +161,7 @@ static void rfcomm_emit_channel_opened(rfcomm_channel_t *channel, uint8_t status
|
||||
bt_store_16(event, pos, channel->rfcomm_cid); pos += 2; // 12 - channel ID
|
||||
bt_store_16(event, pos, channel->max_frame_size); pos += 2; // max frame size
|
||||
hci_dump_packet(HCI_EVENT_PACKET, 0, event, sizeof(event));
|
||||
(*app_packet_handler)(channel->connection, HCI_EVENT_PACKET, 0, (uint8_t *) event, pos);
|
||||
(*app_packet_handler)(HCI_EVENT_PACKET, 0, (uint8_t *) event, pos);
|
||||
}
|
||||
|
||||
// data: event(8), len(8), creidts incoming(8), new credits incoming(8), credits outgoing(8)
|
||||
@ -186,7 +186,7 @@ static void rfcomm_emit_channel_closed(rfcomm_channel_t * channel) {
|
||||
event[1] = sizeof(event) - 2;
|
||||
bt_store_16(event, 2, channel->rfcomm_cid);
|
||||
hci_dump_packet(HCI_EVENT_PACKET, 0, event, sizeof(event));
|
||||
(*app_packet_handler)(channel->connection, HCI_EVENT_PACKET, 0, (uint8_t *) event, sizeof(event));
|
||||
(*app_packet_handler)(HCI_EVENT_PACKET, 0, (uint8_t *) event, sizeof(event));
|
||||
}
|
||||
|
||||
static void rfcomm_emit_credits(rfcomm_channel_t * channel, uint8_t credits) {
|
||||
@ -197,7 +197,7 @@ static void rfcomm_emit_credits(rfcomm_channel_t * channel, uint8_t credits) {
|
||||
bt_store_16(event, 2, channel->rfcomm_cid);
|
||||
event[4] = credits;
|
||||
hci_dump_packet(HCI_EVENT_PACKET, 0, event, sizeof(event));
|
||||
(*app_packet_handler)(channel->connection, HCI_EVENT_PACKET, 0, (uint8_t *) event, sizeof(event));
|
||||
(*app_packet_handler)(HCI_EVENT_PACKET, 0, (uint8_t *) event, sizeof(event));
|
||||
}
|
||||
|
||||
static void rfcomm_emit_remote_line_status(rfcomm_channel_t *channel, uint8_t line_status){
|
||||
@ -208,7 +208,7 @@ static void rfcomm_emit_remote_line_status(rfcomm_channel_t *channel, uint8_t li
|
||||
bt_store_16(event, 2, channel->rfcomm_cid);
|
||||
event[4] = line_status;
|
||||
hci_dump_packet( HCI_EVENT_PACKET, 0, event, sizeof(event));
|
||||
(*app_packet_handler)(channel->connection, HCI_EVENT_PACKET, 0, (uint8_t *) event, sizeof(event));
|
||||
(*app_packet_handler)(HCI_EVENT_PACKET, 0, (uint8_t *) event, sizeof(event));
|
||||
}
|
||||
|
||||
static void rfcomm_emit_port_configuration(rfcomm_channel_t *channel){
|
||||
@ -218,7 +218,7 @@ static void rfcomm_emit_port_configuration(rfcomm_channel_t *channel){
|
||||
event[1] = sizeof(rfcomm_rpn_data_t);
|
||||
memcpy(&event[2], (uint8_t*) &channel->rpn_data, sizeof(rfcomm_rpn_data_t));
|
||||
hci_dump_packet( HCI_EVENT_PACKET, 0, event, sizeof(event));
|
||||
(*app_packet_handler)(channel->connection, HCI_EVENT_PACKET, channel->rfcomm_cid, (uint8_t*)event, sizeof(event));
|
||||
(*app_packet_handler)(HCI_EVENT_PACKET, channel->rfcomm_cid, (uint8_t*)event, sizeof(event));
|
||||
}
|
||||
|
||||
// MARK RFCOMM RPN DATA HELPER
|
||||
@ -1122,7 +1122,7 @@ static void rfcomm_multiplexer_state_machine(rfcomm_multiplexer_t * multiplexer,
|
||||
for (it = (linked_item_t *) rfcomm_channels; it ; it = it->next){
|
||||
rfcomm_channel_t * channel = ((rfcomm_channel_t *) it);
|
||||
if (channel->multiplexer != multiplexer) continue;
|
||||
(*app_packet_handler)(channel->connection, HCI_EVENT_PACKET, 0, (uint8_t *) packet_sent_event, sizeof(packet_sent_event));
|
||||
(*app_packet_handler)(HCI_EVENT_PACKET, 0, (uint8_t *) packet_sent_event, sizeof(packet_sent_event));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -1281,7 +1281,7 @@ static void rfcomm_channel_packet_handler_uih(rfcomm_multiplexer_t *multiplexer,
|
||||
}
|
||||
|
||||
// deliver payload
|
||||
(*app_packet_handler)(channel->connection, RFCOMM_DATA_PACKET, channel->rfcomm_cid,
|
||||
(*app_packet_handler)(RFCOMM_DATA_PACKET, channel->rfcomm_cid,
|
||||
&packet[payload_offset], size-payload_offset-1);
|
||||
}
|
||||
|
||||
@ -1548,12 +1548,12 @@ static void rfcomm_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t
|
||||
|
||||
// we only handle l2cap packet over open multiplexer channel now
|
||||
if (packet_type != L2CAP_DATA_PACKET) {
|
||||
(*app_packet_handler)(NULL, packet_type, channel, packet, size);
|
||||
(*app_packet_handler)(packet_type, channel, packet, size);
|
||||
return;
|
||||
}
|
||||
rfcomm_multiplexer_t * multiplexer = rfcomm_multiplexer_for_l2cap_cid(channel);
|
||||
if (!multiplexer || multiplexer->state != RFCOMM_MULTIPLEXER_OPEN) {
|
||||
(*app_packet_handler)(NULL, packet_type, channel, packet, size);
|
||||
(*app_packet_handler)(packet_type, channel, packet, size);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1689,7 +1689,7 @@ static void rfcomm_channel_state_machine(rfcomm_channel_t *channel, rfcomm_chann
|
||||
modem_status_event[0] = RFCOMM_EVENT_REMOTE_MODEM_STATUS;
|
||||
modem_status_event[1] = 1;
|
||||
modem_status_event[2] = event_msc->modem_status;
|
||||
(*app_packet_handler)(channel->connection, HCI_EVENT_PACKET, channel->rfcomm_cid, (uint8_t*)&modem_status_event, sizeof(modem_status_event));
|
||||
(*app_packet_handler)(HCI_EVENT_PACKET, channel->rfcomm_cid, (uint8_t*)&modem_status_event, sizeof(modem_status_event));
|
||||
// no return, MSC_CMD will be handled by state machine below
|
||||
}
|
||||
|
||||
@ -1875,7 +1875,7 @@ static void rfcomm_channel_state_machine(rfcomm_channel_t *channel, rfcomm_chann
|
||||
case CH_EVT_RCVD_CREDITS: {
|
||||
// notify daemon -> might trigger re-try of parked connections
|
||||
uint8_t credits_event[2] = { DAEMON_EVENT_NEW_RFCOMM_CREDITS, 0 };
|
||||
(*app_packet_handler)(channel->connection, DAEMON_EVENT_PACKET, channel->rfcomm_cid, credits_event, sizeof(credits_event));
|
||||
(*app_packet_handler)(DAEMON_EVENT_PACKET, channel->rfcomm_cid, credits_event, sizeof(credits_event));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -1993,7 +1993,7 @@ void rfcomm_set_required_security_level(gap_security_level_t security_level){
|
||||
}
|
||||
|
||||
// register packet handler
|
||||
void rfcomm_register_packet_handler(void (*handler)(void * connection, uint8_t packet_type,
|
||||
void rfcomm_register_packet_handler(void (*handler)(uint8_t packet_type,
|
||||
uint16_t channel, uint8_t *packet, uint16_t size)){
|
||||
app_packet_handler = handler;
|
||||
}
|
||||
|
@ -378,7 +378,7 @@ void rfcomm_set_required_security_level(gap_security_level_t security_level);
|
||||
/**
|
||||
* @brief Register packet handler.
|
||||
*/
|
||||
void rfcomm_register_packet_handler(void (*handler)(void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size));
|
||||
void rfcomm_register_packet_handler(void (*handler)(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size));
|
||||
|
||||
/*
|
||||
* @brief Create RFCOMM connection to a given server channel on a remote deivce.
|
||||
|
@ -375,11 +375,6 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
||||
}
|
||||
}
|
||||
|
||||
static void packet_handler2 (void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
packet_handler(packet_type, 0, packet, size);
|
||||
}
|
||||
|
||||
|
||||
static void update_auth_req(void){
|
||||
gap_set_bondable_mode(gap_bondable);
|
||||
gap_auth_req = 0;
|
||||
@ -777,7 +772,7 @@ int btstack_main(int argc, const char * argv[]){
|
||||
l2cap_register_fixed_channel(&packet_handler, L2CAP_CID_CONNECTIONLESS_CHANNEL);
|
||||
|
||||
rfcomm_init();
|
||||
rfcomm_register_packet_handler(packet_handler2);
|
||||
rfcomm_register_packet_handler(packet_handler);
|
||||
rfcomm_register_service(RFCOMM_SERVER_CHANNEL, 150); // reserved channel, mtu=100
|
||||
|
||||
// init SDP, create record for SPP and register with SDP
|
||||
|
Loading…
x
Reference in New Issue
Block a user