see: https://developer.mbed.org/users/phsfan/notebook/phsshield/
Fork of PHSShield_httpGET by
main.cpp
00001 #include "mbed.h" 00002 #include "a3gs.h" 00003 00004 Serial pc(USBTX, USBRX); 00005 DigitalOut myled(LED1); 00006 00007 // tx, rx, interrupt, power, regulator 00008 A3GS a3gs(p28, p27, p29, p23, p11, 9600); // mbeduino (LPC1768) 00009 //A3GS a3gs(PA_11, PA_12, D2, D6, D7, 9600); // Nucleo STM32F401RE 00010 00011 const char *server = "developer.mbed.org"; 00012 const char *path = "/media/uploads/phsfan/hello.txt"; 00013 const char *head = "Content-Type: application/x-www-form-urlencoded"; 00014 int port = 80; 00015 00016 int main() { 00017 pc.baud(115200); 00018 pc.printf("*** PHS httpGET\r\n"); 00019 00020 a3gs.start(); 00021 if (a3gs.begin()) { 00022 error("Could not connect"); 00023 } 00024 myled = 1; 00025 00026 char buf[a3gsMAX_RESULT_LENGTH + 1]; 00027 if (a3gs.httpGET(server, port, path, buf, sizeof(buf) - 1, 0, head) == 0) { 00028 pc.printf("OK!\r\n"); 00029 pc.printf(buf); 00030 for (;;) { 00031 int r = a3gs.read(buf, sizeof(buf) - 1); 00032 if (r > 0) { 00033 pc.printf(buf); 00034 } else { 00035 break; 00036 } 00037 } 00038 pc.printf("\r\n"); 00039 } else { 00040 pc.printf("Can't get HTTP response from %s\r\n", server); 00041 } 00042 00043 wait(3); 00044 a3gs.disconnectTCP(); 00045 pc.printf("bye\r\n"); 00046 a3gs.end(); 00047 a3gs.shutdown(); 00048 myled = 0; 00049 }
Generated on Wed Jul 13 2022 02:27:05 by 1.7.2