att_db.c (3b9a211c6022a4d7d30c83db4a21110b27b84b95) att_db.c (af1b7cdc1f740ce7c5e2d679b6c04b63fab5a9c5)
1/*
2 * Copyright (C) 2014 BlueKitchen GmbH
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright

--- 719 unchanged lines hidden (view full) ---

728
729#ifdef ENABLE_ATT_DELAYED_RESPONSE
730 if (it.value_len == ATT_READ_RESPONSE_PENDING) return ATT_READ_RESPONSE_PENDING;
731#endif
732
733 if (value_offset > it.value_len){
734 return setup_error_invalid_offset(response_buffer, request_type, handle);
735 }
1/*
2 * Copyright (C) 2014 BlueKitchen GmbH
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright

--- 719 unchanged lines hidden (view full) ---

728
729#ifdef ENABLE_ATT_DELAYED_RESPONSE
730 if (it.value_len == ATT_READ_RESPONSE_PENDING) return ATT_READ_RESPONSE_PENDING;
731#endif
732
733 if (value_offset > it.value_len){
734 return setup_error_invalid_offset(response_buffer, request_type, handle);
735 }
736
737 // store
738 uint16_t offset = 1;
739 uint16_t bytes_copied = att_copy_value(&it, value_offset, response_buffer + offset, response_buffer_size - offset, att_connection->con_handle);
740 offset += bytes_copied;
741
736
737 // prepare response
742 response_buffer[0] = ATT_READ_BLOB_RESPONSE;
738 response_buffer[0] = ATT_READ_BLOB_RESPONSE;
739 uint16_t offset = 1;
740
741 // fetch more data if available
742 if (value_offset < it.value_len){
743 uint16_t bytes_copied = att_copy_value(&it, value_offset, &response_buffer[offset], response_buffer_size - offset, att_connection->con_handle);
744 offset += bytes_copied;
745 }
743 return offset;
744}
745
746static uint16_t handle_read_blob_request(att_connection_t * att_connection, uint8_t * request_buffer, uint16_t request_len,
747 uint8_t * response_buffer, uint16_t response_buffer_size){
748
749 if (request_len != 5) return setup_error_invalid_pdu(response_buffer, ATT_READ_BLOB_REQUEST);
750

--- 683 unchanged lines hidden ---
746 return offset;
747}
748
749static uint16_t handle_read_blob_request(att_connection_t * att_connection, uint8_t * request_buffer, uint16_t request_len,
750 uint8_t * response_buffer, uint16_t response_buffer_size){
751
752 if (request_len != 5) return setup_error_invalid_pdu(response_buffer, ATT_READ_BLOB_REQUEST);
753

--- 683 unchanged lines hidden ---