#!/usr/bin/python
# coding=UTF-8
import RPi.GPIO as GPIO
import serial
import time
from threading import Timer
from EC200U import*      
rec_buff = ''
APN = 'CMNET'
iphone = '18601658437'
class EC200UCtr:#发AT指令控制模块
    def EC200U_AT(self):
        while(ec200u.ATinit('ATE0\r\n','OK')==0):#判断模块是否存在
            pass
        while(ec200u.ATinit('AT+CIMI\r\n','460')==0):#判断卡是否存在
            pass
        while(ec200u.ATinit('AT+CGATT?\r\n','+CGATT: 1')==0):#判断是否注册网络成功
            pass
ec200u=EC200U('/dev/ttyS0',115200)
ec200uctr=EC200UCtr()
ec200uctr.EC200U_AT()
GPIO.setmode(GPIO.BCM)
GPIO.setup(20,GPIO.OUT)#LED1
GPIO.setup(21,GPIO.OUT)#LED2
ec200u.ATSignle('AT+QAUDMOD=2\r\n','OK')#set phone channel
ec200u.ATSignle('ATD'+iphone+';\r\n','OK')#set call number
time.sleep(0.5)#单位是s
while True:
    pass
         
         