Closed thesabbir closed 8 years ago
Found how to make it human readable:
#!/usr/bin/env python
ORT = '/dev/ttyUSB1'
BAUDRATE = 115200
USSD_STRING = '*5000*500#'
from gsmmodem.modem import GsmModem
from gsmmodem import pdu
def main():
print('Initializing modem...')
#logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.DEBUG)
modem = GsmModem(PORT, BAUDRATE)
modem.connect(None)
modem.waitForNetworkCoverage(10)
response = modem.sendUssd(USSD_STRING)
_response = iter(pdu.toByteArray(response.message))
result = unicode(pdu.decodeUcs2(_response, _response))
print "Reply recieved:"
print result
if response.sessionActive:
print 'Closing USSD session.'
response.cancel()
else:
print 'USSD session was ended by network.'
modem.close()
if __name__ == '__main__':
main()
Mainly a documentation issue. Is there any better way to do it?
Thanks for the awesome library. Noob here. Output by running ussd example:
With debug: