/********************************************************************* * @fn TimeApp_ProcessEvent * * @brief Time App Application Task event processor. This function * is called to process all events for the task. Events * include timers, messages and any other user defined events. * * @param task_id - The OSAL assigned task ID. * @param events - events to process. This is a bit map and can * contain more than one event. * * @return events not processed */ uint16 TimeApp_ProcessEvent( uint8 task_id, uint16 events ) { VOID task_id; // OSAL required parameter that isn't used in this function if ( events & SYS_EVENT_MSG ) { uint8 *pMsg; if ( (pMsg = osal_msg_receive( timeAppTaskId )) != NULL ) { timeApp_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 & START_DEVICE_EVT ) { // Start the Device VOID GAPRole_StartDevice( &timeAppPeripheralCB ); // Register with bond manager after starting device GAPBondMgr_Register( (gapBondCBs_t *) &timeAppBondCB ); return ( events ^ START_DEVICE_EVT ); } if ( events & START_DISCOVERY_EVT ) { if ( timeAppPairingStarted ) { // Postpone discovery until pairing completes timeAppDiscPostponed = TRUE; } else { timeAppDiscState = timeAppDiscStart(); } return ( events ^ START_DISCOVERY_EVT ); } if ( events & CLOCK_UPDATE_EVT ) { timeAppClockDisplay(); // Restart clock tick timer osal_start_timerEx( timeAppTaskId, CLOCK_UPDATE_EVT, DEFAULT_CLOCK_UPDATE_PERIOD ); return ( events ^ CLOCK_UPDATE_EVT ); } // Discard unknown events return 0; }
/********************************************************************* * @fn SimpleBLEPeripheral_ProcessEvent * * @brief Simple BLE Peripheral Application Task event processor. This function * is called to process all events for the task. Events * include timers, messages and any other user defined events. * * @param task_id - The OSAL assigned task ID. * @param events - events to process. This is a bit map and can * contain more than one event. * * @return events not processed */ uint16 SimpleBLEPeripheral_ProcessEvent( uint8 task_id, uint16 events ) { VOID task_id; // OSAL required parameter that isn't used in this function if ( events & SYS_EVENT_MSG ) { uint8 *pMsg; if ( (pMsg = osal_msg_receive( simpleBLEPeripheral_TaskID )) != NULL ) { simpleBLEPeripheral_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 & SBP_START_DEVICE_EVT ) { // << Wayne >> << -23dB TX Power >> ++ HCI_EXT_SetTxPowerCmd(LL_EXT_TX_POWER_MINUS_23_DBM); // << Wayne >> << -23dB TX Power >> -- // Start the Device VOID GAPRole_StartDevice( &simpleBLEPeripheral_PeripheralCBs ); // Start Bond Manager VOID GAPBondMgr_Register( &simpleBLEPeripheral_BondMgrCBs ); // Set timer for first periodic event osal_start_timerEx( simpleBLEPeripheral_TaskID, SBP_PERIODIC_EVT, SBP_PERIODIC_EVT_PERIOD ); return ( events ^ SBP_START_DEVICE_EVT ); } if ( events & SBP_PERIODIC_EVT ) { // Restart timer if ( SBP_PERIODIC_EVT_PERIOD ) { osal_start_timerEx( simpleBLEPeripheral_TaskID, SBP_PERIODIC_EVT, SBP_PERIODIC_EVT_PERIOD ); } // Perform periodic application task performPeriodicTask(); return (events ^ SBP_PERIODIC_EVT); } // << Wayne >> << Clock >> ++ if ( events & SBP_CLOCK_UPDATE_EVT ) { if ( DEFAULT_CLOCK_UPDATE_PERIOD ) { osal_start_timerEx( simpleBLEPeripheral_TaskID, SBP_CLOCK_UPDATE_EVT, DEFAULT_CLOCK_UPDATE_PERIOD ); } timeAppClockDisplay(); if(storeCloseTime(23,59)) { UART_SEND_DEBUG_MSG( "Action > CleanCounter\r\n", 23 ); dbExchangeCounter = 0; } // Restart clock tick timer return (events ^ SBP_CLOCK_UPDATE_EVT); } // << Wayne >> << Clock >> -- // << Wayne >> << Check Connect Overtime> > ++ if ( events & SBP_CONNECT_OVERTIME_EVT ) { Application_TerminateConnection(); UART_SEND_DEBUG_MSG( "Action > Terminate\r\n", 20 ); return (events ^ SBP_CONNECT_OVERTIME_EVT); } // << Wayne >> << Check Connect Overtime> > -- // Discard unknown events return 0; }