static void handleExtraLongButtonPress(void) { /* Clear the long button pressed flag.*/ g_app_hw_data.long_or_short_button_pressed = FALSE; /* Sound three beeps to indicate pairing removal to user */ SoundBuzzer(buzzer_beep_thrice); HandleBondingRemoval(); }
/*----------------------------------------------------------------------------* * NAME * handleExtraLongButtonPress * * DESCRIPTION * This function contains handling of extra long button press, which * triggers pairing / bonding removal. * * PARAMETERS * tid [in] ID of timer that has expired * * RETURNS * Nothing *----------------------------------------------------------------------------*/ static void handleExtraLongButtonPress(timer_id tid) { if(tid == g_app_hw_data.button_press_tid) { /* Re-initialise button press timer */ g_app_hw_data.button_press_tid = TIMER_INVALID; /* Sound three beeps to indicate pairing removal to user */ SoundBuzzer(buzzer_beep_thrice); /* Handle pairing removal */ HandlePairingRemoval(); } /* Else ignore timer */ }
/*----------------------------------------------------------------------------* * NAME * HandlePIOChangedEvent * * DESCRIPTION * This function handles the PIO Changed event. * * PARAMETERS * pio_data [in] State of the PIOs when the event occurred * * RETURNS * Nothing *----------------------------------------------------------------------------*/ extern void HandlePIOChangedEvent(pio_changed_data *pio_data) { if(pio_data->pio_cause & BUTTON_PIO_MASK) { /* PIO changed */ uint32 pios = PioGets(); if(!(pios & BUTTON_PIO_MASK)) { /* This event is triggered when a button is pressed. */ /* Start a timer for EXTRA_LONG_BUTTON_PRESS_TIMER seconds. If the * timer expires before the button is released an extra long button * press is detected. If the button is released before the timer * expires a short button press is detected. */ TimerDelete(g_app_hw_data.button_press_tid); g_app_hw_data.button_press_tid = TimerCreate(EXTRA_LONG_BUTTON_PRESS_TIMER, TRUE, handleExtraLongButtonPress); } else { /* This event comes when a button is released. */ if(g_app_hw_data.button_press_tid != TIMER_INVALID) { /* Timer was already running. This means it was a short button * press. */ TimerDelete(g_app_hw_data.button_press_tid); g_app_hw_data.button_press_tid = TIMER_INVALID; /* Indicate short button press using short beep */ SoundBuzzer(buzzer_beep_short); HandleShortButtonPress(); } } } }
/*----------------------------------------------------------------------------* * NAME * handleANSGattCharValInd * * DESCRIPTION * This function handles alert notification profile specific * GATT_CHAR_VAL_IND messages received from the firmware. * These are received when a value on the server is changed, * causing a notification to be generated. * * RETURNS * Nothing *----------------------------------------------------------------------------*/ extern void handleANSGattCharValInd(GATT_CHAR_VAL_IND_T *ind) { uint8 alerts_cat; if(ind->handle == g_app_ans_data.new_alert_hndl) { /* Record this value. In this case, the value may be many * bytes long because it contains some text. We are not * interested in the text because we have no display. */ MemCopy(g_app_ans_data.new_alert_value, ind->value, 2); /* New alert will be indicated only if number does not match the last * indicated number */ alerts_cat = g_app_ans_data.new_alert_value[0]; /* check if alert category is in valid range or not. If it is not valid, * ignore this indication. */ if(IsAlertCategoryValid(alerts_cat) && (g_app_ans_data.last_num_new_alert[alerts_cat] != g_app_ans_data.new_alert_value[1])) { /* Store the new number received. * Will be used in next comparison */ g_app_ans_data.last_num_new_alert[alerts_cat] = g_app_ans_data.new_alert_value[1]; /* A new alert has been received. Indicate this with a beep sound */ SoundBuzzer(beep_short); /* Process this value */ HandleAlertUpdate(alert_type_new); } } else if(ind->handle == g_app_ans_data.unread_alert_hndl) { /* Record this value */ MemCopy(g_app_ans_data.unread_alert_status_value, ind->value, 2); /* Unread alert will be indicated only if number does not match the last * indicated number */ alerts_cat = g_app_ans_data.unread_alert_status_value[0]; /* check if alert category is in valid range or not. If it is not valid, * ignore this indication. */ if(IsAlertCategoryValid(alerts_cat) && (g_app_ans_data.last_num_unread_alert[alerts_cat] != g_app_ans_data.unread_alert_status_value[1])) { /* Store the new number received. * Will be used in next comparison */ g_app_ans_data.last_num_unread_alert[alerts_cat] = g_app_ans_data.unread_alert_status_value[1]; /* Process this value */ HandleAlertUpdate(alert_type_unread); } } else { /* This signal may be for other services(PAS) supported by this * application. */ } }