C/C++ Bluetooth

Hello! I am a new developer with toriozn.

Currently, I can develop in C/C++ on torizon using VSCODE extension (early access) in a development container. I can build and debug apps. I have provided apps with access to devices such as uart-1 i2c-1 etc.

I have recently started working on bluetooth and have added libbluetooth-dev library and linked it using -lbluetooth. I am able to build the code and deploye it. but somehow it appears my container does not have access to the bluetooth device. A simple btsearch code is as follows:

int btsearch()
{
    int device_id = hci_get_route(NULL);
    if (device_id < 0)
    {
        std::cerr << "Error: No Bluetooth adapter found." << std::endl;
        return 1;
    }

    int socket = hci_open_dev(device_id);
    if (socket < 0)
    {
        std::cerr << "Error: Failed to open Bluetooth socket." << std::endl;
        return 1;
    }

    int max_rsp = 255;
    int flags = IREQ_CACHE_FLUSH;
    inquiry_info *devices = (inquiry_info *)malloc(max_rsp * sizeof(inquiry_info));

    int device_count = hci_inquiry(device_id, 8, max_rsp, NULL, &devices, flags);
    if (device_count < 0)
    {
        std::cerr << "Error: Failed to perform Bluetooth inquiry." << std::endl;
        close(socket);
        return 1;
    }

    for (int i = 0; i < device_count; i++)
    {
        char addr[19] = {0};
        char name[248] = {0};

        ba2str(&(devices + i)->bdaddr, addr);
        if (hci_read_remote_name(socket, &(devices + i)->bdaddr, sizeof(name), name, 0) < 0)
        {
            strcpy(name, "[unknown]");
        }

        std::cout << "Device " << i + 1 << ": " << addr << " - " << name << std::endl;
    }

    free(devices);
    close(socket);
    return 0;
}

The above code exits with error: no bluetooth adapter found.

through the terminal, I am able to access the bluetooth service via ssh using root

Any pointers on how I can provide bluetooth access to my container?

Hi @geopaxpvtltd !

Can you please provide the output of tdx-info?

Also, FYI bluetooth is currently not officially supported on TorizonCore.

But, anyway, how you are configuring your container to run?

Best regards,

Kindly find the output of tdf-info as follows:

Software summary
------------------------------------------------------------
Bootloader:               U-Boot
Kernel version:           5.4.193-5.7.0+git.f78299297185 #1-TorizonCore SMP PREEMPT Mon Jul 11 14:42:03 UTC 2022
Kernel command line:      root=LABEL=otaroot rootfstype=ext4 quiet logo.nologo vt.global_cursor_default=0 plymouth.ignore-serial-consoles splash fbcon=map:3 ostree=/ostree/boot.1/torizon/197df9985ed050833c45da3c9f71a61d0ff961f710a005c4fbb8bb090a5b2ca4/0
Distro name:              NAME="TorizonCore"
Distro version:           VERSION_ID=5.7.0-build.17
Hostname:                 verdin-imx8mm-14756428
------------------------------------------------------------

Hardware info
------------------------------------------------------------
HW model:                 Toradex Verdin iMX8M Mini WB on Verdin Development Board
Toradex version:          0060 V1.1C
Serial number:            14756428
Processor arch:           aarch64

and for tdx-info --all, the following is the output

Software summary
------------------------------------------------------------
Bootloader:               U-Boot
Kernel version:           5.4.193-5.7.0+git.f78299297185 #1-TorizonCore SMP PREEMPT Mon Jul 11 14:42:03 UTC 2022
Kernel command line:      root=LABEL=otaroot rootfstype=ext4 quiet logo.nologo vt.global_cursor_default=0 plymouth.ignore-serial-consoles splash fbcon=map:3 ostree=/ostree/boot.1/torizon/197df9985ed050833c45da3c9f71a61d0ff961f710a005c4fbb8bb090a5b2ca4/0
Distro name:              NAME="TorizonCore"
Distro version:           VERSION_ID=5.7.0-build.17
Hostname:                 verdin-imx8mm-14756428
------------------------------------------------------------

Hardware info
------------------------------------------------------------
HW model:                 Toradex Verdin iMX8M Mini WB on Verdin Development Board
Toradex version:          0060 V1.1C
Serial number:            14756428
Processor arch:           aarch64
------------------------------------------------------------

Bootloader info
------------------------------------------------------------
U-Boot version:           2020.04-5.7.0+git.33bb8e968332
U-Boot vendor:            toradex
U-Boot board:             verdin-imx8mm
U-Boot fdt_board:         dev
U-Boot soc:               imx8m
U-Boot video args:        -
U-Boot secure boot:       -
U-Boot boot delay:        1
------------------------------------------------------------

Device tree
------------------------------------------------------------
Device tree enabled:      imx8mm-verdin-wifi-dev.dtb
Compatible string:        toradex,verdin-imx8mm-wifi-devtoradex,verdin-imx8mm-wifitoradex,verdin-imx8mmfsl,imx8mm
Device trees available:
                          imx8mm-verdin-nonwifi-dahlia.dtb
                          imx8mm-verdin-nonwifi-dev.dtb
                          imx8mm-verdin-wifi-dahlia.dtb
                          imx8mm-verdin-wifi-dev.dtb
------------------------------------------------------------

Device tree overlays
------------------------------------------------------------
Overlays enabled:         fdt_overlays=verdin-imx8mm_lt8912_overlay.dtbo
Overlays available:
                          display-dpi-lt170410_overlay.dtbo
                          display-edt5.7_overlay.dtbo
                          display-edt7_overlay.dtbo
                          display-fullhd_overlay.dtbo
                          display-lt161010_overlay.dtbo
                          display-lt170410_overlay.dtbo
                          display-vga_overlay.dtbo
                          touch-atmel-mxt_overlay.dtbo
                          verdin-imx8mm_disable_can1.dtbo
                          verdin-imx8mm_lt8912_overlay.dtbo
                          verdin-imx8mm_ov5640_overlay.dtbo
                          verdin-imx8mm_sn65dsi84-lt170410_overlay.dtbo
                          verdin-imx8mm_sn65dsi84_overlay.dtbo
------------------------------------------------------------

Devices
------------------------------------------------------------
All devices available:
                          total 0
                          crw-r--r-- 1 root root     10, 235 Apr  7 06:15 autofs
                          drwxr-xr-x 2 root root         620 Apr  7 06:15 block
                          crw------- 1 root root     10, 234 Apr  7 06:15 btrfs-control
                          drwxr-xr-x 3 root root          60 Jan  1  1970 bus
                          crw------- 1 root root     10,  61 Apr  7 06:15 caam-keygen
                          drwxr-xr-x 2 root root        3.6K Apr  7 06:15 char
                          crw------- 1 root root      5,   1 Apr  7 06:15 console
                          crw------- 1 root root     10,  59 Apr  7 06:15 cpu_dma_latency
                          crw------- 1 root root     10, 203 Apr  7 06:15 cuse
                          drwxr-xr-x 7 root root         140 Apr  7 06:15 disk
                          drwxr-xr-x 3 root root         120 Apr  7 06:15 dri
                          lrwxrwxrwx 1 root root           7 Apr  7 06:15 emmc -> mmcblk0
                          lrwxrwxrwx 1 root root          12 Apr  7 06:15 emmc-boot0 -> mmcblk0boot0
                          lrwxrwxrwx 1 root root          12 Apr  7 06:15 emmc-boot1 -> mmcblk0boot1
                          lrwxrwxrwx 1 root root           9 Apr  7 06:15 emmc-part1 -> mmcblk0p1
                          lrwxrwxrwx 1 root root          13 Apr  7 06:15 fd -> /proc/self/fd
                          crw------- 1 root root     10,  60 Apr  7 06:15 fsl-usdpaa-irq
                          crw-rw-rw- 1 root root      1,   7 Apr  7 06:15 full
                          crw-rw-rw- 1 root root     10, 229 Apr  7 06:15 fuse
                          crw-rw---- 1 root video   199,   0 Apr  7 06:15 galcore
                          crw-rw-r-- 1 root gpio    254,   0 Apr  7 06:15 gpiochip0
                          crw-rw-r-- 1 root gpio    254,   1 Apr  7 06:15 gpiochip1
                          crw-rw-r-- 1 root gpio    254,   2 Apr  7 06:15 gpiochip2
                          crw-rw-r-- 1 root gpio    254,   3 Apr  7 06:15 gpiochip3
                          crw-rw-r-- 1 root gpio    254,   4 Apr  7 06:15 gpiochip4
                          drwxr-xr-x 2 root root           0 Apr  7 06:15 hugepages
                          crw------- 1 root root     10, 183 Apr  7 06:15 hwrng
                          crw-rw-r-- 1 root i2cdev   89,   0 Apr  7 06:15 i2c-0
                          crw-rw-r-- 1 root i2cdev   89,   1 Apr  7 06:15 i2c-1
                          crw-rw-r-- 1 root i2cdev   89,   2 Apr  7 06:15 i2c-2
                          crw-rw-r-- 1 root i2cdev   89,   3 Apr  7 06:15 i2c-3
                          crw------- 1 root root    237,   0 Apr  7 06:15 iio:device0
                          lrwxrwxrwx 1 root root          12 Apr  7 06:15 initctl -> /run/initctl
                          drwxr-xr-x 3 root root         100 Apr  7 06:15 input
                          crw------- 1 root root     10,  62 Apr  7 06:15 ion
                          crw-r--r-- 1 root root      1,  11 Apr  7 06:15 kmsg
                          crw-rw-rw- 1 root kvm      10, 232 Apr  7 06:15 kvm
                          lrwxrwxrwx 1 root root          28 Apr  7 06:15 log -> /run/systemd/journal/dev-log
                          crw-rw---- 1 root disk     10, 237 Apr  7 06:15 loop-control
                          brw-rw---- 1 root disk      7,   0 Apr  7 06:15 loop0
                          brw-rw---- 1 root disk      7,   1 Apr  7 06:15 loop1
                          brw-rw---- 1 root disk      7,   2 Apr  7 06:15 loop2
                          brw-rw---- 1 root disk      7,   3 Apr  7 06:15 loop3
                          brw-rw---- 1 root disk      7,   4 Apr  7 06:15 loop4
                          brw-rw---- 1 root disk      7,   5 Apr  7 06:15 loop5
                          brw-rw---- 1 root disk      7,   6 Apr  7 06:15 loop6
                          brw-rw---- 1 root disk      7,   7 Apr  7 06:15 loop7
                          drwxr-xr-x 2 root root          60 Apr  7 06:15 mapper
                          crw-r----- 1 root kmem      1,   1 Apr  7 06:15 mem
                          brw-rw---- 1 root disk    179,   0 Apr  7 06:15 mmcblk0
                          brw-rw---- 1 root disk    179,  32 Apr  7 06:15 mmcblk0boot0
                          brw-rw---- 1 root disk    179,  64 Apr  7 06:15 mmcblk0boot1
                          brw-rw---- 1 root disk    179,   1 Apr  7 06:15 mmcblk0p1
                          crw------- 1 root root    240,   0 Apr  7 06:15 mmcblk0rpmb
                          drwxrwxrwt 2 root root          40 Jan  1  1970 mqueue
                          drwxr-xr-x 2 root root          60 Apr  7 06:15 net
                          crw-rw-rw- 1 root root      1,   3 Apr  7 06:15 null
                          crw-r----- 1 root kmem      1,   4 Apr  7 06:15 port
                          crw------- 1 root root    108,   0 Apr  7 06:15 ppp
                          crw------- 1 root root    250,   0 Apr  7 06:15 pps0
                          crw-rw-rw- 1 root tty       5,   2 Apr  7 06:18 ptmx
                          crw------- 1 root root    249,   0 Apr  7 06:15 ptp0
                          drwxr-xr-x 2 root root           0 Apr  7 06:15 pts
                          crw------- 1 root root      2,   0 Apr  7 06:15 ptyp0
                          crw------- 1 root root      2,   1 Apr  7 06:15 ptyp1
                          crw------- 1 root root      2,   2 Apr  7 06:15 ptyp2
                          crw------- 1 root root      2,   3 Apr  7 06:15 ptyp3
                          crw------- 1 root root      2,   4 Apr  7 06:15 ptyp4
                          crw------- 1 root root      2,   5 Apr  7 06:15 ptyp5
                          crw------- 1 root root      2,   6 Apr  7 06:15 ptyp6
                          crw------- 1 root root      2,   7 Apr  7 06:15 ptyp7
                          crw------- 1 root root      2,   8 Apr  7 06:15 ptyp8
                          crw------- 1 root root      2,   9 Apr  7 06:15 ptyp9
                          crw------- 1 root root      2,  10 Apr  7 06:15 ptypa
                          crw------- 1 root root      2,  11 Apr  7 06:15 ptypb
                          crw------- 1 root root      2,  12 Apr  7 06:15 ptypc
                          crw------- 1 root root      2,  13 Apr  7 06:15 ptypd
                          crw------- 1 root root      2,  14 Apr  7 06:15 ptype
                          crw------- 1 root root      2,  15 Apr  7 06:15 ptypf
                          brw-rw---- 1 root disk      1,   0 Apr  7 06:15 ram0
                          brw-rw---- 1 root disk      1,   1 Apr  7 06:15 ram1
                          brw-rw---- 1 root disk      1,  10 Apr  7 06:15 ram10
                          brw-rw---- 1 root disk      1,  11 Apr  7 06:15 ram11
                          brw-rw---- 1 root disk      1,  12 Apr  7 06:15 ram12
                          brw-rw---- 1 root disk      1,  13 Apr  7 06:15 ram13
                          brw-rw---- 1 root disk      1,  14 Apr  7 06:15 ram14
                          brw-rw---- 1 root disk      1,  15 Apr  7 06:15 ram15
                          brw-rw---- 1 root disk      1,   2 Apr  7 06:15 ram2
                          brw-rw---- 1 root disk      1,   3 Apr  7 06:15 ram3
                          brw-rw---- 1 root disk      1,   4 Apr  7 06:15 ram4
                          brw-rw---- 1 root disk      1,   5 Apr  7 06:15 ram5
                          brw-rw---- 1 root disk      1,   6 Apr  7 06:15 ram6
                          brw-rw---- 1 root disk      1,   7 Apr  7 06:15 ram7
                          brw-rw---- 1 root disk      1,   8 Apr  7 06:15 ram8
                          brw-rw---- 1 root disk      1,   9 Apr  7 06:15 ram9
                          crw-rw-rw- 1 root root      1,   8 Apr  7 06:15 random
                          crw-rw-r-- 1 root root     10, 242 Apr  7 06:15 rfkill
                          lrwxrwxrwx 1 root root           4 Apr  7 06:15 rtc -> rtc0
                          crw------- 1 root root    253,   0 Apr  7 06:15 rtc0
                          crw------- 1 root root    253,   1 Apr  7 06:15 rtc1
                          drwxrwxrwt 2 root root          40 Apr  7 06:15 shm
                          drwxr-xr-x 2 root root          60 Jan  1  1970 snd
                          crw-rw-r-- 1 root spidev  153,   0 Apr  7 06:15 spidev1.0
                          lrwxrwxrwx 1 root root          15 Apr  7 06:15 stderr -> /proc/self/fd/2
                          lrwxrwxrwx 1 root root          15 Apr  7 06:15 stdin -> /proc/self/fd/0
                          lrwxrwxrwx 1 root root          15 Apr  7 06:15 stdout -> /proc/self/fd/1
                          crw-rw-rw- 1 root tty       5,   0 Apr  7 06:16 tty
                          crw--w---- 1 root tty       4,   0 Apr  7 06:15 tty0
                          crw--w---- 1 root tty       4,   1 Apr  7 06:15 tty1
                          crw--w---- 1 root tty       4,  10 Apr  7 06:15 tty10
                          crw--w---- 1 root tty       4,  11 Apr  7 06:15 tty11
                          crw--w---- 1 root tty       4,  12 Apr  7 06:15 tty12
                          crw--w---- 1 root tty       4,  13 Apr  7 06:15 tty13
                          crw--w---- 1 root tty       4,  14 Apr  7 06:15 tty14
                          crw--w---- 1 root tty       4,  15 Apr  7 06:15 tty15
                          crw--w---- 1 root tty       4,  16 Apr  7 06:15 tty16
                          crw--w---- 1 root tty       4,  17 Apr  7 06:15 tty17
                          crw--w---- 1 root tty       4,  18 Apr  7 06:15 tty18
                          crw--w---- 1 root tty       4,  19 Apr  7 06:15 tty19
                          crw--w---- 1 root tty       4,   2 Apr  7 06:15 tty2
                          crw--w---- 1 root tty       4,  20 Apr  7 06:15 tty20
                          crw--w---- 1 root tty       4,  21 Apr  7 06:15 tty21
                          crw--w---- 1 root tty       4,  22 Apr  7 06:15 tty22
                          crw--w---- 1 root tty       4,  23 Apr  7 06:15 tty23
                          crw--w---- 1 root tty       4,  24 Apr  7 06:15 tty24
                          crw--w---- 1 root tty       4,  25 Apr  7 06:15 tty25
                          crw--w---- 1 root tty       4,  26 Apr  7 06:15 tty26
                          crw--w---- 1 root tty       4,  27 Apr  7 06:15 tty27
                          crw--w---- 1 root tty       4,  28 Apr  7 06:15 tty28
                          crw--w---- 1 root tty       4,  29 Apr  7 06:15 tty29
                          crw--w---- 1 root tty       4,   3 Apr  7 06:15 tty3
                          crw--w---- 1 root tty       4,  30 Apr  7 06:15 tty30
                          crw--w---- 1 root tty       4,  31 Apr  7 06:15 tty31
                          crw--w---- 1 root tty       4,  32 Apr  7 06:15 tty32
                          crw--w---- 1 root tty       4,  33 Apr  7 06:15 tty33
                          crw--w---- 1 root tty       4,  34 Apr  7 06:15 tty34
                          crw--w---- 1 root tty       4,  35 Apr  7 06:15 tty35
                          crw--w---- 1 root tty       4,  36 Apr  7 06:15 tty36
                          crw--w---- 1 root tty       4,  37 Apr  7 06:15 tty37
                          crw--w---- 1 root tty       4,  38 Apr  7 06:15 tty38
                          crw--w---- 1 root tty       4,  39 Apr  7 06:15 tty39
                          crw--w---- 1 root tty       4,   4 Apr  7 06:15 tty4
                          crw--w---- 1 root tty       4,  40 Apr  7 06:15 tty40
                          crw--w---- 1 root tty       4,  41 Apr  7 06:15 tty41
                          crw--w---- 1 root tty       4,  42 Apr  7 06:15 tty42
                          crw--w---- 1 root tty       4,  43 Apr  7 06:15 tty43
                          crw--w---- 1 root tty       4,  44 Apr  7 06:15 tty44
                          crw--w---- 1 root tty       4,  45 Apr  7 06:15 tty45
                          crw--w---- 1 root tty       4,  46 Apr  7 06:15 tty46
                          crw--w---- 1 root tty       4,  47 Apr  7 06:15 tty47
                          crw--w---- 1 root tty       4,  48 Apr  7 06:15 tty48
                          crw--w---- 1 root tty       4,  49 Apr  7 06:15 tty49
                          crw--w---- 1 root tty       4,   5 Apr  7 06:15 tty5
                          crw--w---- 1 root tty       4,  50 Apr  7 06:15 tty50
                          crw--w---- 1 root tty       4,  51 Apr  7 06:15 tty51
                          crw--w---- 1 root tty       4,  52 Apr  7 06:15 tty52
                          crw--w---- 1 root tty       4,  53 Apr  7 06:15 tty53
                          crw--w---- 1 root tty       4,  54 Apr  7 06:15 tty54
                          crw--w---- 1 root tty       4,  55 Apr  7 06:15 tty55
                          crw--w---- 1 root tty       4,  56 Apr  7 06:15 tty56
                          crw--w---- 1 root tty       4,  57 Apr  7 06:15 tty57
                          crw--w---- 1 root tty       4,  58 Apr  7 06:15 tty58
                          crw--w---- 1 root tty       4,  59 Apr  7 06:15 tty59
                          crw--w---- 1 root tty       4,   6 Apr  7 06:15 tty6
                          crw--w---- 1 root tty       4,  60 Apr  7 06:15 tty60
                          crw--w---- 1 root tty       4,  61 Apr  7 06:15 tty61
                          crw--w---- 1 root tty       4,  62 Apr  7 06:15 tty62
                          crw--w---- 1 root tty       4,  63 Apr  7 06:15 tty63
                          crw--w---- 1 root root      4,   7 Apr  7 06:15 tty7
                          crw--w---- 1 root tty       4,   8 Apr  7 06:15 tty8
                          crw--w---- 1 root tty       4,   9 Apr  7 06:15 tty9
                          crw-rw---- 1 root dialout   4,  64 Apr  7 06:15 ttyS0
                          crw-rw---- 1 root dialout   4,  65 Apr  7 06:15 ttyS1
                          crw-rw---- 1 root dialout   4,  66 Apr  7 06:15 ttyS2
                          crw-rw---- 1 root dialout   4,  67 Apr  7 06:15 ttyS3
                          crw--w---- 1 root tty     207,  16 Apr  7 06:15 ttymxc0
                          crw-rw---- 1 root dialout 207,  17 Apr  7 06:15 ttymxc1
                          crw-rw---- 1 root dialout 207,  18 Apr  7 06:15 ttymxc2
                          crw------- 1 root root      3,   0 Apr  7 06:15 ttyp0
                          crw------- 1 root root      3,   1 Apr  7 06:15 ttyp1
                          crw------- 1 root root      3,   2 Apr  7 06:15 ttyp2
                          crw------- 1 root root      3,   3 Apr  7 06:15 ttyp3
                          crw------- 1 root root      3,   4 Apr  7 06:15 ttyp4
                          crw------- 1 root root      3,   5 Apr  7 06:15 ttyp5
                          crw------- 1 root root      3,   6 Apr  7 06:15 ttyp6
                          crw------- 1 root root      3,   7 Apr  7 06:15 ttyp7
                          crw------- 1 root root      3,   8 Apr  7 06:15 ttyp8
                          crw------- 1 root root      3,   9 Apr  7 06:15 ttyp9
                          crw------- 1 root root      3,  10 Apr  7 06:15 ttypa
                          crw------- 1 root root      3,  11 Apr  7 06:15 ttypb
                          crw------- 1 root root      3,  12 Apr  7 06:15 ttypc
                          crw------- 1 root root      3,  13 Apr  7 06:15 ttypd
                          crw------- 1 root root      3,  14 Apr  7 06:15 ttype
                          crw------- 1 root root      3,  15 Apr  7 06:15 ttypf
                          crw------- 1 root root     10,  58 Apr  7 06:15 ubi_ctrl
                          crw------- 1 root root     10, 223 Apr  7 06:15 uinput
                          crw-rw-rw- 1 root root      1,   9 Apr  7 06:15 urandom
                          crw-rw---- 1 root tty       7,   0 Apr  7 06:15 vcs
                          crw-rw---- 1 root tty       7,   1 Apr  7 06:15 vcs1
                          crw-rw---- 1 root tty       7,   2 Apr  7 06:15 vcs2
                          crw-rw---- 1 root tty       7,   3 Apr  7 06:15 vcs3
                          crw-rw---- 1 root tty       7,   4 Apr  7 06:15 vcs4
                          crw-rw---- 1 root tty       7,   5 Apr  7 06:15 vcs5
                          crw-rw---- 1 root tty       7,   6 Apr  7 06:15 vcs6
                          crw-rw---- 1 root tty       7,   7 Apr  7 06:15 vcs7
                          crw-rw---- 1 root tty       7, 128 Apr  7 06:15 vcsa
                          crw-rw---- 1 root tty       7, 129 Apr  7 06:15 vcsa1
                          crw-rw---- 1 root tty       7, 130 Apr  7 06:15 vcsa2
                          crw-rw---- 1 root tty       7, 131 Apr  7 06:15 vcsa3
                          crw-rw---- 1 root tty       7, 132 Apr  7 06:15 vcsa4
                          crw-rw---- 1 root tty       7, 133 Apr  7 06:15 vcsa5
                          crw-rw---- 1 root tty       7, 134 Apr  7 06:15 vcsa6
                          crw-rw---- 1 root tty       7, 135 Apr  7 06:15 vcsa7
                          crw-rw---- 1 root tty       7,  64 Apr  7 06:15 vcsu
                          crw-rw---- 1 root tty       7,  65 Apr  7 06:15 vcsu1
                          crw-rw---- 1 root tty       7,  66 Apr  7 06:15 vcsu2
                          crw-rw---- 1 root tty       7,  67 Apr  7 06:15 vcsu3
                          crw-rw---- 1 root tty       7,  68 Apr  7 06:15 vcsu4
                          crw-rw---- 1 root tty       7,  69 Apr  7 06:15 vcsu5
                          crw-rw---- 1 root tty       7,  70 Apr  7 06:15 vcsu6
                          crw-rw---- 1 root tty       7,  71 Apr  7 06:15 vcsu7
                          lrwxrwxrwx 1 root root         100 Apr  7 06:15 verdin-adc1 -> /sys/devices/platform/soc@0/soc@0:bus@30800000/30a20000.i2c/i2c-0/0-0049/iio:device0/in_voltage3_raw
                          lrwxrwxrwx 1 root root         100 Apr  7 06:15 verdin-adc2 -> /sys/devices/platform/soc@0/soc@0:bus@30800000/30a20000.i2c/i2c-0/0-0049/iio:device0/in_voltage2_raw
                          lrwxrwxrwx 1 root root         100 Apr  7 06:15 verdin-adc3 -> /sys/devices/platform/soc@0/soc@0:bus@30800000/30a20000.i2c/i2c-0/0-0049/iio:device0/in_voltage1_raw
                          lrwxrwxrwx 1 root root         100 Apr  7 06:15 verdin-adc4 -> /sys/devices/platform/soc@0/soc@0:bus@30800000/30a20000.i2c/i2c-0/0-0049/iio:device0/in_voltage0_raw
                          lrwxrwxrwx 1 root root           5 Apr  7 06:15 verdin-i2c-on-module -> i2c-0
                          lrwxrwxrwx 1 root root           5 Apr  7 06:15 verdin-i2c1 -> i2c-3
                          lrwxrwxrwx 1 root root           5 Apr  7 06:15 verdin-i2c2 -> i2c-1
                          lrwxrwxrwx 1 root root           5 Apr  7 06:15 verdin-i2c4 -> i2c-2
                          lrwxrwxrwx 1 root root           9 Apr  7 06:15 verdin-spi-cs0 -> spidev1.0
                          lrwxrwxrwx 1 root root           7 Apr  7 06:15 verdin-uart1 -> ttymxc1
                          lrwxrwxrwx 1 root root           7 Apr  7 06:15 verdin-uart2 -> ttymxc2
                          lrwxrwxrwx 1 root root           7 Apr  7 06:15 verdin-uart3 -> ttymxc0
                          lrwxrwxrwx 1 root root           8 Apr  7 06:15 verdin-watchdog -> watchdog
                          drwxr-xr-x 2 root root          60 Jan  1  1970 vfio
                          crw------- 1 root root     10,  63 Apr  7 06:15 vga_arbiter
                          crw------- 1 root root     10, 137 Apr  7 06:15 vhci
                          crw------- 1 root root     10, 130 Apr  7 06:15 watchdog
                          crw------- 1 root root    247,   0 Apr  7 06:15 watchdog0
                          crw-rw-rw- 1 root root      1,   5 Apr  7 06:15 zero
                          brw-rw---- 1 root disk    253,   0 Apr  7 06:15 zram0
------------------------------------------------------------

Kernel modules
------------------------------------------------------------
Kernel modules loaded:
                          Module                  Size  Used by
                          xt_nat                 16384  9
                          xt_tcpudp              20480  11
                          xt_conntrack           16384  2
                          xt_MASQUERADE          20480  3
                          nf_conntrack_netlink    49152  0
                          nfnetlink              16384  2 nf_conntrack_netlink
                          xfrm_user              40960  1
                          xt_addrtype            16384  2
                          iptable_filter         16384  1
                          iptable_nat            16384  3
                          ip_tables              32768  2 iptable_filter,iptable_nat
                          x_tables               45056  7 xt_conntrack,iptable_filter,xt_tcpudp,xt_addrtype,xt_nat,ip_tables,xt_MASQUERADE
                          br_netfilter           28672  0
                          bridge                200704  1 br_netfilter
                          stp                    16384  1 bridge
                          mwifiex_sdio           49152  0
                          mwifiex               299008  1 mwifiex_sdio
                          cfg80211              786432  1 mwifiex
                          bnep                   32768  2
                          mcp25xxfd              53248  0
                          can_dev                36864  1 mcp25xxfd
                          crct10dif_ce           16384  1
                          btmrvl_sdio            32768  0
                          btmrvl                 32768  1 btmrvl_sdio
                          lm75                   28672  0
                          snd_soc_nau8822        53248  0
                          ina2xx                 20480  0
                          ti_ads1015             28672  0
                          industrialio_triggered_buffer    16384  1 ti_ads1015
                          kfifo_buf              16384  1 industrialio_triggered_buffer
                          industrialio           90112  3 industrialio_triggered_buffer,kfifo_buf,ti_ads1015
                          fsl_jr_uio             20480  0
                          imx_sdma               36864  4
                          uio_pdrv_genirq        16384  0
                          uio                    24576  2 uio_pdrv_genirq,fsl_jr_uio
                          openvswitch           143360  0
                          nsh                    16384  1 openvswitch
                          nf_conncount           24576  1 openvswitch
                          nf_nat                 53248  4 xt_nat,openvswitch,iptable_nat,xt_MASQUERADE
                          libcomposite           73728  0
                          galcore               421888  3
------------------------------------------------------------

I have my container set up using the toradex extension for vscode using the sample C/C++ application.

Simple bluetooth communication will not work either? I had chosen the wifi/bt module in order to save space on my custom carrier board. It will not work on a bt module on carrier board either?

For my application I need a simple SPP server for serial comm over bluetooth.

Best Regards,
Hassan.

I am able to search for bluetooth devices using the libsystemd-dev library but not using the libbluetooth-dev

Dear @geopaxpvtltd,

May I ask if you could share some more information regarding your use case with Bluetooth? Also, do you have a timeline for your project by when you want this issue to be solved? Depending on that we will escalate this issue internally.

Hello @rudhi.tx ,

thank you for your followup. I was able to get the bluetooth working properly using d-bus api.

However, if you would like to escalate an issue, if you could sort the wifi issue in the following post, it would be very helpful.

The timeline is soon. I am approximately 70% into the development process. maybe about two to three months.

Best Regards,
Hassan.

Dear @geopaxpvtltd,

I was able to get the bluetooth working properly using d-bus api.

Thanks for that update. Also, glad to hear that you got it running.

In the meantime, I had some time to work on this issue. I was trying to reproduce the issue you are facing and interestingly I found that Bluetooth works just fine on your version of Hardware and TorizonCore. You can test it on the device (outside the container) by running the bluetoothctl commands. You may follow some examples here or on this page.
This would confirm that the Bluetooth controller is working just fine on your Hardware and on your version of TorizonCore installed.

I could reproduce this error thrown from the hci_get_route function in a C++ code running in a debian container. During my attempts to solve the error, I found this thread that is related. As you might have seen, the issue was solved by simply adding an extra argument --net=host to the docker run command. This is to make the container run in the host’s network environment. In my case, this is how I started a simple Debian container with docker run command:
docker run -it --net=host torizon/debian:$CT_TAG_DEBIAN /bin/bash
After that, I was able to compile and run the C++ code successfully within the container (Of course I installed the libbluetooth-dev library and other packages I need inside the container to get it running).
Here is my code:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/socket.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
#include <bluetooth/hci_lib.h>

int main(int argc, char **argv)
{
    inquiry_info *ii = NULL;
    int max_rsp, num_rsp;
    int dev_id, sock, len, flags;
    int i;
    char addr[19] = { 0 };
    char name[248] = { 0 };

    dev_id = hci_get_route(NULL);
    if (dev_id < 0)
    {
        perror("Error: No Bluetooth adapter found.");
        exit(1);
    }
    
    sock = hci_open_dev( dev_id );
    if (dev_id < 0 || sock < 0) {
        perror("opening socket");
        exit(1);
    }

    len  = 8;
    max_rsp = 255;
    flags = IREQ_CACHE_FLUSH;
    ii = (inquiry_info*)malloc(max_rsp * sizeof(inquiry_info));
    
    num_rsp = hci_inquiry(dev_id, len, max_rsp, NULL, &ii, flags);
    if( num_rsp < 0 ) perror("hci_inquiry");

    for (i = 0; i < num_rsp; i++) {
        ba2str(&(ii+i)->bdaddr, addr);
        memset(name, 0, sizeof(name));
        if (hci_read_remote_name(sock, &(ii+i)->bdaddr, sizeof(name), 
            name, 0) < 0)
        strcpy(name, "[unknown]");
        printf("%s  %s\n", addr, name);
    }

    free( ii );
    close( sock );
    return 0;
}

You should be able to do the same using the configuration option
network_mode: "host" in the docker-compose file. Please see the Compose file reference for more details.

I believe this would be the easiest solution for you compared to using dbus-api. If you get some time to test this, let me know how it goes :slight_smile:
In this case, I will not be escalating the issue internally since it already works on this HW and SW setup. Let me know if you have more questions.

Dear @geopaxpvtltd,

I made a mistake in my previous reply regarding the changes needed in DockerFile (In fact, these changes are needed not in dockerfile but in docker-compose file). Please see my edited answer with the changes you need in the docker-compose file.

1 Like

Thank you for the update. I am not so much familiar with docker at the moment. I am just focused on the application right now. But I get the idea. However, I read somewhere that directly modifying docker compose file is not recommended.

I tried it once. But when I re-build the container using the toradex extension for vscode, it all reverts back to the original template.

Dear @geopaxpvtltd,

I am not so much familiar with docker at the moment. I am just focused on the application right now. But I get the idea. However, I read somewhere that directly modifying docker compose file is not recommended.

Modifying the docker-compose file to fit your needs should not be an issue at all. In fact, it is a more convenient way to manage multi-container applications. Even if you have a single-container application, bringing it up using a docker-compose file in which you can define all the necessary configurations for that container would only make your life easier.
Here you will find some examples of running multi-container applications using docker-compose file: Using Multiple Containers with Torizon OS | Toradex Developer Center
Other than that you can find plenty of examples and explanations in the official reference manuals of dockerfile and docker-compose file.

May I ask you how you are developing the application right now on TorizonCore if you are not that familiar with docker? Isn’t your application containerized?

But when I re-build the container using the toradex extension for vscode, it all reverts back to the original template.

Which version of the vscode extension are you using?

Dear @rudhi.tx ,

Maybe it was the dockerfile. not the docker-compose file. Either way thank you for the information and the resources. I will get more familiar with these in time hopefully.

The application is containerized. However, I have little to no modifications to the container itself except for some addition of libraries and sharing some usb and serial ports with the application container. I wanted to be able to develop my application first before getting into the container stuff.

I am using the V1 extension (the experimental one).

In fact, I have started development after 14 years of my electronics engineering. so, I am not so much familiar with stuff now. However, things are moving along. Slowly but surely. I chose this platform to be able to make it easier to manage the application for the end user devices including managing the OTAs and such. Once I am done with the development I shall get into those.

Dear @geopaxpvtltd,

I hope that was helpful. Please feel free to open another ticket in case you have questions that come along during development with our IDE extension or with docker containers on TorizonCore.

1 Like