Announcements

Help us improve the Power & Sensing Selection Guide. Share feedback

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

cross mob
Anonymous
Not applicable

I want to send single advertisement packet on particular event (data from serial interface) without entering Deep Sleep mode, In Project #009: Dynamic Broadcaster I use CyBle_GappStopAdvertisement() to stop advertisement (see code below). However, when I call CyBle_GappStartAdvertisement(CYBLE_ADVERTISING_FAST) it seems to be ignored. Why CyBle_GappStartAdvertisement(uint8 advertisingIntervalType) doesn't work?

   

int main()
{

    InitializeSystem();

   

    UART_1_Start();

   

    for(;;)
    {
        CyBle_ProcessEvents();

   

        rxData = UART_1_UartGetChar();
        if (rxData)
        {
            CyBle_GappStartAdvertisement(CYBLE_ADVERTISING_FAST);   
        }
        else
            CyBle_GappStopAdvertisement();

   

#if ENABLE_DYNAMIC_ADV       
        DynamicADVPayloadUpdate(rxData);
#endif

   

    }
}

0 Likes
1 Solution
Anonymous
Not applicable

It could be that your serial terminal is sending some extra bits (CR, etc) which might be screwing things up.. When I've used a similar method I tend to put UART_SpiUartClearRxBuffer() after UART_UartGetChar() just to clean up the received data.

   

It may also be useful to put if( UART_SpiUartGetRxBufferSize()) in front.

   

You might write instead:

   

        
        if (UART_1_SpiUartGetRxBufferSize())
        {
            CyBle_GappStartAdvertisement(CYBLE_ADVERTISING_FAST);  
            UART_1_SpiUartClearRxBuffer();
        }
        else
            CyBle_GappStopAdvertisement();

   

I would also check to see if the state is advertising (with CyBle_GetState() ) before sending stop advertising command because the stack might just keep throwing HCI status errors back at you.

   

There's probably a bteer solution but I hope this helps.

View solution in original post

0 Likes
2 Replies
Anonymous
Not applicable

It could be that your serial terminal is sending some extra bits (CR, etc) which might be screwing things up.. When I've used a similar method I tend to put UART_SpiUartClearRxBuffer() after UART_UartGetChar() just to clean up the received data.

   

It may also be useful to put if( UART_SpiUartGetRxBufferSize()) in front.

   

You might write instead:

   

        
        if (UART_1_SpiUartGetRxBufferSize())
        {
            CyBle_GappStartAdvertisement(CYBLE_ADVERTISING_FAST);  
            UART_1_SpiUartClearRxBuffer();
        }
        else
            CyBle_GappStopAdvertisement();

   

I would also check to see if the state is advertising (with CyBle_GetState() ) before sending stop advertising command because the stack might just keep throwing HCI status errors back at you.

   

There's probably a bteer solution but I hope this helps.

0 Likes
Anonymous
Not applicable

Thanks George_PR,

   

Issue was not related to UART itself, but to the approach I used. I was reading data from UART constantly in the loop, while BLE sub-system allows to send advertisement with minimum interval of 100 ms. So it was just unable to send any packet before I send stop signal.

   

Anyway your answer gave me some clue and feeling that I am not alone with my problem 🙂

0 Likes