<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.element14.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Implementing Bluetooth technology - in C/C++ code.</title><link>https://community.element14.com/technologies/code_exchange/f/forum/55289/implementing-bluetooth-technology---in-c-c-code</link><description>I am looking for discussion on how to implement Bluetooth technology in C/C++ code. 
 My main concern is toi do this reliably and repeatedly. 
 I am basically using very old HCI approach, implementing &amp;quot;bluez&amp;quot; &amp;quot;library&amp;quot; . 
 The code works, despite lack</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><lastBuildDate>Tue, 19 Nov 2024 17:45:16 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://community.element14.com/technologies/code_exchange/f/forum/55289/implementing-bluetooth-technology---in-c-c-code" /><item><title>RE: Implementing Bluetooth technology - in C/C++ code.</title><link>https://community.element14.com/thread/225312?ContentTypeID=1</link><pubDate>Tue, 19 Nov 2024 17:45:16 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:c574d5a9-3d89-4fc3-ab5f-c27e70cec470</guid><dc:creator>anneranch</dc:creator><description>&lt;p&gt;Thank you. Then Affix for &amp;quot;version 2.6&amp;quot; is also old? Besides - I do not want to install it anyway _ I am still searching for source code for &amp;quot;hci_inquiry&amp;quot;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Implementing Bluetooth technology - in C/C++ code.</title><link>https://community.element14.com/thread/225309?ContentTypeID=1</link><pubDate>Tue, 19 Nov 2024 14:31:17 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:a7786f43-10a5-47e7-ae46-9da79e58a4ac</guid><dc:creator>javagoza</dc:creator><description>&lt;p&gt;No, version 2.6 is quite old; it&amp;#39;s over 20 years old.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Implementing Bluetooth technology - in C/C++ code.</title><link>https://community.element14.com/thread/225308?ContentTypeID=1</link><pubDate>Tue, 19 Nov 2024 13:53:45 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:2e55f911-177f-4580-816f-edc952cc81c8</guid><dc:creator>anneranch</dc:creator><description>&lt;p&gt;My Ubuntu kernel is &amp;quot;6&amp;quot;.&lt;/p&gt;
&lt;p&gt;Is it same as 2.6??&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Implementing Bluetooth technology - in C/C++ code.</title><link>https://community.element14.com/thread/225307?ContentTypeID=1</link><pubDate>Tue, 19 Nov 2024 08:21:36 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:5bae123f-03a3-48e2-a9f2-5221acb99a05</guid><dc:creator>javagoza</dc:creator><description>&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/Linux_kernel_version_history#Releases_2.6.x.y" rel="noopener noreferrer nofollow" target="_blank" data-e14adj="t"&gt;Linux kernel version history - Wikipedia&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Implementing Bluetooth technology - in C/C++ code.</title><link>https://community.element14.com/thread/225302?ContentTypeID=1</link><pubDate>Mon, 18 Nov 2024 18:16:30 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:077a26ac-03b4-469f-9e2a-ec3b9c1538b1</guid><dc:creator>anneranch</dc:creator><description>&lt;p&gt;There is more affix. Looks as &amp;quot;updated&amp;quot; from the previous doc.&lt;/p&gt;
&lt;p&gt;Now for stupid question.&lt;/p&gt;
&lt;p&gt;It has file for &amp;quot;Linux kernel 2.6&amp;quot;.&lt;/p&gt;
&lt;p&gt;My Ubuntu kernel is &amp;quot;6&amp;quot;.&lt;/p&gt;
&lt;p&gt;Is it same as 2.6??&lt;/p&gt;
&lt;p&gt;nov25-1@nov251-desktop:~$ uname -srm&lt;br /&gt;Linux 6.8.0-45-generic x86_64&lt;br /&gt;nov25-1@nov251-desktop:~$&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Download for 2.6 kernels&lt;br /&gt;ChangeLog: affix, affix-kernel.&lt;/p&gt;
&lt;p&gt;NB. Install affix-kernel package first and then affix package.&lt;br /&gt;NB.2. Affix 3.X.Y are for 2.6 kernels only ! (Support for 2.4 kernels here)&lt;/p&gt;
&lt;p&gt;Latest testing version (for developers) Package File to download Latest patch&lt;br /&gt;affix for 2.6 kernels affix-3.2.0.tar.gz&lt;br /&gt;Size: 468K, MD5 affix_320_sec.patch&lt;br /&gt;Size: 1.9K, MD5&lt;br /&gt;affix-kernel for 2.6 kernels affix-kernel-3.2.0.tar.gz&lt;br /&gt;Size: 260K, MD5 patch_hci_3_2_0&lt;br /&gt;Size: 901 , MD5&lt;/p&gt;
&lt;p&gt;Latest stable version (for end users) Package File to download Latest patch&lt;br /&gt;affix for 2.6 kernel affix-3.2.0.tar.gz&lt;br /&gt;Size: 468K, MD5 affix_320_sec.patch&lt;br /&gt;Size: 1.9K, MD5&lt;br /&gt;affix-kernel for 2.6 kernel affix-kernel-3.2.0.tar.gz&lt;br /&gt;Size: 260K, MD5 patch_hci_3_2_0&lt;br /&gt;Size: 901 , MD5&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Implementing Bluetooth technology - in C/C++ code.</title><link>https://community.element14.com/thread/225301?ContentTypeID=1</link><pubDate>Mon, 18 Nov 2024 17:29:07 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:d2f742ce-65fe-462b-8349-0da6780139e2</guid><dc:creator>anneranch</dc:creator><description>&lt;p&gt;I think I found the answer to my problems with Bluetooth.&lt;/p&gt;
&lt;p&gt;&lt;a id="" href="https://affix.sourceforge.net/affix-doc/index.html" rel="noopener noreferrer nofollow" target="_blank" data-e14adj="t"&gt;https://affix.sourceforge.net/affix-doc/index.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It is &amp;quot;unofficial&amp;quot; but seems to &amp;quot;go lower&amp;#39; than &amp;quot;blueZ&amp;quot;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Implementing Bluetooth technology - in C/C++ code.</title><link>https://community.element14.com/thread/225300?ContentTypeID=1</link><pubDate>Mon, 18 Nov 2024 17:05:08 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:cd94ae06-9dca-49d7-9e86-734f39e3590f</guid><dc:creator>anneranch</dc:creator><description>&lt;p&gt;Thanks for reply. Appreciate your contribution.&lt;/p&gt;
[quote userid="190458" url="~/technologies/code_exchange/f/forum/55289/implementing-bluetooth-technology---in-c-c-code/225298"]people.csail.mit.edu/.../quote]
&lt;p&gt;The above is my &amp;quot;template&amp;quot;. It is basically C code and if it does the job I do not argue with it. Yes , it identifies&amp;nbsp; &amp;quot;local devices(s) &amp;quot; and &amp;quot;inquires&amp;quot; about &amp;quot;remote devices&amp;quot;. At this time I have a small issue - I&amp;nbsp; am not getting &amp;quot;remote device name&amp;quot; when I have TWO &amp;quot;local devices&amp;quot;. So it is back to &amp;quot;hci_inquiry&amp;quot; source code. I am getting flustered with&amp;quot;bluez&amp;quot; using interchangeably &amp;quot;dev_id&amp;quot; or &amp;quot;socket&amp;quot; without much warning. &lt;/p&gt;[/quote]&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Implementing Bluetooth technology - in C/C++ code.</title><link>https://community.element14.com/thread/225298?ContentTypeID=1</link><pubDate>Mon, 18 Nov 2024 10:41:33 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:b4be87f5-e7b4-4721-984b-70e9dbd23764</guid><dc:creator>BigG</dc:creator><description>&lt;p&gt;Asking about device driver was just a framing question to understand your hardware config, as in my experience not all implementations are exactly the same - they&amp;#39;re mostly the same. Reason being, at some point in the process (as noted by&lt;a href="https://community.element14.com/members/shabaz"&gt;shabaz&lt;/a&gt;) the device driver takes over to perform the actual scanning process and return a data structure back to the bluez software for your application. This scanning process continues until it receives an instruction to stop. Once it stops you will be left with a device list (struct hci_dev_list_req *devList;)&lt;/p&gt;
&lt;p&gt;Then it&amp;#39;s really a case of checking each item in the device list to see if one of the BLE peripheral devices matches your search requirements, or using one of the predefined filtering options.&lt;/p&gt;
&lt;p&gt;Usually steps involve a &amp;quot;power on&amp;quot; or initialisation process, then a &amp;quot;scan on&amp;quot; process to capture a list or to capture a device that matches the filter parameters. Then there&amp;#39;s a connection process and finally, if requested, a bonding/pairing process.&lt;/p&gt;
&lt;p&gt;Based on your code, it appears you&amp;#39;ve allocated some memory for the scan list data structure based on HCI_MAX_DEV and have a check that the list received is not empty.&lt;/p&gt;
&lt;p&gt;&lt;a id="" href="https://git.kernel.org/pub/scm/bluetooth/bluez.git/about/" rel="noopener noreferrer nofollow" target="_blank" data-e14adj="t"&gt;https://git.kernel.org/pub/scm/bluetooth/bluez.git/about/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a id="" href="https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/client" rel="noopener noreferrer nofollow" target="_blank" data-e14adj="t"&gt;https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/client&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a id="" href="https://people.csail.mit.edu/albert/bluez-intro/c404.html" rel="noopener noreferrer nofollow" target="_blank" data-e14adj="t"&gt;https://people.csail.mit.edu/albert/bluez-intro/c404.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Implementing Bluetooth technology - in C/C++ code.</title><link>https://community.element14.com/thread/225296?ContentTypeID=1</link><pubDate>Sun, 17 Nov 2024 02:28:35 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:8a006ab8-748b-499d-8105-8c99e41297ed</guid><dc:creator>anneranch</dc:creator><description>&lt;p&gt;Thanks for reply. I am little confused by &amp;quot;depends on device driver &amp;quot;. Allow me to get back to what I have as starting point.&amp;nbsp; Using &amp;quot;bluez&amp;quot; or actually HCI - my code&amp;nbsp; determines &amp;quot;dev_id&amp;quot; . I actually think it is wrong term , but will accept it for now.&amp;nbsp; That has no indication of any &amp;quot;dependency / relation&amp;quot; of actual physical device. In your terminology - no device driver is involved.&lt;/p&gt;
&lt;p&gt;Next (logical) step is to assign a socket to this &amp;quot;dev_id&amp;quot; - still no device driver is involved. I would actually say - &amp;quot;locating dev_id and assigning socket to it is the lowest, basic &amp;quot;access &amp;quot; to Bluetooth INDEPENDENT of actual hardware in use.&lt;/p&gt;
&lt;p&gt;Am I correct or not, so far ?&lt;/p&gt;
&lt;p&gt;Since I eventually need the Bluetooth address of the&lt;/p&gt;
&lt;p&gt;local device I am currently implementing ( a copy, not my original code&amp;nbsp; ) / modifying the following code:&lt;/p&gt;
&lt;p&gt;Unfortunately this code ADDS usage of &amp;quot;ioctl&amp;quot; , to HCI usage , which I am NOT ready to analyze.&lt;/p&gt;
&lt;p&gt;// Create a hci socket&lt;/p&gt;
&lt;p&gt;// combines hci_get_route and hci_open_dev&lt;/p&gt;
&lt;p&gt;&lt;br /&gt; int hciSocket = hci_open_dev(hci_get_route(NULL));&lt;br /&gt; if (hciSocket &amp;lt; 0)&lt;br /&gt; {&lt;br /&gt; perror(&amp;quot;Failed to open HCI device&amp;quot;);&lt;br /&gt; return 1;&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;// Create int and pointers to hold results for later&lt;br /&gt; int devCount;&lt;br /&gt; struct hci_dev_list_req *devList;&lt;br /&gt; struct hci_dev_info devInfo;&lt;/p&gt;
&lt;p&gt;// Allocate memory for devList pointer. Based on HCI_MAX_DEV (maximum number of HCI devices) multiplied by the size of struct hci_dev_req, plus the size of uint16_t (to store the device number)&lt;br /&gt; devList = (struct hci_dev_list_req *)malloc(HCI_MAX_DEV * sizeof(struct hci_dev_req) + sizeof(uint16_t));&lt;br /&gt; if (!devList)&lt;br /&gt; {&lt;br /&gt; perror(&amp;quot;Failed to allocate HCI device request memory&amp;quot;);&lt;br /&gt; close(hciSocket);&lt;br /&gt; return 1;&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;// Honestly not sure why we have to do this here?&lt;br /&gt; devList-&amp;gt;dev_num = HCI_MAX_DEV;&lt;/p&gt;
&lt;p&gt;// Send the HCIGETDEVLIST command to get the device list.&lt;br /&gt; if (ioctl(hciSocket, HCIGETDEVLIST, (void *)devList) &amp;lt; 0)&lt;br /&gt; {&lt;br /&gt; perror(&amp;quot;Failed to get HCI device list&amp;quot;);&lt;br /&gt; free(devList);&lt;br /&gt; close(hciSocket);&lt;br /&gt; return 1;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Implementing Bluetooth technology - in C/C++ code.</title><link>https://community.element14.com/thread/225295?ContentTypeID=1</link><pubDate>Sat, 16 Nov 2024 23:26:28 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:981e4aed-bacc-40b0-8266-830e3569db47</guid><dc:creator>BigG</dc:creator><description>&lt;p&gt;Ah ok. Now that makes better sense, especially the &amp;quot;not documented&amp;quot; part in your initial post.&lt;/p&gt;
&lt;p&gt;I believe the answers to the questions you asked would depend on the device driver chosen. There are a number of different hci implementations.&lt;/p&gt;
&lt;p&gt;&lt;a id="" href="https://elixir.bootlin.com/linux/v6.11.8/source/drivers/bluetooth" rel="noopener noreferrer nofollow" target="_blank" data-e14adj="t"&gt;https://elixir.bootlin.com/linux/v6.11.8/source/drivers/bluetooth&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I cannot vouch for this research paper but it popped up following a quick google search.&lt;/p&gt;
&lt;p&gt;&lt;a id="" href="https://www.researchgate.net/publication/345032366_Bluetooth_Stack_and_how_Linux_OS_handles_it" rel="noopener noreferrer nofollow" target="_blank" data-e14adj="t"&gt;https://www.researchgate.net/publication/345032366_Bluetooth_Stack_and_how_Linux_OS_handles_it&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Otherwise another suggestion is to search for yocto implementations of Bluetooth. Tends to throw up some info.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://mediatek.gitlab.io/aiot/doc/aiot-dev-guide/release/v23.1/sw/yocto/app-dev/bluetooth/bluez/bluez-common.html#scan-some-advertising-bluetooth-device-nearby" rel="noopener noreferrer nofollow" target="_blank" data-e14adj="t"&gt;https://mediatek.gitlab.io/aiot/doc/aiot-dev-guide/release/v23.1/sw/yocto/app-dev/bluetooth/bluez/bluez-common.html#scan-some-advertising-bluetooth-device-nearby&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Implementing Bluetooth technology - in C/C++ code.</title><link>https://community.element14.com/thread/225284?ContentTypeID=1</link><pubDate>Sat, 16 Nov 2024 15:09:19 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:33daec25-3462-4c69-aaa7-a8a7d3304dbe</guid><dc:creator>anneranch</dc:creator><description>&lt;p&gt;I am&amp;nbsp; not sure I get the &amp;quot; why you decided to implement the Bluez stack&amp;quot;. I run Linux / Ubuntu and &amp;quot;bluez&amp;quot; is standard&amp;nbsp; package implemented in Linux kernel. Hence I see no choise. I initially used Qt, but it is missing an option to &amp;quot;clear unknown database&amp;quot;&amp;nbsp; containing previously found remote devices, or&amp;nbsp; more accurately - I did not find it. That is part of my reason to go &amp;quot;as close as feasible&amp;quot; to HCI. Not being able to physically control the actually&amp;nbsp; scan for remote devices.&lt;/p&gt;
&lt;p&gt;I believe majority of&amp;nbsp; &amp;quot;improved (? with GUI ) Bluetooth stacks &amp;quot; are all based on &amp;quot;bluez&amp;quot; anyway.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Implementing Bluetooth technology - in C/C++ code.</title><link>https://community.element14.com/thread/225283?ContentTypeID=1</link><pubDate>Sat, 16 Nov 2024 12:31:45 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:b906ac51-b66c-4548-98a9-c201bbe66f33</guid><dc:creator>BigG</dc:creator><description>&lt;p&gt;Can you explain why you decided to implement the Bluez stack as there are a couple other C++ options out there.&lt;/p&gt;
&lt;p&gt;ARM Mbed had a C++ implementation of a BLE stack: &lt;a id="" href="https://github.com/ARMmbed/ble" rel="noopener noreferrer nofollow" target="_blank" data-e14adj="t"&gt;https://github.com/ARMmbed/ble&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a id="" href="https://github.com/arduino-libraries/ArduinoBLE" rel="noopener noreferrer nofollow" target="_blank" data-e14adj="t"&gt;https://github.com/arduino-libraries/ArduinoBLE&lt;/a&gt; (C++ for Arduino devices)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Otherwise mainly c implementations (one example):&lt;/p&gt;
&lt;p&gt;&lt;a href="https://docs.zephyrproject.org/latest/connectivity/bluetooth/bluetooth-arch.html" rel="noopener noreferrer nofollow" target="_blank" data-e14adj="t"&gt;docs.zephyrproject.org/.../bluetooth-arch.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/zephyrproject-rtos/zephyr/tree/main/drivers/bluetooth/hci" rel="noopener noreferrer nofollow" target="_blank" data-e14adj="t"&gt;github.com/.../hci&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Implementing Bluetooth technology - in C/C++ code.</title><link>https://community.element14.com/thread/225281?ContentTypeID=1</link><pubDate>Sat, 16 Nov 2024 05:44:27 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:775a6f67-db58-46cb-a50c-3eab5aa80041</guid><dc:creator>shabaz</dc:creator><description>&lt;p&gt;Thats a pretty rude response from you when someone is trying to help.&lt;/p&gt;
&lt;p&gt;It is not my fault you have trouble articulating what you actually want to know.&lt;/p&gt;
&lt;p&gt;So my answer will be brief, and you can figure out the rest yourself.&lt;/p&gt;
&lt;p&gt;Your snippet of code is already at the lowest level in the BlueZ stack. The aircraft has not taken off yet. The code is operating at the bottom of the blue box.&lt;/p&gt;
&lt;p&gt;You&amp;#39;re not going to be able to see the C code of what then occurs at a lower level, because that&amp;#39;s going to run within hardware/firmware on the Bluetooth processor, not the PC. The state machine that churns away to work at that lower level is inside the Bluetooth processor.&lt;/p&gt;
&lt;p&gt;You can google for an explanation of HCI to understand this. No links, because I&amp;#39;m leaving that to you to figure out. You might also want to pick up some competence at responding in a polite manner.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Implementing Bluetooth technology - in C/C++ code.</title><link>https://community.element14.com/thread/225279?ContentTypeID=1</link><pubDate>Sat, 16 Nov 2024 04:53:32 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:f4d634ac-4f95-4731-a8c3-aa4c0f156605</guid><dc:creator>anneranch</dc:creator><description>&lt;p&gt;Thanks for replies , but that is NOT what I am asking about.&lt;/p&gt;
&lt;p&gt;This approach is all wonderful theory&amp;nbsp; of &amp;quot;Bluetooth stack&amp;quot;, no argument there. I am asking for how to follow the &amp;quot;Bluetooth stack&amp;quot; process using&amp;nbsp; ACTUAL C code.&lt;/p&gt;
&lt;p&gt;Here is a &amp;quot;work in progress&amp;quot; code snippet :&lt;/p&gt;
&lt;p&gt;pET-&amp;gt;start();&lt;br /&gt; dev_id = hci_get_route(NULL);&lt;br /&gt; text = &amp;quot;dev_id \t&amp;quot;;&lt;br /&gt; text += QString::number(dev_id);&lt;br /&gt; m_ui-&amp;gt;textEdit_37-&amp;gt;setText(text);&lt;br /&gt; m_ui-&amp;gt;textEdit_52-&amp;gt;append(text);&lt;/p&gt;
&lt;p&gt;sock = hci_open_dev( dev_id );&lt;br /&gt; if (dev_id &amp;lt; 0 || sock &amp;lt; 0) {&lt;/p&gt;
&lt;p&gt;...&lt;/p&gt;
&lt;p&gt;// actuall scan restart timer&lt;br /&gt; pET-&amp;gt;start();&lt;/p&gt;
&lt;p&gt;num_rsp = hci_inquiry(dev_id, len, max_rsp, NULL, &amp;amp;ii, flags);&lt;br /&gt; if( num_rsp &amp;lt; 0 )&lt;br /&gt; {&lt;br /&gt; text = &amp;quot;\t\t\tERROR no devices found &amp;quot;;&lt;br /&gt; m_ui-&amp;gt;textEdit_37-&amp;gt;append(text); // local&lt;br /&gt; m_ui-&amp;gt;textEdit_52-&amp;gt;append(text); // TRACE&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So my question would be : &lt;br /&gt;&amp;quot;how do &amp;quot;hci_get_route&amp;quot; and &amp;quot;hci_inquiry&amp;quot;&amp;nbsp; functions implements / fits into the above &amp;quot;blue box&amp;quot; ,&amp;nbsp; or similar &amp;quot;blue box&amp;quot; for standard Bluetooth stack?&lt;/p&gt;
&lt;p&gt;PS.&lt;/p&gt;
&lt;p&gt;I understand there are differences between &amp;quot;standard&amp;quot; and &amp;quot;LE&amp;quot; Bluetooth implementation. I am pretty much stuck with &amp;quot;standard&amp;quot; due to my available hardware.&lt;/p&gt;
&lt;p&gt;PPS.&lt;/p&gt;
&lt;p&gt;I am still searching for current bluez version source code to analyze &amp;quot;hci_inquiry&amp;quot;&amp;nbsp; function...&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Implementing Bluetooth technology - in C/C++ code.</title><link>https://community.element14.com/thread/225271?ContentTypeID=1</link><pubDate>Fri, 15 Nov 2024 18:24:17 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:c0df420e-6fc7-4c7b-b025-270680aeaefe</guid><dc:creator>shabaz</dc:creator><description>&lt;p&gt;&lt;br /&gt;The pairing, connect etc are all done by GAP messages. In the diagram below, you can see that those messages are ultimately converted down to a payload that is wrapped with a header and checksum, and then launched over the air to the remote device. There will be a state machine that is executed on both devices, to get through the entire negotiation sequences, i.e. the protocol is implemented with those state machines. Everything in the large blue box is within the Bluez library. It is indeed complicated to follow and has poor documentation, but it does work, and there&amp;#39;s not much choice, it is what it is. It would be a very large effort to write your own implementation from scratch, because there are tens of thousands of pages of Bluetooth documentation to look through.&lt;/p&gt;
&lt;p&gt;Regarding the second question, there are several manufacturers who have implemented this in firmware for their devices. It&amp;#39;s very old technology, google &amp;#39;serial port profile&amp;#39;. If you wish to do it using modern BLE (i.e. Bluetooth LE) then the answer is usually proprietary, since it&amp;#39;s not defined in the standard. You could look at typical example devices like Silabs &lt;br /&gt;BGM220P, and the website offers example code to implement serial communication over BLE (&amp;nbsp;&lt;a id="" href="https://github.com/SiliconLabs/bluetooth_applications/tree/ea5d14cc4884a6d8f5c3af4345d430716433e72d/bluetooth_serial_port_profile" rel="noopener noreferrer nofollow" target="_blank" data-e14adj="t"&gt;https://github.com/SiliconLabs/bluetooth_applications/tree/ea5d14cc4884a6d8f5c3af4345d430716433e72d/bluetooth_serial_port_profile&lt;/a&gt;&amp;nbsp; ) . But because that&amp;#39;s proprietary, you&amp;#39;d have to hope there are drivers for it for the PC (or whatever hardware you are using), if you&amp;#39;re not using their devices at both ends of the communication link.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img alt="image" style="height:602px;max-height:602px;max-width:787px;" height="522" src="https://community.element14.com/resized-image/__size/1574x1204/__key/communityserver-discussions-components-files/80/ble_2D00_stack_2D00_diag.jpg" width="786"  /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>