Zephyr BLE issues

Hello,

I'm currently exploring BLE using zephyr and faced some issues.

1. id like to restart advertising after disconnecting from a device. I tried different approaches like stopping advertising and starting it again. stopping advertising, disabling bluetooth, enabling and starting it again but it always results in the same error. I added some error logs for debugging. I always get error code -12 but don't know how to resolve it.

Disconnected, reason 0x13 
- BLE disconnected
- Stopped BLE advertising
- Uninitialized BLE
- Initialized BLE
- Advertising failed to start (err -12)

I also tried to restart the device, but the linker fails with an undefined function for

sys_reboot(SYS_REBOOT_WARM);

so I guess I probably miss some definition in the pros.conf 

thank you

2. how do I max the ble data rate? do I just have to add some configs in the pros.conf file or do I have to call some functions from the stack additionally? (I'm used to the nordic sdk, but I'm currently learning zephyr and try to get similar behavior)

- I'd like to limit the connection interval

- increase to the max mtu and datalength

- set to 2m phy

Parents Reply Children
  • rsf_pn said:
    can i also set the parameters as ble peripheral or only as central device?

    That course demonstrates setting the parameters on the ble peripheral side, and that will trigger the negotiation with the central device in the connection. so you may not get the full bytes that you request. The device that supports the shortest data length will have the final say.

  • changing the connection paramters worked perfectly fine following the guide.

    i've set the following settings in my proj.conf file (looked at the guide and throughput example for the macros)

    CONFIG_BT_PERIPHERAL_PREF_MIN_INT=6
    CONFIG_BT_PERIPHERAL_PREF_MAX_INT=24
    CONFIG_BT_PERIPHERAL_PREF_LATENCY=0
    CONFIG_BT_PERIPHERAL_PREF_TIMEOUT=400
    CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=y
    CONFIG_BT_USER_PHY_UPDATE=y
    
    CONFIG_BT_MAX_CONN=1
    CONFIG_BT_MAX_PAIRED=1
    
    CONFIG_BT_BUF_ACL_RX_SIZE=502
    CONFIG_BT_ATT_PREPARE_COUNT=2
    CONFIG_BT_ATT_TX_COUNT=10
    CONFIG_BT_L2CAP_TX_MTU=498
    CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y
    CONFIG_BT_CONN_TX_MAX=10
    CONFIG_BT_BUF_ACL_TX_COUNT=10
    CONFIG_BT_BUF_ACL_TX_SIZE=502
    
    CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
    CONFIG_BT_CTLR_PHY_2M=y
    CONFIG_BT_CTLR_PHY_CODED=y
    CONFIG_BT_CTLR_SDC_MAX_CONN_EVENT_LEN_DEFAULT=4000000

    and called the required commands from the guide.

    in the debug logs i can see that the connection interval is set correctly, phy is updated and mtu is updated.

    - BLE connected
    
    PHY updated. New PHY: 2M
    Connection interval: 24 units (30 ms)
    Connection latency: 0
    Supervision timeout: 720 ms
    MTU: 23
    UATT MTU: 23
    
    Connection interval: 24 units (30 ms)
    Connection latency: 0
    Supervision timeout: 4000 ms
    MTU: 498
    UATT MTU: 498

    Only two things that i still don't understand.

    #CONFIG_BT_CTLR_PHY_2M=y
    #CONFIG_BT_CTLR_PHY_CODED=y
    for some reason my main loop is not executed anymore if i add these two lines back in.
    and i don't get the MTU values i thought MTU can be maximum 251 bytes with 244 bytes usable data for bluetooth 5. what does 498 mean. can i really use 498 bytes every connection interval?
    thanks for your advice
  • rsf_pn said:
    #CONFIG_BT_CTLR_PHY_2M=y
    #CONFIG_BT_CTLR_PHY_CODED=y
    for some reason my main loop is not executed anymore if i add these two lines back in.

    It's not clear what might have caused the issue, but you can refer to https://github.com/nrfconnect/sdk-nrf/tree/main/samples/bluetooth/throughput for the settings and coding. 

    rsf_pn said:
    and i don't get the MTU values i thought MTU can be maximum 251 bytes with 244 bytes usable data for bluetooth 5. what does 498 mean. can i really use 498 bytes every connection interval?

    MTU of 498 means the maximum size of a single ATT operation, but not a single on-air packet. The actual on-air packet size is limited by data length up to 251 bytes, while the actual payload that you can send is a maximum of 244 bytes. This is because the 251-byte Data PDU payload needs an L2CAP Header of 4 bytes, and an Attribute header of 3 bytes. This leaves you with 251 – 4 – 3 = 244 bytes that you can actually populate with payload data. 

Related