# Serial Port Profile

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

SPP is a Bluetooth profile that enables wireless communication between devices over a
        virtual serial port.

To perform Bluetooth SPP server or client functions, you must first complete the
                steps in the following procedure.

## Set up device for Bluetooth SPP functions

**Prerequisites**

- Enable SSH to access your host device. For instructions, see [Log in using SSH](https://docs.qualcomm.com/bundle/publicresource/topics/80-70017-254/how_to.html#use-ssh).
- Place the DUT and the remote device in the Bluetooth vicinity.

**Procedure**

1. Run the SSH in command prompt using the following command: 

        ssh root@<device_IP_address>Copy to clipboard

    **Example**

If the IP address of the device is `10.92.160.222`, run
                            the following command:

        ssh root@10.92.160.222Copy to clipboard
2. Connect to the SSH by entering the following password: 

        oelinux123Copy to clipboard
3. Open the Bluetooth test application by running the following command: 

        btappCopy to clipboard

    **Sample output**

sh-5.1# btapp
         get_ap_interface
        :: get_ap_interface
        
        ***************** Menu *******************
                 gap_menu
                 test_menu
                 a2dp_sink_menu
                 hfp_client_menu
                 gattctest_menu
                 gattstest_menu
                 hogp_menu
                 hfp_ag_menu
                 a2dp_source_menu
                 spp_client_menu
                 spp_server_menu
                 eslap_menu
                 exit
         ******************************************Copy to clipboard
4. Enable Bluetooth and pair the device as follows:
    1. Go to the Gap Menu by running the following
                            command: 

            gap_menuCopy to clipboard
    2. Enable Bluetooth by running 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
    3. Pair the device for SPP outgoing by running the following command: 

            pair <bt_address> <transport>Copy to clipboard

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

        **Parameters**

        - [Run Bluetooth inquiry scan](https://docs.qualcomm.com/doc/80-70017-13/topic/gap_commands.html#gap_commands__section_iy1_xnf_41c) to get the `<bt_address>` of the remote
                                        device.
        - The values of the `<transport>`parameter
                                        can be:
            - `0`: Auto selection
            - `1`: BR/EDR
            - `2`: Bluetooth Low Energy

        **Example**

To initiate a BR/EDR pairing for `<bt_address>`
                                    `98:09:cf:a9:82:23`, run the following command:

            pair 98:09:cf:a9:82:23 1Copy to clipboard

        **Sample output**

pair 98:09:cf:a9:82:23 1 
             BR/EDR Bonding
             ACL state:0 change with reason 00 for device: f8:7d:76:9d:9b:6b
            ************************************************
             Pairing state for MyDeviceA is BOND NONE
            ************************************************
             BT pairing request :: MyDeviceB :: Pairing Code :: 776996
            ************************************************
            **Please enter yes / no **
            yes
            ************************************************
             Pairing state for MyDeviceB is BONDED
            ************************************************Copy to clipboard
    4. Return to the Main Menu by running the following
                            command: 

            main_menuCopy to clipboard
5. Go to the SPP server or client menu, as required.
    - To go to the SPP Server Menu, run the
                                    following command from the `main_menu`:

            spp_server_menuCopy to clipboard

        **Sample output**

main_menu
            
            ***************** Menu *******************
                     gap_menu
                     test_menu
                     a2dp_sink_menu
                     hfp_client_menu
                     gattctest_menu
                     gattstest_menu
                     hogp_menu
                     hfp_ag_menu
                     a2dp_source_menu
                     spp_client_menu
                     spp_server_menu
                     eslap_menu
                     exit
             ******************************************
            spp_server_menu
            
            ***************** Menu *******************
                     start_server
                     stop_server
                     send_file<space><directory_with_file_name>eg: send_file /var/fileName.txt
                     recv_file<space><directory_with_file_name>eg: recv_file /var/fileName.txt
                     send_data<space><with_size>eg: send_data 1000[Note:1000 means 1MB]
                     recv_data
                     main_menu
            ******************************************Copy to clipboard

        For SPP server functions, see [Perform Bluetooth SPP server functions](https://docs.qualcomm.com/doc/80-70017-13/topic/perform_bluetooth_functions_in_spp_server.html).
    - To go to the SPP Client Menu, run the
                                    following command from the `main_menu`:

            spp_client_menuCopy to clipboard

        **Sample output**

main_menu
            
            ***************** Menu *******************
                     gap_menu
                     test_menu
                     a2dp_sink_menu
                     hfp_client_menu
                     gattctest_menu
                     gattstest_menu
                     hogp_menu
                     hfp_ag_menu
                     a2dp_source_menu
                     spp_client_menu
                     spp_server_menu
                     eslap_menu
                     exit
             ******************************************
            spp_client_menu
            
            ***************** Menu *******************
                     connect <bt_addr>
                     disconnect
                     send_file<space><directory_with_file_name>eg: send_file /var/fileName.txt
                     recv_file<space><directory_with_file_name>eg: recv_file /var/fileName.txt
                     send_data<space><with_size>eg: send_data 1000[Note:1000 means 1MB]
                     recv_data
                     main_menu
             ******************************************Copy to clipboard

        For SPP client functions, see [Perform Bluetooth SPP client functions](https://docs.qualcomm.com/doc/80-70017-13/topic/perform_bluetooth_functions_in_spp_client.html).
6. Install any third-party Bluetooth host application, which supports SPP client
                    and server roles, on a remote device. For example, a Bluetooth SPP
                        server/client application from the Google Play Store.
    - DUT: Test device
    - Remote device: Any smartphone

- **[Perform Bluetooth SPP server functions](https://docs.qualcomm.com/doc/80-70017-13/topic/perform_bluetooth_functions_in_spp_server.html)**  

You can perform SPP server functions using the `spp_server_menu`         options.
- **[Perform Bluetooth SPP client functions](https://docs.qualcomm.com/doc/80-70017-13/topic/perform_bluetooth_functions_in_spp_client.html)**  

You can perform SPP client functions using the `spp_client_menu`         options.

**Parent Topic:** [Verify functionality of Fluoride stack](https://docs.qualcomm.com/doc/80-70017-13/topic/bluetooth_usecases.html)

Last Published: Dec 26, 2024

[Previous Topic
Perform Bluetooth GAP functions](https://docs.qualcomm.com/bundle/publicresource/80-70017-13/topics/gap_commands.md) [Next Topic
Perform Bluetooth SPP server functions](https://docs.qualcomm.com/bundle/publicresource/80-70017-13/topics/perform_bluetooth_functions_in_spp_server.md)