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

nrf52832 terminate the connection with code 7, BLE_HCI_MEMORY_CAPACITY_EXCEEDED

Hi guys, our team now are trying to used nrf52832 to stream audio to ios app, and as you know we are in trouble.

Here are some info about our test env:

1. mobile app ran on ios 11.4.1, the latest release version

2. nrf52832 code based on nRF5_SDK_15.0.0_a53641a and the softdevice is s132_nrf52_6.0.0_softdevice.hex

3. nrf52832 and mobile app exchange data every 15ms, 20 bytes per packet if there any audio data, sometimes they just exchange empty packet

4. mobile app used "write wihtout reponse" to send data to nrf52832, nrf52832 used "Notification" to send data to mobile app

5. all char value inside nrf52832 are located in stack memory, attr_md.vloc = BLE_GATTS_VLOC_STACK;

5. and here are the ble connection parameter, min conn = 15ms, max conn = 15ms, slave latency = 0, supervision timeout = 4seconds

6. NRF_SDH_BLE_GAP_EVENT_LENGTH = 6, NRF_SDH_BLE_GATT_MAX_MTU_SIZE = 23,  APP_BLE_HVB_TX_QUEUE_SIZE = 12

7. inside the link script, heap and stack size just remain as default, all equal to 8192 bytes

Occasionally the mobile app showed the ble connection had been disconnected by nrf52832 with disconnect reason like "Error Domain=CBErrorDomain Code=7 "The specified device has disconnected from us.""

We tried google it and read ble core specification files and we think Code 7 means “BLE_HCI_MEMORY_CAPACITY_EXCEEDED”. Right?

We do not have much knowledge about the host and controller, so could anyone may help us to explain what that “Code=7” means?

If I reduce the APP_BLE_HVB_TX_QUEUE_SIZE or NRF_SDH_BLE_GAP_EVENT_LENGTH  may help? So does increase the heap size?

  • HI Chamber, 

    I have not seen the  Memory Capacity Exceeded error being the cause for disconnects in previous cases. According to the Core spec the Memory Capacity Exceeded error code indicates to the Host that the Controller has run out of memory to store new parameters.

    The Memory Capacity Exceeded error code shall be returned in the following scenarios:

    LE Add Device To White List Command:

    When a Controller cannot add a device to the White List because there is no
    space available, the Controller shall return the error code
    Memory Capacity Exceeded (0x07).

    LE Add Device To Resolving List Command:

    When a Controller cannot add a device to the list because there is no space
    available, the Controller shall return the error code
    Memory Capacity Exceeded (0x07).

    LE Set Extended Advertising Parameters Command: 

    If the Advertising_Handle does not identify an existing advertising set and the
    Controller is unable to support a new advertising set at present,

    LE Set Extended Advertising Data Command: 

    The Host may set the advertising data in one or more operations using the
    Operation parameter in the command. If the combined length of the data
    exceeds the capacity of the advertising set identified by the
    Advertising_Handle parameter (see Section 7.8.57 LE Read Maximum
    Advertising Data Length Command) or the amount of memory currently
    available, all the data shall be discarded and the Controller shall return the
    error code Memory Capacity Exceeded (0x07)

    LE Set Extended Scan Response Data Command:

    The Host may set the scan response data in one or more operations using the
    Operation parameter in the command. If the combined length of the data
    exceeds the capacity of the advertising set identified by the
    Advertising_Handle parameter (see Section 7.8.57 LE Read Maximum
    Advertising Data Length Command) or the amount of memory currently
    available, all the data shall be discarded and the Controller shall return the
    error code Memory Capacity Exceeded (0x07).

    LE Set Periodic Advertising Parameters Command

    If the Advertising_Handle does not identify an advertising set that is already
    configured for periodic advertising and the Controller is unable to support more
    periodic advertising at present, the Controller shall return the error code
    Memory Capacity Exceeded (0x07).

    LE Add Device To Periodic Advertiser List Command

    When a Controller cannot add a device to the Periodic Advertiser list because
    the list is full, the Controller shall return the error code Memory Capacity
    Exceeded (0x07).

    Would it be possible for you to capture a trace of the on-air packets using a Bluetooth Protocol Analyzer, e.g. Ellisys or using the Nordic Sniffer v2?  I would be very useful to know which commands that are sent between the peers and then examine if any one of them could trigger any of the above scenarios.

    The SoftDevice does not use the heap so I do not think that increasing the heap size will solve this issue. Where is APP_BLE_HVB_TX_QUEUE_SIZE defined in your code?

    Best regards

    Bjørn 

Related