本文整理汇总了Python中gsmmodem.modem.GsmModem.sendUssd方法的典型用法代码示例。如果您正苦于以下问题:Python GsmModem.sendUssd方法的具体用法?Python GsmModem.sendUssd怎么用?Python GsmModem.sendUssd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gsmmodem.modem.GsmModem
的用法示例。
在下文中一共展示了GsmModem.sendUssd方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from gsmmodem.modem import GsmModem [as 别名]
# 或者: from gsmmodem.modem.GsmModem import sendUssd [as 别名]
def main():
print('Initializing modem...')
#logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.DEBUG)
modem = GsmModem(PORT, BAUDRATE)
modem.connect(PIN)
modem.waitForNetworkCoverage(10)
print('Sending USSD string: {0}'.format(USSD_STRING))
response = modem.sendUssd(USSD_STRING) # response type: gsmmodem.modem.Ussd
print('USSD reply received: {0}'.format(response.message))
if response.sessionActive:
print('Closing USSD session.')
# At this point, you could also reply to the USSD message by using response.reply()
response.cancel()
else:
print('USSD session was ended by network.')
modem.close()