'How do I send a long write with Bluez\tools\btgatt_client.c
I'm able to build and use the Bluez\tools\btgatt_client.c code to send <20 bytes with the write-value command, but can't get the write-long-value or write-prepare/write-execute commands to work. It fails at the bt_gatt_client_write_long_value() function.
I've already developed client code for our system using the Bluez dbus interface including OTA/DFU capability, but it has many issues. So my goal is to use these Bluez\src\shared\gatt-client.c functions directly in my client app. Plus, I could be wrong but I've traced the function call chain through the dbus interface, back to these atomic functions. And even though many suggest we really should be using the dbus API, I've greatly improved the scanning/discovery part of my code without it. And like I said, I'm able to send data with the bt_gatt_client_write_value() function.
So what's the difference between bt_gatt_client_write_long_value() and bt_gatt_client_prepare_write()/bt_gatt_client_write_execute().
I've tried changing the MTU, watching traffic with btmon... Not sure why they work through the dbus API but not through the btgatt-client tool. Gotta be how I'm setting up the function parameter structs???
Maybe these are not the low level functions to use. I appreciate any and all help, thanks.
More info... I'm still trying to understand why the btgatt-client tool won't work when I write more than 20 bytes even with large MTU settings, at 247. I see the tool uses the same atomic functions as does the dbus API proxy WriteValue call. I've traced the function call chain: WriteValue -> Bluez\src\gatt-client.c\characteristic_write_value() -> Bluez\src\gatt-client.c\start_write_request() -> Bluez\src\shared\gatt-client.c\bt_gatt_client_write_value() for less than MTU-3 value sizes.
For value sizes > MTU-3, I think it uses the Prepare Writes and Execute Write functions?
Comparing btmon output from my existing dbus code and the btgatt-client tool, writing the same string of just 21 bytes: "k 1234567890 3200 512", shows both sending the same Write Request (0x12). All the connection parameters seem to be the same for both. But I do see a difference in the response: 2 packets for working code, but only 1 for the tool:
HCI Event: Number of Completed Packets (0x13) plen 5 #738 [hci0] 1081.642076 Num handles: 1 Handle: 64 Count: 1 It just hangs here without send any data to the device. I'm missing something basic??? Thanks.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
