LE Scatternet

The LE scatternet sample demonstrates how to develop an application which supports the Peripheral Role and the Central Role at the same time.

Scatternet topology features:

  • A device is permitted to establish physical links to more than one Central at a time.

  • A device is permitted to be Peripheral and Central at the same time.

  • Does not support role switch.

../../../_images/scatternet_architecture.png

The sample uses LE host and LE manager module. The above figure shows the relationships between several modules in the sample.

More information about these modules can be found in the LE Host and LE Manager documentation.

Requirements

The sample supports the following development kits:

Hardware Platforms

Board Name

Build Target

RTL87x3E HDK

RTL87x3E EVB

ble_scatternet_4M_bank0

ble_scatternet_16M_bank0

RTL87x3D HDK

RTL87x3D EVB

ble_scatternet_8M_bank0

ble_scatternet_16M_bank0

ble_scatternet_cs_16M_bank0

This sample project can be found under board\evb\ble_scatternet in SDK folder structure. Developers can choose the project according to the Board Name and choose the Build Target according to the flash map.

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_8M_xxx build target, the sample is configured to compile and run with an 8M flash map.

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

To quickly set up the development environment, please refer to the detailed instructions provided in Quick Start.

Wiring

Please refer to EVB Interfaces and Modules in Quick Start.

The sample requires support for user command interface. For specific wiring instructions, please refer to Data UART Connection in User Command Interface.

Configurations

Configurable Items

All contents that can be configured for the sample are in src\sample\ble_scatternet\app_scatternet_flags.h, developers can configure according to actual needs.

/** @brief  Config APP LE link number */
#define APP_MAX_LINKS  2
/** @brief  Config airplane mode support: 0-Not built in, 1-built in, use user command to set*/
#define F_BT_AIRPLANE_MODE_SUPPORT          0
/** @brief  Config device name characteristic and appearance characteristic property: 0-Not writeable, 1-writeable, save to flash*/
#define F_BT_GAPS_CHAR_WRITEABLE            0
/** @brief  Config set physical: 0-Not built in, 1-built in, use user command to set*/
#define F_BT_LE_5_0_SET_PHY_SUPPORT         1
/** @brief  Config local address type: 0-public address, 1-static random address */
#define F_BT_LE_USE_STATIC_RANDOM_ADDR      0
  • Set airplane mode:

    To open airplane mode, F_BT_AIRPLANE_MODE_SUPPORT should be configured. For more information, please refer to Airplane Mode Setting.

  • GAP service characteristic writeable:

    Need to configure F_BT_GAPS_CHAR_WRITEABLE to open. More information can be found in the chapter GAP Service Characteristic Writable of LE Host.

  • Use static random address:

    Need to configure F_BT_LE_USE_STATIC_RANDOM_ADDR to open. More information can be found in the chapter Local Static Random Address of LE Host.

  • PHY setting:

    Need to configure F_BT_LE_5_0_SET_PHY_SUPPORT to open. More information can be found in the chapter Physical (PHY) Setting of LE Host.

Generating System Config File

Developers shall configure the following items through MCUConfig Tool:

MCUConfig Tool Configuration

Configurable Item

Value

LE link number

APP_MAX_LINKS

LE slave link number

≥ 1

LE master link number

≥ 1

Note

The sum of the LE master link number value and LE slave link number value configured by the developers should be greater than or equal to the APP_MAX_LINKS value configured in app_scatternet_flags.h.

For more information about MCUConfig Tool Configuration, please refer to MCUConfig Tool.

Building and Downloading

Take the project rtl87x3e_ble_scatternet.uvprojx and target ble_scatternet_4M_bank0 as an example. To build and run the sample with Keil development environment, follow the steps listed below:

  1. Open rtl87x3e_ble_scatternet.uvprojx.

  2. Choose the build target ble_scatternet_4M_bank0.

    ../../../_images/chose_build_target13.png
  3. Build the target.

    ../../../_images/building13.png

    After a successful build, the APP bin file ble_scatternet_bank0_MP-v0.0.0.0-xxx.bin will be generated in the directory bin\rtl87x3e\flash_4M_dualbank\bank0.

  4. Download APP bin into EVB.

  5. Press the reset button on the EVB and it will start running.

Experimental Verification

After downloading the sample bin to the EVB, developers can test it by using 2 kits running the LE Peripheral sample and the LE Central sample respectively.

Testing with Other Kits

Prepare three development boards named DUT, Tester 1, and Tester 2 respectively. Developers can capture SoC logs using Debug Analyzer.

Preparation Phase

  1. Use MCUConfig Tool set DUT address to [00:11:22:33:44:80], and then build the LE scatternet sample, and download images into DUT. Developers can enter the user command in the serial port assistant tool in PC. For more information, please refer to How to Use Commands in User Command Interface.

  2. Use MCUConfig Tool set Tester 1 address to [00:11:22:33:44:81], and then build the LE peripheral sample, and download images into Tester 1. For more information, please refer to Building and Downloading in LE Peripheral.

  3. Use MCUConfig Tool set Tester 2 address to [00:11:22:33:44:85], and then build the LE central sample, and download images into Tester 2. For more information, please refer to Building and Downloading in LE Central.

For details about how to change the Bluetooth Address, please refer to MCUConfig Tool.

Testing Phase

Due to support of Peripheral Role and Central Role, the test procedure is a combination of test procedures in LE Peripheral and LE Central.

Connect with Tester 1
  1. Press the reset button on Tester 1 and Tester 1 will start sending connectable undirected advertising events.

    If the advertisement is successfully enabled, the following Debug Analyzer log will be printed. If developers don’t see the following log, it means that the advertisement failed to start. Please check if the software and hardware environment is configured correctly.

    [APP] !**app_peripheral_adv_callback: BLE_EXT_ADV_MGR_ADV_ENABLED
    
  2. Press reset button on DUT and developers can enter the user command in the serial port assistant tool on the PC.

    If the DUT successfully boots up and the serial port assistant tool configuration is successful, developers will see the following log. The serial port assistant tool will display the local address. If developers don’t see the following log, please check if the software and hardware environment is configured correctly.

    local bd addr: xx:xx:xx:xx:xx:xx
    

    Test flow between DUT and Tester 1 of this part is shown as below:

    Step

    DUT User Command

    Description

    DUT Log

    1

    bondclear

    Clear bonding information on DUT-end.

    Debug Analyzer shows:

    [GAP] !**le_clear_all_keys

    2

    scan

    DUT start scanning and viewing information on LE device nearby discovered.

    Debug Analyzer shows:

    [APP] !**GAP scan start

    [APP] app_scan_cb: BLE_SCAN_REPORT event_type 0x13, bd_addr 00::11::22::33::44::80, addr_type 0, rssi -17, data status 0x0

    3

    stopscan

    Stop scanning.

    Debug Analyzer shows:

    [APP] !**GAP scan stop

    4

    showdev

    Show scan device list, the device list is filtered by simple LE service UUID.

    Serial port assistant tool shows:

    Advertising and Scan response: filter uuid = 0xA00A dev list

    RemoteBd[0] = [00:11:22:33:44:81] type = 0

    5

    condev 0

    Initiate connection as Central role.

    Serial port assistant tool shows:

    Connected success conn_id 0

Connect with Tester 2

Press the reset button on Tester 2 so developers can enter the user command in the serial port assistant tool on the PC.

If Tester 2 successfully boots up and the serial port assistant tool configuration is successful, developers will see the following log. The serial port assistant tool will display the local address. If developers don’t see the following log, please check if the software and hardware environment is configured correctly.

local bd addr: xx:xx:xx:xx:xx:xx

The test flow between DUT and Tester 2 for this part is shown below:

Step

DUT User Command

Tester 2 User Command

Description

Tester 2 Log

DUT Log

6

bond clear

Clear bonding information on Tester 2 -end.

Debug Analyzer shows:

[GAP] !**le_clear_all_keys

7

startadv

DUT send connectable and scannable undirected advertising events.

Debug Analyzer shows:

[APP] !**GAP adv start

8

scan

Tester 2 starts scanning and viewing information on LE device nearby discovered.

Debug Analyzer shows:

[APP] !**GAP scan start

[APP] app_scan_cb: BLE_SCAN_REPORT event_type 0x13, bd_addr 00::11::22::33::44::80, addr_type 0, rssi -17, data status 0x0

9

stopscan

Tester 2 stops scanning.

Debug Analyzer shows:

[APP] !**GAP scan stop

10

showdev

Show scan device list, the device list is filtered by simple LE service UUID.

Serial port assistant tool shows:

Advertising and Scan response: filter uuid = 0xA00A dev list

RemoteBd[0] = [00:11:22:33:44:80] type = 0

11

condev 0

Tester 2 initiates the connection establishment with DUT, 0 indicates the index of DUT.

Serial port assistant tool shows:

Connected success conn_id 0

12

showcon

Show the established connections on DUT-end.

Serial port assistant tool shows:

ShowCon conn_id 0 state 0x00000002 role 1

RemoteBd = [00:11:22:33:44:81] type = 0

ShowCon conn_id 1 state 0x00000002 role 2

RemoteBd = [00:11:22:33:44:85] type = 0

active link num 2, idle link num 0

Interact with Tester 1 and Tester 2

At this point, DUT has successfully established connections with Tester 1 and Tester 2 in the Central and Peripheral roles respectively. Next, the following test items will be executed:

Step

DUT User Command

Tester 2 User Command

Description

Tester 2 Log

DUT Log

13

sauth 0

DUT send pairing request to Tester 1.

Serial port assistant tool shows:

Pair succes

14

disc 0

Terminate the connection with Tester 1.

Serial port assistant tool shows:

Disconnect conn_id 0

15

disc 1

Terminate the connection with Tester 2.

Serial port assistant tool shows:

Disconnect conn_id 1

16

condev 0

DUT reconnect with Tester 1.

Serial port assistant tool shows:

Connected success conn_id 0

17

startadv

DUT send connectable and scannable undirected advertising events.

Serial port assistant tool shows:

GAP adv start

18

condev 0

Tester 2 reconnect with DUT.

Serial port assistant tool shows:

Connected success conn_id 0

Pair success

19

sauth 0

DUT sends pairing request to Tester 1.

Serial port assistant tool shows:

Pair success

20

conupdreq 1 x30 x40 0 1000

DUT sends connection parameters update request to Tester 2.

Debug Analyzer shows:

[APP] !**app_handle_conn_param_update_evt update success:conn_id 0, conn_interval 0x3c, conn_slave_latency 0x0, conn_supervision_timeout 0x3e8

Debug Analyzer shows:

[APP] !**app_handle_conn_param_update_evt update success:conn_id 1, conn_interval 0x3c, conn_slave_latency 0x0, conn_supervision_timeout 0x3e8

21

conupdreq 0 x30 x40 0 1000

DUT sends connection parameters update request to Tester 1.

Debug Analyzer shows:

[APP] !**app_handle_conn_param_update_evt update success:conn_id 0, conn_interval 0x3c, conn_slave_latency 0x0, conn_supervision_timeout 0x3e8

22

setphy 1 1

DUT sets the PHY with Tester 2 to 2M.

Debug Analyzer shows:

[APP] !**GAP_MSG_LE_PHY_UPDATE_INFO:conn_id 0, cause 0x0, rx_phy 2, tx_phy 2

Debug Analyzer shows:

[APP] !**GAP_MSG_LE_PHY_UPDATE_INFO:conn_id 1, cause 0x0, rx_phy 2, tx_phy 2

23

setphy 0 1

DUT set the PHY with Tester 1 to 2M.

Debug Analyzer shows:

[APP] !**GAP_MSG_LE_PHY_UPDATE_INFO:conn_id 0, cause 0x0, rx_phy 2, tx_phy 2

24

simpdis 0

DUT initiates the discovery procedure, gets simple LE service information.

Debug Analyzer shows:

[APP] !**app_client_callback: discover simp procedure done

25

gapdis 0

DUT initiates the discovery procedure, gets GAP service information.

Debug Analyzer shows:

[APP] !**app_client_callback: GAPS_READ_DEVICE_NAME device name BLE_PERIPHERAL

Code Overview

This chapter will be introduced according to the following parts:

Source Code Directory

  • Project directory: board\evb\ble_scatternet.

  • Source code directory: src\sample\ble_scatternet.

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

└── ble_scatternet_4M_bank0
    ├── include                  ROM UUID header files. Developers do not need to modify it.
    ├── lib                      Includes all binary symbol files that user application is built on.
        ├── gap_utils.lib
        ├── ROM.lib
        ├── upperstack_4M.lib
        ├── hal_utils.lib
        ├── ble_mgr.lib
        └── sysm.lib
    ├── cmsis                    The cmsis source code. Developers do not need to modify it.
    ├── profile                  The LE profiles source code.
        ├── bas_client.c
        ├── gaps_client.c
        ├── simple_ble_client.c
        ├── bas.c
        └── simple_ble_service.c
    ├── app                      The application source code.
        ├── data_uart.c
        ├── user_cmd_parse.c
        ├── app_scatternet_main.c          Main entry
        ├── app_scatternet_gap.c           LE GAP initialize and message handler
        ├── app_scatternet_service.c       LE profile server role initialize
        ├── app_scatternet_client.c        LE profile client role initialize
        ├── app_scatternet_link_mgr.c      LE link utility
        ├── app_scatternet_user_cmd.c      User Command
        ├── app_scatternet_scan.c          Scan manager
        ├── app_scatternet_adv.c           Advertising manager
        └── app_scatternet_task.c          APP task
    └── io_hal

Initialization

main() function is invoked when the EVB is powered on and the chip boots up, and it performs the following initialization functions:

int main(void)
{
    board_init();
    le_gap_init(APP_MAX_LINKS);
    gap_lib_init();
    app_gap_init();
    app_service_init();
    app_client_init();
    pwr_mgr_init();
    task_init();
    os_sched_start();

    return 0;
}
  • le_gap_init() function is used to initialize GAP and configure link number.

  • app_service_init() function and app_client_init() function are used to initialize Profile.

  • app_gap_init() function is used to initialize the GAP parameters.

GAP Parameter Initialization

The app_gap_init() function is used to initialize the GAP parameters. Developers can easily customize the sample by modifying the following parameter values:

void app_gap_init(void)
{
    /* Device name and device appearance */
    uint8_t  device_name[GAP_DEVICE_NAME_LEN] = "BLE_SCATTERNET";
    uint16_t appearance = GAP_GATT_APPEARANCE_UNKNOWN;
    le_set_gap_param(GAP_PARAM_DEVICE_NAME, GAP_DEVICE_NAME_LEN, device_name);
    le_set_gap_param(GAP_PARAM_APPEARANCE, sizeof(appearance), &appearance);

    ......

    /* Setup the GAP Bond Manager */
    gap_set_param(GAP_PARAM_BOND_PAIRING_MODE, sizeof(auth_pair_mode), &auth_pair_mode);
    gap_set_param(GAP_PARAM_BOND_AUTHEN_REQUIREMENTS_FLAGS, sizeof(auth_flags), &auth_flags);
    gap_set_param(GAP_PARAM_BOND_IO_CAPABILITIES, sizeof(auth_io_cap), &auth_io_cap);
    gap_set_param(GAP_PARAM_BOND_OOB_ENABLED, sizeof(auth_oob), &auth_oob);
    le_bond_set_param(GAP_PARAM_BOND_FIXED_PASSKEY, sizeof(auth_fix_passkey), &auth_fix_passkey);
    le_bond_set_param(GAP_PARAM_BOND_FIXED_PASSKEY_ENABLE, sizeof(auth_use_fix_passkey),
                    &auth_use_fix_passkey);
    le_bond_set_param(GAP_PARAM_BOND_SEC_REQ_REQUIREMENT, sizeof(auth_sec_req_flags),
                    &auth_sec_req_flags);

    /* register GAP message callback */
    le_register_app_cb(app_gap_callback);

    /* ble manager module initialize*/
    app_gap_ble_mgr_init();
    ......
}
  1. le_set_gap_param()

  2. gap_set_param() and le_bond_set_param()

    Initialize GAP pairing parameters.

  3. le_register_app_cb()

    Register the GAP message callback function app_gap_callback(), and all GAP callback messages will be handled in this callback.

  4. app_gap_ble_mgr_init()

    Initialize the LE manager library. More information on LE manager library initialization can be found in the chapter LE Manager Initialization of LE Manager.

    void app_gap_ble_mgr_init(void)
    {
      BLE_MGR_PARAMS param = {0};
      param.ble_scan.enable = true;
      param.ble_ext_adv.enable = true;
      param.ble_ext_adv.adv_num = 1;
      ble_mgr_init(&param);
    }
    

More information on LE GAP initialization and startup flow can be found in the chapter GAP Parameters Initialization of LE Host.

GAP Message Handler

app_handle_gap_msg() function is invoked whenever a GAP message is received from the Bluetooth Host. More information on GAP messages can be found in the chapter Bluetooth LE GAP Message of LE Host.

When the sample handles GAP message, ble_mgr_handle_gap_msg() shall be called to handle the GAP message.

void app_handle_gap_msg(T_IO_MSG *p_gap_msg)
{
    T_LE_GAP_MSG gap_msg;
    uint8_t conn_id;
    memcpy(&gap_msg, &p_gap_msg->u.param, sizeof(p_gap_msg->u.param));
    ble_mgr_handle_gap_msg(p_gap_msg->subtype, &gap_msg);
    APP_PRINT_TRACE1("app_handle_gap_msg: subtype %d", p_gap_msg->subtype);
    switch (p_gap_msg->subtype)
    {
    case GAP_MSG_LE_DEV_STATE_CHANGE:
        {
            app_handle_dev_state_evt(gap_msg.msg_data.gap_dev_state_change.new_state,
                                    gap_msg.msg_data.gap_dev_state_change.cause);
        }
        break;

    ......

    default:
        APP_PRINT_ERROR1("app_handle_gap_msg: unknown subtype %d", p_gap_msg->subtype);
        break;
    }
}

GAP Callback Handler

app_gap_callback() function is used to handle GAP callback messages. More information on GAP callback can be found in the chapter Bluetooth LE GAP Callback of LE Host.

When the sample handles GAP callback, the ble_mgr_handle_gap_cb() shall be called to handle the callback message.

T_APP_RESULT app_gap_callback(uint8_t cb_type, void *p_cb_data)
{
   T_APP_RESULT result = APP_RESULT_SUCCESS;
   T_LE_CB_DATA *p_data = (T_LE_CB_DATA *)p_cb_data;
   ble_mgr_handle_gap_cb(cb_type, p_cb_data);

   ......
}

Profile Client Message Callback

When xxx_add_client is used to register a specific client, the callback function shall be registered to handle the message from the specific client. Developers can register different callback functions to handle different clients or register the common callback function to handle all messages from specific clients.

app_client_callback() function is the common callback function. app_client_callback() can distinguish different clients by client ID.

void app_le_profile_init(void)
{
   client_init(3);
   gaps_client_id  = gaps_add_client(app_client_callback, APP_MAX_LINKS);
   simple_ble_client_id = simp_ble_add_client(app_client_callback, APP_MAX_LINKS);
   bas_client_id = bas_add_client(app_client_callback, APP_MAX_LINKS);
}
T_APP_RESULT app_client_callback(T_CLIENT_ID client_id, uint8_t conn_id, void *p_data)
{
   T_APP_RESULT  result = APP_RESULT_SUCCESS;
   APP_PRINT_INFO2("app_client_callback: client_id %d, conn_id %d",
                   client_id, conn_id);
   if (client_id == gaps_client_id)
   {
       T_GAPS_CLIENT_CB_DATA *p_gaps_cb_data = (T_GAPS_CLIENT_CB_DATA *)p_data;
       switch (p_gaps_cb_data->cb_type)
       {
       case GAPS_CLIENT_CB_TYPE_DISC_STATE:
       ......
   }
}

LE scatternet sample supports several GATT profile clients including GAP service client, simple LE service lient and battery service client.

Profile Service Message Callback

When xxx_add_service is used to register a specific service, the callback function shall be registered to handle the message from the specific service. The developer shall call server_register_app_cb() to register the callback function used to handle the message from the profile server layer.

Developers can register different callback functions to handle different services or register the general callback function to handle all messages from specific services and profile server layer.

app_service_callback() function is the general callback function. app_service_callback() can distinguish different services by service ID.

void app_le_profile_init(void)
{
   server_init(2);
   simp_srv_id = simp_ble_service_add_service(app_service_callback);
   bas_srv_id  = bas_add_service(app_service_callback);
   server_register_app_cb(app_service_callback);
 }

More information can be found in the chapter GATT Profile Server of LE Host.

  • General profile server callback

    SERVICE_PROFILE_GENERAL_ID is the service ID used by the profile server layer. The message used by the profile server layer contains two message types:

    T_APP_RESULT app_service_callback(T_SERVER_ID service_id, void *p_data)
    {
       T_APP_RESULT app_result = APP_RESULT_SUCCESS;
       if (service_id == SERVICE_PROFILE_GENERAL_ID)
       {
           T_SERVER_APP_CB_DATA *p_param = (T_SERVER_APP_CB_DATA *)p_data;
           switch (p_param->eventId)
           {
           case PROFILE_EVT_SRV_REG_COMPLETE:
               APP_PRINT_INFO1("app_service_callback: PROFILE_EVT_SRV_REG_COMPLETE result %d",
                               p_param->event_data.service_reg_result);
               break;
    
           case PROFILE_EVT_SEND_DATA_COMPLETE:
               ......
               break;
           ......
    }
    
  • Battery Service

    bas_srv_id is the service ID of the battery service.

    T_APP_RESULT app_service_callback(T_SERVER_ID service_id, void *p_data)
    {
       T_APP_RESULT app_result = APP_RESULT_SUCCESS;
       ......
       else if (service_id == bas_srv_id)
       {
         T_BAS_CALLBACK_DATA *p_bas_cb_data = (T_BAS_CALLBACK_DATA *)p_data;
         switch (p_bas_cb_data->msg_type)
         {
         case SERVICE_CALLBACK_TYPE_INDIFICATION_NOTIFICATION:
               ......
    }
    
  • Simple LE Service

    simp_srv_id is the service ID of the simple LE service.

    T_APP_RESULT app_service_callback(T_SERVER_ID service_id, void *p_data)
    {
       T_APP_RESULT app_result = APP_RESULT_SUCCESS;
       ......
       else if (service_id == simp_srv_id)
       {
         TSIMP_CALLBACK_DATA *p_simp_cb_data = (TSIMP_CALLBACK_DATA *)p_data;
         switch (p_simp_cb_data->msg_type)
         {
         case SERVICE_CALLBACK_TYPE_INDIFICATION_NOTIFICATION:
              ......
    }
    

Airplane Mode Setting

  1. Register GAP Common Callback

    The developer needs to call gap_register_app_cb() to register a callback function.

    void app_le_gap_init(void)
    {
       ......
       gap_register_app_cb(app_gap_common_callback);
    }
    
  2. GAP Common Callback Handler

    void app_gap_common_callback(uint8_t cb_type, void *p_cb_data)
    {
       T_GAP_CB_DATA cb_data;
       memcpy(&cb_data, p_cb_data, sizeof(T_GAP_CB_DATA));
       APP_PRINT_INFO1("app_gap_common_callback: cb_type = %d", cb_type);
       switch (cb_type)
       {
       case GAP_MSG_WRITE_AIRPLAN_MODE:
          APP_PRINT_INFO1("GAP_MSG_WRITE_AIRPLAN_MODE: cause 0x%x",
                            cb_data.p_gap_write_airplan_mode_rsp->cause);
          break;
       case GAP_MSG_READ_AIRPLAN_MODE:
          APP_PRINT_INFO2("GAP_MSG_READ_AIRPLAN_MODE: cause 0x%x, mode %d",
                            cb_data.p_gap_read_airplan_mode_rsp->cause,
                            cb_data.p_gap_read_airplan_mode_rsp->mode);
          break;
       default:
          break;
       }
       return;
    }
    

    This callback function is used to handle the message GAP_MSG_WRITE_AIRPLAN_MODE and GAP_MSG_READ_AIRPLAN_MODE.

  3. Related APIs

    1. gap_write_airplan_mode() is used to write airplane mode.

    2. gap_read_airplan_mode() is used to read airplane mode.

    static T_USER_CMD_PARSE_RESULT cmd_wairplane(T_USER_CMD_PARSED_VALUE *p_parse_value)
    {
       T_GAP_CAUSE cause;
       uint8_t mode = p_parse_value->dw_param[0];
       cause = gap_write_airplan_mode(mode);
       return (T_USER_CMD_PARSE_RESULT)cause;
    }
    static T_USER_CMD_PARSE_RESULT cmd_rairplane(T_USER_CMD_PARSED_VALUE *p_parse_value)
    {
       T_GAP_CAUSE cause;
       cause = gap_read_airplan_mode();
       return (T_USER_CMD_PARSE_RESULT)cause;
    }