Update advertisement data fails - INVALID_OPERATION

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

cross mob
Anonymous
Not applicable

Hi,

   

I have a running project where i have the PSoC 4 BLE run in what is called multi-role.

   

Peripheral or central role combined with observer/broadcaster.

   

My current issue is that the latency for updating advertisement data is quiet large > 1 minute sometimes. And it is not clear to me why that is.

   

I update advertisement data upon changes in the system. These are queued until they are broadcasted using the advertisement packet.

   

code snippet:

   

        if ( CyBle_GetBleSsState() == CYBLE_BLESS_STATE_EVENT_CLOSE ) 
        {
             CYBLE_API_RESULT_T res = CyBle_GapUpdateAdvData(cyBle_discoveryModeInfo.advData,          cyBle_discoveryModeInfo.scanRspData);
        if ( res == CYBLE_ERROR_OK )
        {
            // Advertisement data updated
        }

   

}

   

My problem is that res == CYBLE_ERROR_INVALID_OPERATION

   

The device is broadcasting advertisement data at that point, so advertisements are enabled and it is in the correct BLESS State, so why do I get this error ?

0 Likes
6 Replies
Anonymous
Not applicable

If you can attach your project that would be much easier for debugging, but otherwise most of our comments will be speculation I think 🙂

0 Likes
user_2457466
Level 3
Level 3
10 replies posted 5 replies posted 5 questions asked

support case created for this.

0 Likes
user_2457466
Level 3
Level 3
10 replies posted 5 replies posted 5 questions asked

Update for future reference:

   

I used only fast scan to continuously scan for certain BLE advertisement events. The timing I used was the default values 30ms.

   

This meant that both scan window and scan interval was 30 ms. This caused my issue since there was almost no time where Rx/Tx were silent.

   

I changed the scan settings so that scan window < scan interval and this resolved the issue for me.

   

 

   

br,

   

Martin

0 Likes
Anonymous
Not applicable

I'm having a similar issue.

   

In my case changing the scan window did not help. I updated  BLE settings to remove the central role and still get CYBLE_ERROR_INVALID_OPERATION. calling CyBle_GapUpdateAdvData. This used to work so I must have done something. I'm at a loss what could cause this.

   

I added an  ISR and a WDT since last time this worked - not sure how this  has any bearing,just throwing it out there .

   

The comment for the function CyBle_GapUpdateAdvData says that the CYBLE_ERROR_INVALID_OPERATION  is returned in the following cases

   

CYBLE_ERROR_INVALID_OPERATION        | ADV Event is not closed, BLESS is active or ADV is not enabled.

   

Since CyBle_GapUpdateAdvData is called only when CyBle_GetBleSsState() == CYBLE_BLESS_STATE_EVENT_CLOSE I don't think the first 2 conditions apply. However how do I check if ADV is enabled? I'm assuming it is since the device is advertising. I can verify that in CySmart ( RSSI changes )

   

What else can cause CyBle_GapUpdateAdvData to return this error?

   

Any suggestions? I cannot share the project  in the open forum - too much proprietary stuff.

   

Thanks

0 Likes
Anonymous
Not applicable

Update

   

Actually making scan window < than interval did work.

   

This thread helped a lot

   

https://electronics.stackexchange.com/questions/82098/ble-scan-interval-and-window

0 Likes
user_2457466
Level 3
Level 3
10 replies posted 5 replies posted 5 questions asked

Hi Andy. Glad you made it work. The reason that the update fails if window = interval is that updates can only take place when Tx/Rx is idle... which is never the case when window == interval.

   

 

   

br,

   

Martin

0 Likes