-
-
Save ToeJamson/5c18c6b5d6f4fc7b9f95 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void loop(){ | |
if(gprs.available()){ | |
Serial.write(gprs.read()); | |
} | |
if(Serial.available()){ | |
gprs.write(Serial.read()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://pubsub.pubnub.com | |
/publish | |
/pub-key | |
/sub-key | |
/signature | |
/channel | |
/callback | |
/message |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RDY | |
+CFUN: 1 | |
+CPIN: READY | |
+PACSP: 0 | |
Call Ready |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ATD1***8675309; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GPRS gprs(PIN_TX, PIN_RX, BAUDRATE,"cmnet"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GPRS(int tx, int rx, uint32_t baudRate = 9600, const char* apn = NULL, const char* userName = NULL, const char *passWord = NULL); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GPRS gprs(PIN_TX, PIN_RX, BAUDRATE, "wap.cingular", "WAP@CINGULARGPRS.COM", "CINGULAR1"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <GPRS_Shield_Arduino.h> | |
#include <SoftwareSerial.h> | |
#include <Wire.h> | |
#include <Suli.h> | |
#define PIN_TX 7 | |
#define PIN_RX 8 | |
//make sure that the baud rate of SIM900 is 9600! | |
//you can use the AT Command(AT+IPR=9600) to set it through SerialDebug | |
#define BAUDRATE 9600 | |
GPRS gprs(PIN_TX, PIN_RX, BAUDRATE, "wap.cingular", "WAP@CINGULARGPRS.COM", "CINGULAR1"); | |
void publishData(String data) { | |
Serial.println("attempting to publish"); | |
while (false == gprs.join()) { | |
Serial.println("gprs join network error"); | |
delay(2000); | |
} | |
String str = "GET /publish/demo/demo/0/pubnub_gprs/0/\"" + data + "\" HTTP/1.0\r\n\r\n"; | |
// Length (with one extra character for the null terminator) | |
int str_len = str.length() + 1; | |
// Prepare the character array (the buffer) | |
char http_cmd[str_len]; | |
// Copy it over | |
str.toCharArray(http_cmd, str_len); | |
char buffer[512]; | |
if (false == gprs.connect(TCP, "pubsub.pubnub.com", 80)) { | |
Serial.println("connect error"); | |
} else { | |
Serial.println("publish success"); | |
Serial.println(data); | |
} | |
gprs.send(http_cmd, sizeof(http_cmd) - 1); | |
gprs.close(); | |
} | |
int counter = 0; | |
void setup() { | |
Serial.println("starting"); | |
Serial.begin(9600); | |
// use DHCP | |
gprs.init(); | |
// attempt DHCP | |
while(true){ | |
publishData(String(counter)); | |
counter++; | |
delay(1000); | |
} | |
gprs.disconnect(); | |
} | |
void loop() { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String str = "GET /publish/demo/demo/0/pubnub_gprs/0/\"" + data + "\" HTTP/1.0\r\n\r\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment