How to refresh the BLE Limited period timeout pro-grammatically ?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
jamec_2673086
Level 3
Level 3
5 likes given First like received First like given

Hello,

I am novice to BLE Development.

Im ny project my BLE device GAP role is peripheral.

In my project i want to start BLE stack advertising on SW2 switch press & wait for 30s to connect any central device.

If any central device does not connect in 30s it should power BLE stack automatically.

In this case when my device start advertising & wait for timeout if anyone press sw2 again it should refresh timeout period to pre-defined value(30s).

Can i do this without using timer component ?

If yes then How ?

0 Likes
3 Replies
Anonymous
Not applicable

You will need to write software to handle the operation, but if you set the BLE component to timeout the advertising after 30 seconds, and just stop then start the advertisement whenever you receive a button press, then it should be feasible to do this without any timing components besides the BLE component's internal timing.

(You can always write a timer in software with interrupts if you are okay with a software abstraction of the timer component).

  • Setup the BLE component to do a fast + slow timeout total of 30 seconds.
  • Upon button press, check if BLE advertising already
  • If yes, then restart advertisement (stop, then start); I don't know for sure if there is a way to reset the advertisement timeout count?
  • If no, then start advertisement
  • After 30 seconds handle the timeout event on the advertisement and turn off the BLE advertisement (might automatically turn off the advertisement on its own)
0 Likes
jamec_2673086
Level 3
Level 3
5 likes given First like received First like given

Hi Pratt,

Thanks for your guidance.

I dig some deep & get to know that there is pre-defined library function CYBLE_API_RESULT_T CyBle_SoftReset (void) To Software reset BLE stack.

And after any BLE timeout(GAP limited discoverable mode,GAP pairing process,GATT response) CYBLE_EVT_TIMEOUT event will occur to be handled by event handler & consequences Advertisement will restart .

We can change this order by a block of logic.

Thank you.

It seems you have good experience in playing with BLE @ e.pratt_1639216

0 Likes
Anonymous
Not applicable

Huh; I missed the CyBle_SoftReset() function, but that is useful to know

That is correct, the CYBLE_EVT_TIMEOUT is the event you will want to do logic on based on the 30s timeout window

I spent a decent amount of time on a project for work, so I had to learn both the BLE and PSoC simultaneously; Sink or swim is a great way to learn stuff well

Thanks for the compliment; Good luck with finishing the project jagir_2673086

0 Likes