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

Dependencies:   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 "TinyHTTP_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 
00010 void callback (char *buf, int len) {
00011     buf[len] = 0;
00012     printf(buf);
00013 }
00014 
00015 int main() {
00016     pc.baud(115200);
00017     pc.printf("*** PHS Shield\r\n");
00018 
00019     a3gs.start();
00020     if (a3gs.begin()) {
00021         error("Could not connect");
00022     }
00023     myled = 1;
00024 
00025     //GET data
00026     printf("Trying to fetch page...\r\n");
00027     httpRequest(METHOD_GET, "developer.mbed.org", 80, "/media/uploads/phsfan/hello.txt", NULL, NULL, callback);
00028     printf("\r\n");
00029 /*
00030     char buf[a3gsMAX_RESULT_LENGTH + 1];
00031     char header[] = "Server: developer.mbed.org\n";
00032     if (a3gs.httpGET("developer.mbed.org", 80, "/media/uploads/phsfan/hello.txt", buf, sizeof(buf), false, header) == 0) {
00033         printf("HTTP GET: %s\r\n", buf);
00034     }
00035 */
00036     wait(1);
00037     pc.printf("bye\r\n");
00038     a3gs.end();
00039     a3gs.shutdown();
00040     myled = 0;
00041 }