Vodafone Test Suite
Dependencies: mbed-rtos mbed HTTPClient VodafoneUSBModem
main.cpp@23:408199b5d2cb, 2012-09-05 (annotated)
- Committer:
- ashleymills
- Date:
- Wed Sep 05 16:38:06 2012 +0000
- Revision:
- 23:408199b5d2cb
- Parent:
- 22:5b1feecf2aeb
- Child:
- 24:8f0f9551122a
- Child:
- 28:c630a04a7198
Added internet test.
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" |
ashleymills | 1:0d63e4db8503 | 9 | #include "socket/bsd_socket.h" |
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 | 1:0d63e4db8503 | 22 | void test(void const*) { |
ashleymills | 1:0d63e4db8503 | 23 | VodafoneUSBModem modem; |
ashleymills | 2:ea883307d02f | 24 | LOG("Constructing TestManager"); |
ashleymills | 2:ea883307d02f | 25 | TestManager *m = new TestManager(&modem); |
ashleymills | 22:5b1feecf2aeb | 26 | LOG("Running tests."); |
ashleymills | 22:5b1feecf2aeb | 27 | TestProfile profile = TESTS_AUTOMATED; |
ashleymills | 22:5b1feecf2aeb | 28 | int numPassed = m->executeTestProfile(profile); |
ashleymills | 22:5b1feecf2aeb | 29 | int numTests = m->getTestProfileLength(profile); |
ashleymills | 22:5b1feecf2aeb | 30 | LOG("%d tests complete: %d passes and %d failures.",numTests,numPassed,numTests-numPassed); |
ashleymills | 1:0d63e4db8503 | 31 | |
ashleymills | 1:0d63e4db8503 | 32 | while(1) { |
ashleymills | 1:0d63e4db8503 | 33 | Thread::wait(1000); |
ashleymills | 1:0d63e4db8503 | 34 | } |
ashleymills | 1:0d63e4db8503 | 35 | } |
ashleymills | 1:0d63e4db8503 | 36 | |
ashleymills | 3:28336c2e94e4 | 37 | time_t startTime = 0; |
ashleymills | 3:28336c2e94e4 | 38 | |
ashleymills | 3:28336c2e94e4 | 39 | void setTime() { |
ashleymills | 3:28336c2e94e4 | 40 | struct tm t; |
ashleymills | 3:28336c2e94e4 | 41 | t.tm_year = 2012; |
ashleymills | 3:28336c2e94e4 | 42 | t.tm_mon = 8; |
ashleymills | 3:28336c2e94e4 | 43 | t.tm_mday = 23; |
ashleymills | 3:28336c2e94e4 | 44 | t.tm_hour = 9; |
ashleymills | 3:28336c2e94e4 | 45 | t.tm_min = 19; |
ashleymills | 3:28336c2e94e4 | 46 | t.tm_sec = 0; |
ashleymills | 3:28336c2e94e4 | 47 | t.tm_year -= 1900; |
ashleymills | 3:28336c2e94e4 | 48 | t.tm_mon -= 1; |
ashleymills | 3:28336c2e94e4 | 49 | set_time(mktime(&t)); |
ashleymills | 3:28336c2e94e4 | 50 | } |
ashleymills | 3:28336c2e94e4 | 51 | |
ashleymills | 1:0d63e4db8503 | 52 | int main() { |
ashleymills | 1:0d63e4db8503 | 53 | |
ashleymills | 1:0d63e4db8503 | 54 | DBG_INIT(); |
ashleymills | 1:0d63e4db8503 | 55 | DBG_SET_SPEED(115200); |
ashleymills | 1:0d63e4db8503 | 56 | DBG_SET_NEWLINE("\r\n"); |
ashleymills | 1:0d63e4db8503 | 57 | |
ashleymills | 3:28336c2e94e4 | 58 | //setTime(); |
ashleymills | 3:28336c2e94e4 | 59 | size_t currentTime = time(NULL); |
ashleymills | 3:28336c2e94e4 | 60 | fprintf(stdout,"Invocation time: %s\r\n",ctime(¤tTime)); |
ashleymills | 3:28336c2e94e4 | 61 | |
ashleymills | 3:28336c2e94e4 | 62 | |
ashleymills | 23:408199b5d2cb | 63 | Thread testTask(test, NULL, osPriorityNormal, 1024 * 8); |
ashleymills | 1:0d63e4db8503 | 64 | // this thread just waits and blinks leds periodically |
ashleymills | 1:0d63e4db8503 | 65 | while(1) { |
ashleymills | 1:0d63e4db8503 | 66 | led1 = !led1; |
ashleymills | 1:0d63e4db8503 | 67 | Thread::wait(500); |
ashleymills | 1:0d63e4db8503 | 68 | led1 = !led1; |
ashleymills | 1:0d63e4db8503 | 69 | Thread::wait(30000); |
ashleymills | 1:0d63e4db8503 | 70 | } |
ashleymills | 0:6d8a9f4b2cc6 | 71 | } |