postpone MTU check

This commit is contained in:
matthias.ringwald@gmail.com 2014-05-11 20:53:02 +00:00
parent 9a0689a770
commit 4e6f32d5a8

View File

@ -634,6 +634,19 @@ static void gatt_client_handle_context_list(){
return; return;
} }
// check MTU for writes
switch (peripheral->gatt_client_state){
case P_W2_SEND_WRITE_CHARACTERISTIC_VALUE:
if (peripheral->attribute_length >= peripheral->mtu - 3) {
hci_dump_log("P_W2_SEND_WRITE_CHARACTERISTIC_VALUE: val len %u > per->mtu %u", peripheral->attribute_length, peripheral->mtu);
return;
}
break;
// TODO add more cases
default:
break;
}
// printf("gatt_client_state %u\n", peripheral->gatt_client_state); // printf("gatt_client_state %u\n", peripheral->gatt_client_state);
switch (peripheral->gatt_client_state){ switch (peripheral->gatt_client_state){
case P_W2_SEND_SERVICE_QUERY: case P_W2_SEND_SERVICE_QUERY:
@ -1192,9 +1205,10 @@ le_command_status_t gatt_client_write_value_of_characteristic_without_response(g
} }
le_command_status_t gatt_client_write_value_of_characteristic(gatt_client_t *peripheral, uint16_t value_handle, uint16_t value_length, uint8_t * value){ le_command_status_t gatt_client_write_value_of_characteristic(gatt_client_t *peripheral, uint16_t value_handle, uint16_t value_length, uint8_t * value){
if (!gatt_client_is_ready(peripheral)) return BLE_PERIPHERAL_IN_WRONG_STATE; if (!gatt_client_is_ready(peripheral)) {
if (value_length >= peripheral->mtu - 3) return BLE_VALUE_TOO_LONG; hci_dump_log("gatt client not ready");
return BLE_PERIPHERAL_IN_WRONG_STATE;
}
peripheral->attribute_handle = value_handle; peripheral->attribute_handle = value_handle;
peripheral->attribute_length = value_length; peripheral->attribute_length = value_length;
peripheral->attribute_value = value; peripheral->attribute_value = value;