3 Replies Latest reply on Mar 29, 2020 6:42 PM by XinghaoZ_26

    如何在hci_serial_gatt_service demo里设置mtu为255

    YaTr_3516311

      Hi,

       

      我在hci_serial_gatt_service demo里设置mtu为255(测connectup的地方设置,在BTM_ENCRYPTION_STATUS_EVT的地方也设置过),两个地方都回复wiced_bt_gatt_configure_mtu failed :128。请问我应该如何设置这个mtu

        • 1. Re: 如何在hci_serial_gatt_service demo里设置mtu为255
          XinghaoZ_26

          请问你client端使用的哪个demo?wiced_bt_gatt_configure_mtu这个API要在client端调用才可以。

          我这边使用hci_audio_gateway (GATT Client)和hci_serial_gatt_service (GATT Server) 的demo进行测试,在hci_audio_gateway的connection_up event里调用这个API可以成功配置MTU size。

          wiced_result_t hci_control_le_connection_up( wiced_bt_gatt_connection_status_t *p_status )

          {

              uint32_t      conn_id = p_status->conn_id;

              uint8_t        role    = HCI_ROLE_MASTER; // tbd this should come from p_status

              wiced_bt_ble_sec_action_type_t  encryption_type;

              wiced_bt_dev_status_t status ;

           

           

              wiced_bt_dev_get_role( p_status->bd_addr, &role, p_status->transport);

           

           

              WICED_BT_TRACE( "hci_control_le_connection_up, id:%d bd (%B) role:%d \n:", p_status->conn_id, p_status->bd_addr, role );

           

           

              /* Stop le connection timer*/

              wiced_stop_timer( &hci_control_le_connect_timer );

           

           

              memcpy( le_control.conn[conn_id].bd_addr, p_status->bd_addr, BD_ADDR_LEN );

              le_control.conn[conn_id].state      = LE_CONTROL_STATE_IDLE;

              le_control.conn[conn_id].conn_id    = p_status->conn_id;

              le_control.conn[conn_id].peer_mtu  = GATT_DEF_BLE_MTU_SIZE;

           

           

              // if we connected as a master configure slave to enable notifications

              if ( hci_control_cb.pairing_allowed && ( role == HCI_ROLE_MASTER ) )

              {

                  wiced_result_t res;

                  if ( ( hci_control_find_nvram_id( p_status->bd_addr, BD_ADDR_LEN ) ) == 0 )

                  {

                      res = wiced_bt_dev_sec_bond( p_status->bd_addr, p_status->addr_type,

                              p_status->transport, 0, NULL );

                      WICED_BT_TRACE( "master role: after bond res:%d\n", res );

                  }

                  else // device already paired previous. Just do encryption

                  {

                      encryption_type = BTM_BLE_SEC_ENCRYPT;

                      res = wiced_bt_dev_set_encryption(p_status->bd_addr, p_status->transport, &encryption_type);

                      WICED_BT_TRACE( "master role: after encrypt res:%d\n",res );

                  }

              }

           

           

              status = wiced_bt_gatt_configure_mtu (p_status->conn_id, 255);

              WICED_BT_TRACE("GATT MTU configure result: %d \n", status);

           

           

              hci_control_le_send_connect_event( 0 /* TBD should come from p_status */, p_status->bd_addr, conn_id, role );

              return ( WICED_SUCCESS );

          }

           

          可以在client和server端看到下面的log:

          Client:

          Server:

          • 2. Re: 如何在hci_serial_gatt_service demo里设置mtu为255
            YaTr_3516311

            hci_serial_gatt_service的demo。 audio_getway是没有问题

            • 3. Re: 如何在hci_serial_gatt_service demo里设置mtu为255
              XinghaoZ_26

              wiced_bt_gatt_configure_mtu只能在client端调用,hci_serial_gatt_service在连接中是作为server端,无法调用这个API。