Re: BlueZ PHY CODED scan via HCI UART on nRF52840_pca10056 #ble #nrf52840 #uart #hci


piotr@...
 
Edited

Hello Johan,
 
Thank you for your response. Following your suggestion I've updated my kernel to 4.20 and there is a change in behavior though I don't see LE CODED  scanning to be working + btmgmt behavior is bit odd which I document below:
 
For testing the PHY changes via btmgmt I've ran this script (added #1-9 to later reference them in btmon logs):
 
#!/bin/bash
# This is where my bluez@master is at
HCITOOL=~/tmp/bluez/tools/hcitool
BTMGMT=~/tmp/bluez/tools/btmgmt
 
echo "Set 1M"
${BTMGMT} phy LE1MTX LE1MRX  #1
sleep 1
${BTMGMT} phy #2
 
echo "Set 2M"
${BTMGMT} phy LE2MTX LE2MRX #3
sleep 1
${BTMGMT} phy #4
sleep 1
 
echo "Set Coded"
${BTMGMT} phy LECODEDTX LECODEDRX #5
sleep 1
${BTMGMT} phy #6
sleep 1
 
echo "Set coded manually"
${HCITOOL} cmd 08 32 #7
${HCITOOL} cmd 08 31 03 04 04 &8
sleep 1
echo "Now it's ok"
${BTMGMT} phy #9
 
 
The btmon output is the following (I've added separators for where each command from the script above was called):
 
 
Bluetooth monitor ver 5.50
= Note: Linux version 4.20.0-042000-generic (x86_64)                   0.300394
= Note: Bluetooth subsystem version 2.22                               0.300400
= New Index: 00:00:00:00:00:00 (Primary,UART,hci0)              [hci0] 0.300402
= Open Index: 00:00:00:00:00:00                                 [hci0] 0.300402
= Index Info: 00:00:00:00:00:00 (not assigned)                  [hci0] 0.300403
@ MGMT Open: bluetoothd (privileged) version 1.14             {0x0003} 0.300404
@ MGMT Open: bluetoothd (privileged) version 1.14             {0x0001} 0.300405
@ MGMT Open: btmon (privileged) version 1.14                  {0x0002} 0.300660
 
${BTMGMT} phy LE1MTX LE1MRX #1
 
@ MGMT Open: btmgmt (privileged) version 1.14                 {0x0004} 3.097362
@ MGMT Command: Set PHY Configuration (0x0045) plen 4  {0x0004} [hci0] 3.097470
        Selected PHYs: 0x0600
          LE 1M TX
          LE 1M RX
< HCI Command: LE Set Default PHY (0x08|0x0031) plen 3       #1 [hci0] 3.097522
        All PHYs preference: 0x00
        TX PHYs preference: 0x01
          LE 1M
        RX PHYs preference: 0x01
          LE 1M
> HCI Event: Command Complete (0x0e) plen 4                  #2 [hci0] 3.098708
      LE Set Default PHY (0x08|0x0031) ncmd 1
        Status: Success (0x00)
@ MGMT Event: Command Complete (0x0001) plen 3         {0x0004} [hci0] 3.098827
      Set PHY Configuration (0x0045) plen 0
        Status: Success (0x00)
@ MGMT Event: PHY Configuration Cha.. (0x0026) plen 4  {0x0002} [hci0] 3.098853
        Selected PHYs: 0x0600
          LE 1M TX
          LE 1M RX
@ MGMT Event: PHY Configuration Cha.. (0x0026) plen 4  {0x0003} [hci0] 3.098853
        Selected PHYs: 0x0600
          LE 1M TX
          LE 1M RX
@ MGMT Event: PHY Configuration Cha.. (0x0026) plen 4  {0x0001} [hci0] 3.098853
        Selected PHYs: 0x0600
          LE 1M TX
          LE 1M RX
@ MGMT Close: btmgmt                                          {0x0004} 3.099048
 
${BTMGMT} phy #2
 
@ MGMT Open: btmgmt (privileged) version 1.14                 {0x0004} 4.104949
@ MGMT Command: Get PHY Configuration (0x0044) plen 0  {0x0004} [hci0] 4.105111
@ MGMT Event: Command Complete (0x0001) plen 15        {0x0004} [hci0] 4.105122
      Get PHY Configuration (0x0044) plen 12
        Status: Success (0x00)
        Supported PHYs: 0x7e00
          LE 1M TX
          LE 1M RX
          LE 2M TX
          LE 2M RX
          LE CODED TX
          LE CODED RX
        Configurable PHYs: 0x7800
          LE 2M TX
          LE 2M RX
          LE CODED TX
          LE CODED RX
        Selected PHYs: 0x0600
          LE 1M TX
          LE 1M RX
@ MGMT Close: btmgmt                                          {0x0004} 4.105236
 
${BTMGMT} phy LE2MTX LE2MRX #3
 
@ MGMT Open: btmgmt (privileged) version 1.14                 {0x0004} 4.108783
@ MGMT Command: Set PHY Configuration (0x0045) plen 4  {0x0004} [hci0] 4.108954
        Selected PHYs: 0x1800
          LE 2M TX
          LE 2M RX
@ MGMT Event: Command Status (0x0002) plen 3           {0x0004} [hci0] 4.108965
      Set PHY Configuration (0x0045)
        Status: Invalid Parameters (0x0d)
@ MGMT Close: btmgmt                                          {0x0004} 4.109075
 
${BTMGMT} phy #4
 
@ MGMT Open: btmgmt (privileged) version 1.14                 {0x0004} 5.116776
@ MGMT Command: Get PHY Configuration (0x0044) plen 0  {0x0004} [hci0] 5.116920
@ MGMT Event: Command Complete (0x0001) plen 15        {0x0004} [hci0] 5.116931
      Get PHY Configuration (0x0044) plen 12
        Status: Success (0x00)
        Supported PHYs: 0x7e00
          LE 1M TX
          LE 1M RX
          LE 2M TX
          LE 2M RX
          LE CODED TX
          LE CODED RX
        Configurable PHYs: 0x7800
          LE 2M TX
          LE 2M RX
          LE CODED TX
          LE CODED RX
        Selected PHYs: 0x0600
          LE 1M TX
          LE 1M RX
@ MGMT Close: btmgmt                                          {0x0004} 5.117054
 
${BTMGMT} phy LECODEDTX LECODEDRX #5
 
@ MGMT Open: btmgmt (privileged) version 1.14                 {0x0004} 6.124056
@ MGMT Command: Set PHY Configuration (0x0045) plen 4  {0x0004} [hci0] 6.124241
        Selected PHYs: 0x6000
          LE CODED TX
          LE CODED RX
@ MGMT Event: Command Status (0x0002) plen 3           {0x0004} [hci0] 6.124251
      Set PHY Configuration (0x0045)
        Status: Invalid Parameters (0x0d)
@ MGMT Close: btmgmt                                          {0x0004} 6.124351
 
${BTMGMT} phy #6
 
@ MGMT Open: btmgmt (privileged) version 1.14                 {0x0004} 7.131377
@ MGMT Command: Get PHY Configuration (0x0044) plen 0  {0x0004} [hci0] 7.131551
@ MGMT Event: Command Complete (0x0001) plen 15        {0x0004} [hci0] 7.131561
      Get PHY Configuration (0x0044) plen 12
        Status: Success (0x00)
        Supported PHYs: 0x7e00
          LE 1M TX
          LE 1M RX
          LE 2M TX
          LE 2M RX
          LE CODED TX
          LE CODED RX
        Configurable PHYs: 0x7800
          LE 2M TX
          LE 2M RX
          LE CODED TX
          LE CODED RX
        Selected PHYs: 0x0600
          LE 1M TX
          LE 1M RX
@ MGMT Close: btmgmt                                          {0x0004} 7.131922
@ RAW Open: hcitool (privileged) version 2.22                 {0x0004} 8.138584
@ RAW Close: hcitool                                          {0x0004} 8.138654
@ RAW Open: hcitool (privileged) version 2.22                 {0x0004} 8.138690
@ RAW Close: hcitool                                          {0x0004} 8.138700
 
${HCITOOL} cmd 08 32 #7
 
@ RAW Open: hcitool (privileged) version 2.22          {0x0004} [hci0] 8.138735
< HCI Command: LE Set PHY (0x08|0x0032) plen 0               #3 [hci0] 8.138854
        invalid packet size
> HCI Event: Command Status (0x0f) plen 4                    #4 [hci0] 8.139762
      LE Set PHY (0x08|0x0032) ncmd 1
        Status: Unsupported Feature or Parameter Value (0x11)
@ RAW Close: hcitool                                   {0x0004} [hci0] 8.139915
@ RAW Open: hcitool (privileged) version 2.22                 {0x0004} 8.143334
@ RAW Close: hcitool                                          {0x0004} 8.143388
@ RAW Open: hcitool (privileged) version 2.22                 {0x0004} 8.143425
@ RAW Close: hcitool                                          {0x0004} 8.143436
 
${HCITOOL} cmd 08 31 03 04 04 #8
 
@ RAW Open: hcitool (privileged) version 2.22          {0x0004} [hci0] 8.143472
< HCI Command: LE Set Default PHY (0x08|0x0031) plen 3       #5 [hci0] 8.143606
        All PHYs preference: 0x03
          No TX PHY preference
          No RX PHY preference
        TX PHYs preference: 0x04
          LE Coded
        RX PHYs preference: 0x04
          LE Coded
> HCI Event: Command Complete (0x0e) plen 4                  #6 [hci0] 8.144779
      LE Set Default PHY (0x08|0x0031) ncmd 1
        Status: Success (0x00)
@ RAW Close: hcitool                                   {0x0004} [hci0] 8.144922
 
${BTMGMT} phy #9
 
@ MGMT Open: btmgmt (privileged) version 1.14                 {0x0004} 9.151090
@ MGMT Command: Get PHY Configuration (0x0044) plen 0  {0x0004} [hci0] 9.151272
@ MGMT Event: Command Complete (0x0001) plen 15        {0x0004} [hci0] 9.151282
      Get PHY Configuration (0x0044) plen 12
        Status: Success (0x00)
        Supported PHYs: 0x7e00
          LE 1M TX
          LE 1M RX
          LE 2M TX
          LE 2M RX
          LE CODED TX
          LE CODED RX
        Configurable PHYs: 0x7800
          LE 2M TX
          LE 2M RX
          LE CODED TX
          LE CODED RX
        Selected PHYs: 0x6000
          LE CODED TX
          LE CODED RX
@ MGMT Close: btmgmt                                          {0x0004} 9.151400
 
 
 
As you see only operation #8 actually changed the PHY settings as reported by btmgmt. This might have something to do with bluez itself, not sure. I'm ok with using hcitool and sending raw commands via hcitool to change the PHY. The thing is that even after changing the PHY to CODED, when I start LE scan I don't get anything even though I have S=8 CODED advertisers around me which also scan each other. I start scanning just by this command:
 
${HCITOOL} cmd 08 0c 01 01 
 
 
Best regards,
PB

Join users@lists.zephyrproject.org to automatically receive all group messages.