fix more l2cap packet handler

This commit is contained in:
Matthias Ringwald 2015-11-13 22:03:53 +01:00
parent ffbf82013e
commit c5a819b6c9
5 changed files with 20 additions and 12 deletions

View File

@ -755,6 +755,10 @@ 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,
@ -764,7 +768,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(packet_handler);
rfcomm_register_packet_handler(rfcomm_packet_handler);
hfp_init(rfcomm_channel_nr);
hfp_supported_features = supported_features;

View File

@ -663,6 +663,10 @@ 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);
@ -691,7 +695,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(packet_handler);
rfcomm_register_packet_handler(rfcomm_packet_handler);
hfp_init(rfcomm_channel_nr);
hfp_supported_features = supported_features;

View File

@ -632,7 +632,7 @@ static int stdin_process(struct data_source *ds){
}
/*************** PANU client routines *********************/
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)
{
uint8_t event;
bd_addr_t event_addr;
@ -782,6 +782,10 @@ static void packet_handler (void * connection, uint8_t packet_type, uint16_t cha
}
}
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);
}
int btstack_main(int argc, const char * argv[]);
int btstack_main(int argc, const char * argv[]){
@ -792,7 +796,7 @@ int btstack_main(int argc, const char * argv[]){
/* Initialise BNEP */
bnep_init();
bnep_register_packet_handler(packet_handler);
bnep_register_packet_handler(packet_handler2);
bnep_register_service(NULL, bnep_local_service_uuid, 1691); /* Minimum L2CAP MTU for bnep is 1691 bytes */
/* Initialize SDP and add PANU record */

View File

@ -638,7 +638,7 @@ static int stdin_process(struct data_source *ds){
case 'l':
printf("Creating RFCOMM Channel to %s #%u\n", bd_addr_to_str(remote_rfcomm), rfcomm_channel_nr);
rfcomm_create_channel_internal(NULL, remote_rfcomm, rfcomm_channel_nr);
rfcomm_create_channel(remote_rfcomm, rfcomm_channel_nr, NULL);
break;
case 'n':
printf("Send RFCOMM Data\n"); // mtu < 60
@ -773,7 +773,7 @@ int btstack_main(int argc, const char * argv[]){
update_auth_req();
l2cap_init();
l2cap_register_packet_handler(&packet_handler2);
l2cap_register_packet_handler(&packet_handler);
l2cap_register_fixed_channel(&packet_handler, L2CAP_CID_CONNECTIONLESS_CHANNEL);
rfcomm_init();

View File

@ -108,10 +108,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 show_usage(void){
printf("\n--- CLI for L2CAP TEST ---\n");
printf("c - create connection to SDP at addr %s\n", bd_addr_to_str(remote));
@ -128,7 +124,7 @@ static int stdin_process(struct data_source *ds){
switch (buffer){
case 'c':
printf("Creating L2CAP Connection to %s, PSM SDP\n", bd_addr_to_str(remote));
l2cap_create_channel_internal(NULL, packet_handler, remote, PSM_SDP, 100);
l2cap_create_channel(packet_handler, remote, PSM_SDP, 100, NULL);
break;
case 's':
printf("Send L2CAP Data\n");
@ -161,7 +157,7 @@ int btstack_main(int argc, const char * argv[]){
hci_discoverable_control(1);
l2cap_init();
l2cap_register_packet_handler(&packet_handler2);
l2cap_register_packet_handler(&packet_handler);
l2cap_register_service(packet_handler, PSM_SDP, 100, LEVEL_0);
// turn on!