This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to enable peripheral mode in Android L

Hello,

I have develop and app to send BLE Advertisement packet in Android. But what I found out is my device has Android Lollipop but it does not have peripheral mode turned on.

Is there a way I can turn on the peripheral mode on my device?

Regrards MJ

  • When I run the call .isMultipleAdvertisementSupported(); it returns with false value. Apart from this when I run a call to the .isOffloadedFilteringSupported() & .isOffloadedScanBatchingSupported(), it also returns false value.

    When I instantiate the GATT server and start advertise, it returns me the Error Code =2 in Advertise callback. Which it is returning in case of simple advertisement without GATT instance.

    Below is the logcat for GATT instance

    D/BluetoothGattServer(12601): registerCallback() - UUID=10316813-e422-4c16-99b4-029675c89d1d

    D/BtGatt.GattService( 7252): registerServer() - UUID=10316813-e422-4c16-99b4-029675c89d1d

    D/BtGatt.btif( 7252): btif_gatts_register_app

    D/BtGatt.btif( 7252): btgatts_handle_event: Event 2000

    E/bt-btif ( 7252): register application first_unuse rcb_idx = 0

    D/BtGatt.btif( 7252): btapp_gatts_handle_cback: Event 0

    D/BtGatt.GattService( 7252): onServerRegistered() - UUID=10316813-e422-4c16-99b4-029675c89d1d, serverIf=5

    D/BluetoothGattServer(12601): onServerRegistered() - status=0 serverIf=5

    D/BluetoothGattServer(12601): addService() - service: 00001802-0000-1000-8000-00805f9b34fb

    D/BtGatt.GattService( 7252): beginServiceDeclaration() - uuid=00001802-0000-1000-8000-00805f9b34fb serverIf=5

    D/BtGatt.GattService( 7252): addCharacteristic() - uuid=00002a06-0000-1000-8000-00805f9b34fb

    D/BtGatt.GattService( 7252): endServiceDeclaration() serverIf=5

    D/BtGatt.GattService( 7252): continueServiceDeclaration() - srvcHandle=0

    D/BtGatt.GattService( 7252): continueServiceDeclaration() - next entry type=1

    D/BtGatt.btif( 7252): btif_gatts_add_service

    D/BtGatt.btif( 7252): btgatts_handle_event: Event 2004

    E/bt-btif ( 7252): create service rcb_idx = 0

    D/BtGatt.btif( 7252): btapp_gatts_handle_cback: Event 7

    D/BtGatt.GattService( 7252): onServiceAdded() UUID=00001802-0000-1000-8000-00805f9b34fb, status=0, handle=40

    D/BtGatt.GattService( 7252): continueServiceDeclaration() - srvcHandle=40

    D/BtGatt.GattService( 7252): continueServiceDeclaration() - next entry type=2

    D/BtGatt.btif( 7252): btif_gatts_add_characteristic

    D/BtGatt.btif( 7252): btgatts_handle_event: Event 2006

    D/BtGatt.btif( 7252): btapp_gatts_handle_cback: Event 9

    D/BtGatt.GattService( 7252): onCharacteristicAdded() UUID=00002a06-0000-1000-8000-00805f9b34fb, status=0, srvcHandle=40, charHandle=42

    D/BtGatt.GattService( 7252): continueServiceDeclaration() - srvcHandle=40

    D/BtGatt.btif( 7252): btif_gatts_start_service

    D/BtGatt.GattService( 7252): continueServiceDeclaration() - completed.

    D/BtGatt.btif( 7252): btgatts_handle_event: Event 2008

    D/BtGatt.btif( 7252): btapp_gatts_handle_cback: Event 12

    D/BtGatt.GattService( 7252): onServiceStarted() srvcHandle=40, status=0

    D/BluetoothGattServer(12601): addService() - service: 0000180a-0000-1000-8000-00805f9b34fb

    D/BtGatt.GattService( 7252): beginServiceDeclaration() - uuid=0000180a-0000-1000-8000-00805f9b34fb serverIf=5

    D/BtGatt.GattService( 7252): addCharacteristic() - uuid=00002a29-0000-1000-8000-00805f9b34fb

    D/BtGatt.GattService( 7252): addCharacteristic() - uuid=00002a24-0000-1000-8000-00805f9b34fb

    D/BtGatt.GattService( 7252): addCharacteristic() - uuid=00002a25-0000-1000-8000-00805f9b34fb

    D/BluetoothGattServer(12601): onServiceAdded() - service=00001802-0000-1000-8000-00805f9b34fbstatus=0

    D/IAS (12601): onServiceAdded status=GATT_SUCCESS service=00001802-0000-1000-8000-00805f9b34fb

    D/BtGatt.GattService( 7252): endServiceDeclaration() serverIf=5

    D/BtGatt.GattService( 7252): continueServiceDeclaration() - srvcHandle=0

    D/BtGatt.GattService( 7252): continueServiceDeclaration() - next entry type=1

    D/BtGatt.btif( 7252): btif_gatts_add_service

    D/BtGatt.btif( 7252): btgatts_handle_event: Event 2004

    E/bt-btif ( 7252): create service rcb_idx = 0

    D/BtGatt.btif( 7252): btapp_gatts_handle_cback: Event 7

    D/BtGatt.GattService( 7252): onServiceAdded() UUID=0000180a-0000-1000-8000-00805f9b34fb, status=0, handle=43

    D/BtGatt.GattService( 7252): continueServiceDeclaration() - srvcHandle=43

    D/BtGatt.GattService( 7252): continueServiceDeclaration() - next entry type=2

    D/BtGatt.btif( 7252): btif_gatts_add_characteristic

    D/BtGatt.btif( 7252): btgatts_handle_event: Event 2006

    D/BtGatt.btif( 7252): btapp_gatts_handle_cback: Event 9

    D/BtGatt.GattService( 7252): onCharacteristicAdded() UUID=00002a29-0000-1000-8000-00805f9b34fb, status=0, srvcHandle=43, charHandle=45

    D/BtGatt.GattService( 7252): continueServiceDeclaration() - srvcHandle=43

    D/BtGatt.GattService( 7252): continueServiceDeclaration() - next entry type=2

    D/BtGatt.btif( 7252): btif_gatts_add_characteristic

    D/BtGatt.btif( 7252): btgatts_handle_event: Event 2006

    D/BtGatt.btif( 7252): btapp_gatts_handle_cback: Event 9

    D/BtGatt.GattService( 7252): onCharacteristicAdded() UUID=00002a24-0000-1000-8000-00805f9b34fb, status=0, srvcHandle=43, charHandle=47

    D/BtGatt.GattService( 7252): continueServiceDeclaration() - srvcHandle=43

    D/BtGatt.GattService( 7252): continueServiceDeclaration() - next entry type=2

    D/BtGatt.btif( 7252): btif_gatts_add_characteristic

    D/BtGatt.btif( 7252): btgatts_handle_event: Event 2006

    D/BtGatt.btif( 7252): btapp_gatts_handle_cback: Event 9

    D/BtGatt.GattService( 7252): onCharacteristicAdded() UUID=00002a25-0000-1000-8000-00805f9b34fb, status=0, srvcHandle=43, charHandle=49

    D/BtGatt.GattService( 7252): continueServiceDeclaration() - srvcHandle=43

    D/BtGatt.btif( 7252): btif_gatts_start_service

    D/BtGatt.GattService( 7252): continueServiceDeclaration() - completed.

    D/BtGatt.btif( 7252): btgatts_handle_event: Event 2008

    D/BluetoothGattServer(12601): onServiceAdded() - service=0000180a-0000-1000-8000-00805f9b34fbstatus=0

    D/IAS (12601): onServiceAdded status=GATT_SUCCESS service=0000180a-0000-1000-8000-00805f9b34fb

    D/BtGatt.btif( 7252): btapp_gatts_handle_cback: Event 12

    D/BtGatt.GattService( 7252): onServiceStarted() srvcHandle=43, status=0

    D/BluetoothManagerService( 880): checkIfCallerIsForegroundUser: valid=true callingUser=0 parentUser=-10000 foregroundUser=0

    D/BluetoothManagerService( 880): checkIfCallerIsForegroundUser: valid=true callingUser=0 parentUser=-10000 foregroundUser=0

    D/BtGatt.GattService( 7252): registerClient() - UUID=cf84d03b-6afc-4ded-8b47-1688e1fe8461

    D/BtGatt.GattService( 7252): onClientRegistered() - UUID=cf84d03b-6afc-4ded-8b47-1688e1fe8461, clientIf=6

    D/BluetoothLeAdvertiser(12601): onClientRegistered() - status=0 clientIf=6

    D/BtGatt.AdvertiseManager( 7252): message : 0

    D/BluetoothAdapterService( 7252): getAdapterService() - returning com.android.bluetooth.btservice.AdapterService@32ffccc4

    D/BtGatt.GattService( 7252): unregisterClient() - clientIf=6

    I/WCNSS_FILTER( 7290): ibs_msm_serial_clock_vote: vote UART CLK ON using UART driver's ioctl()

    D/aBeacon (12601): onStartFailure errorCode=2

  • Right, so given your latest comment it would appear that your chipset falls under scenarios (1) or (3) as outlined above. Also I'm not sure how you would have derived that peripheral mode was 'turned off' from your debug flow. It simply seems to be saying that peripheral mode is 'not supported'.

    Again, you will have to refer to the Qualcomm support forums or log a support ticket with Qualcomm so that they can provide insight into which of the 2 scenarios you are encountering and if it's scenario (1), whether they plan to release updated drivers to support BLE advertisements.

Related