cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 6 MCU

Anonymous
Not applicable

Hi there,

We are looking to integrate continuous bluetooth advertisement into our finite state machine until a connection has been established. However we notice that after the first advertisement timeout, bluetooth fails to advertise and gets stuck in the state CY_BLE_ADV_STATE_ADV_INITIATED.

We concluded that it is an interrupt priority issue since from the BLE Stack Handler, we set pending the interrupt for our state machine (at line 253 of our attached project) whenever the advertisement state changes (on to off or off to on). However instead of executing the rest of the BLE Stack Handler, the state machine preempts its execution and attempts to advertise and calls ProcessEvents which we assume is the issue (trying to ProcessEvents before complete execution of the BLE Stack Handler).

We have set the priority of the state machine to be lower than the bless interrupt so we are unsure why this is occurring. Is the priority of the bless interrupt different from the BLE stack handler's?

It's unusual behavior because if we establish connection before the initial timeout and then disconnect, advertisement successfully restarts, times out, restarts, times out, and so on. In this case, the preemption by the state machine doesn't occur. We are curious why this change preemption is occurring?

Best,

Steve

1 Solution
Employee

Hi Steve,

One thing you missed here was to set the "is_Advertising" flag to true when the BLE starts advertising. In the project that you attached, since the "is_Advertising" is always false this will trigger the state machine to execute  which will try to restart the advertisement again and the process continues until the "is_Advertising" flag is set to true. I am attaching the modified project.

On another note, since you are registering the call back function Bluetooth_BleSsHandler using the Cy_BLE_RegisterAppHostCallback() API, you need not call the Cy_BLE_ProcessEvents in the for loop. This is handled in the Bluetooth_BleSsHandler callback function.

Let me know if this helps.

Regards,

Vaisakh

View solution in original post

0 Likes
Reply
1 Reply
Employee

Hi Steve,

One thing you missed here was to set the "is_Advertising" flag to true when the BLE starts advertising. In the project that you attached, since the "is_Advertising" is always false this will trigger the state machine to execute  which will try to restart the advertisement again and the process continues until the "is_Advertising" flag is set to true. I am attaching the modified project.

On another note, since you are registering the call back function Bluetooth_BleSsHandler using the Cy_BLE_RegisterAppHostCallback() API, you need not call the Cy_BLE_ProcessEvents in the for loop. This is handled in the Bluetooth_BleSsHandler callback function.

Let me know if this helps.

Regards,

Vaisakh

View solution in original post

0 Likes
Reply
Top labels