Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SoftwareSerial.h>
- SoftwareSerial mySerial(7, 8);
- #include<stdio.h>
- #include<string.h>
- #define DEBUG true
- int pon=9;
- void setup()
- {
- Serial.begin(9600);
- mySerial.begin(9600);
- delay(1000);
- pinMode(pon, OUTPUT);
- digitalWrite(pon, HIGH);
- delay(3000);
- digitalWrite(pon, LOW);
- delay(1000);
- Serial.println("After 3s, test begin!!");
- delay(3000);
- }
- void loop()
- {
- sendData("AT+CCID",3000,DEBUG);
- sendData("AT+CREG?",3000,DEBUG);
- sendData("AT+CGATT=1",1000,DEBUG);
- sendData("AT+CGACT=1,1",1000,DEBUG);
- sendData("AT+CSTT=CMNET",3000,DEBUG);
- sendData("AT+CIICR",1000,DEBUG);
- sendData("AT+CIFSR",1000,DEBUG);
- sendData("AT+CDNSGIP=\"www.sim.com\"",1000,DEBUG);
- sendData("AT+CDNSGIP=\"a b c d e f\"",1000,DEBUG);
- sendData("AT+CIPSTART=\"TCP\",\"WWW.SIM.COM\",80",5000,DEBUG);
- delay(10000);
- sendData("AT+CIPSEND=6",1000,DEBUG);
- sendData("123456",1000,DEBUG);
- delay(2000);
- sendData("AT+CIPCLOSE",1000,DEBUG);
- }
- String sendData(String command, const int timeout, boolean debug)
- {
- String response = "";
- mySerial.println(command);
- long int time = millis();
- while( (time+timeout) > millis())
- {
- while(mySerial.available())
- {
- char c = mySerial.read();
- response+=c;
- }
- }
- if(debug)
- {
- Serial.print(response);
- }
- return response;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement