Skip to content

Commit 2e01bd9

Browse files
author
ybzhao
committed
[int][bug][ble] fix battery level notify error
Project: Bluetooth redmine: #5333, REDMINE-5333 ext-redmine: bug|feat#id [Description in detail] Affected branch: [main] Change-Id: Icd739522fc7782c33f66377bc9978382070d1d45
1 parent e5b5546 commit 2e01bd9

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

service/ble/gatt_service/bf0_sibles_bass.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,26 @@ int8_t ble_bass_notify_battery_lvl(uint8_t conn_idx, uint8_t lvl)
160160
value.idx = BAS_IDX_BATT_LVL_VAL;
161161
value.len = sizeof(uint8_t);
162162
value.value = &env->bas_lvl;
163-
int ret = sibles_write_value(conn_idx, &value);
164-
ret = 0;
163+
int write_ret = sibles_write_value(conn_idx, &value);
164+
if (write_ret == value.len)
165+
{
166+
ret = 0;
167+
}
168+
else
169+
{
170+
LOG_W("battery level write failed with %d", write_ret);
171+
ret = -3;
172+
}
165173
}
166-
ret = -2;
174+
else
175+
{
176+
LOG_D("battery level the same %d, skip", lvl);
177+
ret = -2;
178+
}
179+
}
180+
else
181+
{
182+
LOG_I("battery service state not ready %d", env->state);
167183
}
168184
return ret;
169185
}

0 commit comments

Comments
 (0)