def waitRegister(): while(1): RX_API.resetWDT() r, d = sendAT('AT+CREG?', '+CREG: 0,1') if(r == 0): break MOD.sleep(20)
def smsProcessing(): RX_API.resetWDT() 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'): sms.sendSms(sms_msg.SmsMessage('0', message.getNumber(), '', 'WRONG PASSWORD')) else: result = '' for c in commands: result = result + executeCommand(c) if(int(CFG.get('SMS_ACK')) > 0): sms.sendSms(sms_msg.SmsMessage('0', message.getNumber(), '', result)) sms.deleteSms(message.getId())
def resetWatchdog(): MOD.watchdogReset() RX_API.resetWDT()
def sendAlert(text): for num in CFG.getList('ALERT'): RX_API.resetWDT() SER.send('Send alert to: %s\r' % (num)) sms.sendSms(sms_msg.SmsMessage('0', num, '', text))
CALENDAR = CALENDAR + 1 calendar.writeCalendar(CALENDAR) MOD.sleep(30) gsm.reboot() def calendarProcessing(): global CALENDAR if(CALENDAR > (int(CFG.get('ALIVESMS')) - 1)): calendar.writeCalendar(0) CALENDAR = 0 SER.send('Send heartbeat SMS\r') sendAlert('Device is alive.') if __name__ == "__main__": try: RX_API.resetWDT() SER.set_speed('115200') CFG.read() CFG.dump() INPUTS.read() INPUTS.dump() SER.send('Start GSM init\r') gsm.init() SER.send('Start SMS init\r') sms.init() SER.send('IO init\r')