mongoose-os-libs/bt-common

Missing GATT Client Write Without Response

Closed this issue · 8 comments

Hi,

It would be really useful to support gatt write without response. This is one of the basic gatt client functions. Just for this we are building the firmware locally. It would be great if you could fix it.

mgos_bt_gattc.h

bool mgos_bt_gattc_write_no_rsp(int conn_id, uint16_t handle, const void *data, int len);

esp32_bt_gattc.c

bool mgos_bt_gattc_write_no_rsp(int conn_id, uint16_t handle, const void *data, int len) { if (esp32_bt_is_scanning()) return false; struct conn *conn = find_by_conn_id(conn_id); if (conn == NULL) return false; esp_err_t err = esp_ble_gattc_write_char(conn->iface, conn_id, handle, len, (void *) data, ESP_GATT_WRITE_TYPE_NO_RSP, 0); LOG(LL_DEBUG, ("WRITE %d: %d", conn_id, err)); return err == ESP_OK; }

rojer commented

can you submit it as a pull request?

rojer commented

ok, i added it. instead of adding another function, i added an argument to write to specify whether a response is required.

@rojer Thanks 👍 . I was about start on that.

@rojer Do I need to wait for the new mos release?
Remote build system doesn't pick this change. Looks like the deps folder needs to be updated?

mos.yml:
`

error: incompatible type for argument 3 of 'mgos_bt_gattc_write' result = mgos_bt_gattc_write(conn_id, handle, write_data, resp_required); ^ /data/fwbuild-volumes/2.17.0/apps/esp32_tlk_mesh/esp32/build_contexts/build_ctx_614474948/deps/bt-common/include/mgos_bt_gattc.h:66:6: note: expected 'const void *' but argument is of type 'struct mg_str' bool mgos_bt_gattc_write(int conn_id, uint16_t handle, const void *data,

rojer commented

if you are using a release version of mos, then yes, you are still building against 2.17.0.
you need to instruct it to use latest (aka master):

- origin: https://github.com/mongoose-os-libs/bt-common
  version: latest

Got it. Should I just do
mos update latest
and then
mos build --platform esp32 ?

rojer commented

that would be a way to do it, but you don't have to.
here's how library versioning works:

  • first, version key for the specific library entry checked. if not present, then top-level libs_version is used.
  • libs_version can be set to anything but the default mos.yml template sets it to ${mos.version}
  • ${mos.version} resolves to the version of the mos utility you are using (2.17.0 is the current release version) or to latest if you are using mos-latest.

so, mos update latest will switch you to mos-latest channel, this will change mos.version to latest and will thus switch all your libraries to latest master versions. you can achieve the same with setting libs_version: latest in your mos.yml but since you really only need to update bt-common, you can do as i suggested above and just set version: latest on the bt-common library.

Very clear! Thanks a lot Rojer.