diff --git a/test/att_db/att_db_test.c b/test/att_db/att_db_test.c index c2297e6d7..abedaa3d4 100644 --- a/test/att_db/att_db_test.c +++ b/test/att_db/att_db_test.c @@ -53,52 +53,201 @@ #include "btstack_crypto.h" #include "bluetooth_gatt.h" +typedef enum { + READ_CALLBACK_MODE_RETURN_ONE_BYTE = 0, + READ_CALLBACK_MODE_RETURN_PENDING +} read_callback_mode_t; + static uint8_t battery_level = 100; +static uint8_t att_request[200]; +static uint8_t att_response[1000]; + +static read_callback_mode_t read_callback_mode = READ_CALLBACK_MODE_RETURN_ONE_BYTE; // these can be tweaked to report errors or some data as needed by test case static uint16_t att_read_callback(hci_con_handle_t con_handle, uint16_t attribute_handle, uint16_t offset, uint8_t * buffer, uint16_t buffer_size){ - return 0; + switch (read_callback_mode){ + case READ_CALLBACK_MODE_RETURN_ONE_BYTE: + return att_read_callback_handle_byte(0x55, offset, buffer, buffer_size); + case READ_CALLBACK_MODE_RETURN_PENDING: + return ATT_READ_RESPONSE_PENDING; + default: + return 0; + } } static int att_write_callback(hci_con_handle_t con_handle, uint16_t attribute_handle, uint16_t transaction_mode, uint16_t offset, uint8_t *buffer, uint16_t buffer_size){ return 0; } +static uint16_t att_read_multiple_request(uint16_t num_value_handles, uint16_t * value_handles){ + att_request[0] = ATT_READ_MULTIPLE_REQUEST; + int i; + int offset = 1; + for (i=0;i