faucamp / python-gsmmodem

Python module to control a GSM modem attached to the system: send/receive SMS messages, handle calls, etc
GNU Lesser General Public License v3.0
384 stars 302 forks source link

smsReceived Callback not working? #23

Closed EasyViber closed 10 years ago

EasyViber commented 10 years ago

Hi. First of all thanks for great Python module. I've planned to use it just for sending and receiving SMS. So first thing I did was testing sms_handler_demo.py. Example gets to "Waiting for SMS message..." part but it never reads any SMS and it never runs handleSms function.

I've tryed another code and I see that sending and reading of messages works (for example: modem.listStoredSms(0) reads all unread messages), but in my case modem.rxThread.join(2**31) never triggers smsReceivedCallbackFunc.

I've tried that on Raspberry Pi and Mac OS X and it's all the same. I'm using Huawei E3131 USB modem and modem.smsTextMode = True (it didn't work when set to False also). I guess I could write my own code using listStoredSms to check for new SMS from time to time, but callback seems to be more appropriate. Any idea why this doesn't work?

EasyViber commented 10 years ago

For now I use timer and modem.processStoredSms() to trigger smsReceivedCallbackFunc and for now that works fine.

cygnusb commented 10 years ago

Same issue here with Huawei 176. The solution is simple: Huawei devices tend to have multiple /dev/ttyUSBn devices (mostly 2 or 4). Notifications are only send to the last /dev/ttyUSBn device. My Huawei 176 has two devices /dev/ttyUSB0 does not receive notifications. /dev/ttyUSB1 works fine:

DEBUG: notification: ['^BOOT:21083438,0,0,0,25'] DEBUG: Unhandled unsolicited modem notification: ['^BOOT:21083438,0,0,0,25'] DEBUG: notification: ['^RSSI:22'] DEBUG: Unhandled unsolicited modem notification: ['^RSSI:22'] DEBUG: notification: ['^RSSI:22'] DEBUG: Unhandled unsolicited modem notification: ['^RSSI:22'] DEBUG: notification: ['^BOOT:21083438,0,0,0,25'] == SMS message received == From: 49XXXXXXXXX Time: 2014-04-02 21:28:22+02:00 Message: TestTest

faucamp commented 10 years ago

Thanks for this explanation, @cygnusb ! It's easy to forget about this feature of Huawei modems; I will update the documentation at some point to include this as an FAQ entry.