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

Dependencies:   Stewitter_a3gs a3gs mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "a3gs.h"
00003 #include "Stewitter_a3gs.h"
00004 
00005 Serial pc(USBTX, USBRX);
00006 DigitalOut myled(LED1);
00007 
00008 A3GS a3gs(p28, p27, p29, p23, p11, 9600); // tx, rx, interrupt, power, regulator
00009 Stewitter_a3gs twitter("YOUR TOKEN", a3gs);
00010 
00011 const char *msg = "Hello, World! I'm mbed!"; // url encoded ASCII or UTF-8
00012 
00013 int main() {
00014     pc.baud(115200);
00015     pc.printf("*** PHS Shield\r\n");
00016 
00017     a3gs.start();
00018     if (a3gs.begin()) {
00019         error("Could not connect");
00020     }
00021     myled = 1;
00022 
00023     if (twitter.lastMention()) {
00024         int status = twitter.wait();
00025         printf("lastMention: %d '%s'\r\n", status, twitter.response());
00026     }
00027 
00028     if (twitter.post(msg)) {
00029         int status = twitter.wait();
00030         printf("post: %d '%s'\r\n", status, twitter.response());
00031     }
00032 
00033     wait(1);
00034     pc.printf("bye\r\n");
00035     a3gs.end();
00036     a3gs.shutdown();
00037     myled = 0;
00038 }