本文整理汇总了Python中gsmmodem.modem.GsmModem.smsTextMode方法的典型用法代码示例。如果您正苦于以下问题:Python GsmModem.smsTextMode方法的具体用法?Python GsmModem.smsTextMode怎么用?Python GsmModem.smsTextMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gsmmodem.modem.GsmModem
的用法示例。
在下文中一共展示了GsmModem.smsTextMode方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from gsmmodem.modem import GsmModem [as 别名]
# 或者: from gsmmodem.modem.GsmModem import smsTextMode [as 别名]
def main():
print("Iniciando modem...")
logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.DEBUG)
modem = GsmModem(PORT, BAUDRATE)
modem.smsTextMode = False
modem.connect(PIN)
sms=text()
modem.sendSms('649886178',sms )
示例2: main
# 需要导入模块: from gsmmodem.modem import GsmModem [as 别名]
# 或者: from gsmmodem.modem.GsmModem import smsTextMode [as 别名]
def main():
print('Initializing modem...')
# Uncomment the following line to see what the modem is doing:
logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.DEBUG)
modem = GsmModem(PORT, BAUDRATE, smsReceivedCallbackFunc=handleSms)
modem.smsTextMode = False
modem.connect(PIN)
print('Waiting for SMS message...')
try:
modem.rxThread.join(2**31) # Specify a (huge) timeout so that it essentially blocks indefinitely, but still receives CTRL+C interrupt signal
finally:
modem.close();
示例3: listen
# 需要导入模块: from gsmmodem.modem import GsmModem [as 别名]
# 或者: from gsmmodem.modem.GsmModem import smsTextMode [as 别名]
def listen():
global gsm
jeedom_socket.open()
logging.debug("Start listening...")
try:
logging.debug("Connecting to GSM Modem...")
gsm = GsmModem(_device, int(_serial_rate), smsReceivedCallbackFunc=handleSms)
if _text_mode == 'yes' :
logging.debug("Text mode true")
gsm.smsTextMode = True
else :
logging.debug("Text mode false")
gsm.smsTextMode = False
if _pin != 'None':
logging.debug("Enter pin code : "+_pin)
gsm.connect(_pin)
else :
gsm.connect()
if _smsc != 'None' :
logging.debug("Configure smsc : "+_smsc)
gsm.write('AT+CSCA="{0}"'.format(_smsc))
logging.debug("Waiting for network...")
gsm.waitForNetworkCoverage()
logging.debug("Ok")
try:
jeedom_com.send_change_immediate({'number' : 'network_name', 'message' : str(gsm.networkName) });
except Exception, e:
if str(e).find('object has no attribute') <> -1:
pass
logging.error("Exception: %s" % str(e))
try:
gsm.write('AT+CPMS="ME","ME","ME"')
gsm.write('AT+CMGD=1,4')
except Exception, e:
if str(e).find('object has no attribute') <> -1:
pass
logging.error("Exception: %s" % str(e))
示例4: main
# 需要导入模块: from gsmmodem.modem import GsmModem [as 别名]
# 或者: from gsmmodem.modem.GsmModem import smsTextMode [as 别名]
def main():
print('[%s] Initializing modem...' % datetime.datetime.now())
# Uncomment the following line to see what the modem is doing:
logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s', level=logging.DEBUG)
modem = GsmModem(PORT, BAUDRATE, smsReceivedCallbackFunc=handleSms)
modem.smsTextMode = False
modem.connect(PIN)
print('[%s] Initialized modem!' % datetime.datetime.now())
print('[%s] Sending Message...' % datetime.datetime.now())
cellnum = raw_input("Please Enter your phone number:")
text = raw_input("Please Enter your text message:")
print('Type:', type(text))
modem.sendSms(cellnum, unicode(text, 'gbk'))
print('[%s] Waiting for SMS message...' % datetime.datetime.now())
try:
modem.rxThread.join(2 ** 31)
# Specify a (huge) timeout so that it essentially blocks indefinitely,
# but still receives CTRL+C interrupt signal
finally:
modem.close()
示例5: GsmModem
# 需要导入模块: from gsmmodem.modem import GsmModem [as 别名]
# 或者: from gsmmodem.modem.GsmModem import smsTextMode [as 别名]
unit = sys.argv[1]
device = sys.argv[2]
message = "Message"
BAUDRATE = 115200
logging.basicConfig(filename="logs/" + unit + ".log", level = logging.DEBUG, format='%(asctime)s %(levelname)s: %(message)s');
# logging.info("Use file %s", file)
# logging.info("Use dev %s", device)
logging.info("Initializing modem...")
modem = GsmModem(device, BAUDRATE, smsReceivedCallbackFunc=handleSms)
modem.smsTextMode = True
modem.connect()
logging.info("Waiting for network coverage...")
modem.waitForNetworkCoverage(30)
with open( 'data/' + unit + '.csv', 'rU' ) as csvfile:
thisList = csv.reader(csvfile, delimiter=',', quotechar='"')
head = next(thisList)
totalrows = 0
for row in thisList:
totalrows += 1
phone = '0' + str(row[0])
logging.info("%s Send to %s", totalrows, phone)
try:
示例6: str
# 需要导入模块: from gsmmodem.modem import GsmModem [as 别名]
# 或者: from gsmmodem.modem.GsmModem import smsTextMode [as 别名]
unit = str(sys.argv[1])
device = str(sys.argv[2])
cardcode = str(sys.argv[3])
BAUDRATE = 115200
LOADCODE = '1510'
logging.basicConfig(filename="logs/" + unit + ".log", level = logging.DEBUG, format='%(asctime)s %(levelname)s: %(message)s');
# logging.info("Use file %s", file)
# logging.info("Use dev %s", device)
logging.info("Initializing modem...")
modem = GsmModem(device, BAUDRATE)
modem.smsTextMode = False
modem.connect()
logging.info("Waiting for network coverage...")
modem.waitForNetworkCoverage(30)
logging.info("Loading %s with %s", unit, cardcode)
call = modem.dial( LOADCODE + cardcode)
wasAnswered = False
while call.active:
if call.answered:
wasAnswered = True
logging.info("Call answered")
time.sleep(10.0)
示例7: start
# 需要导入模块: from gsmmodem.modem import GsmModem [as 别名]
# 或者: from gsmmodem.modem.GsmModem import smsTextMode [as 别名]
def start(self):
""" Samotne jadro daemona: setupneme GmailAPI, setupneme GSM modem a zacneme provadet nekonecnou smycku """
self.running = True
# (0) SETUP VIRTUAL SERIAL PORT FOR MODEM
if "virtualPortInitCommand" in myconfig['modem']:
try:
virtualSerialPortInstance = virtualSerialPort(myconfig['modem']['virtualPortInitCommand'])
virtualSerialPortInstance.start()
except:
pass
else:
virtualSerialPortInstance = None
# (1) SETUP GMAIL ACCESS
logging.info('Initializing GMAIL access...')
try:
gmailService = gmailUtils.get_service(self.cwd)
except RuntimeError as e:
print(str(e))
logging.critical(str(e))
if (virtualSerialPortInstance is not None):
virtualSerialPortInstance.stop()
#sys.exit(1)
self.stop()
######################################################################################################################################################
# (2) SETUP GSM MODEM + bind a "smsReceived" callback + poll gmail inbox
logging.info('Initializing GSM modem on {0} port @ {1} speed...'.format(myconfig['modem']['port'], myconfig['modem']['baudrate']))
modem = GsmModem(myconfig['modem']['port'], myconfig['modem']['baudrate'], smsReceivedCallbackFunc=self.incomingSmsHandler)
modem.smsTextMode = False
while self.running:
# start of gsm init loop
try:
modem.connect(myconfig['modem']['pin'])
except serial.SerialException:
logging.error('Error: Cannot connect to modem on serial port %s @ %s. Trying again in %d sec...' % (myconfig['modem']['port'], myconfig['modem']['baudrate'], myconfig['modem']['errorRetryWaitTime']))
time.sleep(myconfig['modem']['errorRetryWaitTime'])
except TimeoutException:
logging.error('Error: Serial device %s @ %s timeout. Trying again in %d sec...' % (myconfig['modem']['port'], myconfig['modem']['baudrate'], myconfig['modem']['errorRetryWaitTime']))
time.sleep(myconfig['modem']['errorRetryWaitTime'])
except PinRequiredError:
# Fatal error
logging.critical('Error: SIM card PIN required. Please provide PIN in the config file.')
self.stop()
return 1
except IncorrectPinError:
# Fatal error
logging.critical('Error: Incorrect SIM card PIN entered!')
self.stop()
return 1
else:
logging.info('Modem connected.')
try:
logging.info('Checking for network coverage...')
modem.waitForNetworkCoverage(8) # of seconds
except TimeoutException:
logging.warning('We can now start gmail inbox polling infinite loop.')
print('Network signal strength is not sufficient, please adjust modem position/antenna and try again.')
modem.close()
else:
logging.info('GSM modem is ready.')
logging.info('We are now handling all incoming SMS messages.')
try:
if (myconfig['incomingSmsHandlerSetup']['processStoredSms'] == "all"):
modem.processStoredSms(unreadOnly=False)
elif (myconfig['incomingSmsHandlerSetup']['processStoredSms'] == "unread"):
modem.processStoredSms(unreadOnly=True)
except Exception as e:
logging.critical("Nastal problem pri zpracovani drivejsich neprectenych SMS:")
raise
sys.exit(0)
else:
logging.info('We can now start gmail inbox polling infinite loop.')
try:
while self.running:
# start of main gmail loop
logging.debug('Checking incoming emails...')
newMessagesCount = self.incomingGmailHandler(gmailService, modem)
time.sleep(myconfig['general']['gmailQueueWaitingPeriod'] if newMessagesCount > 0 else myconfig['general']['gmailPollingInterval'])
# end of main gmail loop
except KeyboardInterrupt:
#sys.exit(0)
self.stop()
return 0
except Exception as e:
print("Nastala vyjimka v hlavni smycce daemona, viz log.")
logging.exception("Nastal problem v hlavni smycce:")
raise
finally:
print("Bye gmail loop.")
finally:
print("Bye stored sms handling try-cache.")
finally:
print("Bye.")
modem.close()
if (virtualSerialPortInstance is not None):
#.........这里部分代码省略.........