#include #include #include #include "mock_gatt_client.h" #include "CppUTest/TestHarness.h" #include "CppUTestExt/MockSupport.h" static btstack_timer_source_t * btstack_timer = NULL; void mock_gatt_client_reset(void){ } void mock_gatt_client_add_primary_service(uint16_t service_uuid){ } void mock_gatt_client_add_characteristic(uint16_t characteristic_uuid){ } void mock_gatt_client_add_characteristic_descriptor(uint16_t descriptor_uuid){ } uint8_t gatt_client_read_value_of_characteristic(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_characteristic_t * characteristic){ return ERROR_CODE_SUCCESS; } uint8_t gatt_client_discover_primary_services_by_uuid16(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t uuid16){ return ERROR_CODE_SUCCESS; } uint8_t gatt_client_discover_characteristics_for_handle_range_by_uuid16(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t start_handle, uint16_t end_handle, uint16_t uuid16){ return ERROR_CODE_SUCCESS; } uint8_t gatt_client_discover_characteristic_descriptors(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_characteristic_t * characteristic){ return ERROR_CODE_SUCCESS; } uint8_t gatt_client_read_value_of_characteristic_using_value_handle(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t value_handle){ return ERROR_CODE_SUCCESS; } uint8_t gatt_client_write_client_characteristic_configuration(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_characteristic_t * characteristic, uint16_t configuration){ return ERROR_CODE_SUCCESS; } void gatt_client_listen_for_characteristic_value_updates(gatt_client_notification_t * notification, btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_characteristic_t * characteristic){ } // copied from gatt_client.c void gatt_client_deserialize_service(const uint8_t *packet, int offset, gatt_client_service_t * service){ service->start_group_handle = little_endian_read_16(packet, offset); service->end_group_handle = little_endian_read_16(packet, offset + 2); reverse_128(&packet[offset + 4], service->uuid128); if (uuid_has_bluetooth_prefix(service->uuid128)){ service->uuid16 = big_endian_read_32(service->uuid128, 0); } else { service->uuid16 = 0; } } // copied from gatt_client.c void gatt_client_deserialize_characteristic(const uint8_t * packet, int offset, gatt_client_characteristic_t * characteristic){ characteristic->start_handle = little_endian_read_16(packet, offset); characteristic->value_handle = little_endian_read_16(packet, offset + 2); characteristic->end_handle = little_endian_read_16(packet, offset + 4); characteristic->properties = little_endian_read_16(packet, offset + 6); reverse_128(&packet[offset+8], characteristic->uuid128); if (uuid_has_bluetooth_prefix(characteristic->uuid128)){ characteristic->uuid16 = big_endian_read_32(characteristic->uuid128, 0); } else { characteristic->uuid16 = 0; } } // copied from gatt_client.c void gatt_client_deserialize_characteristic_descriptor(const uint8_t * packet, int offset, gatt_client_characteristic_descriptor_t * descriptor){ descriptor->handle = little_endian_read_16(packet, offset); reverse_128(&packet[offset+2], descriptor->uuid128); if (uuid_has_bluetooth_prefix(descriptor->uuid128)){ descriptor->uuid16 = big_endian_read_32(descriptor->uuid128, 0); } else { descriptor->uuid16 = 0; } } void gatt_client_stop_listening_for_characteristic_value_updates(gatt_client_notification_t * notification){ } void btstack_run_loop_add_timer(btstack_timer_source_t * timer){ btstack_timer = timer; } void * btstack_run_loop_get_timer_context(btstack_timer_source_t * timer){ return btstack_timer; } int btstack_run_loop_remove_timer(btstack_timer_source_t * timer){ btstack_timer = NULL; return 1; } void btstack_run_loop_set_timer(btstack_timer_source_t * timer, uint32_t timeout_in_ms){ } void btstack_run_loop_set_timer_context(btstack_timer_source_t * timer, void * context){ } void btstack_run_loop_set_timer_handler(btstack_timer_source_t * timer, void (*process)(btstack_timer_source_t * _timer)){ }