#!/usr/bin/python import SparqEE #version 1 import re import signal import sys from datetime import datetime #----------------------------------------------------------------------------- try: SparqEE.cmd_setup() #set-up shield GPIO SparqEE.cmd_power() #power on f=open("/home/pi/private/numTel","r") num=f.readline() while(num.startswith('#')): num=f.readline() print("sending:"+num+ " size:"+str(len(num))) f.close() SparqEE.at_sms(num.strip(),"RASPBERRY STARTING AT\n "+str(datetime.now())) SparqEE.cmd_cleanup() SparqEE.closeSerial() #----------------------------------------------------------------------------- except: SparqEE.cmd_cleanup() #clean-up shield GPIO SparqEE.closeSerial() print "Unexpected error:", sys.exc_info()[0] raise
def debug(str): SparqEE.debug_print( str, SparqEE.debug["DEBUG"] ) def debug2(cmd, ret): debug(cmd) debug( "---> CMD RET --->: " + str(ret) ) debug( "---> BUFFER --->" + SparqEE.buffer ) #----------------------------------------------------------------------------- try: SparqEE.cmd_setup() #set-up shield GPIO SparqEE.cmd_power() #power on SparqEE.cmd_connection() #check cellular connection # +12223334444 #BASIC SMS ret = SparqEE.at_sms("+"+num, sms) debug2 ("STATUS", ret) #----------------------------------------------------------------------------- SparqEE.debug_print( "***END***", SparqEE.debug["WARNING"] ) SparqEE.cmd_cleanup() #clean-up shield GPIO except: SparqEE.debug_print( "***END (exception)***", SparqEE.debug["CRITICAL"] ) SparqEE.cmd_cleanup() #clean-up shield GPIO print ("Unexpected error:"), sys.exc_info()[0] raise
for cmp in range(1,len(retour)): chaine=retour[cmp] chaine=chaine.split("\n") print('split:'+chaine[0].split(',')[0]) debugFile.write(retour[cmp]) # if(str[0].startswith("+CMGL")): #Verifie qu'il ne s'agit pas d'une trame vide. numero=(chaine[0].split(','))[2] numero=numero[1:-1]#Remove quote # gotNum=True # else: message=chaine[1] message= "RASPBERRY ACCUSE RECEPTION:"+"\n"+message+"\n"+"HEURE:"+str(datetime.now()) # gotMessage=True # if(gotNum and gotMessage): ret=SparqEE.at_sms(numero,message) # gotNum=False # gotMessage=False if(ret==0): SparqEE.at_delSms() debugFile.close() SparqEE.cmd_cleanup() SparqEE.closeSerial() except: SparqEE.debug_print( "***END (exception)***", SparqEE.debug["CRITICAL"] ) SparqEE.cmd_cleanup() #clean-up shield GPIO SparqEE.closeSerial() print "Unexpected error:", sys.exc_info()[0] raise