This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

merge cdc-acm support and BLE service

I has successfully built the following demos and run them on a nrf52840 dongle (board: nrf52840dongle_nrf52840) :

  • cdc-acm-console demo            from Samples and Demos » Various Subsystems Samples » USB device support samples
  • bluetooth-st_ble_sensor demo from Samples and Demos » Bluetooth Samples

Based on these demos I am trying to introduce cdc-acm-console support to the bluetooth-st_ble_sensor demo.

Could you please help me to produce the right project configuration (and eventual overlay) to merge both functions (cdc-acm-console and ble GATT services) on a single demo ?

thanks in advance

  • I have included the following within the #includes of the main.c :


    #include <usb/usb_device.h>
    #include <drivers/uart.h>
    BUILD_ASSERT(DT_NODE_HAS_COMPAT(DT_CHOSEN(zephyr_console), zephyr_cdc_acm_uart),
    "Console device is not ACM CDC UART device");

    and here is the main() including calls to printk :

    void main(void)
    {
    int err, n=0;

    err = button_init(button_callback);
    if (err) {
         return;
    }

    err = led_init();
    if (err) {
         return;
    }

    // exemple console (SB)
    const struct device *dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_console));
    uint32_t dtr = 0;

    if (usb_enable(NULL)) {
         return;
    }

    /* Poll if the DTR flag was set */
    while (!dtr) {
         uart_line_ctrl_get(dev, UART_LINE_CTRL_DTR, &dtr);
         /* Give CPU resources to low priority threads. */
         k_sleep(K_MSEC(100));
    }

    printk("Hello World! %s\n", CONFIG_ARCH);
    // fin exemple console (SB)

    /* Initialize the Bluetooth Subsystem */
    err = bt_enable(bt_ready);
    if (err) {
    L     OG_ERR("Bluetooth init failed (err %d)", err);
    }

    /* do not exit but print forever */

    while (1) {
         printk("Hello running ! %d\n", n++);
         k_sleep(K_SECONDS(1));
    }

    }

  • Sergio Bezz said:
    but I cannot see any BLE advertising.

    I tested with nRF Connect SDK v1.8.0, and it works fine here.

    What version are you using? Can you try v1.8.0? (use &zephyr_udc if you are on v1.8.0)

Related