/** * @brief Central Profile Task event processing function. * * @param taskId - Task ID * @param events - Events. * * @return events not processed */ uint16 GAPCentralRole_ProcessEvent( uint8 taskId, uint16 events ) { if ( events & SYS_EVENT_MSG ) { uint8 *pMsg; if ( (pMsg = osal_msg_receive( gapCentralRoleTaskId )) != NULL ) { gapCentralRole_ProcessOSALMsg( (osal_event_hdr_t *) pMsg ); // Release the OSAL message VOID osal_msg_deallocate( pMsg ); } // return unprocessed events return (events ^ SYS_EVENT_MSG); } if ( events & GAP_EVENT_SIGN_COUNTER_CHANGED ) { // Sign counter changed, save it to NV VOID osal_snv_write( BLE_NVID_SIGNCOUNTER, sizeof( uint32 ), &gapCentralRoleSignCounter ); return ( events ^ GAP_EVENT_SIGN_COUNTER_CHANGED ); } // Discard unknown events return 0; }
/** * @brief Central Profile Task event processing function. * * @param taskId - Task ID * @param events - Events. * * @return events not processed */ uint16 GAPCentralRole_ProcessEvent( uint8 taskId, uint16 events ) { if ( events & SYS_EVENT_MSG ) { uint8 *pMsg; if ( (pMsg = osal_msg_receive( gapCentralRoleTaskId )) != NULL ) { gapCentralRole_ProcessOSALMsg( (osal_event_hdr_t *) pMsg ); // Release the OSAL message VOID osal_msg_deallocate( pMsg ); } // return unprocessed events return (events ^ SYS_EVENT_MSG); } if ( events & GAP_EVENT_SIGN_COUNTER_CHANGED ) { // Sign counter changed, save it to NV VOID osal_snv_write( BLE_NVID_SIGNCOUNTER, sizeof( uint32 ), &gapCentralRoleSignCounter ); return ( events ^ GAP_EVENT_SIGN_COUNTER_CHANGED ); } if ( events & START_ADVERTISING_EVT ) { if ( gapRole_AdvEnabled ) { gapAdvertisingParams_t params; // Setup advertisement parameters params.eventType = gapRole_AdvEventType; params.initiatorAddrType = gapRole_AdvDirectType; VOID osal_memcpy( params.initiatorAddr, gapRole_AdvDirectAddr, B_ADDR_LEN ); params.channelMap = gapRole_AdvChanMap; params.filterPolicy = gapRole_AdvFilterPolicy; if ( GAP_MakeDiscoverable( gapRole_TaskID, ¶ms ) != SUCCESS ) { gapRole_state = GAPROLE_ERROR; // Notify the application if ( pGapCentralRoleCB && pGapCentralRoleCB->broadcastCB ) { pGapCentralRoleCB->broadcastCB( gapRole_state ); } } } return ( events ^ START_ADVERTISING_EVT ); } // Discard unknown events return 0; }