PSOC 4 ANCS notification consumer receives undefined events

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

cross mob
mabo_1589021
Level 1
Level 1
First reply posted 5 sign-ins First question asked

I am writing a simple application to connect to apple devices and receive notifications using the ANCS service from IOS. I am able to connect and bond but I am receiving undefined events in the stack event handler. To elaborate, I manage the received events with a switch statement and in the "DEFAULT:" case I print out the event code received. After connecting and bonding with an IOS device, I receive event codes of 0x0111, 0x010C and 0x010A. I cannot find a reference to these events in the source files. For example, I receive event code 0x0021 which corresponds to CYBLE_EVT_GAP_AUTH_REQ in the file BLE_Stack.h, but I cannot find the references for these new codes. My application is almost identical to the Day 22 project in the 100 projects in 100 days example.

The application seems to function properly as is but I would like to handle these events properly instead of ignoring them.

Can anyone point me in the right direction or explain what these events are referring to?

Thanks,

Marc.

0 Likes
2 Replies
Owen_Zhang123
Moderator
Moderator
Moderator
5 questions asked 500 solutions authored 250 sign-ins

Where did you see these events? Is it in Ancs_EventHandler()?

Could you share the code where you print the event?

0 Likes
lock attach
Attachments are accessible only for community members.
mabo_1589021
Level 1
Level 1
First reply posted 5 sign-ins First question asked

The events are coming in the main stack handler (defined by CyBle_Start(StackEventHandler) in the main function). I added a new switch case named default: to handle all events that are not handled in the example code. In that default: case I simply print to the UART the eventCode parameter that is passed as an argument to the StackEventHandler. I have included my workspace if you want to see the entire code (but this is just a learning project).

Here is the code snippet that I use from the StackEventHandler.c :

void StackEventHandler(uint32 eventCode, void * eventParam)
{
    CYBLE_GATTC_HANDLE_VALUE_NTF_PARAM_T * handleValueNotification;
    uint16_t advertizingIntervalMaxValue = 0;
    CYBLE_BLESS_CLK_CFG_PARAMS_T clockConfig;
    CYBLE_GAP_AUTH_INFO_T authInfo;
    CYBLE_GAP_SMP_KEY_DIST_T KEY;
    
    switch(eventCode)
    {
        case CYBLE_EVT_STACK_ON:
        break;
.
.
.
        case 266:   // undocumented event received after bonding with ANCS Notification Provider (iPad)
            printf("Unknown event after bonding: 266\r\n");
            //***DEBUG***
            // set flag to request connection parameter change in main loop (only once per connection)
            connectionUpdateRequest = 1;
            //***DEBUG***
        break;

        case 268:   // undocumented event received after bonding with ANCS Notification Provider (iPad)
            printf("Unknown event after bonding: 268\r\n");
        break;
            
        case 273:   // undocumented event received after bonding with ANCS Notification Provider (iPad)
            printf("Unknown event after bonding: 273\r\n");
        break;
            
        default: 
            printf("UNPROGRAMMED EVENT #%ld\r\n",eventCode);
        break;
    }
}

I see this output on my terminal application:

CYBLE_STATE_ADVERTISING:
CYBLE_EVT_GATT_CONNECT_IND

Connected to a peer device.
Service changed indication. Redo service discovery.CYBLE_EVT_GATTC_HANDLE_VALUE_IND

Authentication complete. AUTHENTICATION_COMPLETED:
Security: Unauthenticated and Encryption
Bonding:yes
eKeySize: 0x10
err: 0x0
CYBLE_EVT_GAP_ENCRYPT_CHANGE

Encryption ON
Bonding complete. Negociated MTU size is 185
Unknown event after bonding: 273
Unknown event after bonding: 273
Unknown event after bonding: 273
Unknown event after bonding: 273
Unknown event after bonding: 273
Unknown event after bonding: 273
Unknown event after bonding: 273
Unknown event after bonding: 268
Unknown event after bonding: 268
Unknown event after bonding: 268
Unknown event after bonding: 268
Unknown event after bonding: 268
Unknown event after bonding: 268
Unknown event after bonding: 266
CYBLE_EVT_GATTC_LONG_PROCEDURE_END

 

I would like to handle those 3 events (273, 268, 266) that are received by the StackEventHandler function.

Any ideas where I could find out what these events are? Are they internal stack events that I should ignore or are they coming from the iPad through the Bluetooth connection?

Thanks,

Marc.

0 Likes