see: https://developer.mbed.org/users/phsfan/notebook/phsshield/

Dependencies:   Stewitter_a3gs a3gs mbed

Committer:
phsfan
Date:
Wed Apr 01 06:22:19 2015 +0000
Revision:
0:555e9c594bc5
1st build;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
phsfan 0:555e9c594bc5 1 #include "mbed.h"
phsfan 0:555e9c594bc5 2 #include "a3gs.h"
phsfan 0:555e9c594bc5 3 #include "Stewitter_a3gs.h"
phsfan 0:555e9c594bc5 4
phsfan 0:555e9c594bc5 5 Serial pc(USBTX, USBRX);
phsfan 0:555e9c594bc5 6 DigitalOut myled(LED1);
phsfan 0:555e9c594bc5 7
phsfan 0:555e9c594bc5 8 A3GS a3gs(p28, p27, p29, p23, p11, 9600); // tx, rx, interrupt, power, regulator
phsfan 0:555e9c594bc5 9 Stewitter_a3gs twitter("YOUR TOKEN", a3gs);
phsfan 0:555e9c594bc5 10
phsfan 0:555e9c594bc5 11 const char *msg = "Hello, World! I'm mbed!"; // url encoded ASCII or UTF-8
phsfan 0:555e9c594bc5 12
phsfan 0:555e9c594bc5 13 int main() {
phsfan 0:555e9c594bc5 14 pc.baud(115200);
phsfan 0:555e9c594bc5 15 pc.printf("*** PHS Shield\r\n");
phsfan 0:555e9c594bc5 16
phsfan 0:555e9c594bc5 17 a3gs.start();
phsfan 0:555e9c594bc5 18 if (a3gs.begin()) {
phsfan 0:555e9c594bc5 19 error("Could not connect");
phsfan 0:555e9c594bc5 20 }
phsfan 0:555e9c594bc5 21 myled = 1;
phsfan 0:555e9c594bc5 22
phsfan 0:555e9c594bc5 23 if (twitter.lastMention()) {
phsfan 0:555e9c594bc5 24 int status = twitter.wait();
phsfan 0:555e9c594bc5 25 printf("lastMention: %d '%s'\r\n", status, twitter.response());
phsfan 0:555e9c594bc5 26 }
phsfan 0:555e9c594bc5 27
phsfan 0:555e9c594bc5 28 if (twitter.post(msg)) {
phsfan 0:555e9c594bc5 29 int status = twitter.wait();
phsfan 0:555e9c594bc5 30 printf("post: %d '%s'\r\n", status, twitter.response());
phsfan 0:555e9c594bc5 31 }
phsfan 0:555e9c594bc5 32
phsfan 0:555e9c594bc5 33 wait(1);
phsfan 0:555e9c594bc5 34 pc.printf("bye\r\n");
phsfan 0:555e9c594bc5 35 a3gs.end();
phsfan 0:555e9c594bc5 36 a3gs.shutdown();
phsfan 0:555e9c594bc5 37 myled = 0;
phsfan 0:555e9c594bc5 38 }