HTTP Client test for AbitUSBModem. see: http://developer.mbed.org/users/phsfan/notebook/abitusbmodem/
Dependencies: AbitUSBModem USBHost mbed
Diff: main.cpp
- Revision:
- 0:35cf1b2fc6e2
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Feb 19 00:08:49 2015 +0000 @@ -0,0 +1,47 @@ +#include "mbed.h" +#include "AbitUSBModem.h" +#include "TinyHTTP.h" +#include <new> + +Serial pc(USBTX, USBRX); +DigitalOut myled(LED1); + +void callback (char *buf, int len) { + buf[len] = 0; + printf(buf); +} + +void test(void const*) +{ + AbitUSBModem modem; + + printf("connect\r\n"); + int ret = modem.connect("prin", "prin"); + if(ret) { + printf("Could not connect\r\n"); + return; + } + + printf("IP Address %s\r\n", modem.getIPAddress()); + + //GET data + printf("Trying to fetch page...\r\n"); + httpRequest(METHOD_GET, "developer.mbed.org", 80, "/media/uploads/phsfan/hello.txt", NULL, NULL, callback); + printf("\r\n"); + + Thread::wait(1000); + printf("exit\r\n"); + modem.disconnect(); +} + +int main() +{ + pc.baud(115200); + printf("** PHS\r\n"); + + Thread testTask(test, NULL, osPriorityNormal, 1024 * 4); + while(1) { + myled = !myled; + Thread::wait(1000); + } +}