本文整理汇总了Python中gsmmodem.modem.GsmModem.listStoredSms方法的典型用法代码示例。如果您正苦于以下问题:Python GsmModem.listStoredSms方法的具体用法?Python GsmModem.listStoredSms怎么用?Python GsmModem.listStoredSms使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gsmmodem.modem.GsmModem
的用法示例。
在下文中一共展示了GsmModem.listStoredSms方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getAllText
# 需要导入模块: from gsmmodem.modem import GsmModem [as 别名]
# 或者: from gsmmodem.modem.GsmModem import listStoredSms [as 别名]
def getAllText(key):
if key.strip() == '9703BB8D5A':
modem = GsmModem('/dev/ttyUSB0', 9600)
try:
print "Connecting modem"
modem.connect()
except Exception as e:
return str(e)
try:
messages = modem.listStoredSms()
except Exception as e:
return str(e)
modem.close()
retString = ""
print "Got %d messages" % len(messages)
for message in messages:
retString = retString + "%s : %s" % (message.number, message.text) + "\n"
return retString
else:
return "Incorrect key"
示例2: getUnreadText
# 需要导入模块: from gsmmodem.modem import GsmModem [as 别名]
# 或者: from gsmmodem.modem.GsmModem import listStoredSms [as 别名]
def getUnreadText(key):
if key.strip() == '9703BB8D5A':
modem = GsmModem('/dev/ttyUSB0', 9600)
try:
print "Connecting mode"
modem.connect()
except:
return "Error connecting"
try:
messages = modem.listStoredSms(status=Sms.STATUS_RECEIVED_UNREAD)
except Exception as e:
return str(e)
modem.close()
retString = ""
print "Got %d messages" % len(messages)
for message in messages:
retString = retString + "%s : %s" % (message.number, message.text)
return retString
else:
return "Incorrect key"