diff --git a/test/mock/mock_att_server.c b/test/mock/mock_att_server.c index d06910741..55209af5f 100644 --- a/test/mock/mock_att_server.c +++ b/test/mock/mock_att_server.c @@ -16,11 +16,18 @@ #include "CppUTestExt/MockSupport.h" static att_service_handler_t * service; +static btstack_context_callback_registration_t * mock_callback_registration; att_service_handler_t * mock_att_server_get_service(void){ return service; } +void mock_deinit(void){ + mock().clear(); + mock_callback_registration = NULL; + service = NULL; +} + uint16_t mock_att_service_read_callback(hci_con_handle_t con_handle, uint16_t attribute_handle, uint16_t offset, uint8_t * buffer, uint16_t buffer_size){ btstack_assert(service != NULL); btstack_assert(service->read_callback != NULL); @@ -37,6 +44,11 @@ void att_server_register_service_handler(att_service_handler_t * handler){ service = handler; } +void mock_att_service_trigger_can_send_now(void){ + btstack_assert(mock_callback_registration != NULL); + (*mock_callback_registration->callback)(mock_callback_registration->context); +} + uint16_t att_server_get_mtu(hci_con_handle_t con_handle){ UNUSED(con_handle); mock().actualCall("att_server_get_mtu"); @@ -64,6 +76,8 @@ int att_server_notify(hci_con_handle_t con_handle, uint16_t attribute_handle, co int att_server_register_can_send_now_callback(btstack_context_callback_registration_t * callback_registration, hci_con_handle_t con_handle){ UNUSED(callback_registration); UNUSED(con_handle); + mock_callback_registration = callback_registration; + mock().actualCall("att_server_register_can_send_now_callback"); return ERROR_CODE_SUCCESS; } diff --git a/test/mock/mock_att_server.h b/test/mock/mock_att_server.h index eb7b54c92..30bd3257b 100644 --- a/test/mock/mock_att_server.h +++ b/test/mock/mock_att_server.h @@ -51,6 +51,10 @@ uint16_t mock_att_service_read_callback(hci_con_handle_t con_handle, uint16_t at uint16_t mock_att_service_write_callback(hci_con_handle_t con_handle, uint16_t attribute_handle, uint16_t transaction_mode, uint16_t offset, const uint8_t *buffer, uint16_t buffer_size); +void mock_att_service_trigger_can_send_now(void); + +void mock_deinit(void); + #if defined __cplusplus } #endif