Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset crashed device if needed #371

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions libgammu/phone/at/atgen.c
Expand Up @@ -4725,8 +4725,11 @@ GSM_Error ATGEN_Reset(GSM_StateMachine *s, gboolean hard)
}
smprintf(s, "Resetting device\n");

/* Siemens 35 */
error = ATGEN_WaitForAutoLen(s, "AT+CFUN=1,1\r", 0x00, 20, ID_Reset);
/* Regular phones */
error = ATGEN_WaitForAutoLen(s, "AT+CFUN=0\r", 0x00, 20, ID_Reset);
if (error == ERR_NONE) {
error = ATGEN_WaitForAutoLen(s, "AT+CFUN=1,1\r", 0x00, 20, ID_Reset);
}

if (error != ERR_NONE) {
/* Siemens M20 */
Expand Down
5 changes: 5 additions & 0 deletions smsd/core.c
Expand Up @@ -2196,6 +2196,11 @@ GSM_Error SMSD_MainLoop(GSM_SMSDConfig *Config, gboolean exit_on_failure, int ma
if (error == ERR_EMPTY) {
lastnothingsent = lastloop;
}
if (error == ERR_UNKNOWN) {
/* Huawei devices may return UNKNOWN errors. A soft reset may help to recover */
SMSD_LogError(DEBUG_INFO, Config, "Resetting the device because of error", error);
force_reset = TRUE;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really sure here - ERR_UNKNOWN can also easily happen when Gammu doesn't understand some response and it could easily lead to reset loop.

I'd rather recommend using ResetFrequency to reset phone in defined intervals (eg. weekly).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. However, I did not understand what happened until I thoroughly sniffed the AT command stream, and dug in gammu's code. At least, do you think the log files could be more explicit and give hints about this ResetFrequency when UNKNOWN errors are encountered?
I never payed attention to this feature until I saw it in the code (and I swear I read the documentation before using smsd :-) )

I get your point about a confusion about ERR_UNKNWON when Gammu doesn't understand some response. Do you think we should then distinguish two types of unknown errors, i.e. errors when Gammu does not understand, and errors when the dongle actually sends ERROR 500 messages over the wire? Because such an error 500 (= "unknown error" according to the AT standard) seems to be meaningful, at least for my dongle (more than if Gammu did not understand something).
Maybe we should also add a counter to prevent getting in a reboot loop?

My point is, I agree this may be dangerous, I agree I am using a crappy dongle, but I'm quite sure I'm not the only one to get such errors.
And I'm pretty sure 90% of the people getting such errors won't search as deep as I did. Giving them an out-of-the-box solution may ease their lives?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that error 500 is the most frequent you get from the AT modem. So assuming it is good reason to reset doesn't sound reasonable. I can as well mean that Gammu constructed command that modem doesn't understand and resetting in that case would not make the situation any better.

/* We don't care about other errors here, they are handled in SMSD_SendSMS */
}
if (Config->shutdown) {
Expand Down