cancel
Showing results for 
Search instead for 
Did you mean: 

How to stop timeout on GAP advertising and connection.

MLiva
Associate III
 
7 REPLIES 7
Remi QUINTIN
ST Employee

The device is discoverable until the host issues the ACI_GAP_SET_NON_DISCOVERABLE command.

In a similar way for the connection, just send a ACI_GAP_TERMINATE command.

MLiva
Associate III

I am using my own P2PServer app which seem to timeout on discovery after 60 seconds. The official binary seem not to timeout so I can check the sources. However the official binary does not allow blue tooth PC or phone a connection!!!

MLiva
Associate III

OK, I retried again the official P2PServer app binary on the Nucleo board.

When the board resets the green LED2 blinks fast. If i don't connect to BLE the green LED2 will stop blinking after about 60s. Can I force the firmware to permanently advertise rather then timing out like this.

Scott Löhr
Senior II

In my P2P application running with the library stm32wb5x_BLE_Stack_full_fw.bin, I use aci_gap_set_discoverable() and the advertising is on forever until I explicitly make a call to aci_gap_set_non_discoverable(). Could it also be that simple for you, @MLiva​ ?

MLiva
Associate III

Thanks for the clue.

I checked the source code (app_ble.c) and it looks like the following lines cause the function aci_gap_set_non_discoverable() to be called eventually.

 /**

  * Create timer to handle the Advertising Stop

  */

 HW_TS_Create(CFG_TIM_PROC_ID_ISR, &(BleApplicationContext.Advertising_mgr_timer_Id), hw_ts_SingleShot, Adv_Cancel_Req);

 /**

  * Create timer to handle the Led Switch OFF

  */

 HW_TS_Create(CFG_TIM_PROC_ID_ISR, &(BleApplicationContext.SwitchOffGPIO_timer_Id), hw_ts_SingleShot, Switch_OFF_GPIO);

commenting the first line change the behaviour the way I wanted. However this code is generated by STM32CubeMX so each time I generate code it overwrites any changes I make. I could not see any configuration in STM32CubeMX that configures this behaviour.

Remi QUINTIN
ST Employee

Regarding keeping all code modifications, Could you check you ticked the "Keep User Code when regenerating" option of the Code generator item under the project management tab in CubeMX tool.

All changes have to be inserted within the /* USER CODE BEGIN ****/ and /* USER CODE END ****/to be identified as code to be protected against overwriting.

MLiva
Associate III

Yes the "Keep User Code when regenerating" is ticked. The problem is the code is generated by CubeMX and is not within a /* USER CODE BEGIN ****/ and /* USER CODE END ****/ area so is not marked as user code. I don't think I can forcefully mark it myself with a separate comment block. I think this might be a bug in CubeMX. If the feature to stop advertising after 60s intended for the P2PServer demo can not be configured by CubeMX to be on or off, then the CubeMX should provide a comment block for these calls so the user has the option to disable enable himself.