Skip to content

Commit 8a09e8d

Browse files
committed
Ble: cleanup error handling in ble_gatt_characteristic_update
1 parent 784eb4b commit 8a09e8d

File tree

1 file changed

+9
-10
lines changed
  • targets/f7/ble_glue/furi_ble

1 file changed

+9
-10
lines changed

targets/f7/ble_glue/furi_ble/gatt.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -114,18 +114,17 @@ bool ble_gatt_characteristic_update(
114114
release_data = char_descriptor->data.callback.fn(context, &char_data, &char_data_size);
115115
}
116116

117-
tBleStatus result = aci_gatt_update_char_value(
118-
svc_handle, char_instance->handle, 0, char_data_size, char_data);
119-
if(result) {
117+
tBleStatus result;
118+
size_t retries_left = 1000;
119+
do {
120+
retries_left--;
121+
result = aci_gatt_update_char_value(
122+
svc_handle, char_instance->handle, 0, char_data_size, char_data);
120123
if(result == BLE_STATUS_INSUFFICIENT_RESOURCES) {
121-
FURI_LOG_E(TAG, "Insufficient resources for %s characteristic", char_descriptor->name);
122-
do {
123-
furi_delay_ms(1);
124-
result = aci_gatt_update_char_value(
125-
svc_handle, char_instance->handle, 0, char_data_size, char_data);
126-
} while(result == BLE_STATUS_INSUFFICIENT_RESOURCES);
124+
FURI_LOG_W(TAG, "Insufficient resources for %s characteristic", char_descriptor->name);
125+
furi_delay_ms(1);
127126
}
128-
}
127+
} while(result == BLE_STATUS_INSUFFICIENT_RESOURCES && retries_left);
129128

130129
if(release_data) {
131130
free((void*)char_data);

0 commit comments

Comments
 (0)