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

Sending large data in BLE

Hi , 

I have an Android app that acts as a Central mode and Nordic nRF9160 as peripheral mode. 

Once the connection is established , App will read the characteristics from nRF9160.  nRF9160 upon receiving the read request , responds to App with data of 140 bytes. 

As per the BLE , only 22 bytes are allowed to send . So how do i send the data ? it is like , I need to truncate the data into chunks of size 22 or will the bt_gatt_attr_read does tat ?

From the prints , I see that Android App or bt_gatt_attr_read  it self handles the truncation and sends the data. But after a while i receive "Usage fault"..

The following is the logs :

"

2020-07-30T07:41:00.620Z DEBUG modem << bt_advertise_start >>>>>>>>>
2020-07-30T07:41:02.522Z DEBUG modem << Device Connected: 46:9e:e0:b4:0c:6a (random)
2020-07-30T07:41:02.551Z DEBUG modem << Connected MTU size >>>>>> 23
2020-07-30T07:41:02.552Z DEBUG modem << MTU exchange pending
2020-07-30T07:41:03.217Z DEBUG modem << MTU exchange successful
2020-07-30T07:41:03.257Z DEBUG modem << Current MTU: 23
2020-07-30T07:41:04.046Z DEBUG modem << read start >>>>>>>>>>>>
2020-07-30T07:41:04.078Z DEBUG modem << read start string = {"id":"mIVJY7MtxcYii4Q3EeazvYsdxTCL7rUrUM8qtWaMnFCsd66KB7ljdQ42xfkK1JX0QZYbXr2Gd0+LvYiv8g==","mob":"+12345678901","mp":"nRF9160DK","o":"ORG","v":2} >>>>>>>>>>>>
2020-07-30T07:41:04.080Z DEBUG modem << read start strlen() = 147 >>>>>>>>>>>>
2020-07-30T07:41:04.081Z DEBUG modem << retValue end = 22 ========================
2020-07-30T07:41:04.084Z DEBUG modem << end ========================
2020-07-30T07:41:04.118Z DEBUG modem << ***** USAGE FAULT *****
2020-07-30T07:41:04.121Z DEBUG modem << Illegal load of EXC_RETURN into PC
2020-07-30T07:41:04.122Z DEBUG modem << ***** Hardware exception *****
2020-07-30T07:41:04.125Z DEBUG modem << Current thread ID = 0x20020a48
2020-07-30T07:41:04.127Z DEBUG modem << Faulting instruction address = 0x20029374
2020-07-30T07:41:04.155Z DEBUG modem << Fatal fault in thread 0x20020a48! Aborting.
2020-07-30T07:41:04.186Z DEBUG modem << read start >>>>>>>>>>>>
2020-07-30T07:41:04.188Z DEBUG modem << read start string = {"id":"mIVJY7MtxcYii4Q3EeazvYsdxTCL7rUrUM8qtWaMnFCsd66KB7ljdQ42xfkK1JX0QZYbXr2Gd0+LvYiv8g==","mob":"+12345678901","mp":"nRF9160DK","o":"ORG","v":2} >>>>>>>>>>>>
2020-07-30T07:41:04.190Z DEBUG modem << read start strlen() = 147 >>>>>>>>>>>>
2020-07-30T07:41:04.191Z DEBUG modem << retValue end = 22 ========================
2020-07-30T07:41:04.191Z DEBUG modem << end ========================
2020-07-30T07:41:04.241Z DEBUG modem << read start >>>>>>>>>>>>
2020-07-30T07:41:04.286Z DEBUG modem << read start string = {"id":"mIVJY7MtxcYii4Q3EeazvYsdxTCL7rUrUM8qtWaMnFCsd66KB7ljdQ42xfkK1JX0QZYbXr2Gd0+LvYiv8g==","mob":"+12345678901","mp":"nRF9160DK","o":"ORG","v":2} >>>>>>>>>>>>
2020-07-30T07:41:04.288Z DEBUG modem << read start strlen() = 147 >>>>>>>>>>>>
2020-07-30T07:41:04.290Z DEBUG modem << retValue end = 22 ========================
2020-07-30T07:41:04.291Z DEBUG modem << end ========================
2020-07-30T07:41:04.631Z DEBUG modem << read start >>>>>>>>>>>>
2020-07-30T07:41:04.662Z DEBUG modem << read start string = {"id":"mIVJY7MtxcYii4Q3EeazvYsdxTCL7rUrUM8qtWaMnFCsd66KB7ljdQ42xfkK1JX0QZYbXr2Gd0+LvYiv8g==","mob":"+12345678901","mp":"nRF9160DK","o":"ORG","v":2} >>>>>>>>>>>>
2020-07-30T07:41:04.664Z DEBUG modem << read start strlen() = 147 >>>>>>>>>>>>
2020-07-30T07:41:04.666Z DEBUG modem << retValue end = 22 ========================
2020-07-30T07:41:04.668Z DEBUG modem << end ========================
2020-07-30T07:41:04.826Z DEBUG modem << read start >>>>>>>>>>>>
2020-07-30T07:41:04.857Z DEBUG modem << read start string = {"id":"mIVJY7MtxcYii4Q3EeazvYsdxTCL7rUrUM8qtWaMnFCsd66KB7ljdQ42xfkK1JX0QZYbXr2Gd0+LvYiv8g==","mob":"+12345678901","mp":"nRF9160DK","o":"ORG","v":2} >>>>>>>>>>>>
2020-07-30T07:41:04.860Z DEBUG modem << read start strlen() = 147 >>>>>>>>>>>>
2020-07-30T07:41:04.862Z DEBUG modem << retValue end = 22 ========================
2020-07-30T07:41:04.864Z DEBUG modem << end ========================
2020-07-30T07:41:05.071Z DEBUG modem << read start >>>>>>>>>>>>
2020-07-30T07:41:05.113Z DEBUG modem << read start string = {"id":"mIVJY7MtxcYii4Q3EeazvYsdxTCL7rUrUM8qtWaMnFCsd66KB7ljdQ42xfkK1JX0QZYbXr2Gd0+LvYiv8g==","mob":"+12345678901","mp":"nRF9160DK","o":"ORG","v":2} >>>>>>>>>>>>
2020-07-30T07:41:05.115Z DEBUG modem << read start strlen() = 147 >>>>>>>>>>>>
2020-07-30T07:41:05.116Z DEBUG modem << retValue end = 22 ========================
2020-07-30T07:41:05.118Z DEBUG modem << end ========================
2020-07-30T07:41:05.167Z DEBUG modem << read start >>>>>>>>>>>>
2020-07-30T07:41:05.197Z DEBUG modem << read start string = {"id":"mIVJY7MtxcYii4Q3EeazvYsdxTCL7rUrUM8qtWaMnFCsd66KB7ljdQ42xfkK1JX0QZYbXr2Gd0+LvYiv8g==","mob":"+12345678901","mp":"nRF9160DK","o":"ORG","v":2} >>>>>>>>>>>>
2020-07-30T07:41:05.199Z DEBUG modem << read start strlen() = 147 >>>>>>>>>>>>
2020-07-30T07:41:05.200Z DEBUG modem << retValue end = 15 ========================
2020-07-30T07:41:05.201Z DEBUG modem << end ========================
2020-07-30T07:41:05.313Z DEBUG modem << len :::1 >>>>>>>>>>>>
2020-07-30T07:41:05.339Z DEBUG modem << value :::7 >>>>>>>>>>>>
2020-07-30T07:41:05.341Z DEBUG modem << write_ct value buffer :::7 >>>>>>>>>>>>
2020-07-30T07:41:05.509Z DEBUG modem << len :::20 >>>>>>>>>>>>
2020-07-30T07:41:05.541Z DEBUG modem << value :::{"id":"3w6zaw5LlIeeOˆk >>>>>>>>>>>> write_ct value buffer :::{"id":"3w6zaw5LlIeeOSÏ–H,ì*,ŠÿÐ`)üIQP¿aWž0OÉûïg?wÓÙ$J{¼b1¥¿äÛà¸Z3“k Š”y‘žúÐRegistered͔?÷-ȒÞ-J²Zúяòù6;îOÕ¥$¡â]Cspl{pÔÚ%ÁO·ŸŠ07€#+ >>>>>>>>>>>>
2020-07-30T07:41:06.532Z DEBUG modem << Disconnected (reason 19)
2020-07-30T07:41:50.604Z DEBUG modem << bt_advertise_stop led_tid = 537004616>>>>>>>>>
2020-07-30T07:44:50.609Z DEBUG modem << adv_thread wait for 120 secs .............
2020-07-30T07:44:50.656Z DEBUG modem << bt_advertise_start >>>>>>>>>
2020-07-30T07:45:00.833Z DEBUG modem << Device Connected: 66:45:59:e1:d6:27 (random)
2020-07-30T07:45:00.864Z DEBUG modem << Connected MTU size >>>>>> 23
2020-07-30T07:45:00.866Z DEBUG modem << MTU exchange pending
2020-07-30T07:45:00.867Z DEBUG modem << Device Connected: 66:45:59:e1:d6:27 (random)
2020-07-30T07:45:00.869Z DEBUG modem << Connected MTU size >>>>>> 23
2020-07-30T07:45:00.870Z DEBUG modem << MTU exchange pending
2020-07-30T07:45:00.871Z DEBUG modem << Device Connected: 66:45:59:e1:d6:27 (random)
2020-07-30T07:45:00.872Z DEBUG modem << Connected MTU size >>>>>> 23
2020-07-30T07:45:00.872Z DEBUG modem << MTU exchange pending
2020-07-30T07:45:00.873Z DEBUG modem << Device Connected: 66:45:59:e1:d6:27 (random)
2020-07-30T07:45:00.874Z DEBUG modem << Connected MTU size >>>>>> 23
2020-07-30T07:45:30.925Z DEBUG modem << MTU exchange failed
2020-07-30T07:45:30.976Z DEBUG modem << Exception occurred in Secure State
2020-07-30T07:45:30.977Z DEBUG modem << ***** HARD FAULT *****
2020-07-30T07:45:30.979Z DEBUG modem << Fault escalation (see below)
2020-07-30T07:45:30.981Z DEBUG modem << ***** BUS FAULT *****
2020-07-30T07:45:30.982Z DEBUG modem << Precise data bus error
2020-07-30T07:45:30.983Z DEBUG modem << BFAR Address: 0x50008120
2020-07-30T07:45:30.984Z DEBUG modem << ***** Hardware exception *****
2020-07-30T07:45:30.985Z DEBUG modem << Current thread ID = 0x20026d0c
2020-07-30T07:45:30.986Z DEBUG modem << Faulting instruction address = 0x351e0
2020-07-30T07:45:30.988Z DEBUG modem << Fatal fault in ISR! Spinning...

"

And further , I receive the "HARD FAULT "

How to resolve this ?

Parents Reply Children
  • Hi , 

    I updated to v1.3.0 release.  I followed this link:

    http://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/samples/nrf9160/lte_ble_gateway/README.html.

    I flashed the  Bluetooth-HCI-UART , and then flashed the lte_ble_gateway. 

    When I reboot , my board resets with the following error:

    "

    2020-08-07T07:03:04.824Z DEBUG modem << *** Booting Zephyr OS build v2.3.0-rc1-ncs1 ***
    2020-08-07T07:03:04.827Z DEBUG modem << LTE Sensor Gateway sample started
    2020-08-07T07:03:04.831Z DEBUG modem << Initializing Bluetooth..
    2020-08-07T07:03:04.834Z DEBUG modem << Establishing LTE link (this may take some time) ...
    2020-08-07T07:03:14.821Z DEBUG modem << ASSERTION FAIL [err == 0] @ D:/Workspace/nordic/ncsmaster/zephyr/subsys/bluetooth/host/hci_core.c:370

    "

    Am I missing anything ?

    With regards,

    Saravanan

  • Hi,

     

    It looks like its not able to successfully interface the nRF52840 device.

    Did you recompile hci_uart for board "nrf9160dk_nrf52840" and flash this one as well?

    The nRF9160 should be able to reset the nRF52840 device on boot up.

     

    Kind regards,

    Håkon

  • Hi , 

    I was able to solve that by reflashing twice .  Now I'm trying to reconfigure the MTU size by comfiguring the Zephyr OS using menuconfig in SES. after configuration, I'm not able to build it: 

    "Changed board to secure nrf9160dk_nrf9160 (NOT NS)
    -- Configuring done
    -- Generating done
    CMake Error:
    Running

    'C:/ProgramData/chocolatey/bin/ninja.exe' '-C' 'D:/Workspace/nordic/Master/nrf/samples/nrf9160/lte_ble_gateway/build_nrf9160dk_nrf9160ns' '-t' 'recompact'

    failed with:

    ninja: error: failed recompaction: Permission denied

    CMake Error:
    Running

    'C:/ProgramData/chocolatey/bin/ninja.exe' '-C' 'D:/Workspace/nordic/Master/nrf/samples/nrf9160/lte_ble_gateway/build_nrf9160dk_nrf9160ns' '-t' 'restat' 'build.ninja'

    failed with:

    ninja: error: failed recompaction: Permission denied

    CMake Generate step failed. Build files cannot be regenerated correctly.
    Project load failed
    Reported error: solution load command failed (1)

    "

    Any idea ?

    With regards,
    Saravanan

  • Hi,

     

    This looks to be a problem (corner-case) with ninja:

    https://gitlab.kitware.com/cmake/cmake/-/issues/20274

    Could you try to use another build folder and see if the problem disappears?

     

    Kind regards,

    Håkon

  • Hi , 

    yeah , I tried that too like a  cloning into a new folder and did not work. the ninja version i'm using 1.10.0. May be I need to wait for the next version. 

    BTW , i found the workaround. I mean once we click "Configure ", the configuration is saved in the .config. If I close the SES and open again, I'm able to build the project.

    Also the error

    "

    2020-08-12T14:47:11.181Z DEBUG modem << ASSERTION FAIL [err == 0] @ WEST_TOPDIR/zephyr/subsys/bluetooth/host/hci_core.c:369
    2020-08-12T14:47:11.221Z DEBUG modem << k_sem_take failed with err -11 "

    Keeps repeating.  But when I reflash the hci_uart , it does not come. when I run my app , it comes. Not sure running my app corrupts the HCI or something ? Any idea to debug ?

    With regards,

    Saravanan.

Related