How is the size of a characteristic set in Zephyr?

Am making a project based on NUS central demo and I can connect to our remote unit with the 52840DK, I can send data over a UART into it and I can get data out which is received on the remote BLE node.

I'd like to, well, need to, change the TX and RX characteristics to be 240 bytes in size.

I have seen here:

devzone.nordicsemi.com/.../extends-the-mtu-size-in-latest-zephyr

Someone talking about the maximum overall size (although I don't understand what he's saying in the answer).

Where are these used? ie What file would this be in?

CONFIG_BT_BUF_ACL_RX_SIZE instead of CONFIG_BT_L2CAP_RX_MTU (comes from l2cap.h, 
#define BT_L2CAP_RX_MTU (CONFIG_BT_BUF_ACL_RX_SIZE - BT_L2CAP_HDR_SIZE)

And this:

Max payload size of adv_data with extended advertizement


I'd expect to see it in this:


/* UART Service Declaration */
BT_GATT_SERVICE_DEFINE(nus_svc,
BT_GATT_PRIMARY_SERVICE(BT_UUID_NUS_SERVICE),
BT_GATT_CHARACTERISTIC(BT_UUID_NUS_TX,
BT_GATT_CHRC_NOTIFY,
#ifdef CONFIG_BT_NUS_AUTHEN
BT_GATT_PERM_READ_AUTHEN,
#else
BT_GATT_PERM_READ,
#endif /* CONFIG_BT_NUS_AUTHEN */
NULL, NULL, NULL),
BT_GATT_CCC(nus_ccc_cfg_changed,
#ifdef CONFIG_BT_NUS_AUTHEN
BT_GATT_PERM_READ_AUTHEN | BT_GATT_PERM_WRITE_AUTHEN),
#else
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE),
#endif /* CONFIG_BT_NUS_AUTHEN */
BT_GATT_CHARACTERISTIC(BT_UUID_NUS_RX,
BT_GATT_CHRC_WRITE |
BT_GATT_CHRC_WRITE_WITHOUT_RESP,
#ifdef CONFIG_BT_NUS_AUTHEN
BT_GATT_PERM_READ_AUTHEN | BT_GATT_PERM_WRITE_AUTHEN,
#else
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
#endif /* CONFIG_BT_NUS_AUTHEN */
NULL, on_receive, NULL),
);
In good old SES we had what seems logical to me in this:

   attr_char_value.max_len   = TX_LEN;


    err_code = sd_ble_gatts_characteristic_add( exlrt_service.service_handle,
                                                &char_md,
                                                &attr_char_value,
                                                handle );
So what's the equivalent with Zephyr please? And do I have to add something to the proj file to say what the max allowable size is?
  • OK thanks again, I'll see whether I can sort this out with defining my own service and knit it in with the central project.

    I really detest macros and never, ever use them because they obfuscate code too much, but, in this case, I don't need to  understand what's going on under the hood, so I should just suck it up!

  • I'm still struggling with this.

    It tells me there's an error if I use this in prj.conf

    CONFIG_BT_L2CAP_RX_MTU=247

    If I do this:

    static uint8_t device_info[240];
    static uint8_t send_info[240];
    /* UART Service Declaration */
    BT_GATT_SERVICE_DEFINE(nus_svc,
    BT_GATT_PRIMARY_SERVICE(BT_UUID_NUS_SERVICE),
    BT_GATT_CHARACTERISTIC(BT_UUID_NUS_TX,
    BT_GATT_CHRC_NOTIFY,
    #ifdef CONFIG_BT_NUS_AUTHEN
    BT_GATT_PERM_READ_AUTHEN,
    #else
    BT_GATT_PERM_READ,
    #endif /* CONFIG_BT_NUS_AUTHEN */
    NULL, NULL, send_info),
    BT_GATT_CCC(nus_ccc_cfg_changed,
    #ifdef CONFIG_BT_NUS_AUTHEN
    BT_GATT_PERM_READ_AUTHEN | BT_GATT_PERM_WRITE_AUTHEN),
    #else
    BT_GATT_PERM_READ | BT_GATT_PERM_WRITE),
    #endif /* CONFIG_BT_NUS_AUTHEN */
    BT_GATT_CHARACTERISTIC(BT_UUID_NUS_RX,
    BT_GATT_CHRC_WRITE |
    BT_GATT_CHRC_WRITE_WITHOUT_RESP,
    #ifdef CONFIG_BT_NUS_AUTHEN
    BT_GATT_PERM_READ_AUTHEN | BT_GATT_PERM_WRITE_AUTHEN,
    #else
    BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
    #endif /* CONFIG_BT_NUS_AUTHEN */
    NULL, on_receive, device_info),
    );
    I seem to be able to write long characteristics *IN* to the
    peripheral_uart from a phone, but if I try to send larger chunks of
    data out to the phone from the nrf I get an error -12 which the
    source code tells me is:
    #define ENOMEM 12 /* Out of memory */
    So what is the issue here please?
  • At this point, I have to request you to give me your project so that I understand little better on the configs and other setup you have. Can you please attach you project so that I can test and try to figure out if we need to increase some buffer sizes in the configuration file.

Related