Vodafone Test Suite
Dependencies: mbed-rtos mbed HTTPClient VodafoneUSBModem
main.cpp@54:30062a67e8bb, 2012-09-14 (annotated)
- Committer:
- nherriot
- Date:
- Fri Sep 14 13:23:29 2012 +0000
- Revision:
- 54:30062a67e8bb
- Parent:
- 39:368988b1542f
type name changes to follow with coding convention
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 | 37:847f5f86e9ff | 34 | int* getStack() { |
ashleymills | 37:847f5f86e9ff | 35 | int dummy; |
ashleymills | 37:847f5f86e9ff | 36 | return &dummy; |
ashleymills | 37:847f5f86e9ff | 37 | } |
ashleymills | 37:847f5f86e9ff | 38 | |
ashleymills | 1:0d63e4db8503 | 39 | void test(void const*) { |
ashleymills | 1:0d63e4db8503 | 40 | VodafoneUSBModem modem; |
ashleymills | 2:ea883307d02f | 41 | LOG("Constructing TestManager"); |
ashleymills | 2:ea883307d02f | 42 | TestManager *m = new TestManager(&modem); |
ashleymills | 37:847f5f86e9ff | 43 | int *heap = (int*)malloc(8*sizeof(int)); |
ashleymills | 37:847f5f86e9ff | 44 | int *stack = getStack(); |
ashleymills | 37:847f5f86e9ff | 45 | |
ashleymills | 37:847f5f86e9ff | 46 | LOG("heap: %d, stack: %d, size: %d",heap,stack,stack-heap); |
ashleymills | 22:5b1feecf2aeb | 47 | LOG("Running tests."); |
nherriot | 54:30062a67e8bb | 48 | |
nherriot | 54:30062a67e8bb | 49 | |
nherriot | 54:30062a67e8bb | 50 | |
nherriot | 54:30062a67e8bb | 51 | int numPassed = m->executeTestProfile(TESTS_AUTOMATED); |
nherriot | 54:30062a67e8bb | 52 | |
ashleymills | 24:8f0f9551122a | 53 | loopForever(); |
ashleymills | 1:0d63e4db8503 | 54 | } |
ashleymills | 1:0d63e4db8503 | 55 | |
ashleymills | 3:28336c2e94e4 | 56 | void setTime() { |
ashleymills | 3:28336c2e94e4 | 57 | struct tm t; |
ashleymills | 3:28336c2e94e4 | 58 | t.tm_year = 2012; |
ashleymills | 3:28336c2e94e4 | 59 | t.tm_mon = 8; |
ashleymills | 3:28336c2e94e4 | 60 | t.tm_mday = 23; |
ashleymills | 3:28336c2e94e4 | 61 | t.tm_hour = 9; |
ashleymills | 3:28336c2e94e4 | 62 | t.tm_min = 19; |
ashleymills | 3:28336c2e94e4 | 63 | t.tm_sec = 0; |
ashleymills | 3:28336c2e94e4 | 64 | t.tm_year -= 1900; |
ashleymills | 3:28336c2e94e4 | 65 | t.tm_mon -= 1; |
ashleymills | 3:28336c2e94e4 | 66 | set_time(mktime(&t)); |
ashleymills | 3:28336c2e94e4 | 67 | } |
ashleymills | 3:28336c2e94e4 | 68 | |
ashleymills | 1:0d63e4db8503 | 69 | int main() { |
ashleymills | 1:0d63e4db8503 | 70 | |
ashleymills | 1:0d63e4db8503 | 71 | DBG_INIT(); |
ashleymills | 1:0d63e4db8503 | 72 | DBG_SET_SPEED(115200); |
ashleymills | 1:0d63e4db8503 | 73 | DBG_SET_NEWLINE("\r\n"); |
ashleymills | 1:0d63e4db8503 | 74 | |
ashleymills | 3:28336c2e94e4 | 75 | //setTime(); |
ashleymills | 3:28336c2e94e4 | 76 | size_t currentTime = time(NULL); |
ashleymills | 3:28336c2e94e4 | 77 | fprintf(stdout,"Invocation time: %s\r\n",ctime(¤tTime)); |
ashleymills | 3:28336c2e94e4 | 78 | |
ashleymills | 39:368988b1542f | 79 | Thread testTask(test, NULL, osPriorityNormal, 1024 * 8); |
ashleymills | 1:0d63e4db8503 | 80 | // this thread just waits and blinks leds periodically |
ashleymills | 1:0d63e4db8503 | 81 | while(1) { |
ashleymills | 1:0d63e4db8503 | 82 | led1 = !led1; |
ashleymills | 1:0d63e4db8503 | 83 | Thread::wait(500); |
ashleymills | 1:0d63e4db8503 | 84 | led1 = !led1; |
ashleymills | 1:0d63e4db8503 | 85 | Thread::wait(30000); |
ashleymills | 1:0d63e4db8503 | 86 | } |
ashleymills | 0:6d8a9f4b2cc6 | 87 | } |