BR/EDR iAP

The iAP defines the protocols and procedures that shall be used by devices to transmit data with iOS device.

The iAP demo project gives a simple example on how to use iAP. More knowledge about iAP profile can be found in iAP. The purpose of this document is to give an overview of the iAP demo application.

Requirements

The sample supports the following development kits:

Hardware Platforms

Board Name

Build Target

RTL87x3E HDK

RTL87x3E EVB

bt_iap_demo_4M_bank0
bt_iap_demo_16M_bank0

RTL87x3D HDK

RTL87x3D EVB

bt_iap_demo_16M_bank0

  • When built for an xxx_4M_xxx build target, the sample is configured to compile and run with a 4M flash map.

  • When built for an xxx_16M_xxx build target, the sample is configured to compile and run with a 16M flash map.

The users can choose the project according to the Board Name and choose the Build Target according to the flash map.

  1. To quickly set up the development environment, you can refer to Hardware Development Environment.

  2. In order to interact with the application, users need to input commands through the UART in the host terminal. For additional information regarding the UART connection, please refer to UART in IO. To enter a command, you can use a serial port assistant tool in the host terminal. Simply type the command in the tool and press [ENTER] on your keyboad or click [Send] to send it.

  3. In order to process the iAP authentication procedure, the Apple Authentication 3.0 Coprocessor must be correctly connected to the EVB board. The Apple Authentication 3.0 Coprocessor acts as a I2C device, for additional information regarding the I2C, please refer to I2C in IO.

The TX and RX pin settings for the console are defined in the app_bt_iap_demo_main.c file. It is important to note that the TX and RX pins need to be wired in reverse, which means that the TX pin of console should be connected to P3_0, and the RX pin should be connected to P3_1 in order to establish a connection with the serial port.

#define IAP_DEMO_UART_TX          P3_1
#define IAP_DEMO_UART_RX          P3_0

The SCL and SDA pin settings for I2C are defined in the app_bt_iap_demo_main.c file. The SCL pin of the Apple Authentication 3.0 Coprocessor should be connected to P0_3, and the SDA pin of the Apple Authentication 3.0 Coprocessor should be connected to P0_2.

#define IAP_DEMO_CP_DAT           P0_2
#define IAP_DEMO_CP_CLK           P0_3

Configurations

Device Information

The Bluetooth address and Bluetooth name are defined in the app_bt_iap_demo_main.c file.

const uint8_t local_bd_addr[6]  = {0x11, 0x22, 0x56, 0x34, 0x56, 0x77};
const char *local_name = "iAP demo app";

The user can modify the Bluetooth address and Bluetooth name by adjusting these two variables.

Connection Parameters

User can configure connection parameters by calling bt_iap_param_set(); if user not configure connection parameters, default connection parameters will be used.

Identification Information

User must configure identification information correctly. Remote device will require identification information when building iAP connection. The application should reply identification information after receive BT_EVENT_IAP_IDENTITY_INFO_REQ.

Building and Downloading

The detailed information about Building and Downloading can be found in Building and Downloading. This sample can be found under sdk\board\evb\bt_iap_demo in SDK folder structure.

Take the project rtl87x3e_bt_iap_demo.uvprojx and target bt_iap_demo_4M_bank0 as an example, to build and run the sample with Keil development environment, follow the steps listed below:

  1. Open rtl87x3e_bt_iap_demo.uvprojx.

  2. Choose the build target bt_iap_demo_4M_bank0.

  3. Building the target. After a successful compilation, the app bin file bt_iap_demo_bank0_MP-vxxx-xxx.bin will be generated in the directory bin\rtl87x3e\flash_4M_dualbank\bank0.

  4. Download app bin into EVB board.

Experimental Verification

User need to perform the following preparations before testing iAP demo functions:

  1. One evolution board shall be prepared, and iAP demo application shall be downloaded.

  2. The TX and RX pins for the UART is defined in app_bt_iap_demo_main.c file.

  3. Debug Analyzer used to get the evolution board log.

  4. iOS Audio Connect should be installed in phone.

  5. Make sure remote device connectable.

iAP Command

This section provides a detailed description of the usage of user commands for the iAP demo.

The iAP demo requires inputting commands through the UART in the host terminal to perform interaction. This allows various actions to be executed and the application to be controlled.

iAP Connect

The flow of the iap connect command is to connect iAP with remote device. User can input command below to connect iAP. The address in the command is the remote bluetooth device.

iap connect [remote_device_bluetooth_address]

The console will print iAP Connected! informing user that iAP is connected.

Information

Description

Command

Input command: iap connect [bd_addr]

Usage

Connect iAP with remote device

Example

iap connect 11 22 33 44 55 66

The reference API can be found in bt_iap_connect_req(), and the iAP connect flow is shown below.

iAP Disconnect

The flow of the iap disconnect command is to disconnect iAP with remote device. User can input command below to disconnect iAP.

iap disconnect

The console will print iAP Disconnected! informing user that iAP is disconnected.

Information

Description

Command

Input command: iap disconnect

Usage

Disconnect iAP with remote device

Example

iap disconnect

The reference API can be found in bt_iap_disconnect_req(), and the iAP disconnect flow is shown below.

iAP Data Send

The flow of the iap data_send command is to send a iAP data packet to remote device. User can input command below to send data.

iap data_send

The console will print iAP Data Sent! informing user that a data packet has been sent out.

Information

Description

Command

iap data_send

Usage

Start send an iAP packet in external accessory session

Example

iap data_send

The reference API can be found in bt_iap_data_send(), and the iAP data sent flow is shown below.

Note

The default radio mode is BT_DEVICE_MODE_DISCOVERABLE_CONNECTABLE in this demo. User can also connect the tested accessory in bluetooth setting Interface of remote device.

MFi Certification

The MFi Program provides access to Apple proprietary technologies and components. Please refer to https://mfi.apple.com/ for more details.

MFi Test Environment

Hardware:

  • MacBook, BPA 100/600, iPhone device, accessory(to be certificated).

Software:

  • ATS tool(Should be installed in MacBook).

MFi Test Procedure

  1. Connect BPA 100/600 to MacBook.

  2. Configure ATS tool.
    As shown below, user should configure ATS tool parameters as follows:

    1. Select [Wireless] options.

    2. Click [Start Inquiry] button.

    3. Select the iPhone device used to test in [Apple Device] field.

    4. Select the accessory device to be tested in [Accessory] field.

    5. Input the bluetooth link key of two test devices in [Link Key] field.

    6. Select iAP2 in [Protocol] field.

  1. Click [Start Capture] in ATS tool to start test.

Code Overview

The following sections describe important components of this application.

Source Code Directory

This section describes project directory and project structure. Reference files directory is as follows:

  • Project source code directory: sdk\src\sample\bt_iap_demo.

Source files in the sample project are currently categorized into several groups as below.

└── Project: bt_iap_demo_4M_bank0
    ├── include                         ROM UUID header files. Users do not need to modify it.
    ├── Lib                             Includes all binary symbol files that user application is built on.
    ├── cmsis                           The cmsis source code. Users do not need to modify it.
    └── APP                             The application source code.
        ├── app_bt_iap_demo_app.c
        ├── app_bt_iap_demo_console.c 
        ├── app_bt_iap_demo_gap.c
        ├── app_bt_iap_demo_link.c
        ├── app_bt_iap_demo_main.c
        ├── app_bt_iap_demo_sdp.c
        ├── app_bt_iap_demo_task.c
        ├── app_console_msg.c
        ├── app_dlps.c
        ├── app_io_msg.c
        ├── console_uart.c

Initialization

main() is invoked when the application is powered on or the chip is reset, and it performs the following initialization functions.

int main(void)
{
    board_init();
    driver_init();
    task_init();

    framework_init();
    app_bt_gap_init();
    iap_demo_gap_init();
    iap_demo_sdp_init();
    iap_demo_app_init();
    app_iap_cmd_register();

    os_sched_start();

    return 0;
}

Please refer to iAP demo source code for initialization function declaration.

Profile Message Callback

APP can register different callback functions to handle different profiles.

void iap_demo_gap_init(void)
{
    ...

    bt_mgr_cback_register(iap_demo_gap_bt_cback);
}

void iap_demo_app_init(void)
{
    ...

    bt_mgr_cback_register(iap_demo_app_bt_cback);
}