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
386 stars 304 forks source link

USSD Ordering issue (Initiating Release) #14

Closed jonathanendersby closed 11 years ago

jonathanendersby commented 11 years ago

Hi

I've found another ordering/sequence issue, this time with Vodacom's response to a USSD balance enquiry. I know this is unique to Vodacom because it doesn't happen with MTN, Telkom or Cell-C.

AT Log

.OK .AT+CSQ

.+CSQ: 11,0 . .OK .AT+CIMI

.655014247036844 . .OK .AT+CUSD=1,"*100#",15

.+CUSD: 2,"Initiating Release",15 . .+CUSD: 0,"Your balance is R49.96. Out of Airtime? Dial *111# for Airtime Advance. T&Cs apply.",15 . .OK .AT+COPS?

.+COPS: 0,0,"VodaCom-SA",2 . .OK .

Result

What this means is that I get a Timeout on my USSD call, and a my COPS call (print modem.write("AT+COPS?")) responds with:

['+CUSD: 2,"Initiating Release",15', '+CUSD: 0,"Your balance is R49.96. Out of Airtime? Dial *111# for Airtime Advance. T&Cs apply. ",15', 'OK']

So I imagine you're just not expecting that "+CUSD: 2" line.

From the 3gpp:

For an USSD response from the network, or a network initiated operation, the format is: +CUSD: [,,].

: integer type (shows the USSD response from the network or the network initiated operation) 0 no further user action required (network initiated USSD Notify, or no further information needed after mobile initiated operation) 1 further user action required (network initiated USSD Request, or further information needed after mobile initiated operation) 2 USSD terminated by network 3 other local client has responded 4 operation not supported 5 network time out --- And no, the oddity of Vodacom terminating the session and the giving you more info is not lost on me.
smn commented 11 years ago

This seems to be a modem related quirk, my psitek doesn't do it, my Vodacom 3G modem does the same.

faucamp commented 11 years ago

Thanks for the report, and apologies for the late reply - hectic day-job week. This should be relatively easy to detect, but it is indeed strange - I'll add it to the test edge cases and fix it right away. Can I ask which modem(s) you guys have seen this on? (I'm guessing ZTE - they seem to be very chatty, and Vodacom's 3G modems are mostly Huawei or ZTE)

faucamp commented 11 years ago

I've added tests and a fix for this in 0d2c749a68069fcf5f8b98f90a3cd39ce3e9ebc0 - please test it to ensure it works for you, and close the ticket if it's fine. Thanks!

jonathanendersby commented 11 years ago

This does indeed fix the issue, but exposes another issue which I will open an issue for now (and provide the fix). Thank you!

EDIT: And yes, this is a manufacturer: "Vodafone (ZTE)" and model "K3772-Z".