diff --git a/MSP-EXP430F5438-CC256x/example-ble/ble_server.c b/MSP-EXP430F5438-CC256x/example-ble/ble_server.c index 93d6856dd..16b46de76 100644 --- a/MSP-EXP430F5438-CC256x/example-ble/ble_server.c +++ b/MSP-EXP430F5438-CC256x/example-ble/ble_server.c @@ -112,7 +112,7 @@ void hexdump2(void *data, int size){ static void att_try_respond(void){ if (!att_response_size) return; if (!att_response_handle) return; - if (!hci_can_send_packet_now(HCI_ACL_DATA_PACKET)) return; + if (!hci_can_send_packet_now_using_packet_buffer(HCI_ACL_DATA_PACKET)) return; // update state before sending packet uint16_t size = att_response_size; diff --git a/ble/att_server.c b/ble/att_server.c index 4c7106dab..4eca7e5b3 100644 --- a/ble/att_server.c +++ b/ble/att_server.c @@ -253,7 +253,7 @@ static void att_run(void){ // NOTE: fall through for regular commands case ATT_SERVER_REQUEST_RECEIVED_AND_VALIDATED: - if (!hci_can_send_packet_now_using_packet_buffer(HCI_ACL_DATA_PACKET)) return; + if (!l2cap_can_send_connectionless_packet_now()) return; uint8_t att_response_buffer[28]; uint16_t att_response_size = att_handle_request(&att_connection, att_request_buffer, att_request_size, att_response_buffer); @@ -326,7 +326,7 @@ void att_server_register_packet_handler(btstack_packet_handler_t handler){ int att_server_can_send(){ if (att_request_handle == 0) return 0; - return hci_can_send_packet_now_using_packet_buffer(HCI_ACL_DATA_PACKET); + return l2cap_can_send_connectionless_packet_now(); } int att_server_notify(uint16_t handle, uint8_t *value, uint16_t value_len){ @@ -337,7 +337,7 @@ int att_server_notify(uint16_t handle, uint8_t *value, uint16_t value_len){ int att_server_indicate(uint16_t handle, uint8_t *value, uint16_t value_len){ if (att_handle_value_indication_handle) return ATT_HANDLE_VALUE_INDICATION_IN_PORGRESS; - if (!hci_can_send_packet_now_using_packet_buffer(HCI_ACL_DATA_PACKET)) return BTSTACK_ACL_BUFFERS_FULL; + if (!l2cap_can_send_connectionless_packet_now()) return BTSTACK_ACL_BUFFERS_FULL; // track indication att_handle_value_indication_handle = handle; diff --git a/ble/sm.c b/ble/sm.c index f1937928a..99313bded 100644 --- a/ble/sm.c +++ b/ble/sm.c @@ -738,7 +738,7 @@ static void sm_run(void){ // assert that we can send either one if (!hci_can_send_packet_now_using_packet_buffer(HCI_COMMAND_DATA_PACKET)) return; - if (!hci_can_send_packet_now_using_packet_buffer(HCI_ACL_DATA_PACKET)) return; + if (!l2cap_can_send_connectionless_packet_now()) return; // distributed key generation switch (dkg_state){ diff --git a/ble/sm_minimal.c b/ble/sm_minimal.c index 7fef8a7a9..2bcb58ad9 100644 --- a/ble/sm_minimal.c +++ b/ble/sm_minimal.c @@ -201,7 +201,7 @@ static void sm_run(void){ // assert that we can send either one if (!hci_can_send_packet_now_using_packet_buffer(HCI_COMMAND_DATA_PACKET)) return; - if (!hci_can_send_packet_now_using_packet_buffer(HCI_ACL_DATA_PACKET)) return; + if (!l2cap_can_send_connectionless_packet_now()) return; switch (sm_state_responding){ case SM_STATE_SEND_LTK_REQUESTED_NEGATIVE_REPLY: diff --git a/example/libusb/ble_client.c b/example/libusb/ble_client.c index b7bb246b8..d66710850 100644 --- a/example/libusb/ble_client.c +++ b/example/libusb/ble_client.c @@ -119,17 +119,13 @@ void le_central_register_packet_handler(void (*handler)(uint8_t packet_type, uin static void gatt_client_run(); // START Helper Functions - to be sorted -static int l2cap_can_send_conectionless_packet_now(){ - return hci_can_send_packet_now_using_packet_buffer(HCI_ACL_DATA_PACKET); -} - static uint16_t l2cap_max_mtu_for_handle(uint16_t handle){ return l2cap_max_mtu(); } // END Helper Functions -// precondition: l2cap_can_send_conectionless_packet_now() == true +// precondition: l2cap_can_send_connectionless_packet_now() == true static le_command_status_t att_confirmation(uint16_t peripheral_handle){ uint8_t request[1]; request[0] = ATT_HANDLE_VALUE_CONFIRMATION; @@ -138,7 +134,7 @@ static le_command_status_t att_confirmation(uint16_t peripheral_handle){ } static le_command_status_t att_find_information_request(uint16_t request_type, uint16_t peripheral_handle, uint16_t start_handle, uint16_t end_handle){ - if (!l2cap_can_send_conectionless_packet_now()) return BLE_PERIPHERAL_BUSY; + if (!l2cap_can_send_connectionless_packet_now()) return BLE_PERIPHERAL_BUSY; uint8_t request[5]; request[0] = request_type; @@ -151,7 +147,7 @@ static le_command_status_t att_find_information_request(uint16_t request_type, u static le_command_status_t att_find_by_type_value_request(uint16_t request_type, uint16_t attribute_group_type, uint16_t peripheral_handle, uint16_t start_handle, uint16_t end_handle, uint8_t * value, uint16_t value_size){ - if (!l2cap_can_send_conectionless_packet_now()) return BLE_PERIPHERAL_BUSY; + if (!l2cap_can_send_connectionless_packet_now()) return BLE_PERIPHERAL_BUSY; uint8_t request[23]; // TODO: use prepared packets @@ -166,7 +162,7 @@ static le_command_status_t att_find_by_type_value_request(uint16_t request_type, } static le_command_status_t att_read_by_type_or_group_request(uint16_t request_type, uint16_t attribute_group_type, uint16_t peripheral_handle, uint16_t start_handle, uint16_t end_handle){ - if (!l2cap_can_send_conectionless_packet_now()) return BLE_PERIPHERAL_BUSY; + if (!l2cap_can_send_connectionless_packet_now()) return BLE_PERIPHERAL_BUSY; // printf("att_read_by_type_or_group_request : %02X, %02X - %02X \n", peripheral_handle, start_handle, end_handle); uint8_t request[7]; @@ -180,7 +176,7 @@ static le_command_status_t att_read_by_type_or_group_request(uint16_t request_ty } static le_command_status_t att_read_request(uint16_t request_type, uint16_t peripheral_handle, uint16_t attribute_handle){ - if (!l2cap_can_send_conectionless_packet_now()) return BLE_PERIPHERAL_BUSY; + if (!l2cap_can_send_connectionless_packet_now()) return BLE_PERIPHERAL_BUSY; uint8_t request[3]; request[0] = request_type; @@ -191,7 +187,7 @@ static le_command_status_t att_read_request(uint16_t request_type, uint16_t peri } static le_command_status_t att_read_blob_request(uint16_t request_type, uint16_t peripheral_handle, uint16_t attribute_handle, uint16_t value_offset){ - if (!l2cap_can_send_conectionless_packet_now()) return BLE_PERIPHERAL_BUSY; + if (!l2cap_can_send_connectionless_packet_now()) return BLE_PERIPHERAL_BUSY; uint8_t request[5]; request[0] = request_type; bt_store_16(request, 1, attribute_handle); @@ -203,7 +199,7 @@ static le_command_status_t att_read_blob_request(uint16_t request_type, uint16_t static le_command_status_t att_write_request(uint16_t request_type, uint16_t peripheral_handle, uint16_t attribute_handle, uint16_t value_length, uint8_t * value){ - if (!l2cap_can_send_conectionless_packet_now()) return BLE_PERIPHERAL_BUSY; + if (!l2cap_can_send_connectionless_packet_now()) return BLE_PERIPHERAL_BUSY; // TODO: use prepared buffers uint8_t request[3+value_length]; request[0] = request_type; @@ -215,7 +211,7 @@ static le_command_status_t att_write_request(uint16_t request_type, uint16_t per } static le_command_status_t att_execute_write_request(uint16_t request_type, uint16_t peripheral_handle, uint8_t execute_write){ - if (!l2cap_can_send_conectionless_packet_now()) return BLE_PERIPHERAL_BUSY; + if (!l2cap_can_send_connectionless_packet_now()) return BLE_PERIPHERAL_BUSY; uint8_t request[2]; request[0] = request_type; request[1] = execute_write; @@ -225,7 +221,7 @@ static le_command_status_t att_execute_write_request(uint16_t request_type, uint static le_command_status_t att_prepare_write_request(uint16_t request_type, uint16_t peripheral_handle, uint16_t attribute_handle, uint16_t value_offset, uint16_t blob_length, uint8_t * value){ - if (!l2cap_can_send_conectionless_packet_now()) return BLE_PERIPHERAL_BUSY; + if (!l2cap_can_send_connectionless_packet_now()) return BLE_PERIPHERAL_BUSY; uint8_t request[5+blob_length]; request[0] = request_type; bt_store_16(request, 1, attribute_handle); @@ -414,7 +410,7 @@ static void handle_peripheral_list(){ if (!hci_can_send_packet_now_using_packet_buffer(HCI_COMMAND_DATA_PACKET)) return; // printf("handle_peripheral_list 4\n"); - if (!l2cap_can_send_conectionless_packet_now()) return; + if (!l2cap_can_send_connectionless_packet_now()) return; // printf("handle_peripheral_list 5\n"); // printf("handle_peripheral_list empty %u\n", linked_list_empty(&le_connections)); @@ -846,7 +842,7 @@ static void gatt_client_run(){ // check if command is send if (!hci_can_send_packet_now_using_packet_buffer(HCI_COMMAND_DATA_PACKET)) return; - if (!l2cap_can_send_conectionless_packet_now()) return; + if (!l2cap_can_send_connectionless_packet_now()) return; switch(state){ case START_SCAN: