1 Reply Latest reply on Apr 23, 2020 1:09 AM by AnjanaM_61

    Customising BLE_PROFILE_CFG parameters in the application

    RoHe_4370821

      Hi,

       

      I see within the examples such as hello_client.c that a BLE_PROFILE_CFG struct is defined with all parameters, for example hello_client_cfg

       

      const BLE_PROFILE_CFG hello_client_cfg =
      {
          /*.fine_timer_interval            =*/ 1000, // ms
          /*.default_adv                    =*/ HIGH_UNDIRECTED_DISCOVERABLE,
      
          etc etc...
          /*.encr_required                  =*/(SECURITY_ENABLED | SECURITY_REQUEST), 
      };
      

       

       

      During APPLICATION_INIT(), the hello_client_cfg is passed to bleapp_set_cfg()

       

      // Application initialization
      APPLICATION_INIT()
      {
          bleapp_set_cfg((UINT8 *)hello_client_gatt_database,
                         sizeof(hello_client_gatt_database),
                         (void *)&hello_client_cfg,
                         (void *)&hello_client_puart_cfg,
                         (void *)&hello_client_gpio_cfg,
                         hello_client_create);
      }
      

       

       

      However, the application code does not refer to this configuration. Instead, the application refers to the default configuration pointer, bleprofile_p_cfg. For example, within hello_client_connection_up() there is source code as follows:

       

      // if we connected as a master configure slave to enable notifications
      if (hello_client.dev_info[cm_index].role == MASTER)
      {
          if (bleprofile_p_cfg->encr_required == 0)
          {
              UINT16 u16 = 1;
              bleprofile_sendWriteReq(HANDLE_HELLO_SENSOR_CLIENT_CONFIGURATION_DESCRIPTOR, (UINT8 *)&u16, 2);
          }
          else
          {
              // following call will start bonding if devices are not pairing, or will request
              // encryption if bonding has been established before
              lesmp_setPtr(&hello_client.smp_info[cm_index]);
      
              lesmp_startPairing(NULL);
              ble_trace0("starting security");
          }
      
          // count number of slave connections
          hello_client.num_slaves++;
      }
      else
      {
          hello_client.handle_to_master = con_handle;
      
          // the code below may cause problem with iOS 6 and 7, fixed in iOS8
          if ((bleprofile_p_cfg->encr_required & SECURITY_REQUEST) != 0)
          {
              lesmp_sendSecurityRequest();
          }
      
          // ask master to set preferred connection parameters
          lel2cap_sendConnParamUpdateReq(100, 116, 0, 500);
      }
      

       

       

      1. In this example, how is the hello_client_cfg being used?
      2. Are the members of the underlying bleprofile_p_cfg struct copied into this application defined struct under-the-hood? i.e. does hello_client_cfg point to bleprofile_p_cfg after the call to bleapp_set_cfg()?
      3. Why is the hello_client_connection_up() is not making use of the hello_client_cfg config?
      4. When the custom config is passed into bleapp_set_cfg(), does the stack make use of it?
      5. I see there is a function named bleprofile_CFGRegister() which is defined within bleprofile.h - should the application make use of this function to register an application-specific BLE_PROFILE_CFG which will be used by both the application and the stack?

       

      /**
      * \brief Register Configuration
      * \ingroup bleprofile
      *
      * \details Application can call this function to overwrite default configuration.
      *
      * \param p_cfg Pointer to the BLE_PROFILE_CFG configuration structure.
      *
      */
      void bleprofile_CFGRegister(BLE_PROFILE_CFG *p_cfg);
      

       

      An explanation would be gratefully received!