Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TW#28016] btc_gatts_arg_deep_copy NULL response warning #2811

Closed
mreutman opened this issue Dec 10, 2018 · 1 comment
Closed

[TW#28016] btc_gatts_arg_deep_copy NULL response warning #2811

mreutman opened this issue Dec 10, 2018 · 1 comment

Comments

@mreutman
Copy link
Contributor

mreutman commented Dec 10, 2018

Environment

  • Development Kit: None
  • Module or chip used: ESP32-WROOM-32
  • IDF version (run git describe --tags to find it): v3.3-dev-386-gf1b4c18c2
  • Build System: Make
  • Compiler version (run xtensa-esp32-elf-gcc --version to find it): 1.22.0-80-g6c4433a
  • Operating System: Linux
  • Power Supply: USB

Problem Description

Dug up some old bluetooth code I was working on and brought it up to speed with the latest esp-idf release. I noticed that I get warnings printed to the console when my code was calling esp_ble_gatts_send_response with the *rsp argument set to NULL; this was not the case previously if I recall correctly. Just to be certain it wasn't a problem with my code, I recompiled the example gatts_demo.c and observed the same warning when esp_ble_gatts_send_response is called with a NULL response.

I'm not sure if I am misusing the API, but the existing example code and the API documentation lead me to believe that it is perfectly valid to call that function in this manner. If this call is valid, then I believe that the warning should be removed or changed to a debug level log print as to avoid confusion. Warning a user on a valid use of the API seems very wrong.

For further details, it looks like the warning comes from btc_gatts_arg_deep_copy, which is invoked from within esp_ble_gatts_send_response.

    case BTC_GATTS_ACT_SEND_RESPONSE: {
        if (src->send_rsp.rsp) {
            dst->send_rsp.rsp = (esp_gatt_rsp_t *) osi_malloc(sizeof(esp_gatt_rsp_t));
            if (dst->send_rsp.rsp) {
                memcpy(dst->send_rsp.rsp, src->send_rsp.rsp, sizeof(esp_gatt_rsp_t));
            } else {
                BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act);
            }
        } else {
            BTC_TRACE_WARNING("%s %d, NULL response", __func__, msg->act);
        }
        break;

Expected Behavior

No warning printed to console.

Actual Behavior

Warning printed to console.

Steps to repropduce

  1. Compile and flash gatts_demo.c to ESP32.
  2. Connect to the ESP32 using a BLE capable client (I used my Android phone running nRF Connect).
  3. Send one byte of data to either of the custom services defined in gatts_demo.c.
  4. Observe warning printed to console.

Code to reproduce this issue

The example code gatts_demo.c included in the esp-idf can be used to reproduce the issue. Below is the particular call that triggers the warning.

esp_ble_gatts_send_response(gatts_if, param->write.conn_id, param->write.trans_id, status, NULL);

Debug Logs

I (485839) GATTS_DEMO: GATT_WRITE_EVT, conn_id 0, trans_id 1, handle 42
I (485839) GATTS_DEMO: GATT_WRITE_EVT, value len 1, value :
I (485849) GATTS_DEMO: bc 
W (485849) BT_BTC: btc_gatts_arg_deep_copy 11, NULL response
@chegewara
Copy link
Contributor

#2737 (comment)

@Alvin1Zhang Alvin1Zhang changed the title btc_gatts_arg_deep_copy NULL response warning [TW#28016] btc_gatts_arg_deep_copy NULL response warning Dec 21, 2018
@igrr igrr closed this as completed in 11a5fb8 Jan 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants