postpone MTU exchange by writes

This commit is contained in:
mila@ringwald.ch 2014-05-15 15:08:59 +00:00
parent f50fd90e48
commit a027ff0287

View File

@ -601,12 +601,11 @@ static void gatt_client_run(){
// check MTU for writes // check MTU for writes
switch (peripheral->gatt_client_state){ switch (peripheral->gatt_client_state){
case P_W2_SEND_WRITE_CHARACTERISTIC_VALUE: case P_W2_SEND_WRITE_CHARACTERISTIC_VALUE:
if (peripheral->attribute_length >= peripheral->mtu - 3) { case P_W2_SEND_WRITE_CHARACTERISTIC_DESCRIPTOR:
hci_dump_log("P_W2_SEND_WRITE_CHARACTERISTIC_VALUE: val len %u > per->mtu %u", peripheral->attribute_length, peripheral->mtu); if (peripheral->attribute_length < peripheral->mtu - 3) break;
return; peripheral->gatt_client_state = P_READY;
} send_gatt_complete_event(peripheral, ATT_ERROR_INVALID_ATTRIBUTE_VALUE_LENGTH);
break; return;
// TODO add more cases
default: default:
break; break;
} }
@ -726,7 +725,7 @@ static void gatt_client_run(){
} }
static void gatt_client_report_error_if_pending(gatt_client_t *peripheral, uint8_t error_code) { static void gatt_client_report_error_if_pending(gatt_client_t *peripheral, uint8_t error_code) {
if (peripheral->gatt_client_state == P_READY) return; if (gatt_client_is_ready(peripheral)) return;
send_gatt_complete_event(peripheral, error_code); send_gatt_complete_event(peripheral, error_code);
} }