Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed-rtos mbed HTTPClient VodafoneUSBModem
main.cpp@36:dd730ff4962e, 2012-09-13 (annotated)
- Committer:
- donatien
- Date:
- Thu Sep 13 13:54:17 2012 +0000
- Revision:
- 36:dd730ff4962e
- Parent:
- 35:6867af70c51c
- Child:
- 38:83085bfd1018
Updated HTTPClient lib
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| ashleymills | 1:0d63e4db8503 | 1 | #define __DEBUG__ 4 //Maximum verbosity |
| ashleymills | 1:0d63e4db8503 | 2 | #ifndef __MODULE__ |
| ashleymills | 1:0d63e4db8503 | 3 | #define __MODULE__ "net_3g_basic_http_test.cpp" |
| ashleymills | 1:0d63e4db8503 | 4 | #endif |
| ashleymills | 1:0d63e4db8503 | 5 | |
| ashleymills | 2:ea883307d02f | 6 | #include "LogHeader.h" |
| ashleymills | 2:ea883307d02f | 7 | |
| ashleymills | 1:0d63e4db8503 | 8 | #include "mbed.h" |
| donatien | 36:dd730ff4962e | 9 | |
| ashleymills | 1:0d63e4db8503 | 10 | #include "rtos.h" |
| ashleymills | 1:0d63e4db8503 | 11 | #include "VodafoneUSBModem.h" |
| ashleymills | 1:0d63e4db8503 | 12 | #include "VodafoneTestCase.h" |
| ashleymills | 20:18373fb68ad7 | 13 | #include "TestManager.h" |
| ashleymills | 1:0d63e4db8503 | 14 | |
| ashleymills | 1:0d63e4db8503 | 15 | DigitalOut led1(LED1); |
| ashleymills | 1:0d63e4db8503 | 16 | DigitalOut led2(LED2); |
| ashleymills | 1:0d63e4db8503 | 17 | DigitalOut led3(LED3); |
| ashleymills | 1:0d63e4db8503 | 18 | DigitalOut led4(LED4); |
| ashleymills | 1:0d63e4db8503 | 19 | |
| ashleymills | 1:0d63e4db8503 | 20 | extern "C" void HardFault_Handler() { error("Hard Fault!\n"); } |
| ashleymills | 1:0d63e4db8503 | 21 | |
| ashleymills | 24:8f0f9551122a | 22 | time_t startTime = 0; |
| ashleymills | 24:8f0f9551122a | 23 | time_t gPreviousUptime = 0; |
| ashleymills | 24:8f0f9551122a | 24 | time_t gUptime = 0; |
| ashleymills | 24:8f0f9551122a | 25 | |
| ashleymills | 24:8f0f9551122a | 26 | void loopForever() { |
| ashleymills | 24:8f0f9551122a | 27 | while(1) { |
| ashleymills | 24:8f0f9551122a | 28 | Thread::wait(1000); |
| ashleymills | 24:8f0f9551122a | 29 | time_t now = time(NULL); |
| ashleymills | 24:8f0f9551122a | 30 | gPreviousUptime = gUptime; |
| ashleymills | 24:8f0f9551122a | 31 | } |
| ashleymills | 24:8f0f9551122a | 32 | } |
| ashleymills | 24:8f0f9551122a | 33 | |
| ashleymills | 1:0d63e4db8503 | 34 | void test(void const*) { |
| ashleymills | 1:0d63e4db8503 | 35 | VodafoneUSBModem modem; |
| ashleymills | 2:ea883307d02f | 36 | LOG("Constructing TestManager"); |
| ashleymills | 2:ea883307d02f | 37 | TestManager *m = new TestManager(&modem); |
| ashleymills | 22:5b1feecf2aeb | 38 | LOG("Running tests."); |
| ashleymills | 33:16126e029d58 | 39 | int numPassed = m->executeTestProfile(TESTS_AUTOMATED); |
| ashleymills | 24:8f0f9551122a | 40 | loopForever(); |
| ashleymills | 1:0d63e4db8503 | 41 | } |
| ashleymills | 1:0d63e4db8503 | 42 | |
| ashleymills | 3:28336c2e94e4 | 43 | void setTime() { |
| ashleymills | 3:28336c2e94e4 | 44 | struct tm t; |
| ashleymills | 3:28336c2e94e4 | 45 | t.tm_year = 2012; |
| ashleymills | 3:28336c2e94e4 | 46 | t.tm_mon = 8; |
| ashleymills | 3:28336c2e94e4 | 47 | t.tm_mday = 23; |
| ashleymills | 3:28336c2e94e4 | 48 | t.tm_hour = 9; |
| ashleymills | 3:28336c2e94e4 | 49 | t.tm_min = 19; |
| ashleymills | 3:28336c2e94e4 | 50 | t.tm_sec = 0; |
| ashleymills | 3:28336c2e94e4 | 51 | t.tm_year -= 1900; |
| ashleymills | 3:28336c2e94e4 | 52 | t.tm_mon -= 1; |
| ashleymills | 3:28336c2e94e4 | 53 | set_time(mktime(&t)); |
| ashleymills | 3:28336c2e94e4 | 54 | } |
| ashleymills | 3:28336c2e94e4 | 55 | |
| ashleymills | 1:0d63e4db8503 | 56 | int main() { |
| ashleymills | 1:0d63e4db8503 | 57 | |
| ashleymills | 1:0d63e4db8503 | 58 | DBG_INIT(); |
| ashleymills | 1:0d63e4db8503 | 59 | DBG_SET_SPEED(115200); |
| ashleymills | 1:0d63e4db8503 | 60 | DBG_SET_NEWLINE("\r\n"); |
| ashleymills | 1:0d63e4db8503 | 61 | |
| ashleymills | 3:28336c2e94e4 | 62 | //setTime(); |
| ashleymills | 3:28336c2e94e4 | 63 | size_t currentTime = time(NULL); |
| ashleymills | 3:28336c2e94e4 | 64 | fprintf(stdout,"Invocation time: %s\r\n",ctime(¤tTime)); |
| ashleymills | 3:28336c2e94e4 | 65 | |
| donatien | 36:dd730ff4962e | 66 | Thread testTask(test, NULL, osPriorityNormal, 1024 * 6); |
| ashleymills | 1:0d63e4db8503 | 67 | // this thread just waits and blinks leds periodically |
| ashleymills | 1:0d63e4db8503 | 68 | while(1) { |
| ashleymills | 1:0d63e4db8503 | 69 | led1 = !led1; |
| ashleymills | 1:0d63e4db8503 | 70 | Thread::wait(500); |
| ashleymills | 1:0d63e4db8503 | 71 | led1 = !led1; |
| ashleymills | 1:0d63e4db8503 | 72 | Thread::wait(30000); |
| ashleymills | 1:0d63e4db8503 | 73 | } |
| ashleymills | 0:6d8a9f4b2cc6 | 74 | } |

