This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Not able to write 14 Bytes into Queued Writes module

Hi Nordic,

Please provide the way to debug not able to write 14 Bytes data into Queued Writes module, my application not get any nrf_ble_qwr_on_ble_evt.

[Project Informaiton]
nrf52832 (S132 SoftDevice v6.1.1) + MCU (CXD5602), UART interface to connect between each other.

[Design description]
My application designs both ble_peripheral, and ble_central in one.
I integrate "write-queued-characteristic-with-less-than-20-bytes" solutions into my application.

[sdk_config.h]
#define NRF_BLE_QWR_ENABLED 1
#define NRF_BLE_QWR_MAX_ATTR 1

[Issue description]
Not able write more than 13 Bytes data (while write 14 Bytes, My application stuck) into My applcation with nrf_connect android application
In nrf_connect android application shows log in "Log 2020-01-17 11_37_48.txt"

[Central][Log in nrf_connect android application]
1). write 13 Bytes, result: PASS
V 11:37:05.688 Writing request to characteristic 6e400002-b5a3-f393-e0a9-e50e24dcca9e
D 11:37:05.688 gatt.writeCharacteristic(6e400002-b5a3-f393-e0a9-e50e24dcca9e, value=0x31323334353637383930313233)
I 11:37:06.088 Data written to 6e400002-b5a3-f393-e0a9-e50e24dcca9e, value: (0x) 31-32-33-34-35-36-37-38-39-30-31-32-33, "1234567890123"
A 11:37:06.088 "1234567890123" sent

2). write 14 Bytes, result: NG
V 11:37:28.334 Writing request to characteristic 6e400002-b5a3-f393-e0a9-e50e24dcca9e
D 11:37:28.334 gatt.writeCharacteristic(6e400002-b5a3-f393-e0a9-e50e24dcca9e, value=0x3132333435363738393031323334)
D 11:37:32.522 [Server callback] Connection state changed with status: 0 and new state: DISCONNECTED (0)
I 11:37:32.522 [Server] Device disconnected
E 11:37:32.538 Error 133 (0x85): GATT ERROR

[Peripheral][Log in my application with nrf52832]
1). write 13 Bytes, result: PASS
[2020-01-17 11:36:49] ble_spresense_handler_on_le_connect_status_change, ble_state_s.ble_connect_handle = 0x0001
[2020-01-17 11:36:49] [BLE_GATT] Connect status ADDR:6D:E1:DE:BF:A7:C3, status:Connected, ble_state->ble_connect_handle = 0x0001
[2020-01-17 11:36:49] Debug : RESP_OK => nrf_ble_qwr_on_ble_evt, p_ble_evt->header.evt_id = 16
[2020-01-17 11:36:49] Debug : RESP_OK => nrf_ble_qwr_on_ble_evt, p_ble_evt->header.evt_id = 35
[2020-01-17 11:36:49] Debug : RESP_OK => nrf_ble_qwr_on_ble_evt, p_ble_evt->header.evt_id = 36
[2020-01-17 11:36:49] Debug : RESP_OK => PHY update request.
[2020-01-17 11:36:49] Debug : RESP_OK => nrf_ble_qwr_on_ble_evt, p_ble_evt->header.evt_id = 33
[2020-01-17 11:36:50] Debug : RESP_OK => nrf_ble_qwr_on_ble_evt, p_ble_evt->header.evt_id = 34
[2020-01-17 11:36:50] Debug : RESP_OK => nrf_ble_qwr_on_ble_evt, p_ble_evt->header.evt_id = 18
[2020-01-17 11:36:51] Debug : RESP_OK => nrf_ble_qwr_on_ble_evt, p_ble_evt->header.evt_id = 18
[2020-01-17 11:36:55] Debug : RESP_OK => nrf_ble_qwr_on_ble_evt, p_ble_evt->header.evt_id = 18
[2020-01-17 11:37:07] Debug : RESP_OK => nrf_ble_qwr_on_ble_evt, p_ble_evt->header.evt_id = 81
[2020-01-17 11:37:07] Debug : RESP_OK => BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST
[2020-01-17 11:37:07] Debug : RESP_OK => on_rw_authorize_request, p_auth_req->request.write.op = 0x1
[2020-01-17 11:37:07] Debug : RESP_OK => nrf_ble_qwrs_on_qwr_evt, p_evt->evt_type = 2
[2020-01-17 11:37:07] Debug : RESP_OK => BLE_QWRS_NEW_DATA_RCVD
[2020-01-17 11:37:07] Debug : RESP_OK => 31323334353637383930313233


2). write 14 Bytes, result: NG
My application not show any evt in nrf_ble_qwr_on_ble_evt fuction, I guess while handle 14 Bytes data write request in softdevice has exception.
Please Nordic help to provide me the way to do next debug

[Attached files]
sdk_config.h (#define NRF_BLE_QWR_ENABLED 1 #define NRF_BLE_QWR_MAX_ATTR 1)
nrf_ble_qwr.c
nrf_ble_qwr.h
nrf_ble_qwrs.c
nrf_ble_qwrs.h
ble_wrap_15.c (my application)

Many thanks.
Caspar

sdk_config.h

nrf_ble_qwr.h

nrf_ble_qwrs.h

Parents
  • Hi Sigurd,

    Currently, I just want to write a long characteristic in custom ble service.
    I found this for reference. Is https://github.com/bjornspockeli/custom_ble_service_example suitable to integrate  into my application ?
    Would you please give me a reference example code for integration ?

    Many thanks
    Caspar

  • Hi Nordic, 

    I use github.com/.../custom_ble_service_example in my application to act as peripheral-role, and it works.
    However, my application dose not able to connect other peripheral-role device, while my application do  sd_ble_gap_connect to peripheral device.
    1). Did you have any idea how many FLASH/RAM should increase while adding a vendor-specific UUID to the BLE stack results in the RAM requirement of the SoftDevice increasing, which we need to take into account ?
    2). Did you have any suggestion the way to debug sd_ble_gap_connect not able to connect peripheral problem ?

    Now, I'm trying to make RTT logging with J-Link RTT Viewer.

    Many thanks.
    Caspar

  • 1) The function sd_ble_enable()/ nrf_sdh_ble_enable() will tell you how much RAM is required to enable the SoftDevice with the current SD configuration. Turn on logging, and the values should be printed in the log.

    2) Did sd_ble_gap_connect() return any error-code ? You might also want to set a scan-timout in p_scan_params for sd_ble_gap_connect()

  • Hi Sigurd,

    1). my application print out below logs
    ble_stack_init, nrf_sdh_ble_default_cfg_set() = 0, ram_start = 200028C0
    ble_stack_init, nrf_sdh_ble_enable() = 0, ram_start = 200028C0
    Attached my application "app_mem_conf.ld"
    UUID_COUNT = 2
    RAM_REDUCE = 16 * UUID_COUNT = 32
    MEMORY
    {
    FLASH (rx) : ORIGIN = 0x26000, LENGTH = 0x5d000
    RAM (rwx) : ORIGIN = 0x20002890+RAM_REDUC, LENGTH = 0xD740-RAM_REDUC
    }
    after caculate RAM(rwx) would be ORIGIN = 0x200028C2, LENGTH = D70E, however nrf_sdh_ble_enable() is 0x200028C0.
    Would that be no problem for my app_mem_conf.ld define ?
     app_mem_conf.ld
    2). sd_ble_gap_connect() return NRF_SUCCESS, however my android nrfconnect application not receive any connect message,
    Need to debug why sd_ble_gap_connect() not work even though got NRF_SUCCESS.
    Did you have any suggestion to get more debug information ?

    3). my applicatin scan_timeout is 0x0000 //disables timeout.

    4). sd_ble_gap_connect() does not work, after intergate https://github.com/bjornspockeli/custom_ble_service_example into my application.


    Many thanks.
    Caspar

  • Hi Sigurd,

    1). After mark "BLE_CUS_DEF(m_cus)", sd_ble_gap_connect() works very well.
    //BLE_CUS_DEF(m_cus); /**< Context for the Queued Write module.*/
    It would be somewhere not configure properly, and would you please provide me what's item should configure well for intergeate github.com/.../custom_ble_service_example into my application ?

    2). Attached ble_cus.zip (ble_wrap_15.c is my application already integratehttps://github.com/bjornspockeli/custom_ble_service_example )

    3). sd_ble_gap_connect() return NRF_SUCCESS, please check attached


    [2020-02-27 09:16:36] Debug : RESP_OK => ble_wrap_connect_to, sd_ble_gap_connect, err_code = 0

    Many thanks.
    Caspar

  • Hi,

    after caculate RAM(rwx) would be ORIGIN = 0x200028C2, LENGTH = D70E, however nrf_sdh_ble_enable() is 0x200028C0.
    Would that be no problem for my app_mem_conf.ld define ?

    The nrf_sdh_ble_enable() returns the value you should use.

    Need to debug why sd_ble_gap_connect() not work even though got NRF_SUCCESS.

    When sd_ble_gap_connect() returns NRF_SUCCESS, it will start to scan for the device to connect to. If the device is not found, or if it's not possible to connect to the device, it will continue to scan(until timeout, if enabled), and you will not get the the BLE_GAP_EVT_CONNECTED.

    Attached ble_cus.zip (ble_wrap_15.c is my application already integrate

    The zip does not seem to have been attached, only ble_wrap_15.c. If are still having issues with this, please upload the whole project.

    sd_ble_gap_connect() return NRF_SUCCESS, please check attached

    Do you get BLE_GAP_EVT_CONNECTED ?

Reply
  • Hi,

    after caculate RAM(rwx) would be ORIGIN = 0x200028C2, LENGTH = D70E, however nrf_sdh_ble_enable() is 0x200028C0.
    Would that be no problem for my app_mem_conf.ld define ?

    The nrf_sdh_ble_enable() returns the value you should use.

    Need to debug why sd_ble_gap_connect() not work even though got NRF_SUCCESS.

    When sd_ble_gap_connect() returns NRF_SUCCESS, it will start to scan for the device to connect to. If the device is not found, or if it's not possible to connect to the device, it will continue to scan(until timeout, if enabled), and you will not get the the BLE_GAP_EVT_CONNECTED.

    Attached ble_cus.zip (ble_wrap_15.c is my application already integrate

    The zip does not seem to have been attached, only ble_wrap_15.c. If are still having issues with this, please upload the whole project.

    sd_ble_gap_connect() return NRF_SUCCESS, please check attached

    Do you get BLE_GAP_EVT_CONNECTED ?

Children
  • Hi ,

    Use ozone to debug, and find out the root cause is NULL pointer causes fatal error.
    The application is both central, and peripheral.role.
    Both central, and peripheral should have customer_ble_service, however only peripheral role do ble_cus_init(&m_cus, &cus_init);
    Due to central-role does not do ble_cus_init(&m_cus, &cus_init), on_connect() function access null pointer in p_cus->evt_handler(p_cus, &evt); fatal error.
    Would you please share how to extract crash log, and stack dump from nRF52832 ? and the way to parse stack dump to call-stack ?
    Many thanks.
    Caspar
  • Caspar_Tsai said:
    on_connect() function access null pointer in p_cus->evt_handler(p_cus, &evt); fatal error.

     Won't the ble_cus_on_ble_evt() just return, and not call on_connect() if the pointer is NULL ?

    Snippet:

    Caspar_Tsai said:
    The application is both central, and peripheral.role.

     If you are doing concurrent central and peripheral role, you might get some ideas on how to implement that by looking at the ble_app_hrs_rscs_relay() example in the nRF5 SDK.

    Caspar_Tsai said:
    Would you please share how to extract crash log, and stack dump from nRF52832 ? and the way to parse stack dump to call-stack ?

     To get all the information in the call-stack, remove compiler optimization. You should also set DEBUG as a preprocessor symbol.

  • Hi Sigurd,
    1). I will check ble_app_hrs_rscs_relay() for more information.
    2). Would you please tell me the license for both ble_cus.c, and ble_cus.h in github.com/.../custom_ble_service_example ?
    I apply ble_cus.c, and ble_cus.h into my applicaton, and need to know the license for those two file.
    If those files are GNU General Public License v3.0, then I am not able to use.

    Many thanks.
    Caspar

  • Caspar_Tsai said:
    I apply ble_cus.c, and ble_cus.h into my applicaton, and need to know the license for those two file.

     You can use the same license here as for the rest of the nRF5 SDK files.