Skip to content

Commit

Permalink
Fixes #52. Clears newly allocated payload temporary copy once used.
Browse files Browse the repository at this point in the history
Zephyr requires a char* allocation to copy to its attribute cache. Usage is correct.
We now also clear up the temporary value. I have confirmed Zephyr doesn't do this itself.
Tested on nRF52832DK.
Signed-off-by: Adam Fowler <adam@adamfowler.org>
  • Loading branch information
adamfowleruk committed Apr 26, 2021
1 parent 95dd012 commit 3dcbaaa
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion herald/src/ble/zephyr/concrete_ble_transmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,10 @@ namespace zephyrinternal {
newvalue[i] = (char)payload->at(i);
}
value = newvalue;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
auto res = bt_gatt_attr_read(conn, attr, buf, len, offset, value,
payload->size());
delete newvalue;
return res;
// } else {
// value = "venue value"; // TODO replace with the use of PDS
}
Expand Down

0 comments on commit 3dcbaaa

Please sign in to comment.