5 Replies Latest reply on Oct 4, 2019 3:42 AM by AnjanaM_61

    Size of notification

    AkKa_1343671

      I am trying to understand BLE_HelloSensor with CYBT-213043-MESH Evalution Kit.

      And I tried changing the size of notification,

      It will not be larger than 20.

      Even if wiced_bt_gatt_send_notification () is set to a length and data string exceeding 20, the receiving side will be 20 Bytes.

      Is this a send problem or a receive problem?

      Please let me know if any settings need to be changed.

        • 1. Re: Size of notification
          AnjanaM_61

          Hi,

           

          Can you please confirm which is your client device and what is the MTU size set ?

          Mostly the Central device which you are using will have an MTU set at 23 which is making the effective data to be send over the notification as (MTU  (23) -  3 bytes ) 20 bytes.

          Can you please provide the peer device info?

           

          Thanks,
          Anjana

          • 2. Re: Size of notification
            AkKa_1343671

            Hello Anjana-san,

             

            Thank you for your response.

             

            The opposite side is the same as CYBT-213043.

            These are equipped with CYW 20819.

            The sample firmware used is BLE_HelloClient_main.app.

             

            Where do I know the MTU setting?

            Or do I have to set intentionally?

             

            Best Regards,

            Kanda

            • 3. Re: Size of notification
              AnjanaM_61

              Hi Kanda San,

               

              Please check max_mtu_size  set in the wiced_bt_cfg_settings_t

              Refer to following thread: Re: We are trying to send the response of MTU_REQ using MTU_RES from peripheral to client. How to do that ?

               

              Thanks,

              Anjana

              • 4. Re: Size of notification
                AkKa_1343671

                Hello Anjana-san,

                 

                wiced_bt_cfg_settings_t

                     .gatt_cfg.max_attr_len = 507,

                     .gatt_cfg.max_mtu_size = 512

                 

                Server and Client are set.

                When is this value used?

                 

                Are there any other setting items required to make MTU larger than 23 Bytes?

                 

                Best Regards,

                Kanda

                • 5. Re: Size of notification
                  AnjanaM_61

                  Hello Kanda San,

                   

                  Sorry that I missed to update this thread.

                   

                  Please call wiced_bt_gatt_configure_mtu API to configure MTU greater than 20 in hello_client_gatt_connection_up on hello_client project .

                   

                  For example :

                  /* This function will be called on every connection establishment */

                  /* This function is invoked when connection is established */

                  wiced_bt_gatt_status_t hello_client_gatt_connection_up( wiced_bt_gatt_connection_status_t *p_conn_status )

                  {

                      uint8_t dev_role;

                      wiced_bt_dev_status_t status ;

                   

                   

                      if ( g_hello_client.num_connections > HELLO_CLIENT_MAX_CONNECTIONS )

                      {

                          WICED_BT_TRACE("g_hello_client max connect limit!\n");

                          wiced_bt_gatt_disconnect( p_conn_status->conn_id );

                          return WICED_BT_GATT_SUCCESS;

                      }

                   

                   

                      // Keep number of active connections

                      g_hello_client.num_connections++;

                   

                   

                      wiced_bt_dev_get_role( p_conn_status->bd_addr, &dev_role, BT_TRANSPORT_LE );

                   

                   

                      // Adding the peer info

                      hello_client_add_peer_info( p_conn_status->conn_id, p_conn_status->bd_addr, dev_role , p_conn_status->transport, p_conn_status->addr_type );

                   

                   

                      WICED_BT_TRACE( "hclient_connection_up Conn Id:%d Num conn:%d,Addr:<%B> role:%d\n ",

                         p_conn_status->conn_id, g_hello_client.num_connections, p_conn_status->bd_addr, dev_role );

                   

                   

                      // This application supports single connection to master (phone) and multiple connections to slaves (hello_sensors)

                      if ( dev_role == HCI_ROLE_MASTER )

                      {

                          WICED_BT_TRACE("Role master\r\n");

                          g_hello_client.conn_id = p_conn_status->conn_id;

                          status = wiced_bt_gatt_configure_mtu (p_conn_status->conn_id, 400);

                          WICED_BT_TRACE("Gatt MTU req send %d\r\n",status);

                      }

                      else // Connected as slave

                      {

                          // Update the connection handle to the master

                          g_hello_client.master_conn_id = p_conn_status->conn_id;

                   

                   

                          // Stop the advertisement

                          status =  wiced_bt_start_advertisements( BTM_BLE_ADVERT_OFF, 0, NULL );

                          WICED_BT_TRACE(" [%s] start adv status %d \n", __FUNCTION__, status);

                      }

                      UNUSED_VARIABLE(status);

                      return WICED_BT_GATT_SUCCESS;

                  }

                   

                   

                  Note: Please don't send any write commands to enable notification immediately after sending wiced_bt_gatt_configure_mtu  API.

                           You need to wait till MTU response and then only you should do next GATT operation.

                  In my case , I send enable notification on button press as below:

                   

                   

                   

                  /* This function is invoked on button interrupt events */

                  void hello_client_interrupt_handler(void* user_data, uint8_t value )

                  {

                      wiced_result_t  result;

                      int             num_slaves = 0;

                      static uint32_t button_pushed_time = 0;

                   

                   

                      //WICED_BT_TRACE( "But1 %d, But2 %d, But3 %d \n", value & 0x01, ( value & 0x02 ) >> 1, ( value & 0x04 ) >> 2 );

                      WICED_BT_TRACE( "hello_client_interrupt_handler, app timer :%d\n", g_hello_client.app_timer_count );

                   

                   

                      if ( wiced_hal_gpio_get_pin_input_status(HELLO_CLIENT_GPIO_BUTTON) == HELLO_CLIENT_BUTTON_PRESSED_VALUE )

                      {

                          WICED_BT_TRACE( " Button pressed\n" );

                          button_pushed_time = g_hello_client.app_timer_count;

                      }

                      else if ( button_pushed_time != 0 )

                      {

                          WICED_BT_TRACE( " Button released " );

                          //Start the scan if the button is pressed for more than 5 seconds

                          if ( g_hello_client.app_timer_count - button_pushed_time > 5 )

                          {

                  num_slaves = hello_client_get_num_slaves();

                              WICED_BT_TRACE( " after more than 5s, connecting to next slave number %d\n", num_slaves+1 );

                   

                   

                              if ( num_slaves < HELLO_CLIENT_MAX_SLAVES )

                              {

                                  start_scan = 1;

                                  if( wiced_bt_ble_get_current_scan_state() == BTM_BLE_SCAN_TYPE_NONE )

                                  {

                                      result = wiced_bt_ble_scan( BTM_BLE_SCAN_TYPE_HIGH_DUTY, WICED_TRUE, hello_client_scan_result_cback );

                                      WICED_BT_TRACE( "\nhello_client_interrupt_handler wiced_bt_ble_scan: %d\n", result );

                                  }

                              }

                              else

                              {

                                  WICED_BT_TRACE(" Scan Not Started. Connected to HELLO_CLIENT_MAX_SLAVES!! \n" );

                              }

                          }

                          else

                          {

                              WICED_BT_TRACE( " before less than 5s, sending notifications\n" );

                              hello_client_gatt_enable_notification( );

                          }

                      }

                  }

                   

                   

                  I tried and its working. Please test at your side.

                   

                  Regards,

                  Anjana