# Perform Bluetooth GAP functions

Source: [https://docs.qualcomm.com/doc/80-70017-13/topic/gap_commands.html](https://docs.qualcomm.com/doc/80-70017-13/topic/gap_commands.html)

You can perform various Bluetooth GAP functions using the generic
            `gap_menu` options.

Before you begin, set up the device and go to the `gap_menu` as described
            in [Set up device for Bluetooth GAP functions](https://docs.qualcomm.com/doc/80-70017-13/topic/gap_operation.html#gap_operation__section_kzq_ggb_1cc_navyanka_07-10-24-2044-49-668).

## Enable Bluetooth 

To enable Bluetooth on the device, run the following
                command:

    enableCopy to clipboard

**Sample output**

gap_menu
    
    ***************** Menu *******************
             enable
             disable
             inquiry
             cancel_inquiry
             get_role_req<space><bt_address>     eg. get_role_req 00:11:22:33:44:55
             pair<space><bt_address><space><transport>     eg. pair 00:11:22:33:44:55 0(auto)/1(BREDR)/2(BLE)
             unpair<space><bt_address>     eg. unpair 00:11:22:33:44:55
             inquiry_list
             bonded_list
             get_state
             get_bt_name
             get_bt_address
             set_bt_name<space><bt name>     eg. set_bt_name MDM_Fluoride
             set_scan_mode<space><scan mode value (range 0-2)>     eg. set_scan_mode 0 --0-BT_SCAN_MODE_NONE,1- BT_SCAN_MODE_CONNECTABLE,2-BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE
             set_afh<space><AFH_Host_Channel_Classification>     eg. set_afh 112233445566778899f0
             send_hci_cmd<space><hci_cmd>     eg. send_hci_cmd 01,04,05,33,8b,9e,0a,00 - For Inquiry
             read_clock<space><which_clock range(0-1)><space><bt_address>     eg. read_clock 0(local)/1(acl connection) 00:11:22:33:44:55
             main_menu
             switch_role_req<bt_address><space><new_role>     eg. switch_role_req 00:11:22:33:44:55 0 or get_role_req 00:11:22:33:44:55 1
     ******************************************
    enable
     current State = 0, new state = 1
     BT State is ONCopy to clipboard

## Run Bluetooth inquiry scan

To initiate an inquiry for nearby devices, run the following
                command:

    inquiryCopy to clipboard

**Sample output**

inquiry
     Inquiry Started
    Device Found details:
    Found device Addr: d8:b0:53:e5:6a:32
    Found device Name: MyDeviceB
    Device Type is: 1
    Device Found details:
    Found device Addr: f8:7d:76:9d:9b:6b
    Found device Name: MyDeviceA
    Device Type is: 1
     Inquiry Stopped automaticallyCopy to clipboard

## Cancel Bluetooth inquiry scan

To cancel an inquiry that is in progress, run the following command:

    cancel_inquiryCopy to clipboard

**Sample output**

cancel_inquiry
    
    **************************** Inquiry List *********************************
    1          MyDeviceB                                 d8:b0:53:e5:6a:32
    2          MyDeviceA                                 f8:7d:76:9d:9b:6b
    **************************** End of List *********************************
     Inquiry Stopped due to user input
    Copy to clipboard

## Get Bluetooth/Bluetooth Low Energy device list

To get the list of discovered devices, run the following
                command:

    inquiry_listCopy to clipboard

**Sample output**

inquiry_list
    
    **************************** Inquiry List *********************************
    1          MyDeviceB                                 d8:b0:53:e5:6a:32
    2          MyDeviceA                                 f8:7d:76:9d:9b:6b
    **************************** End of List *********************************Copy to clipboard

## Pair with remote Bluetooth device

To initiate outgoing Secure Simple Pairing (SSP), run the following command:

    pair <bt_address> <transport>Copy to clipboard

To accept the outgoing/incoming pairing, enter `yes`. To reject the
                outgoing/incoming pairing, enter `no`.

Note: Ensure that you provide the
                correct pin for the incoming legacy pairing.

**Parameters**

- `<bt_address>` is the Bluetooth address of the remote
                    device.
- `<transport>` is the radio for pairing. The value of the
                        `<transport>`parameter can be:
    - `0`: Auto selection
    - `1`: BR/EDR
    - `2`: Bluetooth Low Energy

**Example**

To pair a remote device with `<bt_address>`
                `f8:7d:76:9d:9b:6b`, run the following command:

    pair f8:7d:76:9d:9b:6b 0Copy to clipboard

**Sample output**

pair f8:7d:76:9d:9b:6b 0
     Auto select in the stack
     ACL state:0 change with reason 00 for device: f8:7d:76:9d:9b:6b
    
     BT pairing_variant 0
    *************************************************
     BT pairing request::Device MyDeviceB::Pairing Code:: 999712
    *************************************************
     ** Please enter yes / no **
    yes
    
    *****************DidInfoCb*******************
     MAC address:f8:7d:76:9d:9b:6b
     spec_id:0x102 :
     vendor:0x4c :
     vendor_id_source:0x1 :
     product:0x760a :
     vendor:0x4c :
     primary_record:0x1 :
     client_executable_url: :
     service_description:PnP Information :
     documentation_url: :
     DID info result :0 :
    
    *****************FINISH*******************
    
    *************************************************
     Pairing state for MyDeviceB is BONDED
    *************************************************Copy to clipboard

## Get the bonded/paired device list

To get a verified list of paired devices, run the following
                command:

    bonded_listCopy to clipboard

**Sample output**

bonded_list
    
    **************************** Bonded Device List ****************************
    MyDeviceB                                 f8:7d:76:9d:9b:6b
    ****************************  End of List *********************************Copy to clipboard

## Set the Bluetooth device name

To change or set the local Bluetooth device name, run the following command:

    set_bt_name <bt name>Copy to clipboard

**Parameters**

`<bt name>` is the name of the device to be set.

**Example**

To set the device name as `K2L`, run the following command:

    set_bt_name K2LCopy to clipboard

**Sample output**

get_bt_name
    BT Name : Pstack_test
    set_bt_name K2L
    BT name is set to K2L
    get_bt_name
    BT Name : K2LCopy to clipboard

## Get the Bluetooth name

To get the Bluetooth device name, run the following
                command:

    get_bt_nameCopy to clipboard

**Sample output**

In the following sample output of this command, the device name appears as
                    `K2L`:

get_bt_name
    BT Name : K2LCopy to clipboard

## Get the Bluetooth address

To set the Bluetooth MAC address, see [General Access Profile](https://docs.qualcomm.com/doc/80-70017-13/topic/gap_operation.html).

To get the Bluetooth device address, run the following
                command:

    get_bt_addressCopy to clipboard

**Sample output**

In the following sample output of this command, the device address appears as
                    `11:22:33:44:55:66`:

get_bt_address
     BT Address : 11:22:33:44:55:66Copy to clipboard

## Disable Bluetooth 

To disable Bluetooth, run the following
                command:

    disableCopy to clipboard

**Sample output**

gap_menu
    
    ***************** Menu *******************
             enable
             disable
             inquiry
             cancel_inquiry
             get_role_req<space><bt_address>     eg. get_role_req 00:11:22:33:44:55
             pair<space><bt_address><space><transport>     eg. pair 00:11:22:33:44:55 0(auto)/1(BREDR)/2(BLE)
             unpair<space><bt_address>     eg. unpair 00:11:22:33:44:55
             inquiry_list
             bonded_list
             get_state
             get_bt_name
             get_bt_address
             set_bt_name<space><bt name>     eg. set_bt_name MDM_Fluoride
             set_scan_mode<space><scan mode value (range 0-2)>     eg. set_scan_mode 0 --0-BT_SCAN_MODE_NONE,1- BT_SCAN_MODE_CONNECTABLE,2-BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE
             set_afh<space><AFH_Host_Channel_Classification>     eg. set_afh 112233445566778899f0
             send_hci_cmd<space><hci_cmd>     eg. send_hci_cmd 01,04,05,33,8b,9e,0a,00 - For Inquiry
             read_clock<space><which_clock range(0-1)><space><bt_address>     eg. read_clock 0(local)/1(acl connection) 00:11:22:33:44:55
             main_menu
             switch_role_req<bt_address><space><new_role>     eg. switch_role_req 00:11:22:33:44:55 0 or get_role_req 00:11:22:33:44:55 1
    *******************************************
    disable
     current State = 1, new state = 0
    BT_AUDIO_HAL_INTEGRATION needs to be defined
    killall: qcbtdaemon: no process killed
    killall: wcnssfilter: no process killed
     BT State is OFFCopy to clipboard

**Parent Topic:** [General Access Profile](https://docs.qualcomm.com/doc/80-70017-13/topic/gap_operation.html)

Last Published: Dec 26, 2024

[Previous Topic
General Access Profile](https://docs.qualcomm.com/bundle/publicresource/80-70017-13/topics/gap_operation.md) [Next Topic
Serial Port Profile](https://docs.qualcomm.com/bundle/publicresource/80-70017-13/topics/set_up_bluetooth_in_spp.md)