当前位置: 首页>>代码示例>>Python>>正文


Python GsmModem.smsTextMode方法代码示例

本文整理汇总了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 )
开发者ID:Gynoid-M,项目名称:Oxypi-Project,代码行数:10,代码来源:sendData.py

示例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();
开发者ID:tomchy,项目名称:python-gsmmodem,代码行数:14,代码来源:sms_handler_demo.py

示例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))
开发者ID:jeedom,项目名称:plugin-sms,代码行数:40,代码来源:smsd.py

示例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()
开发者ID:archsh,项目名称:python-gsmmodem,代码行数:22,代码来源:sms_handler_demo.py

示例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:
开发者ID:radbasa,项目名称:py-smsmachine,代码行数:32,代码来源:blastmessage.py

示例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)
开发者ID:radbasa,项目名称:py-smsmachine,代码行数:33,代码来源:loadsmart.py

示例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):
#.........这里部分代码省略.........
开发者ID:babca,项目名称:plutaniumSmsServer,代码行数:103,代码来源:server.py


注:本文中的gsmmodem.modem.GsmModem.smsTextMode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。