Reputation: 13
My code below is for an emergency text. So if DU_Reason.bits.EmergencyDialIn
is set it will log into the network. Then if send_update
is set it will send Compose_Report()
. This is not a problem because send_update is cleared after the message is sent. But if tempalarm is set it will send a message and stay set unless it receives a message telling it to clear. This is to stop a message being sent constantly over and over when temp drops below limit. So if tempalarm has not been reset and if a leak is detected I want to only send the Compose_Leak_Report();
but it sends Compose_Temp_Report();
instead.
What is the way around doing this could anyone help.
if (DU_Reason.bits.EmergencyDialIn) {
if (Send_Update) {
Compose_Report();
GSM_Send_Text_Sms (GSM_Tx_Buff, SenderNum);
num_Leaks_month = 0;
monthly_timer = 0;
Send_Update = 0;
DU_Reason.bits.EmergencyDialIn = 0;
}
else if (TempAlarm) {
Compose_Temp_Report();
GSM_Send_Text_Sms (GSM_Tx_Buff, SenderNum);
DU_Reason.bits.EmergencyDialIn = 0;
}
else {
Compose_Leak_Report();
GSM_Send_Text_Sms (GSM_Tx_Buff, SenderNum);
DU_Reason.bits.EmergencyDialIn = 0;
}
Upvotes: 0
Views: 60
Reputation: 2547
I am modifying your code by adding one more variable TempAlarmTriggered
and initializing it with zero.
if (DU_Reason.bits.EmergencyDialIn) {
if (Send_Update) {
Compose_Report();
GSM_Send_Text_Sms (GSM_Tx_Buff, SenderNum);
num_Leaks_month = 0;
monthly_timer = 0;
Send_Update = 0;
DU_Reason.bits.EmergencyDialIn = 0;
}
else if ((TempAlarm) && (TempAlarmTriggered == 0)) {
TempAlarmTriggered = 1;
Compose_Temp_Report();
GSM_Send_Text_Sms (GSM_Tx_Buff, SenderNum);
DU_Reason.bits.EmergencyDialIn = 0;
}
else {
Compose_Leak_Report();
GSM_Send_Text_Sms (GSM_Tx_Buff, SenderNum);
DU_Reason.bits.EmergencyDialIn = 0;
}
When your temp resets clear both TempAlarmTriggered
and TempAlarm
.
Upvotes: 1