Bluetooth C Example

Discussion in 'UDOO NEO' started by DOUGLAS R JOSEPH, Apr 25, 2019.

  1. DOUGLAS R JOSEPH

    DOUGLAS R JOSEPH New Member

    Joined:
    Apr 25, 2019
    Messages:
    4
    Likes Received:
    0
    I need to use Bluetooth to send a bidirectional serial stream to a windows based PC.

    I've looked down the forum and see some posts on bluetooth, but not a lot on resolution. The one post that said read this article, the article now requires permissions so I have no access to it.

    Does anyone have an example of doing this on the NEO and hopefully in C or C++?

    Thanks in advance.
    Doug
     
  2. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    You have to perform several steps in order to establish communication.
    1. You have to pair your desired bluetooth device using bluetoothctl ( or use the Bluetooth Manager application in the Preferences menu of the UDOObuntu Desktop https://www.udoo.org/docs-neo/Wireless_Communication/Bluetooth.html )

      sudo bluetoothctl -a

      Where XX:XX:XX:XX:XX:XX is the MAC address of your bluetooth device.

    2. You have to create the serial device that binds to your paired bluetooth device.

      sudo rfcomm bind /dev/rfcomm0 XX:XX:XX:XX:XX:XX 1

      The last number is the communication channel. It has to bee unique for all your connections.
    Then you should be able to open a serial connection on /dev/rfcomm0 with your C or C+ program. These you have to google yourself ;-) It is straight forward serial communication. Udoo team has made an example for Udoo Linux <--> Arduino communication that you can rewrite for your application: https://www.udoo.org/docs-neo/Serial_Libraries/index.html
     
  3. DOUGLAS R JOSEPH

    DOUGLAS R JOSEPH New Member

    Joined:
    Apr 25, 2019
    Messages:
    4
    Likes Received:
    0
    Thanks for the reply, I will play with this.Ultimately, I need this to just boot up and search until something pairs with it... then proceed to the bidirectional communication section of my code. Is there a way to just configure this at bootup.... I don't care if it has to wait until something pairs with it.

    Thanks
    Doug
     
  4. DOUGLAS R JOSEPH

    DOUGLAS R JOSEPH New Member

    Joined:
    Apr 25, 2019
    Messages:
    4
    Likes Received:
    0
    Okay so there is no bluetoothctl command on my device, but I could pair the computer using the bluetooth tool at the desktop, the bind using rfcomm. I tried using the command sudo minicom -s and changing the serial port to /dev/rfcomm0 after the bind and it said it was unable to do this.

    Am I missing something?
     
  5. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    Well, as I have no Bluetooth option on my Neo it will difficult for me to assist you further.
    Is there a rfcomm0 device in /Dev now?
    It could also be that the Bluetooth device of the Neo is not able to support serial communication. Perhaps there is some extra software needed to get it done.
     
  6. DOUGLAS R JOSEPH

    DOUGLAS R JOSEPH New Member

    Joined:
    Apr 25, 2019
    Messages:
    4
    Likes Received:
    0
    It let me bind it, but it doesn't say anything beyond that. Thanks for your replies, I guess I'll have to do some more sleuthing and hopefully someone else will chime in.
     

Share This Page