From 947a838a7b5e40fe42bdcaf061895f5a0829ddf6 Mon Sep 17 00:00:00 2001 From: meancoot Date: Fri, 21 Jun 2013 15:49:35 -0400 Subject: [PATCH] (iOS, BTstack) Cleanup l2cap commands --- ios/RetroArch/input/BTStack/btpad.c | 10 +- ios/RetroArch/input/BTStack/btpad_queue.c | 107 ---------------------- ios/RetroArch/input/BTStack/btpad_queue.h | 4 - 3 files changed, 5 insertions(+), 116 deletions(-) diff --git a/ios/RetroArch/input/BTStack/btpad.c b/ios/RetroArch/input/BTStack/btpad.c index 9270c20f5f..27599c6dda 100644 --- a/ios/RetroArch/input/BTStack/btpad.c +++ b/ios/RetroArch/input/BTStack/btpad.c @@ -116,8 +116,8 @@ void btpad_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet btpad_queue_reset(); btpad_queue_hci_read_bd_addr(); - btpad_queue_l2cap_register_service(PSM_HID_CONTROL, 672); // TODO: Where did I get 672 for mtu? - btpad_queue_l2cap_register_service(PSM_HID_INTERRUPT, 672); + bt_send_cmd_ptr(l2cap_register_service_ptr, PSM_HID_CONTROL, 672); // TODO: Where did I get 672 for mtu? + bt_send_cmd_ptr(l2cap_register_service_ptr, PSM_HID_INTERRUPT, 672); btpad_queue_hci_inquiry(HCI_INQUIRY_LAP, 3, 1); btpad_queue_run(1); @@ -180,8 +180,8 @@ void btpad_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet btpad_connection[slot].state = BTPAD_CONNECTING; btpad_connection[slot].slot = slot; - btpad_queue_l2cap_create_channel(btpad_connection[slot].address, PSM_HID_CONTROL); - btpad_queue_l2cap_create_channel(btpad_connection[slot].address, PSM_HID_INTERRUPT); + bt_send_cmd_ptr(l2cap_create_channel_ptr, btpad_connection[slot].address, PSM_HID_CONTROL); + bt_send_cmd_ptr(l2cap_create_channel_ptr, btpad_connection[slot].address, PSM_HID_INTERRUPT); } } } @@ -259,7 +259,7 @@ void btpad_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet } ios_add_log_message("BTpad: Incoming L2CAP connection (Slot: %d, PSM: %02X)", slot, psm); - btpad_queue_l2cap_accept_connection(channel_id); + bt_send_cmd_ptr(l2cap_accept_connection_ptr, channel_id); } break; diff --git a/ios/RetroArch/input/BTStack/btpad_queue.c b/ios/RetroArch/input/BTStack/btpad_queue.c index 89f25f6c48..eb16b1b59a 100644 --- a/ios/RetroArch/input/BTStack/btpad_queue.c +++ b/ios/RetroArch/input/BTStack/btpad_queue.c @@ -17,9 +17,6 @@ #include "btpad.h" #include "btpad_queue.h" -// NOTE: It seems that it is not needed to wait for the l2cap commands; TODO: Confirm -// #define WAIT_FOR_L2CAP - struct btpad_queue_command { const hci_cmd_t* command; @@ -57,31 +54,6 @@ struct btpad_queue_command bd_addr_t bd_addr; bd_addr_t pin; } hci_pin_code_request_reply; - -#ifdef WAIT_FOR_L2CAP - struct - { - uint16_t psm; - uint16_t mtu; - } l2cap_register_service; - - struct - { - bd_addr_t bd_addr; - uint16_t psm; - } l2cap_create_channel; - - struct - { - uint16_t cid; - } l2cap_accept_connection; - - struct - { - uint16_t cid; - uint8_t reason; - } l2cap_decline_connection; -#endif }; }; @@ -125,16 +97,6 @@ void btpad_queue_process() cmd->hci_remote_name_request.reserved, cmd->hci_remote_name_request.clock_offset); else if (cmd->command == hci_pin_code_request_reply_ptr) bt_send_cmd_ptr(cmd->command, cmd->hci_pin_code_request_reply.bd_addr, 6, cmd->hci_pin_code_request_reply.pin); -#ifdef WAIT_FOR_L2CAP - else if (cmd->command == l2cap_register_service_ptr) - bt_send_cmd_ptr(cmd->command, cmd->l2cap_register_service.psm, cmd->l2cap_register_service.mtu); - else if (cmd->command == l2cap_create_channel_ptr) - bt_send_cmd_ptr(cmd->command, cmd->l2cap_create_channel.bd_addr, cmd->l2cap_create_channel.psm); - else if (cmd->command == l2cap_accept_connection_ptr) - bt_send_cmd_ptr(cmd->command, cmd->l2cap_accept_connection.cid); - else if (cmd->command == l2cap_decline_connection_ptr) - bt_send_cmd_ptr(cmd->command, cmd->l2cap_decline_connection.cid, cmd->l2cap_decline_connection.reason); -#endif INCPOS(read); } @@ -212,72 +174,3 @@ void btpad_queue_hci_pin_code_request_reply(bd_addr_t bd_addr, bd_addr_t pin) btpad_queue_process(); } -// NOTE: It seems the l2cap commands don't need to wait -#ifdef WAIT_FOR_L2CAP -void btpad_queue_l2cap_register_service(uint16_t psm, uint16_t mtu) -{ - struct btpad_queue_command* cmd = &commands[insert_position]; - - cmd->command = l2cap_register_service_ptr; - cmd->l2cap_register_service.psm = psm; - cmd->l2cap_register_service.mtu = mtu; - - INCPOS(insert); - btpad_queue_process(); -} - -void btpad_queue_l2cap_create_channel(bd_addr_t bd_addr, uint16_t psm) -{ - struct btpad_queue_command* cmd = &commands[insert_position]; - - cmd->command = l2cap_create_channel_ptr; - memcpy(cmd->l2cap_create_channel.bd_addr, bd_addr, sizeof(bd_addr_t)); - cmd->l2cap_create_channel.psm = psm; - - INCPOS(insert); - btpad_queue_process(); -} - -void btpad_queue_l2cap_accept_connection(uint16_t cid) -{ - struct btpad_queue_command* cmd = &commands[insert_position]; - - cmd->command = l2cap_accept_connection_ptr; - cmd->l2cap_accept_connection.cid = cid; - - INCPOS(insert); - btpad_queue_process(); -} - -void btpad_queue_l2cap_decline_connection(uint16_t cid, uint8_t reason) -{ - struct btpad_queue_command* cmd = &commands[insert_position]; - - cmd->command = l2cap_decline_connection_ptr; - cmd->l2cap_decline_connection.cid = cid; - cmd->l2cap_decline_connection.reason = reason; - - INCPOS(insert); - btpad_queue_process(); -} -#else -void btpad_queue_l2cap_register_service(uint16_t psm, uint16_t mtu) -{ - bt_send_cmd_ptr(l2cap_register_service_ptr, psm, mtu); -} - -void btpad_queue_l2cap_create_channel(bd_addr_t bd_addr, uint16_t psm) -{ - bt_send_cmd_ptr(l2cap_create_channel_ptr, bd_addr, psm); -} - -void btpad_queue_l2cap_accept_connection(uint16_t cid) -{ - bt_send_cmd_ptr(l2cap_accept_connection_ptr, cid); -} - -void btpad_queue_l2cap_decline_connection(uint16_t cid, uint8_t reason) -{ - bt_send_cmd_ptr(l2cap_decline_connection_ptr, cid, reason); -} -#endif \ No newline at end of file diff --git a/ios/RetroArch/input/BTStack/btpad_queue.h b/ios/RetroArch/input/BTStack/btpad_queue.h index 6c9fc347f0..f152aab02b 100644 --- a/ios/RetroArch/input/BTStack/btpad_queue.h +++ b/ios/RetroArch/input/BTStack/btpad_queue.h @@ -26,9 +26,5 @@ void btpad_queue_hci_disconnect(uint16_t handle, uint8_t reason); void btpad_queue_hci_inquiry(uint32_t lap, uint8_t length, uint8_t num_responses); void btpad_queue_hci_remote_name_request(bd_addr_t bd_addr, uint8_t page_scan_repetition_mode, uint8_t reserved, uint16_t clock_offset); void btpad_queue_hci_pin_code_request_reply(bd_addr_t bd_addr, bd_addr_t pin); -void btpad_queue_l2cap_register_service(uint16_t psm, uint16_t mtu); -void btpad_queue_l2cap_create_channel(bd_addr_t bd_addr, uint16_t psm); -void btpad_queue_l2cap_accept_connection(uint16_t cid); -void btpad_queue_l2cap_decline_connection(uint16_t cid, uint8_t reason); #endif