title: Bluetooth over uart using hciattach?
body: <p>I am using <code>QN9021</code> SoC working in <code>controller mode</code> (BLE Bluetooth core specification v4.0). It supports some standard <code>HCI</code> commands as well as some vendor specific commands. I am trying to attach it in my <code>ubuntu</code> laptop.</p>
  
  <p>The command that i have used is <code>hciattach</code>.</p>
  
  <pre><code>hciattach -s 9600 /dev/ttyUSBx any 9600 noflow nosleep 
  </code></pre>
  
  <p>The <code>hcidump</code> shows while executing <code>sudo hciconfig hci1 up</code>.</p>
  
  <pre><code>HCI sniffer - Bluetooth packet analyzer ver 5.37
  device: hci1 snap_len: 1500 filter: 0xffffffffffffffff
  &gt; HCI Event: Command Complete (0x0e) plen 12
      Read Local Supported Features (0x04|0x0003) ncmd 11
      status 0x00
      Features: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
  &gt; HCI Event: Command Complete (0x0e) plen 12
      Read Local Version Information (0x04|0x0001) ncmd 11
      status 0x00
      HCI Version: 4.0 (0x6) HCI Revision: 0x400
      LMP Version: 4.0 (0x6) LMP Subversion: 0x400
      Manufacturer: Quintic Corp. (142)
  &gt; HCI Event: Command Complete (0x0e) plen 10
      Read BD ADDR (0x04|0x0009) ncmd 11
      status 0x00 bdaddr 08:7C:BE:3E:34:BB
  &gt; HCI Event: Command Complete (0x0e) plen 11
      Read Buffer Size (0x04|0x0005) ncmd 11
      status 0x00
      ACL MTU 0:0 SCO MTU 0:0
  &gt; HCI Event: Command Complete (0x0e) plen 4
      Read Class of Device (0x03|0x0023) ncmd 11
      status 0x01 class 0x000000
      Error: Unknown HCI Command
  </code></pre>
  
  <p>The <code>hciconfig</code> command shows:</p>
  
  <pre><code>hci1:   Type: BR/EDR  Bus: UART
      BD Address: 08:7C:BE:3E:34:BB  ACL MTU: 0:0  SCO MTU: 0:0
      DOWN 
      RX bytes:192 acl:0 sco:0 events:15 errors:0
      TX bytes:60 acl:0 sco:0 commands:15 errors:0
  
  hci0:   Type: BR/EDR  Bus: USB
      BD Address: C4:8E:8F:66:3B:0E  ACL MTU: 820:8  SCO MTU: 255:16
      UP RUNNING PSCAN 
      RX bytes:2457 acl:0 sco:0 events:196 errors:0
      TX bytes:24646 acl:0 sco:0 commands:196 errors:0
  </code></pre>
  
  <p>I would like to know how to prevent the kernel or some bluetooth kernel module to send non-supported HCI commands. Do i need to patch linux kernel source code or write a module for my SoC.</p>
  
  <p>Note:- Changing the SoC or writing firmware for it to support all necessary commands is not possible for this project.</p>
  
  <hr>
  
  <p>EDIT:</p>
  
  <p>I know the list of <code>HCI</code>command supported by my SoC. I am thinking of creating a <code>module</code> to tell the kernel and daemons running to send only supported commands to the SoC. I have a look at linux kernel source (specifically at this <a href="https://github.com/abhiarora4/linux/blob/master/net/bluetooth/hci_core.c">hci_core.c</a>). I think modifying it may solve the problem after going through this <a href="https://bugzilla.kernel.org/show_bug.cgi?id=60901#c5">link</a>. In this link, some developer has provided a patch to support a <code>bluetooth dongle</code>. The patch prevents the <a href="https://github.com/abhiarora4/linux/blob/master/net/bluetooth/hci_core.c">hci_core.c</a> file to send a specific HCI command to a dongle of a particular manufacturer.</p>
  
  <p>All i want is suggestion to resolve this problem. Do i need to modify the linux kernel or write a module for my SoC?</p>
  
  <p>NOTE:- The application will run on <code>openwrt</code> linux.</p>