sim300模組AT指令C語言定義原始碼
阿新 • • 發佈:2019-02-06
//基本命令集
//------------------------------------------------------------------
const romchar AT_AT[] = {"AT\r\n"};
const romchar AT_CBC[] ={"AT+CBC\r\n"}; //檢查充電狀態,以及電池電量佔容量的百分比+CBC: 0,97,4164
const romchar AT_CREG[] = {"AT+CREG?\r\n"}; //查詢網路註冊狀態
const romchar AT_CREGINIT[] = {"AT+CREG=1\r\n"}; //初始化網路註冊狀態
const romchar AT_ATE[] = {"ATE0\r\n"}; //儲存當前的設定引數
const romchar AT_Save[] = {"AT&W\r\n"}; //儲存當前的引數
//0 disable slow clock 1 enable slow clock
const romchar AT_CSCLK[] = {"AT+CSCLK=1\r\n"}; //enable slow clock
//0 minimum ality 1 full ality (Default) 4 disable phone both transmit and receive RF circuits
const romchar AT_CFUN[] = {"AT+CFUN=1\r\n"}; //使模組在重啟後電源進入功能性的電平
const romchar AT_CGMR[] = {"AT+CGMR\r\n"}; //軟體版本標識
const romchar AT_CCID[] = {"AT+CCID\r\n"}; //獲得SIM卡標識
const romchar AT_CGSN[]={"AT+CGSN\r\n"}; //IMEI
const romchar AT_CSQ[]={"AT+CSQ\r\n"}; //訊號強度
const romchar AT_CSMINS[]={"AT+CSMINS?\r\n"}; //檢測SIM卡是否插入+CSMINS: 0,1
const romchar AT_COPS[]={"AT+COPS?\r\n"};
const romchar AT_CPOL[]={"AT+CPOL?\r\n"};
const romchar AT_REG_COPS[]={"AT+CPOL=1,2,\""};
//******************************************************************************
//SMS命令集
//------------------------------------------------------------------
const romchar AT_CMGF[] = {"AT+CMGF=1\r\n"}; //指定資訊的輸入輸出格式為文字格式
const romchar AT_CMGFNMEA[] = {"AT+CMGF=0\r\n"}; //指定資訊的輸入輸出格式為PDU格式
const romchar AT_CSCS[] = {"AT+CSCS=\"GSM\"\r\n"}; //AT+CSCS=“GSM”設定什麼樣的字型讓模組接受
const romchar AT_CMGS[] = {"AT+CMGS=\""}; //發簡訊
const romchar AT_CMGR[] = {"\r\nAT+CMGR="}; //讀簡訊
const romchar AT_CMGD1[] = {"AT+CMGD=1\r\n"}; //刪除簡訊
const romchar AT_CMGD2[] = {"AT+CMGD=2\r\n"}; //刪除簡訊
const romchar AT_CMGD3[] = {"AT+CMGD=3\r\n"}; //刪除簡訊
const romchar AT_CMGD4[] = {"AT+CMGD=4\r\n"}; //刪除簡訊
const romchar AT_CMGD5[] = {"AT+CMGD=5\r\n"}; //刪除簡訊
const romchar AT_CMGD6[] = {"AT+CMGD=6\r\n"}; //刪除簡訊
const romchar AT_CMGD7[] = {"AT+CMGD=7\r\n"}; //刪除簡訊
const romchar AT_CMGD8[] = {"AT+CMGD=8\r\n"}; //刪除簡訊
const romchar AT_CMGD9[] = {"AT+CMGD=9\r\n"}; //刪除簡訊
const romchar AT_CNMI[] = {"AT+CNMI=2,1\r\n"}; // ? 初始化AT指令時要用上
const romchar AT_CMGL[] = {"AT+CMGL=\"REC UNREAD\"\r\n"}; //接收沒有讀的資訊
//const romchar AT_CSMP[] = {"AT+CSMP=17,167,0,240 \r\n"};
//const romchar AT_IFC[] = {"AT+IFC=2,2 \r\n"}; //建立資料呼叫,通過RTS和CTS控制
//const romchar AT_CBST[] = {"AT+CBST=0,0, 1 \r\n"};
//------------------------------------------------------------------
//GPRS命令集
//------------------------------------------------------------------
const romchar Gprs_class[] = {"AT+CGCLASS=\"B\"\r\n"}; //length = 16B 顯示GPRS資訊移動的型別
const romchar Gprs_apn[] = {"AT+CSTT=\""}; //GPRS通用的名字
const romchar Gprs_CSTT[]={"AT+CIPCSGP=1,\""}; //設定GPRS為無線連線的模式
const romchar Gprs_cgatt[] = {"AT+CGATT=1\r\n"}; //length = 12B顯示GPRS配置是附加的
const romchar Gprs_cgreg[] = {"AT+CGREG?\r\n"}; //查詢GPRS網路註冊狀態
const romchar Gprs_cgreginit[] = {"AT+CGREG=1\r\n"}; //初始化GPRS網路註冊狀態
const romchar Gprs_T_S[] = {"AT+CIPSTART=\"TCP\",\""}; //建立TCP連線;連線成功反饋CONNECT OK
const romchar Gprs_U_S[] = {"AT+CIPSTART=\"UDP\",\""}; //建立UDP連線
const romchar Gprs_ipshut[] = {"AT+CIPSHUT\r\n"}; // //使GPRS的PDP失效
const romchar Gprs_send[] = {"AT+CIPSEND\r\n"}; //傳送資料;
const romchar Gprs_dpdp[] = {"AT+CIPDPDP=1,60,3\r\n"}; //自動檢測GPRS是否為附著狀態;60毫秒,檢測3次
const romchar SetBand[]= "AT+IPR=9600\r\n"; //設定與終端裝置通訊的波特率為9600
//------------------------------------------------------------------
//通話命令集
//------------------------------------------------------------------
const romchar Gsm_cmd_call_view[] = {"AT+CLIP=1\r\n"}; //使能來電顯示
const romchar Gsm_P_ATD[] = {"\r\nATD"}; //撥號
const romchar Gsm_cmd_call_ack[] = {"ATA\r\n"}; //接通
const romchar Gsm_call_connect[] = {"AT+CLCC\r\n"}; //查詢是否接通
const romchar Gsm_cmd_call_noack[] = {"ATH\r\n"}; //結束通話
const romchar Gsm_cmd_call_sel[] = {"AT+CHFA=0\r\n"}; //選主通道
const romchar Gsm_cmd_call_CMIC[] = {"AT+CMIC=0,9\r\n"}; //MIC增益+13.5dB,選擇主麥克風
const romchar Gsm_cmd_call_CLVL[] = {"AT+CLVL=90\r\n"}; //受話器音量級別
const romchar Gsm_cmd_Voice_num1[] = {"AT+VTS=1\r\n"}; //撥號鍵3
const romchar Gsm_cmd_Voice_num2[] = {"AT+VTS=2\r\n"}; //撥號鍵3
const romchar Gsm_cmd_Voice_num3[] = {"AT+VTS=3\r\n"}; //撥號鍵3
const romchar Gsm_cmd_Voice_num4[] = {"AT+VTS=4\r\n"}; //撥號鍵3
const romchar Gsm_cmd_Voice_num5[] = {"AT+VTS=5\r\n"}; //撥號鍵3
const romchar Gsm_cmd_Voice_num6[] = {"AT+VTS=6\r\n"}; //撥號鍵3
const romchar AT_VTS[] = {"AT+VTS=\r\n"}; //Send DTMF
const romchar ATMicOn[]="AT+CMUT=0\r\n";
const romchar ATMicOff[]="AT+CMUT=1\r\n";
const romchar Gsm_cmd_Turn_Off[] = {"AT+CPOWD=1\r\n"}; //關模組命令
//------------------------------------------------------------------
const romchar AT_AT[] = {"AT\r\n"};
const romchar AT_CBC[] ={"AT+CBC\r\n"}; //檢查充電狀態,以及電池電量佔容量的百分比+CBC: 0,97,4164
const romchar AT_CREG[] = {"AT+CREG?\r\n"}; //查詢網路註冊狀態
const romchar AT_CREGINIT[] = {"AT+CREG=1\r\n"}; //初始化網路註冊狀態
const romchar AT_ATE[] = {"ATE0\r\n"}; //儲存當前的設定引數
const romchar AT_Save[] = {"AT&W\r\n"}; //儲存當前的引數
//0 disable slow clock 1 enable slow clock
const romchar AT_CSCLK[] = {"AT+CSCLK=1\r\n"}; //enable slow clock
//0 minimum ality 1 full ality (Default) 4 disable phone both transmit and receive RF circuits
const romchar AT_CFUN[] = {"AT+CFUN=1\r\n"}; //使模組在重啟後電源進入功能性的電平
const romchar AT_CGMR[] = {"AT+CGMR\r\n"}; //軟體版本標識
const romchar AT_CCID[] = {"AT+CCID\r\n"}; //獲得SIM卡標識
const romchar AT_CGSN[]={"AT+CGSN\r\n"}; //IMEI
const romchar AT_CSQ[]={"AT+CSQ\r\n"}; //訊號強度
const romchar AT_CSMINS[]={"AT+CSMINS?\r\n"}; //檢測SIM卡是否插入+CSMINS: 0,1
const romchar AT_COPS[]={"AT+COPS?\r\n"};
const romchar AT_CPOL[]={"AT+CPOL?\r\n"};
const romchar AT_REG_COPS[]={"AT+CPOL=1,2,\""};
//******************************************************************************
//SMS命令集
//------------------------------------------------------------------
const romchar AT_CMGF[] = {"AT+CMGF=1\r\n"}; //指定資訊的輸入輸出格式為文字格式
const romchar AT_CMGFNMEA[] = {"AT+CMGF=0\r\n"}; //指定資訊的輸入輸出格式為PDU格式
const romchar AT_CSCS[] = {"AT+CSCS=\"GSM\"\r\n"}; //AT+CSCS=“GSM”設定什麼樣的字型讓模組接受
const romchar AT_CMGS[] = {"AT+CMGS=\""}; //發簡訊
const romchar AT_CMGR[] = {"\r\nAT+CMGR="}; //讀簡訊
const romchar AT_CMGD1[] = {"AT+CMGD=1\r\n"}; //刪除簡訊
const romchar AT_CMGD2[] = {"AT+CMGD=2\r\n"}; //刪除簡訊
const romchar AT_CMGD3[] = {"AT+CMGD=3\r\n"}; //刪除簡訊
const romchar AT_CMGD4[] = {"AT+CMGD=4\r\n"}; //刪除簡訊
const romchar AT_CMGD5[] = {"AT+CMGD=5\r\n"}; //刪除簡訊
const romchar AT_CMGD6[] = {"AT+CMGD=6\r\n"}; //刪除簡訊
const romchar AT_CMGD7[] = {"AT+CMGD=7\r\n"}; //刪除簡訊
const romchar AT_CMGD8[] = {"AT+CMGD=8\r\n"}; //刪除簡訊
const romchar AT_CMGD9[] = {"AT+CMGD=9\r\n"}; //刪除簡訊
const romchar AT_CNMI[] = {"AT+CNMI=2,1\r\n"}; // ? 初始化AT指令時要用上
const romchar AT_CMGL[] = {"AT+CMGL=\"REC UNREAD\"\r\n"}; //接收沒有讀的資訊
//const romchar AT_CSMP[] = {"AT+CSMP=17,167,0,240 \r\n"};
//const romchar AT_IFC[] = {"AT+IFC=2,2 \r\n"}; //建立資料呼叫,通過RTS和CTS控制
//const romchar AT_CBST[] = {"AT+CBST=0,0, 1 \r\n"};
//------------------------------------------------------------------
//GPRS命令集
//------------------------------------------------------------------
const romchar Gprs_class[] = {"AT+CGCLASS=\"B\"\r\n"}; //length = 16B 顯示GPRS資訊移動的型別
const romchar Gprs_apn[] = {"AT+CSTT=\""}; //GPRS通用的名字
const romchar Gprs_CSTT[]={"AT+CIPCSGP=1,\""}; //設定GPRS為無線連線的模式
const romchar Gprs_cgatt[] = {"AT+CGATT=1\r\n"}; //length = 12B顯示GPRS配置是附加的
const romchar Gprs_cgreg[] = {"AT+CGREG?\r\n"}; //查詢GPRS網路註冊狀態
const romchar Gprs_cgreginit[] = {"AT+CGREG=1\r\n"}; //初始化GPRS網路註冊狀態
const romchar Gprs_T_S[] = {"AT+CIPSTART=\"TCP\",\""}; //建立TCP連線;連線成功反饋CONNECT OK
const romchar Gprs_U_S[] = {"AT+CIPSTART=\"UDP\",\""}; //建立UDP連線
const romchar Gprs_ipshut[] = {"AT+CIPSHUT\r\n"}; // //使GPRS的PDP失效
const romchar Gprs_send[] = {"AT+CIPSEND\r\n"}; //傳送資料;
const romchar Gprs_dpdp[] = {"AT+CIPDPDP=1,60,3\r\n"}; //自動檢測GPRS是否為附著狀態;60毫秒,檢測3次
const romchar SetBand[]= "AT+IPR=9600\r\n"; //設定與終端裝置通訊的波特率為9600
//------------------------------------------------------------------
//通話命令集
//------------------------------------------------------------------
const romchar Gsm_cmd_call_view[] = {"AT+CLIP=1\r\n"}; //使能來電顯示
const romchar Gsm_P_ATD[] = {"\r\nATD"}; //撥號
const romchar Gsm_cmd_call_ack[] = {"ATA\r\n"}; //接通
const romchar Gsm_call_connect[] = {"AT+CLCC\r\n"}; //查詢是否接通
const romchar Gsm_cmd_call_noack[] = {"ATH\r\n"}; //結束通話
const romchar Gsm_cmd_call_sel[] = {"AT+CHFA=0\r\n"}; //選主通道
const romchar Gsm_cmd_call_CMIC[] = {"AT+CMIC=0,9\r\n"}; //MIC增益+13.5dB,選擇主麥克風
const romchar Gsm_cmd_call_CLVL[] = {"AT+CLVL=90\r\n"}; //受話器音量級別
const romchar Gsm_cmd_Voice_num1[] = {"AT+VTS=1\r\n"}; //撥號鍵3
const romchar Gsm_cmd_Voice_num2[] = {"AT+VTS=2\r\n"}; //撥號鍵3
const romchar Gsm_cmd_Voice_num3[] = {"AT+VTS=3\r\n"}; //撥號鍵3
const romchar Gsm_cmd_Voice_num4[] = {"AT+VTS=4\r\n"}; //撥號鍵3
const romchar Gsm_cmd_Voice_num5[] = {"AT+VTS=5\r\n"}; //撥號鍵3
const romchar Gsm_cmd_Voice_num6[] = {"AT+VTS=6\r\n"}; //撥號鍵3
const romchar AT_VTS[] = {"AT+VTS=\r\n"}; //Send DTMF
const romchar ATMicOn[]="AT+CMUT=0\r\n";
const romchar ATMicOff[]="AT+CMUT=1\r\n";
const romchar Gsm_cmd_Turn_Off[] = {"AT+CPOWD=1\r\n"}; //關模組命令