This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/WILINK8-WIFI-NLCP: BLE peripheral mode issue on Android 6

Part Number: WILINK8-WIFI-NLCP

Tool/software: Linux

Hi,

I want to set the WL8 to BLE peripheral mode with Bluedroid stack but I get errors when run ble peripheral app.

The error like below :

 01-21 09:16:31.259  1155  1360 E bt_btm  : wrong length for btm_ble_multi_adv_vsc_cmpl_cback

Does WL8 support peripheral mode on Android 6? 

Does anyone have any ideas for this? 

The attached files are patch file for peripheral mode supported with bluedroid stack and android logcat file.

Thanks.

patch1.txt
diff --git a/base/core/java/android/bluetooth/BluetoothAdapter.java b/base/core/java/android/bluetooth/BluetoothAdapter.java
index daeef39..4573bf1 100755
--- a/base/core/java/android/bluetooth/BluetoothAdapter.java
+++ b/base/core/java/android/bluetooth/BluetoothAdapter.java
@@ -570,7 +570,7 @@ public final class BluetoothAdapter {
      */
     public BluetoothLeAdvertiser getBluetoothLeAdvertiser() {
         if (!getLeAccess()) return null;
-        if (!isMultipleAdvertisementSupported() && !isPeripheralModeSupported()) {
+        if (!isMultipleAdvertisementSupported() /*&& !isPeripheralModeSupported()*/) {
             Log.e(TAG, "Bluetooth LE advertising not supported");
             return null;
         }
jason@jason-ThinkPad-X200:~/TG/rk3288-TG/frameworks$ git show 92a86bb26659c78432541d2a6a1831b7a96b403f
commit 92a86bb26659c78432541d2a6a1831b7a96b403f
Author: Jason Wang <jason@aaeon.com.tw>
Date:   Tue Apr 24 10:45:46 2018 +0800

    Enable BLE peripheral mode

diff --git a/base/core/res/res/values/config.xml b/base/core/res/res/values/config.xml
index 1778fbb..66a480a 100755
--- a/base/core/res/res/values/config.xml
+++ b/base/core/res/res/values/config.xml
@@ -1207,7 +1207,7 @@
     <bool name="config_bluetooth_address_validation">false</bool>
 
     <!-- Boolean indicating if current platform supports BLE peripheral mode -->
-    <bool name="config_bluetooth_le_peripheral_mode_supported">false</bool>
+    <bool name="config_bluetooth_le_peripheral_mode_supported">true</bool>
 
     <!-- Max number of scan filters supported by blutooth controller. 0 if the
          device does not support hardware scan filters-->

patch2.txt
diff --git a/include/bt_target.h b/include/bt_target.h
index ae2c897..50ab658 100755
--- a/include/bt_target.h
+++ b/include/bt_target.h
@@ -132,6 +132,10 @@
 #define BTA_AV_RET_TOUT 15
 #endif
 
+#ifndef PORCHE_PAIRING_CONFLICT
+#define PORCHE_PAIRING_CONFLICT  TRUE
+#endif
+
 #ifndef BTA_AV_CO_CP_SCMS_T
 #define BTA_AV_CO_CP_SCMS_T  FALSE
 #endif
@@ -671,14 +675,8 @@
 
 /* Minimum number of ACL credit for high priority link */
 #ifndef L2CAP_HIGH_PRI_MIN_XMIT_QUOTA
-/*BOARD_HAVE_BLUETOOTH_RTK_COEX begin*/
-#ifdef BLUETOOTH_RTK_COEX
-#define L2CAP_HIGH_PRI_MIN_XMIT_QUOTA       8
-#else
 #define L2CAP_HIGH_PRI_MIN_XMIT_QUOTA       5
 #endif
-/*BOARD_HAVE_BLUETOOTH_RTK_COEX end*/
-#endif
 
 /* used for monitoring HCI ACL credit management */
 #ifndef L2CAP_HCI_FLOW_CONTROL_DEBUG
@@ -796,7 +794,7 @@
  * feature discovery, multi-adv etc.
  */
 #ifndef BLE_VND_INCLUDED
-#define BLE_VND_INCLUDED        FALSE
+#define BLE_VND_INCLUDED        TRUE
 #endif
 
 #ifndef BTM_BLE_ADV_TX_POWER
@@ -1657,12 +1655,8 @@ The maximum number of payload octets that the local device can receive in a sing
 ******************************************************************************/
 
 #ifndef HCILP_INCLUDED
-#ifdef BLUETOOTH_RTK
-#define HCILP_INCLUDED                  FALSE
-#else
 #define HCILP_INCLUDED                  TRUE
 #endif
-#endif
 
 /******************************************************************************
 **

logcat-BLE.txt

Nathan Kuo

  • Hi ,

    Attachment is BT firmware log .

    firmware_log.7z

    Nathan 

  • nathan kuo said:
    Does WL8 support peripheral mode on Android 6? 

    The WL8 Bluetooth controller has the LE peripheral capabilities. Placing the WL8 in connectable advertisement mode and connecting to it from a central is just like any other BLE device, since this procedure is defined by the Bluetooth Specification. Whether the Bluedroid stack has the proper capabilities is the question.

    In the FW logs attached, I see that the WL8 device starts LE scanning (something a BLE central would do). If the WL8 is in this mode, it cannot act as a peripheral.

    BR,

    Vihang

  • Hi Vihang,

    Thanks for your reply,

    Do you know how to Placing the WL8 in connectable advertisement mode? Does the BT firmware need to be modified?

    Nathan Kuo

  • Hi Vihang,
    BLE Peripheral mode working with another wifi chip in the same Android BSP , so I don't think there is a problem with bluedroid.
    Do you have any idea about this?


    Nathan Kuo

  • Nathan,

    nathan kuo said:
    Do you know how to Placing the WL8 in connectable advertisement mode? Does the BT firmware need to be modified?

    As I mentioned in my previous post, this process is clearly documented in the BT spec. There are a set of HCI commands that the host sends to the BT controller (i.e. WL8) to start connectable advertisement.

    A stack handles this implementation while allowing user to configure some of the parameters from the application layer. Since the Bluedroid stack is not officially supported for WL8, we do not have the expertise to help you debug this open source stack functions/operations. It doesn't mean that the connectable advertisement is not possible in this system, but we can only provide support regarding HCI and below protocols in this case. Hope this clears up our position.

    I would recommend you check on opensource android forums to see if anyone has implemented something similar.

    Best regards,

    Vihang

  • Hi Vihang,

    Thanks for your reply.

    I have more question for this issue.

    I enabled the debug on bluedroid stack , we saw the bluedroid always send the HCI vendor commmand to WL8. as below log

    01-21 08:50:31.054 1180 1354 E bt_btm : BTM: BTM_VendorSpecificCommand: Opcode: 0xFD54, ParamLen: 8.
    01-21 08:50:31.055 1180 1354 E bt_btm : BTM: BTM_VendorSpecificCommand: Opcode: 0xFD54, ParamLen: 8.
    01-21 08:50:31.056 1180 1354 E bt_btm : BTM: BTM_VendorSpecificCommand: Opcode: 0xFD54, ParamLen: 8.

    In firmware log the WL8 received event is "HCI_VS_Configure_Bad_Voice_Scenario_Params" not "LE_Multi_Advt_Command"

    "LE_Multi_Advt_Command" HCI Requirements in android.

    #define HCI_BLE_MULTI_ADV_OCF (0x0154 | HCI_GRP_VENDOR_SPECIFIC)
    #define HCI_GRP_VENDOR_SPECIFIC (0x3F << 10) /* 0xFC00

    In addition , Do I need to add below command in the firmware? Is there any documentation to explain this?

    Send_HCI_LE_Write_Advertise_Enable 0x01
    Wait_HCI_Command_Complete_LE_Write_Advertise_Enable_Event 5000, any, HCI_LE_Write_Advertise_Enable, 0, Any

     

    logcat-ble-tg-wl1837.txt

    Nathan Kuo

  • Nathan,

    The LE_Multi_Adv is not a valid command for TI Bluetooth controllers. The 0xFD54 (OGF 0x3F & OCF 0x0154) is a vendor specific(VS) command and not a standard BT spec command. The VS opcode 0xFD54 means something else for the WL18xx and that is the reason you see the HCI_VS_Configure_Bad_Voice_Scenario_Params event in return.

    nathan kuo said:

    "LE_Multi_Advt_Command" HCI Requirements in android.

    #define HCI_BLE_MULTI_ADV_OCF (0x0154 | HCI_GRP_VENDOR_SPECIFIC)
    #define HCI_GRP_VENDOR_SPECIFIC (0x3F << 10) /* 0xFC00

    This is not a BT spec command and it is not required for advertisement. It must be part of some vendor (non-TI) specific implementation in android stack.

    nathan kuo said:

    In addition , Do I need to add below command in the firmware? Is there any documentation to explain this?

    Send_HCI_LE_Write_Advertise_Enable 0x01
    Wait_HCI_Command_Complete_LE_Write_Advertise_Enable_Event 5000, any, HCI_LE_Write_Advertise_Enable, 0, Any

    Yes. This command must be sent after the host sets the advertising parameters and the advertising data in order to start advertisement. Please refer to the message sequences explained in detail in the Bluetooth core specification document.

    For example, the message sequence for advertisement is illustrated in the section 3.1 UNDIRECTED ADVERTISING of the BLUETOOTH SPECIFICATION Version 4.2 [Vol 6, Part D]. You will also find documentation explanation of these BT spec HCI commands in the same document.

    Best regards,

    Vihang

  • I encountered the same issue in December but progress on this issue has been sidetracked since then. I am now looking at it again where it still exists on our system after upgrading from 7.1.1 to 7.1.2:

    https://e2e.ti.com/support/wireless_connectivity/wilink_wifi_bluetooth/f/307/p/646497/2380764

    So is the proposed solution to modify the Bluedroid stack to delete the 0xFD54 command? 

  • Tyler Arnold45 said:
    So is the proposed solution to modify the Bluedroid stack to delete the 0xFD54 command? 

    Bluedroid is an open source stack and it is not maintained by TI. So I cannot make suggestions regarding stack changes since I am not familiar with this stack. That being said, the 0xFD54 is a vendor specific command for some non-TI SOC. So it makes sense to make sure that the stack does not send that command to the WL8 controller. Since you have the source code of this stack, I am sure you can figure out how to do it.

    Best regards,

    Vihang