Giter VIP home page Giter VIP logo

Comments (10)

jthurner avatar jthurner commented on August 15, 2024

copied from faucamp#43 - just stumbled about this fork by accident but am not actively using the library anymore, so I am unlikely to be of much further help - sorry

According to the GSM spec, USSD responses can have the following status codes:

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

I've never seen 0 or 3, but the 4s and 5s don't have any message text fields (e.g. +CUSD: 4).
This response isn't matched by the cusd regex, which leads to a nullpointer exception in parseCusdResponse.

Also, having access to the statuscodes would be nice, to be able to differentiate between a network timeout and unsopperted operation.

I've made a rough patch which changes the second regex group to optional (improvements welcome...), adds the statuscode as variable to USSD() and changes sessionActive to a property.

However, I am unsure how to adapt this if block. It looks to me like that is basically setting the message to the last CUSD indication with statuscode !=2. Is that really intended behaviour? Because in the "normal" case, statuscode 2 is what you get for succesfull "oneshot" USSD commands (e.g. checking credit).

from python-gsmmodem.

babca avatar babca commented on August 15, 2024

Hi jthurner, it seems that I missed your USSD-statuscode-fixes branch in your repo. Is it safe to merge your commit?

from python-gsmmodem.

enviel avatar enviel commented on August 15, 2024

hi @jthurner and @babca what is the best way to fix this problem?
should i use @jthurner's fork?

from python-gsmmodem.

babca avatar babca commented on August 15, 2024

I merged his code into my USSD-statuscode-fixes branch. Please test this: https://github.com/babca/python-gsmmodem/tree/USSD-statuscode-fixes

If it will work, I will merge it to master.

from python-gsmmodem.

enviel avatar enviel commented on August 15, 2024

doesn't seem to work
first try it doesn't show response properly

Initializing modem...
Sending USSD string: *888#
USSD reply received:
+CGREG: 2
USSD session was ended by

second try i got error

Initializing modem...
Process Process-2:
Traceback (most recent cal
File "C:\Python27\lib\mu
self.run()
File "C:\Python27\lib\mu
self._target(*self._ar
File "D:\Work Data\Serve
modem.waitForNetworkCo
File "build\bdist.win32
erage
raise TimeoutException
TimeoutException: None

third try

Initializing modem..
Sending USSD string:
None

fourth try the device just become unusable like some other program is using it

could not open port u'com3': WindowsError(5, 'Access is denied.')

fifth

Initializing modem...
Sending USSD string: *888#
USSD reply received: None
USSD session was ended by network.

from python-gsmmodem.

babca avatar babca commented on August 15, 2024

Well I'm not on PC at the moment to test it myself, it would be needed to setup a logger and see what is going on. You can setup the logger to stdout/stderr, or to a file (set the log level to debug and show the live log with a command $ tail -f /tmp/path/to/my/logfile.log) and see an actual communication with the modem.

I will try to help, but I have two weeks of vacation now. :-)

from python-gsmmodem.

enviel avatar enviel commented on August 15, 2024

here is the AT command log when the error occur

http://pastebin.com/mSQH7rZe

the response is
DEBUG: write: AT+CUSD=1,"*111#",15
DEBUG: response: ['OK']
DEBUG: notification: ['+CUSD: 4']

meanwhile the non-error response is
DEBUG: write: AT+CUSD=1,"*111#",15
DEBUG: response: ['OK']
DEBUG: notification: ['+CUSD: 1,"Bal: Rp 2000.0\n1. Info pulsa/internet hemat\n2. Bonus Pulsa\n3. Isi Ulang Promo\n4. Cek Kuota\n5. Cek Pulsa Internet\n6. Yuk Solat\n7. Mau Cepat Kaya?\n8. Facebook",15']
DEBUG: write: AT+CUSD=2
DEBUG: response: ['OK']

from python-gsmmodem.

enviel avatar enviel commented on August 15, 2024

ups sorry misclicked the comment button

from python-gsmmodem.

jthurner avatar jthurner commented on August 15, 2024

Initializing modem...
Sending USSD string: *888#
USSD reply received:
+CGREG: 2
USSD session was ended by

The regex in the patch is rubbish, then. I'll fix this, though it may take another weak or so because I'm rather tied up with work atm.

from python-gsmmodem.

enviel avatar enviel commented on August 15, 2024

for now all i can do is this

#sessionActive = cusdMatches[0].group(1) == '1'
sessionActive = False
#message = cusdMatches[0].group(2)
message = lines

just so it doesn't crash and stop the script but still return the response

updated version

#sessionActive = cusdMatches[0].group(1) == '1'
linesJoined = ''.join(lines)
sessionEnd = linesJoined.startswith('+CUSD: 2')
if sessionEnd:
    sessionActive = False
#message = cusdMatches[0].group(2)
message = lines

from python-gsmmodem.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.