Integrating the ublox LISA C200 modem
Fork of SprintUSBModemHTTPClientTest by
main.cpp
- Committer:
- sam_grove
- Date:
- 2013-10-07
- Revision:
- 20:39772b740985
- Parent:
- 19:f1d893c651e5
- Child:
- 21:3f45e53afe4f
File content as of revision 20:39772b740985:
#include "mbed.h" #include "SprintUSBModem.h" #include "HTTPClient.h" #include "Websocket.h" void websocketTest(void const*) { SprintUSBModem modem(p18, true, 1); char msg[2048]; // Using C16-C20 make sure to connect mbed p18 to J2 pin 16 modem.power(true); int ret = modem.connect(); if(ret) { error("Modem connect failed: %s %d", __PRETTY_FUNCTION__ , __LINE__); } // See the output on http://sockets.mbed.org/sg_test/viewer Websocket ws("ws://sockets.mbed.org:443/ws/sg_test/rw"); ws.connect(); for(int i=0; i<0x7fffffff; ++i) { // create json string with acc/tmp data sprintf(msg, "Testing mbed Websockets Loop: %d", i); ws.send(msg); wait(0.5f); memset(msg, 0, 2048); if (ws.read(msg)) { printf("rcv: %s\r\n", msg); } else { printf("Loop %d ws.read() returns 0\n", i); } } ws.close(); modem.disconnect(); modem.power(false); puts("Powered off Test Complete"); while(1); } int main() { Thread task(websocketTest, NULL, osPriorityNormal, 1024 * 5); // Thread task(httpTest, NULL, osPriorityNormal, 1024 * 5); DigitalOut led(LED1); while(1) { led = !led; Thread::wait(1000); } return 0; }