bt_ascs: Failed to register ISO server -134

Hi, we are developping a medical device that receives an audio stream from a smartphone. We have a custom board connected to a different DSP than the one in the nrf5340_audio_DK, so for us does not make sense to use the provided example files (on the contrary is creating quite confusion for us).

With a standard nrf5340_DK board, and a modified example unicast server we are getting error "*** Booting nRF Connect SDK v2.9.1-60d0d6c8d42d ***
*** Using Zephyr OS v3.7.99-ca954a6216c9 ***
[00:00:00.279,296] <wrn> bt_hci_core: opcode 0x203a status 0x01 
[00:00:00.279,327] <wrn> bt_hci_core: Controller does not support 'LE_READ_MAX_ADV_DATA_LEN'. Assuming maximum length is 31 bytes.
[00:00:00.282,135] <inf> bt_hci_core: HW Platform: Nordic Semiconductor (0x0002)
[00:00:00.282,165] <inf> bt_hci_core: HW Variant: nRF53x (0x0003)
[00:00:00.282,165] <inf> bt_hci_core: Firmware: Standard Bluetooth controller (0x00) Version 224.11902 Build 2231721665
[00:00:00.284,088] <inf> bt_hci_core: Identity: F6:5A:AE:C8:06:82 (random)
[00:00:00.284,088] <inf> bt_hci_core: HCI: version 5.4 (0x0d) revision 0x2077, manufacturer 0x0059
[00:00:00.284,118] <inf> bt_hci_core: LMP: version 5.4 (0x0d) subver 0x2077
Bluetooth initialized
[00:00:00.284,179] <err> bt_ascs: Failed to register ISO server -134
[00:00:00.284,637] <wrn> bt_hci_core: opcode 0x2036 status 0x01 
Failed to create adv set (err -5)"

We have created a folder \sysbuild\ and added a conf file for the CPUNET as explained on this same forum "/sysbuild/ipc_radio/overlay-bt_hci_ipc.conf"

CONFIG_CLOCK_CONTROL=y
CONFIG_CLOCK_CONTROL_NRF=y
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
CONFIG_BT=y
CONFIG_BT_EXT_ADV=y

this is our prj.conf:

#
# prj.conf — nRF5340 DK CPUAPP as LE Audio Unicast Server
#

# Bluetooth core
CONFIG_BT=y
CONFIG_BT_HCI=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_EXT_ADV=y
CONFIG_BT_DEVICE_NAME="INDESmed Audio Server"

#Hci core Problem migth be related to CLK???
CONFIG_CLOCK_CONTROL=y
CONFIG_CLOCK_CONTROL_NRF=y
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC_CALIBRATION=y
CONFIG_CLOCK_CONTROL_NRF_K32SRC_500PPM=y

# — BLE Audio roles y servicios
CONFIG_BT_AUDIO=y
CONFIG_BT_PAC_SNK=y
CONFIG_BT_ASCS=y

CONFIG_BT_BAP_UNICAST_SERVER=y
CONFIG_BT_CAP_ACCEPTOR=y

# LC3 y soporte interno
CONFIG_FPU=y
CONFIG_LIBLC3=y  
CONFIG_SW_CODEC_LC3_T2_SOFTWARE=y
CONFIG_BT_ISO_PERIPHERAL=y
CONFIG_BT_ISO_SYNC_RECEIVER=y
CONFIG_BT_ATT_PREPARE_COUNT=2

# Added large stack sizes. Can be optimized.
CONFIG_MAIN_STACK_SIZE=8192
CONFIG_HEAP_MEM_POOL_SIZE=16384
CONFIG_LC3_ENC_CHAN_MAX=2
CONFIG_LC3_DEC_CHAN_MAX=2

# Logging / RTT
CONFIG_PRINTK=y
CONFIG_LOG=y

thanks in advance for the support.

Parents
  • Hi Rafael, 

    I will look into this, my first step will be to reproduce the error. Do you have and overview of the modifications made to the Unicast Audio Server sample?

    Have you been able to make an unmodified sample run successfully? 

    Best regards,

    Maria

  • Hi Maria,

    thanks for the quick reply; I attach the modified unicast example file. We have tried to simplify as much as possible the code. On the main, we just call ble_audio_init(); and no, we have not been able to run the unicast server. I think the problem is related to configuration.

    
    #include <zephyr/kernel.h>
    #include <zephyr/sys/printk.h>
    
    #include <zephyr/bluetooth/bluetooth.h>
    #include <zephyr/bluetooth/conn.h>
    #include <zephyr/bluetooth/audio/audio.h>
    #include <zephyr/bluetooth/audio/bap.h>
    #include <zephyr/bluetooth/audio/pacs.h>
    #include <zephyr/bluetooth/hci.h>
    
    /* ----------------------------------------
     * Globals
     * ---------------------------------------- */
    
    static struct bt_conn                *default_conn;
    static struct bt_bap_stream          sink_streams[CONFIG_BT_ASCS_MAX_ASE_SNK_COUNT];
    static struct bt_le_ext_adv          *adv;
    
    /* LC3 sink capability */
    static const struct bt_audio_codec_cap lc3_cap = BT_AUDIO_CODEC_CAP_LC3(
        BT_AUDIO_CODEC_CAP_FREQ_ANY,
        BT_AUDIO_CODEC_CAP_DURATION_10,
        BT_AUDIO_CODEC_CAP_CHAN_COUNT_SUPPORT(1),
        40u, 120u, 1u,
        BT_AUDIO_CONTEXT_TYPE_CONVERSATIONAL |
        BT_AUDIO_CONTEXT_TYPE_MEDIA);
    
    /* PACS sink registration */
    static struct bt_pacs_cap cap_sink = {
        .codec_cap = &lc3_cap,
    };
    
    
    /* ------------------------------------------------------------------
     * Unicast-server registration parameters (posicional)
     * ------------------------------------------------------------------ */
    
    static const struct bt_bap_unicast_server_register_param unicast_param = {
        CONFIG_BT_ASCS_MAX_ASE_SNK_COUNT, /* num_sink_ases */
        0                                 /* num_source_ases */
    };
    
    
    /* Advertising data */
    static const struct bt_data ad[] = {
        BT_DATA_BYTES(BT_DATA_FLAGS,       BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR),
        BT_DATA_BYTES(BT_DATA_UUID16_ALL,  BT_UUID_16_ENCODE(BT_UUID_ASCS_VAL)),
        BT_DATA(BT_DATA_NAME_COMPLETE,
                CONFIG_BT_DEVICE_NAME,
                sizeof(CONFIG_BT_DEVICE_NAME) - 1),
    };
    
    /* ----------------------------------------
     * Connection callbacks
     * ---------------------------------------- */
    
    static void connected(struct bt_conn *conn, uint8_t err)
    {
        if (err || default_conn) {
            return;
        }
        default_conn = bt_conn_ref(conn);
        printk("[BLE] Conectado\n");
    }
    
    static void disconnected(struct bt_conn *conn, uint8_t reason)
    {
        if (conn != default_conn) {
            return;
        }
        bt_conn_unref(default_conn);
        default_conn = NULL;
        printk("[BLE] Desconectado\n");
    }
    
    BT_CONN_CB_DEFINE(conn_callbacks) = {
        .connected    = connected,
        .disconnected = disconnected,
    };
    
    /* ----------------------------------------
     * Stream operations
     * ---------------------------------------- */
    
    static void stream_started(struct bt_bap_stream *stream)
    {
        printk("Stream iniciado %p\n", stream);
    }
    
    static void stream_stopped(struct bt_bap_stream *stream, uint8_t reason)
    {
        printk("Stream detenido %p (0x%02x)\n", stream, reason);
    }
    
    static void stream_enabled(struct bt_bap_stream *stream)
    {
        int err = bt_bap_stream_start(stream);
        if (err) {
            printk("Error al iniciar stream %p (%d)\n", stream, err);
        }
    }
    
    static void stream_recv(struct bt_bap_stream *stream,
                            const struct bt_iso_recv_info *info,
                            struct net_buf *buf)
    {
        ARG_UNUSED(info);
        printk("Audio recibido: %u bytes\n", buf->len);
    }
    
    static struct bt_bap_stream_ops stream_ops = {
        .recv    = stream_recv,
        .started = stream_started,
        .stopped = stream_stopped,
        .enabled = stream_enabled,
    };
    
    /* ----------------------------------------
     * Unicast server callbacks
     * ---------------------------------------- */
    
    static int cb_config(struct bt_conn *conn, const struct bt_bap_ep *ep,
                         enum bt_audio_dir dir,
                         const struct bt_audio_codec_cfg *cfg,
                         struct bt_bap_stream **stream,
                         struct bt_audio_codec_qos_pref *qos_pref,
                         struct bt_bap_ascs_rsp *rsp)
    {
        printk("Config sink: conn %p ep %p dir %u\n", conn, ep, dir);
    
        /* Busca un sink libre */
        for (size_t i = 0; i < ARRAY_SIZE(sink_streams); i++) {
            if (!sink_streams[i].conn) {
                *stream = &sink_streams[i];
                break;
            }
        }
        if (!*stream) {
            *rsp = BT_BAP_ASCS_RSP(
                BT_BAP_ASCS_RSP_CODE_NO_MEM,
                BT_BAP_ASCS_REASON_NONE);
            return -ENOMEM;
        }
    
        /* QoS preferido */
        *qos_pref = (struct bt_audio_codec_qos_pref){
            .unframed_supported = false,
            .phy                = BT_GAP_LE_PHY_2M,
            .rtn                = 2,
            .latency            = 10,     /* ms */
            .pd_min             = 40000,  /* µs */
            .pd_max             = 40000,
            .pref_pd_min        = 40000,
            .pref_pd_max        = 40000,
        };
    
        return 0;
    }
    
    static const struct bt_bap_unicast_server_cb unicast_cb = {
        .config = cb_config,
    };
    
    /* ----------------------------------------
     * Initialization
     * ---------------------------------------- */
    
    void ble_audio_init(void)
    {
        int err;
    
        /* 1) BT on */
        err = bt_enable(NULL);
        if (err) {
            printk("Bluetooth init failed (err %d)\n", err);
            return;
        }
        printk("Bluetooth initialized\n");
    
        /* 2) PACS register */
        err = bt_pacs_cap_register(BT_AUDIO_DIR_SINK, &cap_sink);
        if (err) {
            printk("PACS register failed (err %d)\n", err);
            return;
        }
    
        /* 3) Stream callbacks */
        for (size_t i = 0; i < ARRAY_SIZE(sink_streams); i++) {
            bt_bap_stream_cb_register(&sink_streams[i], &stream_ops);
        }
    
        /* 4) Unicast server */
        bt_bap_unicast_server_register(&unicast_param);
        bt_bap_unicast_server_register_cb(&unicast_cb);
    
        /* 5) Extended advertising */
        err = bt_le_ext_adv_create(BT_LE_EXT_ADV_CONN, NULL, &adv);
        if (err) {
            printk("Failed to create adv set (err %d)\n", err);
            return;
        }
    
        err = bt_le_ext_adv_set_data(adv, ad, ARRAY_SIZE(ad), NULL, 0);
        if (err) {
            printk("Failed to set adv data (err %d)\n", err);
            return;
        }
    
        err = bt_le_ext_adv_start(adv, BT_LE_EXT_ADV_START_DEFAULT);
        if (err) {
            printk("Failed to start adv (err %d)\n", err);
        } else {
            printk("BLE Audio Unicast Server advertising\n");
        }
    }
    

Reply
  • Hi Maria,

    thanks for the quick reply; I attach the modified unicast example file. We have tried to simplify as much as possible the code. On the main, we just call ble_audio_init(); and no, we have not been able to run the unicast server. I think the problem is related to configuration.

    
    #include <zephyr/kernel.h>
    #include <zephyr/sys/printk.h>
    
    #include <zephyr/bluetooth/bluetooth.h>
    #include <zephyr/bluetooth/conn.h>
    #include <zephyr/bluetooth/audio/audio.h>
    #include <zephyr/bluetooth/audio/bap.h>
    #include <zephyr/bluetooth/audio/pacs.h>
    #include <zephyr/bluetooth/hci.h>
    
    /* ----------------------------------------
     * Globals
     * ---------------------------------------- */
    
    static struct bt_conn                *default_conn;
    static struct bt_bap_stream          sink_streams[CONFIG_BT_ASCS_MAX_ASE_SNK_COUNT];
    static struct bt_le_ext_adv          *adv;
    
    /* LC3 sink capability */
    static const struct bt_audio_codec_cap lc3_cap = BT_AUDIO_CODEC_CAP_LC3(
        BT_AUDIO_CODEC_CAP_FREQ_ANY,
        BT_AUDIO_CODEC_CAP_DURATION_10,
        BT_AUDIO_CODEC_CAP_CHAN_COUNT_SUPPORT(1),
        40u, 120u, 1u,
        BT_AUDIO_CONTEXT_TYPE_CONVERSATIONAL |
        BT_AUDIO_CONTEXT_TYPE_MEDIA);
    
    /* PACS sink registration */
    static struct bt_pacs_cap cap_sink = {
        .codec_cap = &lc3_cap,
    };
    
    
    /* ------------------------------------------------------------------
     * Unicast-server registration parameters (posicional)
     * ------------------------------------------------------------------ */
    
    static const struct bt_bap_unicast_server_register_param unicast_param = {
        CONFIG_BT_ASCS_MAX_ASE_SNK_COUNT, /* num_sink_ases */
        0                                 /* num_source_ases */
    };
    
    
    /* Advertising data */
    static const struct bt_data ad[] = {
        BT_DATA_BYTES(BT_DATA_FLAGS,       BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR),
        BT_DATA_BYTES(BT_DATA_UUID16_ALL,  BT_UUID_16_ENCODE(BT_UUID_ASCS_VAL)),
        BT_DATA(BT_DATA_NAME_COMPLETE,
                CONFIG_BT_DEVICE_NAME,
                sizeof(CONFIG_BT_DEVICE_NAME) - 1),
    };
    
    /* ----------------------------------------
     * Connection callbacks
     * ---------------------------------------- */
    
    static void connected(struct bt_conn *conn, uint8_t err)
    {
        if (err || default_conn) {
            return;
        }
        default_conn = bt_conn_ref(conn);
        printk("[BLE] Conectado\n");
    }
    
    static void disconnected(struct bt_conn *conn, uint8_t reason)
    {
        if (conn != default_conn) {
            return;
        }
        bt_conn_unref(default_conn);
        default_conn = NULL;
        printk("[BLE] Desconectado\n");
    }
    
    BT_CONN_CB_DEFINE(conn_callbacks) = {
        .connected    = connected,
        .disconnected = disconnected,
    };
    
    /* ----------------------------------------
     * Stream operations
     * ---------------------------------------- */
    
    static void stream_started(struct bt_bap_stream *stream)
    {
        printk("Stream iniciado %p\n", stream);
    }
    
    static void stream_stopped(struct bt_bap_stream *stream, uint8_t reason)
    {
        printk("Stream detenido %p (0x%02x)\n", stream, reason);
    }
    
    static void stream_enabled(struct bt_bap_stream *stream)
    {
        int err = bt_bap_stream_start(stream);
        if (err) {
            printk("Error al iniciar stream %p (%d)\n", stream, err);
        }
    }
    
    static void stream_recv(struct bt_bap_stream *stream,
                            const struct bt_iso_recv_info *info,
                            struct net_buf *buf)
    {
        ARG_UNUSED(info);
        printk("Audio recibido: %u bytes\n", buf->len);
    }
    
    static struct bt_bap_stream_ops stream_ops = {
        .recv    = stream_recv,
        .started = stream_started,
        .stopped = stream_stopped,
        .enabled = stream_enabled,
    };
    
    /* ----------------------------------------
     * Unicast server callbacks
     * ---------------------------------------- */
    
    static int cb_config(struct bt_conn *conn, const struct bt_bap_ep *ep,
                         enum bt_audio_dir dir,
                         const struct bt_audio_codec_cfg *cfg,
                         struct bt_bap_stream **stream,
                         struct bt_audio_codec_qos_pref *qos_pref,
                         struct bt_bap_ascs_rsp *rsp)
    {
        printk("Config sink: conn %p ep %p dir %u\n", conn, ep, dir);
    
        /* Busca un sink libre */
        for (size_t i = 0; i < ARRAY_SIZE(sink_streams); i++) {
            if (!sink_streams[i].conn) {
                *stream = &sink_streams[i];
                break;
            }
        }
        if (!*stream) {
            *rsp = BT_BAP_ASCS_RSP(
                BT_BAP_ASCS_RSP_CODE_NO_MEM,
                BT_BAP_ASCS_REASON_NONE);
            return -ENOMEM;
        }
    
        /* QoS preferido */
        *qos_pref = (struct bt_audio_codec_qos_pref){
            .unframed_supported = false,
            .phy                = BT_GAP_LE_PHY_2M,
            .rtn                = 2,
            .latency            = 10,     /* ms */
            .pd_min             = 40000,  /* µs */
            .pd_max             = 40000,
            .pref_pd_min        = 40000,
            .pref_pd_max        = 40000,
        };
    
        return 0;
    }
    
    static const struct bt_bap_unicast_server_cb unicast_cb = {
        .config = cb_config,
    };
    
    /* ----------------------------------------
     * Initialization
     * ---------------------------------------- */
    
    void ble_audio_init(void)
    {
        int err;
    
        /* 1) BT on */
        err = bt_enable(NULL);
        if (err) {
            printk("Bluetooth init failed (err %d)\n", err);
            return;
        }
        printk("Bluetooth initialized\n");
    
        /* 2) PACS register */
        err = bt_pacs_cap_register(BT_AUDIO_DIR_SINK, &cap_sink);
        if (err) {
            printk("PACS register failed (err %d)\n", err);
            return;
        }
    
        /* 3) Stream callbacks */
        for (size_t i = 0; i < ARRAY_SIZE(sink_streams); i++) {
            bt_bap_stream_cb_register(&sink_streams[i], &stream_ops);
        }
    
        /* 4) Unicast server */
        bt_bap_unicast_server_register(&unicast_param);
        bt_bap_unicast_server_register_cb(&unicast_cb);
    
        /* 5) Extended advertising */
        err = bt_le_ext_adv_create(BT_LE_EXT_ADV_CONN, NULL, &adv);
        if (err) {
            printk("Failed to create adv set (err %d)\n", err);
            return;
        }
    
        err = bt_le_ext_adv_set_data(adv, ad, ARRAY_SIZE(ad), NULL, 0);
        if (err) {
            printk("Failed to set adv data (err %d)\n", err);
            return;
        }
    
        err = bt_le_ext_adv_start(adv, BT_LE_EXT_ADV_START_DEFAULT);
        if (err) {
            printk("Failed to start adv (err %d)\n", err);
        } else {
            printk("BLE Audio Unicast Server advertising\n");
        }
    }
    

Children
No Data
Related