def smsProcessing(): message = sms.receiveSms() if message is not None: commands = sms_prot.parseCommand(CFG.get('PASS'), message.getText()) if(len(commands) > 0): if(commands[0].getCommand() == 'WRONG_PASSWORD'): print ('Wrong password') else: result = '' for c in commands: result = result + executeCommand(c) sms.sendSms(sms_msg.SmsMessage('0', message.getNumber(), '', result)) if(CFG.get('SMSDELETEALL') == '0'): sms.deleteSms(message.getId()) if(CFG.get('SMSDELETEALL') == '1'): sms.deleteSms(message.getId())
def receiveSms(): r, d = gsm.sendAT("AT+CMGL=ALL", "OK", 5) if (r == 0): position = d.find('+CMGL') if (position != -1): d = d[position:] one = d.split('\r') if (len(one) > 1): header = one[0].strip()[7:] data = one[1].strip() header_data = header.split(',') if (len(header_data) > 5): index = header_data[0] status = header_data[1].replace('"', '') number = header_data[2].replace('"', '') time = header_data[4].replace( '"', '') + ',' + header_data[5].replace('"', '') sms = sms_msg.SmsMessage(index, number, time, data) return sms return None
def sendAlert(text): for num in CFG.getList('ALERT'): print('Send alert to: %s\r' % (num)) sms.sendSms(sms_msg.SmsMessage('0', num, '', text))
def sendAlarm(text): r = -1; for num in CFG.getList('ALARMPHONES'): print 'Send alarm to: %s' % (num) r = sms.sendSms(sms_msg.SmsMessage('0', num, '', text)) return r