Skip to main content
MLiva
Associate III
June 11, 2020
Question

How to stop timeout on GAP advertising and connection.

  • June 11, 2020
  • 7 replies
  • 1732 views

..

This topic has been closed for replies.

7 replies

Remi QUINTIN
Technical Moderator
June 11, 2020

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
MLivaAuthor
Associate III
June 11, 2020

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
MLivaAuthor
Associate III
June 11, 2020

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 III
June 11, 2020

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
MLivaAuthor
Associate III
June 11, 2020

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
Technical Moderator
June 12, 2020

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
MLivaAuthor
Associate III
June 12, 2020

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.