How to: Debug modems from kannel logs

Continue reading below only if you’re interested in how to decode the hex strings and other info in the kannel bearerbox.log:These are the errors that keep showing up repeatedly:2012-06-29 01:19:42 [1567] [6] DEBUG: AT2[usb0-modem]: TP-Validity-Period: 24.0 hours
2012-06-29 01:19:42 [1567] [6] DEBUG: AT2[usb0-modem]: –> AT+CMGS=153^M
2012-06-29 01:19:42 [1567] [6] DEBUG: AT2[usb0-modem]: <– >
2012-06-29 01:19:42 [1567] [6] DEBUG: AT2[usb0-modem]: send command status: 1
2012-06-29 01:19:42 [1567] [6] DEBUG: AT2[usb0-modem]: –>
2012-06-29 01:19:42 [1567] [6] DEBUG: AT2[usb0-modem]: –> ^Z
2012-06-29 01:19:45 [1567] [6] DEBUG: AT2[usb0-modem]: <– >
2012-06-29 01:19:45 [1567] [6] DEBUG: AT2[usb0-modem]: <– ERROR
2012-06-29 01:19:45 [1567] [6] ERROR: AT2[usb0-modem]: Generic error: ERROR
2012-06-29 01:19:45 [1567] [6] DEBUG: AT2[usb0-modem]: send command status: -1

It looks like what it’s doing is it keeps all failed SMS’s in its queue for a certain period of time, and keeps trying to resend SMS’s in its queue which in turn keep failing. Here’s some useful info:

–> AT+CMGS=153^M
This is the command to tell it to send a message.  The 153 is supposed to be the number of bytes in the string (although I count 154 bytes).  What follows is the hex string containing the number, the mesage, and other info, and then it sends a –> ^Z to denote the end of the message.

To extract the phone number from the hex string (this wasn’t online anywhere but I was able to figure this out by reconciling it with the message log):

Starting with the 6th byte, extract all bytes until you reach 00.  From the example above, this gets us: 20729100F0.  Next, the nibbles in each byte appear to be in litte-endian format, so reverse them.  This gets: 022719000F.  Finally, the F digit is just filler for phone numbers with an odd number of digits (so when there’s an even number of digits it’s not there), and the final number is 022719000 (the “Top-Up Origin” contact).

After the phone number, there seems to be two bytes of info and then the rest of the hex string is the actual message to send (the above one is in unicode).



Similar Articles

The World's Most Powerful Mobile Data Collection Platform

Start a FREE 30-day CommCare trial today. No credit card required.

Get Started

Learn More

Get the latest news delivered
straight to your inbox