Vodafone Test Suite
Dependencies: mbed-rtos mbed HTTPClient VodafoneUSBModem
Revision 54:30062a67e8bb, committed 2012-09-14
- Comitter:
- nherriot
- Date:
- Fri Sep 14 13:23:29 2012 +0000
- Parent:
- 39:368988b1542f
- Commit message:
- type name changes to follow with coding convention
Changed in this revision
--- a/Tests/Test12.h Thu Sep 13 15:46:50 2012 +0000 +++ b/Tests/Test12.h Fri Sep 14 13:23:29 2012 +0000 @@ -50,7 +50,7 @@ return false; } LOG("The message is from number: %s and the message is: \"%s\"", num, msg); - if (strcmp (msg, alphabetNumbersMessage) ==0) + if (strcmp (msg, gAlphabetNumbersMessage) ==0) { LOG("Success receiving alphabet message matches the sent message"); return true;
--- a/Tests/Test13.h Thu Sep 13 15:46:50 2012 +0000 +++ b/Tests/Test13.h Fri Sep 14 13:23:29 2012 +0000 @@ -50,7 +50,7 @@ return false; } LOG("The message is from number: %s and the message is: \"%s\"", num, msg); - if (strcmp (msg, irregularMessage) ==0) + if (strcmp (msg, gIrregularMessage) ==0) { LOG("Success receiving alphabet message matches the sent message"); return true;
--- a/Tests/Test14.h Thu Sep 13 15:46:50 2012 +0000 +++ b/Tests/Test14.h Fri Sep 14 13:23:29 2012 +0000 @@ -1,86 +1,85 @@ -#pragma once -#include "VodafoneTestCase.h" -//#define __DEBUG__ 1 - -// this test case will wait to send an SMS from the modem. -// if the method that sends a message returns an error it will fail. -// it will report the test as failed if any of the above happens. -// it does not wait after it has succesfully sent an SMS. -// this test basic characters and numbers can be sent via SMS. - -extern const char *gTest14Description; - -class Test14 : public VodafoneTestCase { - public: - - - Test14(VodafoneUSBModem *m) : VodafoneTestCase(m) { - _description = gTest14Description; - _testCaseNumber = 14; - } - - - virtual bool execute() { - - LinkMonitor::REGISTRATION_STATE regState = LinkMonitor::REGISTRATION_STATE_UNKNOWN; - LinkMonitor::BEARER bearer = LinkMonitor::BEARER_UNKNOWN; - int rssi = -1000; - if(_modem->getLinkState(&rssi, ®State, &bearer)==0) - { - if(rssi==-1000) - { LOG("Checking signal strength - RSSI: Error."); return false;} - else - { LOG("Signal strength is: RSSI: %d",rssi);} - - - switch(regState) { - case LinkMonitor::REGISTRATION_STATE_UNKNOWN: - LOG("regState: UNKNOWN. Failing."); - return false; - case LinkMonitor::REGISTRATION_STATE_REGISTERING: - LOG("regState: REGISTERING"); - break; - case LinkMonitor::REGISTRATION_STATE_DENIED: - LOG("regState: DENIED"); - return false; - case LinkMonitor::REGISTRATION_STATE_NO_SIGNAL: - LOG("regState: NO SIGNAL"); - return false; - case LinkMonitor::REGISTRATION_STATE_HOME_NETWORK: - LOG("regState: HOME NETWORK"); - break; - case LinkMonitor::REGISTRATION_STATE_ROAMING: - LOG("regState: ROAMING"); - break; - default: - LOG("regState: ERROR. Failing."); - return false; - } - } - - - LOG("Test %d sending an SMS message...", _testCaseNumber); - LOG("Sending SMS:' %s ' to test phone: %s , waiting for response.", irregularMessage, testPhoneNumber); - - int ret = _modem->sendSM(testPhoneNumber, irregularMessage); - - if (ret) - { - LOG("Error in sending the SMS message. The return values is: %d", ret); - - switch(ret){ - case(NET_INVALID): LOG("Error message is: 'phone number is invalid size, must be less than 16 digits'.");break; - case(NET_PROTOCOL): LOG("Error message is: 'protocol error from the modem'.");break; - default: LOG("Undefined error message."); - - } - return false; - } - LOG("Test %d passed...", _testCaseNumber); - return true; - } - - private: - - +#pragma once +#include "VodafoneTestCase.h" +//#define __DEBUG__ 1 + +// this test case will wait to send an SMS from the modem. +// if the method that sends a message returns an error it will fail. +// it will report the test as failed if any of the above happens. +// it does not wait after it has succesfully sent an SMS. +// this test basic characters and numbers can be sent via SMS. + +extern const char *gTest14Description; + +class Test14 : public VodafoneTestCase { + public: + + + Test14(VodafoneUSBModem *m) : VodafoneTestCase(m) { + _description = gTest14Description; + _testCaseNumber = 14; + } + + + virtual bool execute() { + + LinkMonitor::REGISTRATION_STATE regState = LinkMonitor::REGISTRATION_STATE_UNKNOWN; + LinkMonitor::BEARER bearer = LinkMonitor::BEARER_UNKNOWN; + int rssi = -1000; + if(_modem->getLinkState(&rssi, ®State, &bearer)==0) + { + if(rssi==-1000) + { LOG("Checking signal strength - RSSI: Error."); return false;} + else + { LOG("Signal strength is: RSSI: %d",rssi);} + + + switch(regState) { + case LinkMonitor::REGISTRATION_STATE_UNKNOWN: + LOG("regState: UNKNOWN. Failing."); + return false; + case LinkMonitor::REGISTRATION_STATE_REGISTERING: + LOG("regState: REGISTERING"); + break; + case LinkMonitor::REGISTRATION_STATE_DENIED: + LOG("regState: DENIED"); + return false; + case LinkMonitor::REGISTRATION_STATE_NO_SIGNAL: + LOG("regState: NO SIGNAL"); + return false; + case LinkMonitor::REGISTRATION_STATE_HOME_NETWORK: + LOG("regState: HOME NETWORK"); + break; + case LinkMonitor::REGISTRATION_STATE_ROAMING: + LOG("regState: ROAMING"); + break; + default: + LOG("regState: ERROR. Failing."); + return false; + } + } + + + LOG("Test %d sending an SMS message...", _testCaseNumber); + LOG("Sending SMS:' %s ' to test phone: %s , waiting for response.", gIrregularMessage, gTestPhoneNumber); + + int ret = _modem->sendSM(gTestPhoneNumber, gIrregularMessage); + + if (ret) + { + LOG("Error in sending the SMS message. The return values is: %d", ret); + + switch(ret){ + case(NET_INVALID): LOG("Error message is: 'phone number is invalid size, must be less than 16 digits'.");break; + case(NET_PROTOCOL): LOG("Error message is: 'protocol error from the modem'.");break; + default: LOG("Undefined error message."); + + } + return false; + } + LOG("Test %d passed...", _testCaseNumber); + return true; + } + + private: + }; \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Tests/Test14.h.orig Fri Sep 14 13:23:29 2012 +0000 @@ -0,0 +1,87 @@ +#pragma once +#include "VodafoneTestCase.h" +//#define __DEBUG__ 1 + +// this test case will wait to send an SMS from the modem. +// if the method that sends a message returns an error it will fail. +// it will report the test as failed if any of the above happens. +// it does not wait after it has succesfully sent an SMS. +// this test basic characters and numbers can be sent via SMS. + +static const char *gTest14Description = "Send an SMS message with irregular characters and numbers..."; + + +class Test14 : public VodafoneTestCase { + public: + + + Test14(VodafoneUSBModem *m) : VodafoneTestCase(m) { + _description = gTest14Description; + _testCaseNumber = 14; + } + + + virtual bool execute() { + + LinkMonitor::REGISTRATION_STATE regState = LinkMonitor::REGISTRATION_STATE_UNKNOWN; + LinkMonitor::BEARER bearer = LinkMonitor::BEARER_UNKNOWN; + int rssi = -1000; + if(_modem->getLinkState(&rssi, ®State, &bearer)==0) + { + if(rssi==-1000) + { LOG("Checking signal strength - RSSI: Error."); return false;} + else + { LOG("Signal strength is: RSSI: %d",rssi);} + + + switch(regState) { + case LinkMonitor::REGISTRATION_STATE_UNKNOWN: + LOG("regState: UNKNOWN. Failing."); + return false; + case LinkMonitor::REGISTRATION_STATE_REGISTERING: + LOG("regState: REGISTERING"); + break; + case LinkMonitor::REGISTRATION_STATE_DENIED: + LOG("regState: DENIED"); + return false; + case LinkMonitor::REGISTRATION_STATE_NO_SIGNAL: + LOG("regState: NO SIGNAL"); + return false; + case LinkMonitor::REGISTRATION_STATE_HOME_NETWORK: + LOG("regState: HOME NETWORK"); + break; + case LinkMonitor::REGISTRATION_STATE_ROAMING: + LOG("regState: ROAMING"); + break; + default: + LOG("regState: ERROR. Failing."); + return false; + } + } + + + LOG("Test %d sending an SMS message...", _testCaseNumber); + LOG("Sending SMS:' %s ' to test phone: %s , waiting for response.", gIrregularMessage, gTestPhoneNumber); + + int ret = _modem->sendSM(gTestPhoneNumber, gIrregularMessage); + + if (ret) + { + LOG("Error in sending the SMS message. The return values is: %d", ret); + + switch(ret){ + case(NET_INVALID): LOG("Error message is: 'phone number is invalid size, must be less than 16 digits'.");break; + case(NET_PROTOCOL): LOG("Error message is: 'protocol error from the modem'.");break; + default: LOG("Undefined error message."); + + } + return false; + } + LOG("Test %d passed...", _testCaseNumber); + return true; + } + + private: + + +}; \ No newline at end of file
--- a/Tests/Test16.h Thu Sep 13 15:46:50 2012 +0000 +++ b/Tests/Test16.h Fri Sep 14 13:23:29 2012 +0000 @@ -26,6 +26,7 @@ LinkMonitor::REGISTRATION_STATE regState = LinkMonitor::REGISTRATION_STATE_UNKNOWN; LinkMonitor::BEARER bearer = LinkMonitor::BEARER_UNKNOWN; int rssi = -1000; + LOG("Test is starting...."); if(_modem->getLinkState(&rssi, ®State, &bearer)==0) { if(rssi==-1000) @@ -61,9 +62,9 @@ LOG("Test %d sending an SMS message...", _testCaseNumber); - LOG("Sending SMS:' %s ' to test phone: %s , waiting for response.", alphabetNumbersMessage, testPhoneNumber); + LOG("Sending SMS:' %s ' to test phone: %s , waiting for response.", gAlphabetNumbersMessage, gTestPhoneNumber); - int ret = _modem->sendSM(testPhoneNumber, alphabetNumbersMessage); + int ret = _modem->sendSM(gTestPhoneNumber, gAlphabetNumbersMessage); if (ret) {
--- a/Tests/Test56.h Thu Sep 13 15:46:50 2012 +0000 +++ b/Tests/Test56.h Fri Sep 14 13:23:29 2012 +0000 @@ -57,21 +57,21 @@ LOG("Creating GSM test buffer"); LOG("Test %d sending an SMS message...", _testCaseNumber); - LOG("Sending SMS:' %s ' to test phone: %s , waiting for response.", irregularMessage, testPhoneNumber); + LOG("Sending SMS:' %s ' to test phone: %s , waiting for response.", gIrregularMessage, gTestPhoneNumber); // create a buffer and send each character until you can send them all char shortBuffer[30]; - for (int i=0; i < sizeof(irregularMessage); i++) + for (int i=0; i < sizeof(gIrregularMessage); i++) { - shortBuffer[i] = irregularMessage[i]; + shortBuffer[i] = gIrregularMessage[i]; LOG("Buffer is now: %s", shortBuffer); - LOG("Irregular message is %s", irregularMessage); - int ret = _modem->sendSM(testPhoneNumber, shortBuffer); + LOG("Irregular message is %s", gIrregularMessage); + int ret = _modem->sendSM(gTestPhoneNumber, shortBuffer); } - int ret = _modem->sendSM(testPhoneNumber, irregularMessage); + int ret = _modem->sendSM(gTestPhoneNumber, gIrregularMessage); if (ret) {
--- a/VodafoneTestCase.h Thu Sep 13 15:46:50 2012 +0000 +++ b/VodafoneTestCase.h Fri Sep 14 13:23:29 2012 +0000 @@ -3,12 +3,13 @@ #include "LogHeader.h" const char myMessage[] = "myMessage is golden"; -//const char testPhoneNumber[] = "+447717275049"; -const char testPhoneNumber[] = "+447785666088"; -const char testMessage[] = "this is a test message !"; -const char alphabetNumbersMessage[] = "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ"; -const char allCharsMessage[] = "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ[]{}()!£$%&*,.':;"; -const char irregularMessage[] = "/:[]{}()!£$%&*,.';"; + +//const char testPhoneNumber[] = "+447717275049"; // this is my number - change to this to get all the 'send' tests to send to my number +const char gTestPhoneNumber[] = "+447785666088"; // this is my test contract sim - change to this to get all the 'send' tests to send to it's self - making tests automatic! :-) +const char gTestMessage[] = "this is a test message !"; +const char gAlphabetNumbersMessage[] = "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ"; +const char gAallCharsMessage[] = "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ[]{}()!£$%&*,.':;"; +const char gIrregularMessage[] = "/:[]{}()!£$%&*,.';"; class VodafoneTestCase {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/VodafoneTestCase.h.orig Fri Sep 14 13:23:29 2012 +0000 @@ -0,0 +1,47 @@ +#pragma once +#include "VodafoneUSBModem.h" +#include "LogHeader.h" + +const char myMessage[] = "myMessage is golden"; +//const char testPhoneNumber[] = "+447717275049"; // this is my number - change to this to get all the 'send' tests to send to my number +const char gTestPhoneNumber[] = "+447785666088"; // this is my test contract sim - change to this to get all the 'send' tests to send to it's self - making tests automatic! :-) +const char gTestMessage[] = "this is a test message !"; +const char gAlphabetNumbersMessage[] = "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ"; +const char gAallCharsMessage[] = "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ[]{}()!£$%&*,.':;"; +const char gIrregularMessage[] = "/:[]{}()!£$%&*,.';"; + + +class VodafoneTestCase { + public: + VodafoneTestCase(VodafoneUSBModem *m) : _modem(m) , _lastRunTime(0), _lastRunOutcome(false) { + } + + bool run() { + _lastRunTime = time(NULL); + setupTest(); + _lastRunOutcome = execute(); + endTest(); + return _lastRunOutcome; + } + + virtual void setupTest() { + } + + virtual bool execute() { + LOG("Base class runTest called!"); + return true; + } + + virtual void endTest() { + + } + + protected: + VodafoneUSBModem *_modem; + + public: + time_t _lastRunTime; + bool _lastRunOutcome; + int _testCaseNumber; + const char* _description; +}; \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/VodafoneUSBModem_bleedingedge.lib.orig Fri Sep 14 13:23:29 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/donatien/code/VodafoneUSBModem_bleedingedge/#0900b15d44d1
--- a/main.cpp Thu Sep 13 15:46:50 2012 +0000 +++ b/main.cpp Fri Sep 14 13:23:29 2012 +0000 @@ -45,7 +45,11 @@ LOG("heap: %d, stack: %d, size: %d",heap,stack,stack-heap); LOG("Running tests."); - int numPassed = m->executeTestProfile(TESTS_AUTOMATED); + + + + int numPassed = m->executeTestProfile(TESTS_AUTOMATED); + loopForever(); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp.orig Fri Sep 14 13:23:29 2012 +0000 @@ -0,0 +1,80 @@ +#define __DEBUG__ 4 //Maximum verbosity +#ifndef __MODULE__ +#define __MODULE__ "net_3g_basic_http_test.cpp" +#endif + +#include "LogHeader.h" + +#include "mbed.h" +#include "socket/bsd_socket.h" +#include "rtos.h" +#include "VodafoneUSBModem.h" +#include "VodafoneTestCase.h" +#include "TestManager.h" + +DigitalOut led1(LED1); +DigitalOut led2(LED2); +DigitalOut led3(LED3); +DigitalOut led4(LED4); + +extern "C" void HardFault_Handler() { error("Hard Fault!\n"); } + +time_t startTime = 0; +time_t gPreviousUptime = 0; +time_t gUptime = 0; + +void loopForever() { + while(1) { + Thread::wait(1000); + time_t now = time(NULL); + gPreviousUptime = gUptime; + } +} + +void test(void const*) { + VodafoneUSBModem modem; + LOG("Constructing TestManager"); + TestManager *m = new TestManager(&modem); + LOG("Running tests."); + + + int numPassed = m->executeTestProfile(TESTS_MANUAL); + + loopForever(); +} + + + +void setTime() { + struct tm t; + t.tm_year = 2012; + t.tm_mon = 8; + t.tm_mday = 23; + t.tm_hour = 9; + t.tm_min = 19; + t.tm_sec = 0; + t.tm_year -= 1900; + t.tm_mon -= 1; + set_time(mktime(&t)); +} + +int main() { + + DBG_INIT(); + DBG_SET_SPEED(115200); + DBG_SET_NEWLINE("\r\n"); + + //setTime(); + size_t currentTime = time(NULL); + fprintf(stdout,"Invocation time: %s\r\n",ctime(¤tTime)); + + + Thread testTask(test, NULL, osPriorityNormal, 1024 * 8); + // this thread just waits and blinks leds periodically + while(1) { + led1 = !led1; + Thread::wait(500); + led1 = !led1; + Thread::wait(30000); + } +} \ No newline at end of file