flow control working, disable some dbg msgs

This commit is contained in:
matthias.ringwald 2010-07-31 09:07:48 +00:00
parent 0e7bc007cb
commit 8ea03fa513
4 changed files with 25 additions and 23 deletions

View File

@ -216,6 +216,9 @@ static int daemon_client_handler(connection_t *connection, uint16_t packet_type,
}
break;
}
if (err) {
printf("Daemon Handler: err %d\n", err);
}
return err;
}
@ -258,21 +261,16 @@ static void deamon_status_event_handler(uint8_t *packet, uint16_t size){
}
static void daemon_packet_handler(void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
switch (packet_type) {
case HCI_EVENT_PACKET:
deamon_status_event_handler(packet, size);
// forward event to client(s)
if (connection) {
socket_connection_send_packet(connection, packet_type, 0, packet, size);
} else {
socket_connection_send_packet_all(packet_type, 0, packet, size);
}
break;
case L2CAP_DATA_PACKET:
socket_connection_send_packet(connection, L2CAP_DATA_PACKET, channel, packet, size);
break;
default:
break;
if (packet_type == HCI_EVENT_PACKET) {
deamon_status_event_handler(packet, size);
if (packet[0] == HCI_EVENT_NUMBER_OF_COMPLETED_PACKETS) {
socket_connection_retry_parked();
}
}
if (connection) {
socket_connection_send_packet(connection, packet_type, channel, packet, size);
} else {
socket_connection_send_packet_all(packet_type, channel, packet, size);
}
}

View File

@ -198,7 +198,7 @@ int hci_send_acl_packet(uint8_t *packet, int size){
// count packet
connection->num_acl_packets_sent++;
log_dbg("hci_send_acl_packet - handle %u, sent %u\n", connection->con_handle, connection->num_acl_packets_sent);
// log_dbg("hci_send_acl_packet - handle %u, sent %u\n", connection->con_handle, connection->num_acl_packets_sent);
// send packet - ignore errors
hci_stack.hci_transport->send_acl_packet(packet, size);
@ -326,7 +326,7 @@ static void event_handler(uint8_t *packet, int size){
continue;
}
conn->num_acl_packets_sent -= num_packets;
log_dbg("hci_number_completed_packet (hci) %u processed for handle %u, outstanding %u\n", num_packets, handle, conn->num_acl_packets_sent);
// log_dbg("hci_number_completed_packet %u processed for handle %u, outstanding %u\n", num_packets, handle, conn->num_acl_packets_sent);
}
break;

View File

@ -191,8 +191,10 @@ int l2cap_send_signaling_packet(hci_con_handle_t handle, L2CAP_SIGNALING_COMMAND
int l2cap_send_internal(uint16_t local_cid, uint8_t *data, uint16_t len){
// check for free places on BT module
if (!hci_number_free_acl_slots()) return -1;
if (!hci_number_free_acl_slots()) {
log_dbg("l2cap_send_internal cid %u, BT module full <-----\n", local_cid);
return -1;
}
int err = 0;
// find channel for local_cid, construct l2cap packet and send
@ -202,11 +204,11 @@ int l2cap_send_internal(uint16_t local_cid, uint8_t *data, uint16_t len){
++channel->packets_outgoing;
if (channel->packets_granted > 0){
--channel->packets_granted;
// log_dbg("l2cap_send_internal cid %u, 1 credit used, credits left %u; outgoing count %u\n",
// local_cid, channel->packets_granted, channel->packets_outgoing);
} else {
log_err("l2cap_send_internal cid %u, no credits!\n", local_cid);
}
log_dbg("l2cap_send_internal cid %u, 1 credit used, credits left %u; outgoing count %u\n",
local_cid, channel->packets_granted, channel->packets_outgoing);
// 0 - Connection handle : PB=10 : BC=00
bt_store_16(acl_buffer, 0, channel->handle | (2 << 12) | (0 << 14));
@ -366,8 +368,8 @@ void l2cap_event_handler( uint8_t *packet, uint16_t size ){
// decrease packets
if (fullest_channel) {
fullest_channel->packets_outgoing--;
log_dbg("hci_number_completed_packet (l2cap) for cid %u, outgoing count %u\n",
fullest_channel->local_cid, fullest_channel->packets_outgoing);
// log_dbg("hci_number_completed_packet (l2cap) for cid %u, outgoing count %u\n",
// fullest_channel->local_cid, fullest_channel->packets_outgoing);
} else {
log_err("hci_number_completed_packet but no outgoing packet in records\n");
}

View File

@ -221,6 +221,7 @@ int socket_connection_hci_process(struct data_source *ds) {
* pre: connections get parked iff packet was dispatched but could not be sent
*/
void socket_connection_retry_parked(){
// log_dbg("socket_connection_hci_process retry parked\n");
linked_item_t *next;
linked_item_t *it;
for (it = (linked_item_t *) parked; it ; it = next){
@ -228,6 +229,7 @@ void socket_connection_retry_parked(){
connection_t * conn = (connection_t *) it;
// dispatch packet !!! connection, type, channel, data, size
log_dbg("socket_connection_hci_process retry parked #0\n");
int dispatch_err = (*socket_connection_packet_callback)(conn, READ_BT_16( conn->buffer, 0), READ_BT_16( conn->buffer, 2),
&conn->buffer[sizeof(packet_header_t)], READ_BT_16( conn->buffer, 4));
// "un-park" if successful