att_db.c (2ea28401b3ec711ab56f5414fc39883c806892bb) | att_db.c (154069291bf4430a673aac500b317cdf472b1904) |
---|---|
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 --- 1076 unchanged lines hidden (view full) --- 1085 } 1086 response_buffer[0] = ATT_EXECUTE_WRITE_RESPONSE; 1087 return 1; 1088} 1089 1090// MARK: ATT_WRITE_COMMAND 0x52 1091// Core 4.0, vol 3, part F, 3.4.5.3 1092// "No Error Response or Write Response shall be sent in response to this command" | 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 --- 1076 unchanged lines hidden (view full) --- 1085 } 1086 response_buffer[0] = ATT_EXECUTE_WRITE_RESPONSE; 1087 return 1; 1088} 1089 1090// MARK: ATT_WRITE_COMMAND 0x52 1091// Core 4.0, vol 3, part F, 3.4.5.3 1092// "No Error Response or Write Response shall be sent in response to this command" |
1093static void handle_write_command(att_connection_t * att_connection, uint8_t * request_buffer, uint16_t request_len, 1094 uint8_t * response_buffer, uint16_t response_buffer_size){ | 1093static void handle_write_command(att_connection_t * att_connection, uint8_t * request_buffer, uint16_t request_len, uint16_t required_flags){ |
1095 | 1094 |
1096 UNUSED(response_buffer); 1097 UNUSED(response_buffer_size); 1098 | |
1099 uint16_t handle = little_endian_read_16(request_buffer, 1); 1100 if (!att_write_callback) return; 1101 1102 att_iterator_t it; 1103 int ok = att_find_handle(&it, handle); 1104 if (!ok) return; 1105 if ((it.flags & ATT_PROPERTY_DYNAMIC) == 0) return; | 1095 uint16_t handle = little_endian_read_16(request_buffer, 1); 1096 if (!att_write_callback) return; 1097 1098 att_iterator_t it; 1099 int ok = att_find_handle(&it, handle); 1100 if (!ok) return; 1101 if ((it.flags & ATT_PROPERTY_DYNAMIC) == 0) return; |
1106 if ((it.flags & ATT_PROPERTY_WRITE_WITHOUT_RESPONSE) == 0) return; | 1102 if ((it.flags & required_flags) == 0) return; |
1107 if (att_validate_security(att_connection, ATT_WRITE, &it)) return; 1108 att_persistent_ccc_cache(&it); 1109 (*att_write_callback)(att_connection->con_handle, handle, ATT_TRANSACTION_MODE_NONE, 0, request_buffer + 3, request_len - 3); 1110} 1111 1112// MARK: helper for ATT_HANDLE_VALUE_NOTIFICATION and ATT_HANDLE_VALUE_INDICATION 1113static uint16_t prepare_handle_value(att_connection_t * att_connection, 1114 uint16_t handle, --- 68 unchanged lines hidden (view full) --- 1183 break; 1184 case ATT_PREPARE_WRITE_REQUEST: 1185 response_len = handle_prepare_write_request(att_connection, request_buffer, request_len, response_buffer, response_buffer_size); 1186 break; 1187 case ATT_EXECUTE_WRITE_REQUEST: 1188 response_len = handle_execute_write_request(att_connection, request_buffer, request_len, response_buffer, response_buffer_size); 1189 break; 1190 case ATT_WRITE_COMMAND: | 1103 if (att_validate_security(att_connection, ATT_WRITE, &it)) return; 1104 att_persistent_ccc_cache(&it); 1105 (*att_write_callback)(att_connection->con_handle, handle, ATT_TRANSACTION_MODE_NONE, 0, request_buffer + 3, request_len - 3); 1106} 1107 1108// MARK: helper for ATT_HANDLE_VALUE_NOTIFICATION and ATT_HANDLE_VALUE_INDICATION 1109static uint16_t prepare_handle_value(att_connection_t * att_connection, 1110 uint16_t handle, --- 68 unchanged lines hidden (view full) --- 1179 break; 1180 case ATT_PREPARE_WRITE_REQUEST: 1181 response_len = handle_prepare_write_request(att_connection, request_buffer, request_len, response_buffer, response_buffer_size); 1182 break; 1183 case ATT_EXECUTE_WRITE_REQUEST: 1184 response_len = handle_execute_write_request(att_connection, request_buffer, request_len, response_buffer, response_buffer_size); 1185 break; 1186 case ATT_WRITE_COMMAND: |
1191 handle_write_command(att_connection, request_buffer, request_len, response_buffer, response_buffer_size); | 1187 handle_write_command(att_connection, request_buffer, request_len, ATT_PROPERTY_WRITE_WITHOUT_RESPONSE); |
1192 break; 1193#ifdef ENABLE_LE_SIGNED_WRITE 1194 case ATT_SIGNED_WRITE_COMMAND: | 1188 break; 1189#ifdef ENABLE_LE_SIGNED_WRITE 1190 case ATT_SIGNED_WRITE_COMMAND: |
1195 log_info("handle_signed_write_command preprocessed by att_server.c"); | 1191 handle_write_command(att_connection, request_buffer, request_len, ATT_PROPERTY_AUTHENTICATED_SIGNED_WRITE); |
1196 break; 1197#endif 1198 default: 1199 log_info("Unhandled ATT Command: %02X, DATA: ", request_buffer[0]); 1200 log_info_hexdump(&request_buffer[9], request_len-9); 1201 break; 1202 } 1203 return response_len; --- 214 unchanged lines hidden --- | 1192 break; 1193#endif 1194 default: 1195 log_info("Unhandled ATT Command: %02X, DATA: ", request_buffer[0]); 1196 log_info_hexdump(&request_buffer[9], request_len-9); 1197 break; 1198 } 1199 return response_len; --- 214 unchanged lines hidden --- |