cancel
Showing results for 
Search instead for 
Did you mean: 

STM32WBA55 Where to change the BLE advertising interval in code?

ledi7
Associate III

Hi,

i am playing with the code example BLE_p2pServer_ota with NUCLEO-WBA55 and i would like to change the BLE advertising intervall in the code (not with CubeMX).

For example, if I switch on the blue LED with using ST BLE Toolbox on the smartphone, the advertising interval should change to 100ms - 200ms after BLE disconnection. If I switch off the LED, the advertising interval should be reset to the default value after the BLE connection is disconnected.

My idea was to change paramA and ParamB in the file app_ble.c:

  /* Call ACI APIs */
  switch(ProcGapPeripheralId)
  {
    case PROC_GAP_PERIPH_ADVERTISE_START_FAST:
    case PROC_GAP_PERIPH_ADVERTISE_START_LP:
    case PROC_GAP_PERIPH_ADVERTISE_NON_CONN_START_FAST:
    case PROC_GAP_PERIPH_ADVERTISE_NON_CONN_START_LP:
    {
      /* Start Advertising */
      if (ledState == 1)
      {
    	  paramA = 0x64;	// new min time (100ms)
    	  paramB = 0xC8;	// new max time (200ms)
      }
      else if (ledState == 0)
      {
          paramA = ADV_INTERVAL_MIN;	// min time default value
          paramB = ADV_INTERVAL_MAX;	// max time default value
      }
      status = aci_gap_set_discoverable(paramD,
                                        paramA,
                                        paramB,
                                        CFG_BD_ADDRESS_TYPE,
                                        ADV_FILTER,
                                        0, 0, 0, 0, 0, 0);

But when i disconnect, nothing has changed.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ledi7
Associate III

The code is working :)

There was an error with ledState variable.

View solution in original post

1 REPLY 1
ledi7
Associate III

The code is working :)

There was an error with ledState variable.