mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-28 19:20:54 +00:00
panu_demo: enable tun interface read callback
This commit is contained in:
parent
dbc206868b
commit
36b4a12c09
@ -278,19 +278,12 @@ static void process_tap_dev_data(btstack_data_source_t *ds, btstack_data_source_
|
|||||||
}
|
}
|
||||||
|
|
||||||
network_buffer_len = len;
|
network_buffer_len = len;
|
||||||
log_info("network packet, len %u", (int) len);
|
|
||||||
if (bnep_can_send_packet_now(bnep_cid)) {
|
// disable reading from netif
|
||||||
log_info("direct send");
|
btstack_run_loop_disable_data_source_callbacks(&tap_dev_ds, DATA_SOURCE_CALLBACK_READ);
|
||||||
bnep_send(bnep_cid, network_buffer, network_buffer_len);
|
|
||||||
network_buffer_len = 0;
|
// request permission to send
|
||||||
} else {
|
bnep_request_can_send_now_event(bnep_cid);
|
||||||
log_info("cannort send, request permission");
|
|
||||||
// park the current network packet
|
|
||||||
btstack_run_loop_remove_data_source(&tap_dev_ds);
|
|
||||||
// and request a send permission
|
|
||||||
bnep_request_can_send_now_event(bnep_cid);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
/* LISTING_END */
|
/* LISTING_END */
|
||||||
|
|
||||||
@ -525,6 +518,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
|||||||
btstack_run_loop_set_data_source_fd(&tap_dev_ds, tap_fd);
|
btstack_run_loop_set_data_source_fd(&tap_dev_ds, tap_fd);
|
||||||
btstack_run_loop_set_data_source_handler(&tap_dev_ds, &process_tap_dev_data);
|
btstack_run_loop_set_data_source_handler(&tap_dev_ds, &process_tap_dev_data);
|
||||||
btstack_run_loop_add_data_source(&tap_dev_ds);
|
btstack_run_loop_add_data_source(&tap_dev_ds);
|
||||||
|
btstack_run_loop_enable_data_source_callbacks(&tap_dev_ds, DATA_SOURCE_CALLBACK_READ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -547,19 +541,16 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* @text BNEP_EVENT_CAN_SEND_NOW indicates that a new packet can be send. This triggers the retry of a
|
/* @text BNEP_EVENT_CAN_SEND_NOW indicates that a new packet can be send. This triggers the send of a
|
||||||
* parked network packet. If this succeeds, the data source element is added to the run loop again.
|
* stored network packet. The tap datas source can be enabled again
|
||||||
*/
|
*/
|
||||||
case BNEP_EVENT_CAN_SEND_NOW:
|
case BNEP_EVENT_CAN_SEND_NOW:
|
||||||
// Check for parked network packets and send it out now
|
|
||||||
if (network_buffer_len > 0) {
|
if (network_buffer_len > 0) {
|
||||||
log_info("indirect send");
|
|
||||||
bnep_send(bnep_cid, network_buffer, network_buffer_len);
|
bnep_send(bnep_cid, network_buffer, network_buffer_len);
|
||||||
network_buffer_len = 0;
|
network_buffer_len = 0;
|
||||||
// Re-add the tap device data source
|
// Re-enable the tap device data source
|
||||||
btstack_run_loop_add_data_source(&tap_dev_ds);
|
btstack_run_loop_enable_data_source_callbacks(&tap_dev_ds, DATA_SOURCE_CALLBACK_READ);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -596,8 +587,6 @@ int btstack_main(int argc, const char * argv[]){
|
|||||||
(void)argc;
|
(void)argc;
|
||||||
(void)argv;
|
(void)argv;
|
||||||
|
|
||||||
printf("Client HCI init done\n");
|
|
||||||
|
|
||||||
panu_setup();
|
panu_setup();
|
||||||
|
|
||||||
// parse human readable Bluetooth address
|
// parse human readable Bluetooth address
|
||||||
|
Loading…
x
Reference in New Issue
Block a user