cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC™ 4

Anonymous
Not applicable

How can I change an advertisement packet...

I followed this tutorial...

PSoC-4-BLE/100_Projects_in_100_Days/Day009_Dynamic_Broadcaster at master · cypresssemiconductorco/PS...

and made my own version for my application.. I'm currently debugging it.

I set my Service Data to 0.

I need it to switch it from 0 to 1, and vice versa.

pastedImage_0.png

CYBLE_GAPP_DISC_MODE_INFO_T discoveryReport;

int main(void)

{

    CYBLE_API_RESULT_T apiResult;

    CyGlobalIntEnable; /* Enable global interrupts. */

    apiResult = CyBle_Start(StackEventHandler);

    /* Place your initialization/startup code here (e.g. MyInst_Start()) */

    for(;;)

    {

        CyBle_ProcessEvents();

        DynamicADVPayloadUpdate();

    }

}

void DynamicADVPayloadUpdate(void)

{

    if(CyBle_GetBleSsState() == CYBLE_BLESS_STATE_EVENT_CLOSE)

    {

        discoveryReport.advData->advData[14u] = 0x01;

        CyBle_GapUpdateAdvData(discoveryReport.advData, discoveryReport.scanRspData);

    }

}

void StackEventHandler(uint32 event, void *eventParam)

{

    switch(event)

    {

        /* Mandatory events to be handled by Find Me Target design */

        case CYBLE_EVT_STACK_ON:

        case CYBLE_EVT_GAP_DEVICE_DISCONNECTED:

            /* Start BLE advertisement for 30 seconds and update link

             * status on LEDs */

            CyBle_GappStartAdvertisement(CYBLE_ADVERTISING_FAST);

          break;

        case CYBLE_EVT_GAPP_ADVERTISEMENT_START_STOP:

            if(CyBle_GetState() == CYBLE_STATE_DISCONNECTED)

            {

                CyBle_GappStartAdvertisement(CYBLE_ADVERTISING_FAST);

            }

            break;

        default:

        break;

    }

}

Message was edited by: Cyrus Nikko Pante

0 Likes
1 Solution
Anonymous
Not applicable

CYBLE_BLESS_STATE_EVENT_CLOSE is an event state that occurs when the advertising radio is temporarily "off", meaning that there is no active wireless transmission at that time (iirc), which should occur automatically on its own when you are advertising. It is not related to deep sleep or hibernate.

Anytime the unit is advertising, it means that the radio is ready and will accept a connection from your central device if requested (barring the addition of security and other software checking.)

View solution in original post

3 Replies
Anonymous
Not applicable

It looks like you are doing it correctly. The only difference you would need would be to account for changing the value between 0x01 and 0x00 for your requirements

Anonymous
Not applicable

It is not working though... Learned that I need to

make this happen CyBle_GetBleSsState() == CYBLE_BLESS_STATE_EVENT_CLOSE

But how do I get to that State?

I saw that it needs to be hibernated or in sleep mode?

Also after that, can I connect to that device(set into a Peripheral) to my Central?

0 Likes
Anonymous
Not applicable

CYBLE_BLESS_STATE_EVENT_CLOSE is an event state that occurs when the advertising radio is temporarily "off", meaning that there is no active wireless transmission at that time (iirc), which should occur automatically on its own when you are advertising. It is not related to deep sleep or hibernate.

Anytime the unit is advertising, it means that the radio is ready and will accept a connection from your central device if requested (barring the addition of security and other software checking.)

View solution in original post