Vodafone Test Suite
Dependencies: mbed-rtos mbed HTTPClient VodafoneUSBModem
Revision 66:6b00a764e549, committed 2012-11-01
- Comitter:
- ashleymills
- Date:
- Thu Nov 01 11:19:47 2012 +0000
- Parent:
- 65:ef3357b6ce97
- Child:
- 67:a61d60fa342c
- Commit message:
- Renamed tests in sequential order to make it easier to manage and cleaner to follow.
Changed in this revision
--- a/TestManager.cpp Tue Oct 30 15:51:53 2012 +0000 +++ b/TestManager.cpp Thu Nov 01 11:19:47 2012 +0000 @@ -8,33 +8,33 @@ VodafoneTestCase* TestManager::constructTest(int testID) { switch(testID) { - case 0: break; - case 1: break; - case 2: break; - case 3: break; - case 4: break; - case 5: break; - case 6: break; - case 7: break; - case 8: return (VodafoneTestCase*) new Test08(_modem); - case 9: break; - case 10: return (VodafoneTestCase*) new Test10(_modem); - case 11: break; - case 12: return (VodafoneTestCase*) new Test12(_modem); - case 13: return (VodafoneTestCase*) new Test13(_modem); - case 14: return (VodafoneTestCase*) new Test14(_modem); + case 0: return (VodafoneTestCase*) new Test00(_modem); + case 1: return (VodafoneTestCase*) new Test01(_modem); + case 2: return (VodafoneTestCase*) new Test02(_modem); + case 3: return (VodafoneTestCase*) new Test03(_modem); + case 4: return (VodafoneTestCase*) new Test04(_modem); + case 5: return (VodafoneTestCase*) new Test05(_modem); + case 6: return (VodafoneTestCase*) new Test06(_modem);; + case 7: return (VodafoneTestCase*) new Test07(_modem);; + case 8: return (VodafoneTestCase*) new Test08(_modem);; + case 9: return (VodafoneTestCase*) new Test09(_modem);; + case 10: return (VodafoneTestCase*) new Test10(_modem);; + case 11: return (VodafoneTestCase*) new Test11(_modem);; + case 12: return (VodafoneTestCase*) new Test12(_modem);; + case 13: return (VodafoneTestCase*) new Test13(_modem);; + case 14: break; case 15: break; - case 16: return (VodafoneTestCase*) new Test16(_modem); + case 16: break; case 17: break; case 18: break; case 19: break; case 20: break; - case 21: return (VodafoneTestCase*) new Test21(_modem); - case 22: return (VodafoneTestCase*) new Test22(_modem); - case 23: return (VodafoneTestCase*) new Test23(_modem); + case 21: break; + case 22: break; + case 23: break; case 24: break; - case 25: return (VodafoneTestCase*) new Test25(_modem); - case 26: return (VodafoneTestCase*) new Test26(_modem); + case 25: break; + case 26: break; case 27: break; case 28: break; case 29: break; @@ -58,13 +58,13 @@ case 47: break; case 48: break; case 49: break; - case 50: return (VodafoneTestCase*) new Test50(_modem); - case 51: return (VodafoneTestCase*) new Test51(_modem); + case 50: break; + case 51: break; case 52: break; case 53: break; case 54: break; case 55: break; - case 56: return (VodafoneTestCase*) new Test56(_modem); + case 56: break; case 57: break; case 58: break; case 59: break;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Tests/Test00.cpp Thu Nov 01 11:19:47 2012 +0000 @@ -0,0 +1,148 @@ +#include "Test00.h" +#include "socket.h" + +bool connectToSocket(char *ipAddress, int port, int *sockfd) { + *sockfd = -1; + // create the socket + if((*sockfd=socket(AF_INET,SOCK_STREAM,0))<0) { + LOG("Error opening socket\r\n"); + return false; + } else { + LOG("Socket open\r\n"); + } + + // create the socket address + sockaddr_in serverAddress; + std::memset(&serverAddress, 0, sizeof(struct sockaddr_in)); + serverAddress.sin_addr.s_addr = inet_addr(ipAddress); + serverAddress.sin_family = AF_INET; + serverAddress.sin_port = htons(port); + + // do socket connect + LOG("Connecting socket to %s:%d", inet_ntoa(serverAddress.sin_addr), ntohs(serverAddress.sin_port)); + if(connect(*sockfd, (const struct sockaddr *)&serverAddress, sizeof(serverAddress))<0) { + ::close(*sockfd); + LOG("Could not connect"); + return false; + } else { + LOG("Connection OK"); + } + return true; +} + +const char *gTest00DNSIn[5] = { + "m2mthings.com", + "kent.ac.uk", + "example.com", + "m2mcontroller.com", + "www.mbed.org", +}; + +const char *gTest00DNSOut[5] = { + "109.74.199.96", + "129.12.10.249", + "192.0.43.10", + "62.105.171.138", + "217.140.101.20", +}; + +const int gTest00NumDNSVals = 5; + +Test00::Test00(VodafoneUSBModem *m) : VodafoneTestCase(m) {} + +void Test00::setupTest() {} + +bool Test00::executeTest() { + bool outcome = true; + LOG("Description: %s",gTest00Description); + LOG("Connecting to internet"); + if(_modem->connect("internet","web","web")==0) { + LOG("Connected to internet"); + } else { + LOG("Failed to connect to internet"); + outcome = false; + } + + // try connecting to DNS server directly + int sockfd; + //if(connectToSocket("88.82.13.28",53,&sockfd)) { + + if(connectToSocket("109.74.199.96",80,&sockfd)) { + close(sockfd); + } + + + struct hostent *server; + do { + while(1) { + LOG("Getting host address"); + server = ::gethostbyname("m2mthings.com"); + if(server==NULL) { + LOG("Failure getting host address!"); + outcome = false; + //break; + } else { + LOG("got host address, length %d",server->h_length); + break; + } + } + + if(server->h_length==4) { + LOG("DNS lookup returned %d.%d.%d.%d", + server->h_addr[0], + server->h_addr[1], + server->h_addr[2], + server->h_addr[3] + ); + outcome = true; + } else { + LOG("Only IPv4 addresses are supported."); + outcome = false; + break; + } + } while(0); + + // this is the real test + + char dnsOut[32]; + + for(int i=0; i<gTest00NumDNSVals; i++) { + LOG("Running DNS lookup for %s",gTest00DNSIn[i]); + server = ::gethostbyname(gTest00DNSIn[i]); + if(server==NULL) { + LOG("Failure getting host address!"); + outcome = false; + break; + } else { + LOG("Got host address, length %d",server->h_length); + } + + if(server->h_length==4) { + sprintf(dnsOut,"%d.%d.%d.%d", + server->h_addr[0], + server->h_addr[1], + server->h_addr[2], + server->h_addr[3] + ); + LOG("DNS lookup returned %s",dnsOut); + } else { + LOG("Error. Only IPv4 addresses are supported."); + outcome = false; + break; + } + + LOG("Expected %s, got %s",gTest00DNSOut[i],dnsOut); + if(strcmp(dnsOut,gTest00DNSOut[i])!=0) { + LOG("Mismatch. Fail."); + outcome = false; + break; + } else { + LOG("Match. OK."); + } + } + + _modem->disconnect(); + return outcome; +} + +void Test00::endTest() { } \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Tests/Test00.h Thu Nov 01 11:19:47 2012 +0000 @@ -0,0 +1,16 @@ +#pragma once +#include "VodafoneTestCase.h" +#include "HTTPClient.h" +extern const char *gTest00Description; + +/** Resolve 5 DNS requests and match against known IPs. + */ +class Test00 : public VodafoneTestCase { + public: + Test00(VodafoneUSBModem *m); + + private: + virtual void setupTest(); + virtual bool executeTest(); + virtual void endTest(); +}; \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Tests/Test01.cpp Thu Nov 01 11:19:47 2012 +0000 @@ -0,0 +1,108 @@ +#include "Test01.h" + +class HTTPFileValidator : public IHTTPDataIn { +public: + HTTPFileValidator(int sockfd) { + _fileIsValid = false; + _bytesRead = 0; + } + + bool isValid() { + return _fileIsValid; + } + + int bytesRead() { + return _bytesRead; + } + +protected: + //IHTTPDataIn + virtual int write(const char* buf, size_t len) { + int i = 0; + // do nothing if file already found invalid + if(!_fileIsValid) + return len; + + // check that received characters are in correct sequence + for(i=0; i<len; i++) { + if(buf[i]!=_expectedChar) { + _fileIsValid = false; + break; + } + _expectedChar++; + if(_expectedChar==256) { + _expectedChar = 0; + } + } + _bytesRead += i; + + return len; + } + virtual void writeReset() { + _fileIsValid = true; + _expectedChar = 0; + _bytesRead = 0; + } + virtual void setDataType(const char* type) {} + virtual void setIsChunked(bool chunked) {} + virtual void setDataLen(size_t len) {} + bool _fileIsValid; + char _expectedChar; + int _bytesRead; +}; + + +Test01::Test01(VodafoneUSBModem *m) : VodafoneTestCase(m) {} + +void Test01::setupTest() {} + +bool Test01::executeTest() { + HTTPClient http; + char urlBuffer[125]; + bool outcome = true; + LOG("Description: %s",gTest01Description); + LOG("Connecting to internet"); + if(_modem->connect("internet","web","web")==0) { + LOG("Connected to internet"); + } else { + LOG("Failed to connect to internet"); + _modem->disconnect(); + return false; + } + + // retrieve files whose sizes are successive powers of 2 from 128 bytes upto 1MB + int bytesToRead = 128; + HTTPFileValidator fileValidator(0); + Timer t; + for(int i=0; i<14; i++) { + sprintf(urlBuffer,"http://www.m2mthings.com/test%d.txt",bytesToRead); + LOGX("Doing HTTP GET for %s ... ",urlBuffer); + + // read the file + t.reset(); + t.start(); + if(http.get(urlBuffer, &fileValidator)!=0) { + LOG("ERROR reading file from website"); + outcome = false; + t.stop(); + break; + } + t.stop(); + + // check that all received bytes were valid, and that the total number of bytes read is as expected + if(fileValidator.isValid()&&fileValidator.bytesRead()==bytesToRead) { + LOG("OK. (%f seconds, %f kb/s)",t.read(),((float)bytesToRead/1000.0)/t.read()); + } else { + LOG("ERROR in file validation after %f seconds and %d bytes read.",t.read(),fileValidator.bytesRead()); + outcome = false; + break; + } + + bytesToRead *= 2; + } + + _modem->disconnect(); + return outcome; +} + +void Test01::endTest() { } \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Tests/Test01.h Thu Nov 01 11:19:47 2012 +0000 @@ -0,0 +1,14 @@ +#pragma once +#include "VodafoneTestCase.h" +#include "HTTPClient.h" +extern const char *gTest01Description; + +class Test01 : public VodafoneTestCase { + public: + Test01(VodafoneUSBModem *m); + + private: + virtual void setupTest(); + virtual bool executeTest(); + virtual void endTest(); +}; \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Tests/Test02.h Thu Nov 01 11:19:47 2012 +0000 @@ -0,0 +1,62 @@ +#pragma once +#include "VodafoneTestCase.h" + +// this test case will wait to receive an SMS from the modem. +// if the method that reports a message waiting returns an error it will fail. +// if the method that returns the message from the mailbox returns an error it will fai. +// it will report the test as failed if any of the above happens. +// it waits forever for an SMS. +// TODO: this should wait for a set time before failing. + +extern const char *gTest02Description; +extern const char *gAlphabetNumbersMessage; + +class Test02 : public VodafoneTestCase { + public: + + char num[17]; + char msg[160]; + size_t count; + + Test02(VodafoneUSBModem *m) : VodafoneTestCase(m) {} + + private: + + virtual bool executeTest() { + LOG(gTest02Description); + LOG("Receiving SMS from test phone, waiting for response."); + + while(true) + { + LOG("Waiting for an SMS message..."); + int ret = _modem->getSMCount(&count); + if(ret) + { + LOG("getSMCount returned %d", ret); + Thread::wait(3000); + continue; + } + + if( count > 0) + { + LOG("%d SMS to read", count); + ret = _modem->getSM(num, msg, 64); + if(ret) + { + LOG("Error receiving sms. The method getSMS returned %d", ret); + return false; + } + LOG("The message is from number: %s and the message is: \"%s\"", num, msg); + if (strcmp (msg, gAlphabetNumbersMessage) ==0) + { + LOG("Success receiving alphabet message matches the sent message"); + return true; + } + + return false; + } + Thread::wait(500); + } + + } +};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Tests/Test03.h Thu Nov 01 11:19:47 2012 +0000 @@ -0,0 +1,65 @@ +#pragma once +#include "VodafoneTestCase.h" + +#define TEST_PHONE_NUMBER "+447717275049" + +// this test case will wait to receive an SMS from the modem. +// if the method that reports a message waiting returns an error it will fail. +// if the method that returns the message from the mailbox returns an error it will fai. +// it will report the test as failed if any of the above happens. +// it waits forever for an SMS. +// TODO: this should wait for a set time before failing. + +extern const char *gTest03Description; +extern const char *gIrregularMessage; + +class Test03 : public VodafoneTestCase { + public: + + char num[17]; + char msg[160]; + size_t count; + + Test03(VodafoneUSBModem *m) : VodafoneTestCase(m) {} + + private: + + virtual bool executeTest() { + LOG(gTest03Description); + LOG("Receiving SMS from test phone, waiting for response."); + + while(true) + { + LOG("Waiting for an SMS message..."); + int ret = _modem->getSMCount(&count); + if(ret) + { + LOG("getSMCount returned %d", ret); + Thread::wait(3000); + continue; + } + + if( count > 0) + { + LOG("%d SMS to read", count); + ret = _modem->getSM(num, msg, 64); + + if(ret) + { + LOG("Error receiving sms. The method getSMS returned %d", ret); + return false; + } + LOG("The message is from number: %s and the message is: \"%s\"", num, msg); + if (strcmp (msg, gIrregularMessage) ==0) + { + LOG("Success receiving alphabet message matches the sent message"); + return true; + } + + return true; + } + Thread::wait(500); + } + + } +}; \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Tests/Test04.h Thu Nov 01 11:19:47 2012 +0000 @@ -0,0 +1,78 @@ +#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 *gTest04Description; +extern const char *gTestPhoneNumber; +extern const char *gAlphabetNumbersMessage; + +class Test04 : public VodafoneTestCase { + public: + + Test04(VodafoneUSBModem *m) : VodafoneTestCase(m) {} + + private: + virtual bool executeTest() { + LOG(gTest04Description); + 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("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; + } + return true; + } +}; \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Tests/Test05.h Thu Nov 01 11:19:47 2012 +0000 @@ -0,0 +1,79 @@ +#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 *gTest05Description; + +class Test05 : public VodafoneTestCase { + public: + + + Test05(VodafoneUSBModem *m) : VodafoneTestCase(m) {} + + private: + + virtual bool executeTest() { + LOG(gTest05Description); + 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("Sending SMS:' %s ' to test phone: %s , waiting for response.", gAlphabetNumbersMessage, gTestPhoneNumber); + + int ret = _modem->sendSM(gTestPhoneNumber, gAlphabetNumbersMessage); + + 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; + } + return true; + } +}; \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Tests/Test06.h Thu Nov 01 11:19:47 2012 +0000 @@ -0,0 +1,34 @@ +#pragma once +#include "VodafoneTestCase.h" + +extern const char* gTest06Description; +//const int gTest06Depends[] = {}; + +class Test06 : public VodafoneTestCase { + public: + Test06(VodafoneUSBModem *m) : VodafoneTestCase(m) {} + + private: + + virtual void setupTest() { + _ussdResponse = (char*)malloc(16*sizeof(char)); + } + + virtual bool executeTest() { + LOG(gTest06Description); + + if(_modem->sendUSSD("*#100#",_ussdResponse,16)!=0) { + LOG("Error sending USSD"); + return false; + } + + LOG("Received USSD response: \"%s\"",_ussdResponse); + return true; + } + + virtual void endTest() { + free(_ussdResponse); + } + + char *_ussdResponse; +};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Tests/Test07.h Thu Nov 01 11:19:47 2012 +0000 @@ -0,0 +1,31 @@ +#pragma once +#include "VodafoneTestCase.h" +extern const char* gTest07Description; + +class Test07 : public VodafoneTestCase { + public: + Test07(VodafoneUSBModem *m) : VodafoneTestCase(m) {} + + private: + virtual void setupTest() { + _ussdResponse = (char*)malloc(16*sizeof(char)); + } + + virtual bool executeTest() { + LOG(gTest07Description); + + if(_modem->sendUSSD(".2890",_ussdResponse,16)!=0) { + LOG("Error sending USSD"); + return false; + } + + LOG("Expecting \"Unknown command\". Received USSD response: \"%s\"",_ussdResponse); + return (strcmp(_ussdResponse,"Unknown command")==0); + } + + virtual void endTest() { + free(_ussdResponse); + } + + char *_ussdResponse; +};
--- a/Tests/Test08.cpp Tue Oct 30 15:51:53 2012 +0000 +++ b/Tests/Test08.cpp Thu Nov 01 11:19:47 2012 +0000 @@ -1,148 +1,30 @@ +#pragma once #include "Test08.h" -#include "socket.h" - -bool connectToSocket(char *ipAddress, int port, int *sockfd) { - int ret = -1; - *sockfd = -1; - // create the socket - if((*sockfd=socket(AF_INET,SOCK_STREAM,0))<0) { - LOG("Error opening socket\r\n"); - } else { - LOG("Socket open\r\n"); - } - - // create the socket address - sockaddr_in serverAddress; - std::memset(&serverAddress, 0, sizeof(struct sockaddr_in)); - serverAddress.sin_addr.s_addr = inet_addr(ipAddress); - serverAddress.sin_family = AF_INET; - serverAddress.sin_port = htons(port); - // do socket connect - LOG("Connecting socket to %s:%d", inet_ntoa(serverAddress.sin_addr), ntohs(serverAddress.sin_port)); - if((ret=::connect(*sockfd, (const struct sockaddr *)&serverAddress, sizeof(serverAddress)))<0) { - ::close(*sockfd); - LOG("Could not connect"); - return false; - } else { - LOG("Connection OK"); - } - return true; -} - -const char *gTest08DNSIn[5] = { - "m2mthings.com", - "kent.ac.uk", - "example.com", - "m2mcontroller.com", - "www.mbed.org", -}; - -const char *gTest08DNSOut[5] = { - "109.74.199.96", - "129.12.10.249", - "192.0.43.10", - "62.105.171.138", - "217.140.101.20", -}; - -const int gTest08NumDNSVals = 5; +const char gTest08USSDMessage[161] = "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; Test08::Test08(VodafoneUSBModem *m) : VodafoneTestCase(m) {} -void Test08::setupTest() {} - -bool Test08::executeTest() { - bool outcome = true; - LOG("Description: %s",gTest08Description); - LOG("Connecting to internet"); - if(_modem->connect("internet","web","web")==0) { - LOG("Connected to internet"); - } else { - LOG("Failed to connect to internet"); - outcome = false; - } - - // try connecting to DNS server directly - int sockfd; - //if(connectToSocket("88.82.13.28",53,&sockfd)) { - - if(connectToSocket("109.74.199.96",80,&sockfd)) { - close(sockfd); - } - +// virtual +void Test08::setupTest() { + _ussdResponse = (char*)malloc(16*sizeof(char)); +} - struct hostent *server; - do { - while(1) { - LOG("Getting host address"); - server = ::gethostbyname("m2mthings.com"); - if(server==NULL) { - LOG("Failure getting host address!"); - outcome = false; - //break; - } else { - LOG("got host address, length %d",server->h_length); - break; - } - } - - if(server->h_length==4) { - LOG("DNS lookup returned %d.%d.%d.%d", - server->h_addr[0], - server->h_addr[1], - server->h_addr[2], - server->h_addr[3] - ); - outcome = true; - } else { - LOG("Only IPv4 addresses are supported."); - outcome = false; - break; - } - } while(0); - - // this is the real test - - char dnsOut[32]; - - for(int i=0; i<gTest08NumDNSVals; i++) { - LOG("Running DNS lookup for %s",gTest08DNSIn[i]); - server = ::gethostbyname(gTest08DNSIn[i]); - if(server==NULL) { - LOG("Failure getting host address!"); - outcome = false; - break; - } else { - LOG("Got host address, length %d",server->h_length); - } - - if(server->h_length==4) { - sprintf(dnsOut,"%d.%d.%d.%d", - server->h_addr[0], - server->h_addr[1], - server->h_addr[2], - server->h_addr[3] - ); - LOG("DNS lookup returned %s",dnsOut); - } else { - LOG("Error. Only IPv4 addresses are supported."); - outcome = false; - break; - } - - LOG("Expected %s, got %s",gTest08DNSOut[i],dnsOut); - if(strcmp(dnsOut,gTest08DNSOut[i])!=0) { - LOG("Mismatch. Fail."); - outcome = false; - break; - } else { - LOG("Match. OK."); - } +// virtual +bool Test08::executeTest() { + + LOG(gTest08Description); + + if(_modem->sendUSSD(gTest08USSDMessage,_ussdResponse,16)!=0) { + LOG("Error sending USSD"); + return false; } - - _modem->disconnect(); - return outcome; + + LOG("Expecting \"Unknown Command\". Received USSD response: \"%s\"",_ussdResponse); + return (strcmp(_ussdResponse,"Unknown command")==0); } -void Test08::endTest() { } \ No newline at end of file +// virtual +void Test08::endTest() { + free(_ussdResponse); +} \ No newline at end of file
--- a/Tests/Test08.h Tue Oct 30 15:51:53 2012 +0000 +++ b/Tests/Test08.h Thu Nov 01 11:19:47 2012 +0000 @@ -1,16 +1,14 @@ -#pragma once -#include "VodafoneTestCase.h" -#include "HTTPClient.h" -extern const char *gTest08Description; - -/** Resolve 5 DNS requests and match against known IPs. - */ -class Test08 : public VodafoneTestCase { - public: - Test08(VodafoneUSBModem *m); - - private: - virtual void setupTest(); - virtual bool executeTest(); - virtual void endTest(); +#pragma once +#include "VodafoneTestCase.h" + +extern const char *gTest08Description; + +class Test08 : public VodafoneTestCase { + public: + Test08(VodafoneUSBModem *m); + private: + virtual void setupTest(); + virtual bool executeTest(); + virtual void endTest(); + char *_ussdResponse; }; \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Tests/Test09.h Thu Nov 01 11:19:47 2012 +0000 @@ -0,0 +1,89 @@ +#pragma once +#include "VodafoneTestCase.h" + +extern const char* gTest09Description; + +class Test09 : public VodafoneTestCase { + public: + Test09(VodafoneUSBModem *m) : VodafoneTestCase(m) {} + private: + + virtual void setupTest() { + + } + + virtual bool executeTest() { + + LOG(gTest09Description); + int rssi = -1000; + LinkMonitor::REGISTRATION_STATE regState = LinkMonitor::REGISTRATION_STATE_UNKNOWN; + LinkMonitor::BEARER bearer = LinkMonitor::BEARER_UNKNOWN; + + if(_modem->getLinkState(&rssi, ®State, &bearer)==0) { + if(rssi==-1000) { + LOG("RSSI: Error."); + return false; + } else { + LOG("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"); + break; + case LinkMonitor::REGISTRATION_STATE_NO_SIGNAL: + LOG("regState: NO SIGNAL"); + break; + 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; + } + + switch(bearer) { + case LinkMonitor::BEARER_UNKNOWN: + LOG("bearer: UNKNOWN. Failing."); + return false; + case LinkMonitor::BEARER_GSM: + LOG("bearer: GSM"); + break; + case LinkMonitor::BEARER_EDGE: + LOG("bearer: EDGE"); + break; + case LinkMonitor::BEARER_UMTS: + LOG("bearer: UMTS"); + break; + case LinkMonitor::BEARER_HSPA: + LOG("bearer: HSPA"); + break; + case LinkMonitor::BEARER_LTE: + LOG("bearer: LTE"); + break; + default: + LOG("bearer: ERROR. Failing."); + return false; + } + + } else { + return false; + } + + return true; + } + + virtual void endTest() { + + } + +};
--- a/Tests/Test10.cpp Tue Oct 30 15:51:53 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,108 +0,0 @@ -#include "Test10.h" - -class HTTPFileValidator : public IHTTPDataIn { -public: - HTTPFileValidator(int sockfd) { - _fileIsValid = false; - _bytesRead = 0; - } - - bool isValid() { - return _fileIsValid; - } - - int bytesRead() { - return _bytesRead; - } - -protected: - //IHTTPDataIn - virtual int write(const char* buf, size_t len) { - int i = 0; - // do nothing if file already found invalid - if(!_fileIsValid) - return len; - - // check that received characters are in correct sequence - for(i=0; i<len; i++) { - if(buf[i]!=_expectedChar) { - _fileIsValid = false; - break; - } - _expectedChar++; - if(_expectedChar==256) { - _expectedChar = 0; - } - } - _bytesRead += i; - - return len; - } - virtual void writeReset() { - _fileIsValid = true; - _expectedChar = 0; - _bytesRead = 0; - } - virtual void setDataType(const char* type) {} - virtual void setIsChunked(bool chunked) {} - virtual void setDataLen(size_t len) {} - bool _fileIsValid; - char _expectedChar; - int _bytesRead; -}; - - -Test10::Test10(VodafoneUSBModem *m) : VodafoneTestCase(m) {} - -void Test10::setupTest() {} - -bool Test10::executeTest() { - HTTPClient http; - char urlBuffer[125]; - bool outcome = true; - LOG("Description: %s",gTest10Description); - LOG("Connecting to internet"); - if(_modem->connect("internet","web","web")==0) { - LOG("Connected to internet"); - } else { - LOG("Failed to connect to internet"); - _modem->disconnect(); - return false; - } - - // retrieve files whose sizes are successive powers of 2 from 128 bytes upto 1MB - int bytesToRead = 128; - HTTPFileValidator fileValidator(0); - Timer t; - for(int i=0; i<14; i++) { - sprintf(urlBuffer,"http://www.m2mthings.com/test%d.txt",bytesToRead); - LOGX("Doing HTTP GET for %s ... ",urlBuffer); - - // read the file - t.reset(); - t.start(); - if(http.get(urlBuffer, &fileValidator)!=0) { - LOG("ERROR reading file from website"); - outcome = false; - t.stop(); - break; - } - t.stop(); - - // check that all received bytes were valid, and that the total number of bytes read is as expected - if(fileValidator.isValid()&&fileValidator.bytesRead()==bytesToRead) { - LOG("OK. (%f seconds, %f kb/s)",t.read(),((float)bytesToRead/1000.0)/t.read()); - } else { - LOG("ERROR in file validation after %f seconds and %d bytes read.",t.read(),fileValidator.bytesRead()); - outcome = false; - break; - } - - bytesToRead *= 2; - } - - _modem->disconnect(); - return outcome; -} - -void Test10::endTest() { } \ No newline at end of file
--- a/Tests/Test10.h Tue Oct 30 15:51:53 2012 +0000 +++ b/Tests/Test10.h Thu Nov 01 11:19:47 2012 +0000 @@ -1,14 +1,92 @@ #pragma once #include "VodafoneTestCase.h" -#include "HTTPClient.h" -extern const char *gTest10Description; + +extern const char* gTest10Description; class Test10 : public VodafoneTestCase { public: - Test10(VodafoneUSBModem *m); - + Test10(VodafoneUSBModem *m) : VodafoneTestCase(m) {} + private: - virtual void setupTest(); - virtual bool executeTest(); - virtual void endTest(); -}; \ No newline at end of file + + virtual void setupTest() { + + } + + virtual bool executeTest() { + LOG(gTest10Description); + for(int count=0; count<30; count++) { + LOG("Iteration %d of 30",count); + int rssi = -1000; + LinkMonitor::REGISTRATION_STATE regState = LinkMonitor::REGISTRATION_STATE_UNKNOWN; + LinkMonitor::BEARER bearer = LinkMonitor::BEARER_UNKNOWN; + + if(_modem->getLinkState(&rssi, ®State, &bearer)==0) { + if(rssi==-1000) { + LOG("RSSI: Error."); + return false; + } else { + LOG("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"); + break; + case LinkMonitor::REGISTRATION_STATE_NO_SIGNAL: + LOG("regState: NO SIGNAL"); + break; + 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; + } + + switch(bearer) { + case LinkMonitor::BEARER_UNKNOWN: + LOG("bearer: UNKNOWN. Failing."); + return false; + case LinkMonitor::BEARER_GSM: + LOG("bearer: GSM"); + break; + case LinkMonitor::BEARER_EDGE: + LOG("bearer: EDGE"); + break; + case LinkMonitor::BEARER_UMTS: + LOG("bearer: UMTS"); + break; + case LinkMonitor::BEARER_HSPA: + LOG("bearer: HSPA"); + break; + case LinkMonitor::BEARER_LTE: + LOG("bearer: LTE"); + break; + default: + LOG("bearer: ERROR. Failing."); + return false; + } + } else { + return false; + } + } + + return true; + } + + virtual void endTest() { + + } + +}; +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Tests/Test11.h Thu Nov 01 11:19:47 2012 +0000 @@ -0,0 +1,121 @@ +#pragma once +#include "VodafoneTestCase.h" + +extern const char* gTest11Description; + +class Test11 : public VodafoneTestCase { + public: + Test11(VodafoneUSBModem *m) : VodafoneTestCase(m) { + _smsLen = 32; + _smsMaxSize = 160; // max size of SMS using + _numberLen = 16; + } + + private: + + virtual void setupTest() { + allocStorage(); + } + + virtual void endTest() { + freeStorage(); + } + + virtual bool executeTest() { + LOG(gTest11Description); + int numIterations = 10; + size_t smCount; + + // Clear out the SMS mail box before we run this test. + // loop 3 times with a 1/2 second break in between each + LOG("... Clearing out SMS mail box first"); + for(int j=0; j<3; j++) { + if(_modem->getSMCount(&smCount)!=0) { + LOG("Faiure getting SM count"); + return false; + } + + for(int i=0; i<smCount; i++) { + if(_modem->getSM(_senderNumber,_smsJunkBuffer,_smsMaxSize)!=0) { + LOG("Strange! The SMS count is bigger than zero but I can't fetch the SMS?"); + return false; + } + LOG("Got SMS: %s",_smsJunkBuffer); + LOG("Clearing that out before running the test."); + } + Thread::wait(500); + } + + LOG("Getting MSISDN"); + _modem->sendUSSD("*#100#",_ownNumber,_numberLen); + LOG("Got MSISDN %s",_ownNumber); + for(int i=0; i<numIterations; i++) { + createRandomString(_smsOut,_smsLen); + if(_modem->sendSM(_ownNumber,_smsOut)!=0) { + LOG("Error sending short message"); + } + LOG("Created: %s",_smsOut); + bool gotMessage = false; + Timer t; + t.start(); + while(!gotMessage && t.read_ms()<25000) { + if(_modem->getSMCount(&smCount)!=0) { + LOG("Faiure getting SM count"); + return false; + } + + if(smCount>0) { + if(_modem->getSM(_senderNumber,_smsIn,_smsLen)!=0) { + LOG("Failure getting SM"); + return false; + } + LOG("Got SMS: %s",_smsIn); + if(strcmp(_smsIn,_smsOut)!=0) { + LOG("FAIL: strings did not match"); + return false; + } + gotMessage = true; + } + Thread::wait(50); + } + if(!gotMessage) { + LOG("FAIL: timeout on waiting for SMS"); + return false; + } + } + + return true; + } + + void createRandomString(char *target, int len) { + for(int i=0; i<len; i++) { + target[i] = 65+rand()%16; + } + target[len-1] = 0x00; + } + + void allocStorage() { + _ownNumber = (char*)malloc(_numberLen*sizeof(char)); + _senderNumber = (char*)malloc(_numberLen*sizeof(char)); + _smsOut = (char*)malloc(_smsLen*sizeof(char)); + _smsIn = (char*)malloc(_smsLen*sizeof(char)); + _smsJunkBuffer= (char*)malloc(_smsMaxSize*sizeof(char)); + } + + void freeStorage() { + free(_ownNumber); + free(_senderNumber); + free(_smsOut); + free(_smsIn); + free(_smsJunkBuffer); + } + + char* _ownNumber; + char* _senderNumber; + char* _smsOut; + char* _smsIn; + char* _smsJunkBuffer; + int _smsLen; + int _smsMaxSize; + int _numberLen; +}; \ No newline at end of file
--- a/Tests/Test12.h Tue Oct 30 15:51:53 2012 +0000 +++ b/Tests/Test12.h Thu Nov 01 11:19:47 2012 +0000 @@ -1,62 +1,162 @@ #pragma once #include "VodafoneTestCase.h" -// this test case will wait to receive an SMS from the modem. -// if the method that reports a message waiting returns an error it will fail. -// if the method that returns the message from the mailbox returns an error it will fai. -// it will report the test as failed if any of the above happens. -// it waits forever for an SMS. -// TODO: this should wait for a set time before failing. - -extern const char *gTest12Description; -extern const char *gAlphabetNumbersMessage; +extern const char* gTest12Description; class Test12 : public VodafoneTestCase { - public: - - char num[17]; - char msg[160]; - size_t count; - - Test12(VodafoneUSBModem *m) : VodafoneTestCase(m) {} + public: + Test12(VodafoneUSBModem *m) : VodafoneTestCase(m) { + _smsLen = 32; + _smsMaxSize = 160; // max size of SMS using + _numberLen = 16; + } private: - - virtual bool executeTest() { - LOG(gTest12Description); - LOG("Receiving SMS from test phone, waiting for response."); + + virtual void setupTest() { + allocStorage(); + } + + virtual void endTest() { + freeStorage(); + } - while(true) - { - LOG("Waiting for an SMS message..."); - int ret = _modem->getSMCount(&count); - if(ret) - { - LOG("getSMCount returned %d", ret); - Thread::wait(3000); - continue; - } - - if( count > 0) - { - LOG("%d SMS to read", count); - ret = _modem->getSM(num, msg, 64); - if(ret) - { - LOG("Error receiving sms. The method getSMS returned %d", ret); - return false; - } - LOG("The message is from number: %s and the message is: \"%s\"", num, msg); - if (strcmp (msg, gAlphabetNumbersMessage) ==0) - { - LOG("Success receiving alphabet message matches the sent message"); - return true; - } - - return false; - } - Thread::wait(500); + virtual bool executeTest() { + // locals + int smsToSend = 50, mailBoxSize = 25; + size_t smCount, oldSMCount; + Timer t; + + LOG(gTest12Description); + + // Clear out the SMS mail box before we run this test. + // loop 3 times with a 1/2 second break in between each + LOG("... Clearing out SMS mail box first"); + for(int j=0; j<3; j++) { + if(_modem->getSMCount(&smCount)!=0) { + LOG("Faiure getting SM count"); + return false; + } + + for(int i=0; i<smCount; i++) { + if(_modem->getSM(_senderNumber,_smsJunkBuffer,_smsMaxSize)!=0) { + LOG("Strange! The SMS count is bigger than zero but I can't fetch the SMS?"); + return false; + } + LOG("Deleting SMS: \"%s\"",_smsJunkBuffer); + } + Thread::wait(500); + } + + // get own number + LOG("Getting MSISDN"); + _modem->sendUSSD("*#100#",_ownNumber,_numberLen); + LOG("Got MSISDN %s",_ownNumber); + + // send 50 SMS to self + + for(int i=0; i<smsToSend; i++) { + if(i<mailBoxSize) { + sprintf(_smsOut,"A SMS %d",i); + } else { + sprintf(_smsOut,"B SMS %d",i); + } + if(_modem->sendSM(_ownNumber,_smsOut)!=0) { + LOG("Error sending short message"); + return false; + } else { + LOG("Sent %d/%d: \"%s\"",i,smsToSend,_smsOut); + } + } + Thread::wait(5000); + + // wait for 25 to arrive and then read them as quickly as possible + smCount = 0, oldSMCount = 0; + t.start(); + // wait a maximum of 10 minutes + while(smCount<mailBoxSize&&t.read_ms()<600000) { + if(_modem->getSMCount(&smCount)!=0) { + LOG("Failure getting SM count"); + return false; + } else { + if(smCount!=oldSMCount) { + LOG("smCount: %d",smCount); + oldSMCount = smCount; + } } - + Thread::wait(500); + } + if(smCount<mailBoxSize) { + LOG("Timeout waiting for SMSs, got to %d",smCount); + return false; + } + + LOG("dumping SMS"); + for(int i=0; i<mailBoxSize; i++) { + if(_modem->getSM(_senderNumber,_smsIn,_smsLen)!=0) { + LOG("Error reading SMS %d",i); + return false; + } else { + LOG("Got SMS: \"%s\" (%s)",_smsIn,_senderNumber); + } + } + + // wait for next 25 to arrive and then read them as quickly as possible + smCount = 0, oldSMCount = 0; + t.start(); + // wait a maximum of 10 minutes + while(smCount<mailBoxSize&&t.read_ms()<600000) { + if(_modem->getSMCount(&smCount)!=0) { + LOG("Failure getting SM count"); + return false; + } else { + if(smCount!=oldSMCount) { + LOG("smCount: %d",smCount); + oldSMCount = smCount; + } + } + Thread::wait(500); + } + if(smCount!=mailBoxSize) { + LOG("Timeout waiting for SMSs, got to %d",smCount); + return false; + } + + LOG("dumping SMS"); + for(int i=0; i<mailBoxSize; i++) { + if(_modem->getSM(_senderNumber,_smsIn,_smsLen)!=0) { + LOG("Error reading SMS %d",i); + return false; + } else { + LOG("Got SMS: \"%s\" (%s)",_smsIn,_senderNumber); + } + } + + return true; } -}; + + void allocStorage() { + _ownNumber = (char*)malloc(_numberLen*sizeof(char)); + _senderNumber = (char*)malloc(_numberLen*sizeof(char)); + _smsOut = (char*)malloc(_smsLen*sizeof(char)); + _smsIn = (char*)malloc(_smsLen*sizeof(char)); + _smsJunkBuffer= (char*)malloc(_smsMaxSize*sizeof(char)); + } + + void freeStorage() { + free(_ownNumber); + free(_senderNumber); + free(_smsOut); + free(_smsIn); + free(_smsJunkBuffer); + } + + char* _ownNumber; + char* _senderNumber; + char* _smsOut; + char* _smsIn; + char* _smsJunkBuffer; + int _smsLen; + int _smsMaxSize; + int _numberLen; +}; \ No newline at end of file
--- a/Tests/Test13.h Tue Oct 30 15:51:53 2012 +0000 +++ b/Tests/Test13.h Thu Nov 01 11:19:47 2012 +0000 @@ -1,65 +1,94 @@ #pragma once #include "VodafoneTestCase.h" - -#define TEST_PHONE_NUMBER "+447717275049" +//#define __DEBUG__ 1 -// this test case will wait to receive an SMS from the modem. -// if the method that reports a message waiting returns an error it will fail. -// if the method that returns the message from the mailbox returns an error it will fai. +// 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 waits forever for an SMS. -// TODO: this should wait for a set time before failing. - -extern const char *gTest13Description; -extern const char *gIrregularMessage; +// it does not wait after it has succesfully sent an SMS. +extern const char* gTest13Description; class Test13 : public VodafoneTestCase { public: - char num[17]; - char msg[160]; - size_t count; - Test13(VodafoneUSBModem *m) : VodafoneTestCase(m) {} private: virtual bool executeTest() { LOG(gTest13Description); - LOG("Receiving SMS from test phone, waiting for response."); - - while(true) + LinkMonitor::REGISTRATION_STATE regState = LinkMonitor::REGISTRATION_STATE_UNKNOWN; + LinkMonitor::BEARER bearer = LinkMonitor::BEARER_UNKNOWN; + int rssi = -1000; + if(_modem->getLinkState(&rssi, ®State, &bearer)==0) { - LOG("Waiting for an SMS message..."); - int ret = _modem->getSMCount(&count); - if(ret) - { - LOG("getSMCount returned %d", ret); - Thread::wait(3000); - continue; + 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("Creating GSM test buffer"); + 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]; + + // XXX What are you doing here nick? What is the size of gIrregularMessage? It's a pointer!! You're looking for strlen + // And gIrregularMessage is longer than shortBuffer so you are goign to kill someone's memory + for (int i=0; i < sizeof(gIrregularMessage); i++) + { + shortBuffer[i] = gIrregularMessage[i]; + LOG("Buffer is now: %s", shortBuffer); + LOG("Irregular message is %s", gIrregularMessage); + int ret = _modem->sendSM(gTestPhoneNumber, shortBuffer); + + } + + 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."); + } - - if( count > 0) - { - LOG("%d SMS to read", count); - ret = _modem->getSM(num, msg, 64); - - if(ret) - { - LOG("Error receiving sms. The method getSMS returned %d", ret); - return false; - } - LOG("The message is from number: %s and the message is: \"%s\"", num, msg); - if (strcmp (msg, gIrregularMessage) ==0) - { - LOG("Success receiving alphabet message matches the sent message"); - return true; - } - - return true; - } - Thread::wait(500); + return false; } + return true; } + + char gsm03dot38CharacterSet[127]; + + }; \ No newline at end of file
--- a/Tests/Test14.h Tue Oct 30 15:51:53 2012 +0000 +++ b/Tests/Test14.h Thu Nov 01 11:19:47 2012 +0000 @@ -1,78 +0,0 @@ -#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; -extern const char *gTestPhoneNumber; -extern const char *gAlphabetNumbersMessage; - -class Test14 : public VodafoneTestCase { - public: - - Test14(VodafoneUSBModem *m) : VodafoneTestCase(m) {} - - private: - virtual bool executeTest() { - LOG(gTest14Description); - 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("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; - } - return true; - } -}; \ No newline at end of file
--- a/Tests/Test16.h Tue Oct 30 15:51:53 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,79 +0,0 @@ -#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 *gTest16Description; - -class Test16 : public VodafoneTestCase { - public: - - - Test16(VodafoneUSBModem *m) : VodafoneTestCase(m) {} - - private: - - virtual bool executeTest() { - LOG(gTest16Description); - 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("Sending SMS:' %s ' to test phone: %s , waiting for response.", gAlphabetNumbersMessage, gTestPhoneNumber); - - int ret = _modem->sendSM(gTestPhoneNumber, gAlphabetNumbersMessage); - - 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; - } - return true; - } -}; \ No newline at end of file
--- a/Tests/Test21.h Tue Oct 30 15:51:53 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -#pragma once -#include "VodafoneTestCase.h" - -extern const char* gTest21Description; -//const int gTest21Depends[] = {}; - -class Test21 : public VodafoneTestCase { - public: - Test21(VodafoneUSBModem *m) : VodafoneTestCase(m) {} - - private: - - virtual void setupTest() { - _ussdResponse = (char*)malloc(16*sizeof(char)); - } - - virtual bool executeTest() { - LOG(gTest21Description); - - if(_modem->sendUSSD("*#100#",_ussdResponse,16)!=0) { - LOG("Error sending USSD"); - return false; - } - - LOG("Received USSD response: \"%s\"",_ussdResponse); - return true; - } - - virtual void endTest() { - free(_ussdResponse); - } - - char *_ussdResponse; -};
--- a/Tests/Test22.h Tue Oct 30 15:51:53 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -#pragma once -#include "VodafoneTestCase.h" -extern const char* gTest22Description; - -class Test22 : public VodafoneTestCase { - public: - Test22(VodafoneUSBModem *m) : VodafoneTestCase(m) {} - - private: - virtual void setupTest() { - _ussdResponse = (char*)malloc(16*sizeof(char)); - } - - virtual bool executeTest() { - LOG(gTest22Description); - - if(_modem->sendUSSD(".2890",_ussdResponse,16)!=0) { - LOG("Error sending USSD"); - return false; - } - - LOG("Expecting \"Unknown command\". Received USSD response: \"%s\"",_ussdResponse); - return (strcmp(_ussdResponse,"Unknown command")==0); - } - - virtual void endTest() { - free(_ussdResponse); - } - - char *_ussdResponse; -};
--- a/Tests/Test23.cpp Tue Oct 30 15:51:53 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -#pragma once -#include "Test23.h" - -const char gTest23USSDMessage[161] = "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; - -Test23::Test23(VodafoneUSBModem *m) : VodafoneTestCase(m) {} - -// virtual -void Test23::setupTest() { - _ussdResponse = (char*)malloc(16*sizeof(char)); -} - -// virtual -bool Test23::executeTest() { - - LOG(gTest23Description); - - if(_modem->sendUSSD(gTest23USSDMessage,_ussdResponse,16)!=0) { - LOG("Error sending USSD"); - return false; - } - - LOG("Expecting \"Unknown Command\". Received USSD response: \"%s\"",_ussdResponse); - return (strcmp(_ussdResponse,"Unknown command")==0); -} - -// virtual -void Test23::endTest() { - free(_ussdResponse); -} \ No newline at end of file
--- a/Tests/Test23.h Tue Oct 30 15:51:53 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -#pragma once -#include "VodafoneTestCase.h" - -extern const char *gTest23Description; - -class Test23 : public VodafoneTestCase { - public: - Test23(VodafoneUSBModem *m); - private: - virtual void setupTest(); - virtual bool executeTest(); - virtual void endTest(); - char *_ussdResponse; -}; \ No newline at end of file
--- a/Tests/Test25.h Tue Oct 30 15:51:53 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,89 +0,0 @@ -#pragma once -#include "VodafoneTestCase.h" - -extern const char* gTest25Description; - -class Test25 : public VodafoneTestCase { - public: - Test25(VodafoneUSBModem *m) : VodafoneTestCase(m) {} - private: - - virtual void setupTest() { - - } - - virtual bool executeTest() { - - LOG(gTest25Description); - int rssi = -1000; - LinkMonitor::REGISTRATION_STATE regState = LinkMonitor::REGISTRATION_STATE_UNKNOWN; - LinkMonitor::BEARER bearer = LinkMonitor::BEARER_UNKNOWN; - - if(_modem->getLinkState(&rssi, ®State, &bearer)==0) { - if(rssi==-1000) { - LOG("RSSI: Error."); - return false; - } else { - LOG("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"); - break; - case LinkMonitor::REGISTRATION_STATE_NO_SIGNAL: - LOG("regState: NO SIGNAL"); - break; - 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; - } - - switch(bearer) { - case LinkMonitor::BEARER_UNKNOWN: - LOG("bearer: UNKNOWN. Failing."); - return false; - case LinkMonitor::BEARER_GSM: - LOG("bearer: GSM"); - break; - case LinkMonitor::BEARER_EDGE: - LOG("bearer: EDGE"); - break; - case LinkMonitor::BEARER_UMTS: - LOG("bearer: UMTS"); - break; - case LinkMonitor::BEARER_HSPA: - LOG("bearer: HSPA"); - break; - case LinkMonitor::BEARER_LTE: - LOG("bearer: LTE"); - break; - default: - LOG("bearer: ERROR. Failing."); - return false; - } - - } else { - return false; - } - - return true; - } - - virtual void endTest() { - - } - -};
--- a/Tests/Test26.h Tue Oct 30 15:51:53 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,92 +0,0 @@ -#pragma once -#include "VodafoneTestCase.h" - -extern const char* gTest26Description; - -class Test26 : public VodafoneTestCase { - public: - Test26(VodafoneUSBModem *m) : VodafoneTestCase(m) {} - - private: - - virtual void setupTest() { - - } - - virtual bool executeTest() { - LOG(gTest26Description); - for(int count=0; count<30; count++) { - LOG("Iteration %d of 30",count); - int rssi = -1000; - LinkMonitor::REGISTRATION_STATE regState = LinkMonitor::REGISTRATION_STATE_UNKNOWN; - LinkMonitor::BEARER bearer = LinkMonitor::BEARER_UNKNOWN; - - if(_modem->getLinkState(&rssi, ®State, &bearer)==0) { - if(rssi==-1000) { - LOG("RSSI: Error."); - return false; - } else { - LOG("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"); - break; - case LinkMonitor::REGISTRATION_STATE_NO_SIGNAL: - LOG("regState: NO SIGNAL"); - break; - 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; - } - - switch(bearer) { - case LinkMonitor::BEARER_UNKNOWN: - LOG("bearer: UNKNOWN. Failing."); - return false; - case LinkMonitor::BEARER_GSM: - LOG("bearer: GSM"); - break; - case LinkMonitor::BEARER_EDGE: - LOG("bearer: EDGE"); - break; - case LinkMonitor::BEARER_UMTS: - LOG("bearer: UMTS"); - break; - case LinkMonitor::BEARER_HSPA: - LOG("bearer: HSPA"); - break; - case LinkMonitor::BEARER_LTE: - LOG("bearer: LTE"); - break; - default: - LOG("bearer: ERROR. Failing."); - return false; - } - } else { - return false; - } - } - - return true; - } - - virtual void endTest() { - - } - -}; -
--- a/Tests/Test50.h Tue Oct 30 15:51:53 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,121 +0,0 @@ -#pragma once -#include "VodafoneTestCase.h" - -extern const char* gTest50Description; - -class Test50 : public VodafoneTestCase { - public: - Test50(VodafoneUSBModem *m) : VodafoneTestCase(m) { - _smsLen = 32; - _smsMaxSize = 160; // max size of SMS using - _numberLen = 16; - } - - private: - - virtual void setupTest() { - allocStorage(); - } - - virtual void endTest() { - freeStorage(); - } - - virtual bool executeTest() { - LOG(gTest50Description); - int numIterations = 10; - size_t smCount; - - // Clear out the SMS mail box before we run this test. - // loop 3 times with a 1/2 second break in between each - LOG("... Clearing out SMS mail box first"); - for(int j=0; j<3; j++) { - if(_modem->getSMCount(&smCount)!=0) { - LOG("Faiure getting SM count"); - return false; - } - - for(int i=0; i<smCount; i++) { - if(_modem->getSM(_senderNumber,_smsJunkBuffer,_smsMaxSize)!=0) { - LOG("Strange! The SMS count is bigger than zero but I can't fetch the SMS?"); - return false; - } - LOG("Got SMS: %s",_smsJunkBuffer); - LOG("Clearing that out before running the test."); - } - Thread::wait(500); - } - - LOG("Getting MSISDN"); - _modem->sendUSSD("*#100#",_ownNumber,_numberLen); - LOG("Got MSISDN %s",_ownNumber); - for(int i=0; i<numIterations; i++) { - createRandomString(_smsOut,_smsLen); - if(_modem->sendSM(_ownNumber,_smsOut)!=0) { - LOG("Error sending short message"); - } - LOG("Created: %s",_smsOut); - bool gotMessage = false; - Timer t; - t.start(); - while(!gotMessage && t.read_ms()<25000) { - if(_modem->getSMCount(&smCount)!=0) { - LOG("Faiure getting SM count"); - return false; - } - - if(smCount>0) { - if(_modem->getSM(_senderNumber,_smsIn,_smsLen)!=0) { - LOG("Failure getting SM"); - return false; - } - LOG("Got SMS: %s",_smsIn); - if(strcmp(_smsIn,_smsOut)!=0) { - LOG("FAIL: strings did not match"); - return false; - } - gotMessage = true; - } - Thread::wait(50); - } - if(!gotMessage) { - LOG("FAIL: timeout on waiting for SMS"); - return false; - } - } - - return true; - } - - void createRandomString(char *target, int len) { - for(int i=0; i<len; i++) { - target[i] = 65+rand()%16; - } - target[len-1] = 0x00; - } - - void allocStorage() { - _ownNumber = (char*)malloc(_numberLen*sizeof(char)); - _senderNumber = (char*)malloc(_numberLen*sizeof(char)); - _smsOut = (char*)malloc(_smsLen*sizeof(char)); - _smsIn = (char*)malloc(_smsLen*sizeof(char)); - _smsJunkBuffer= (char*)malloc(_smsMaxSize*sizeof(char)); - } - - void freeStorage() { - free(_ownNumber); - free(_senderNumber); - free(_smsOut); - free(_smsIn); - free(_smsJunkBuffer); - } - - char* _ownNumber; - char* _senderNumber; - char* _smsOut; - char* _smsIn; - char* _smsJunkBuffer; - int _smsLen; - int _smsMaxSize; - int _numberLen; -}; \ No newline at end of file
--- a/Tests/Test51.h Tue Oct 30 15:51:53 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,162 +0,0 @@ -#pragma once -#include "VodafoneTestCase.h" - -extern const char* gTest51Description; - -class Test51 : public VodafoneTestCase { - public: - Test51(VodafoneUSBModem *m) : VodafoneTestCase(m) { - _smsLen = 32; - _smsMaxSize = 160; // max size of SMS using - _numberLen = 16; - } - - private: - - virtual void setupTest() { - allocStorage(); - } - - virtual void endTest() { - freeStorage(); - } - - virtual bool executeTest() { - // locals - int smsToSend = 50, mailBoxSize = 25; - size_t smCount, oldSMCount; - Timer t; - - LOG(gTest51Description); - - // Clear out the SMS mail box before we run this test. - // loop 3 times with a 1/2 second break in between each - LOG("... Clearing out SMS mail box first"); - for(int j=0; j<3; j++) { - if(_modem->getSMCount(&smCount)!=0) { - LOG("Faiure getting SM count"); - return false; - } - - for(int i=0; i<smCount; i++) { - if(_modem->getSM(_senderNumber,_smsJunkBuffer,_smsMaxSize)!=0) { - LOG("Strange! The SMS count is bigger than zero but I can't fetch the SMS?"); - return false; - } - LOG("Deleting SMS: \"%s\"",_smsJunkBuffer); - } - Thread::wait(500); - } - - // get own number - LOG("Getting MSISDN"); - _modem->sendUSSD("*#100#",_ownNumber,_numberLen); - LOG("Got MSISDN %s",_ownNumber); - - // send 50 SMS to self - - for(int i=0; i<smsToSend; i++) { - if(i<mailBoxSize) { - sprintf(_smsOut,"A SMS %d",i); - } else { - sprintf(_smsOut,"B SMS %d",i); - } - if(_modem->sendSM(_ownNumber,_smsOut)!=0) { - LOG("Error sending short message"); - return false; - } else { - LOG("Sent %d/%d: \"%s\"",i,smsToSend,_smsOut); - } - } - Thread::wait(5000); - - // wait for 25 to arrive and then read them as quickly as possible - smCount = 0, oldSMCount = 0; - t.start(); - // wait a maximum of 10 minutes - while(smCount<mailBoxSize&&t.read_ms()<600000) { - if(_modem->getSMCount(&smCount)!=0) { - LOG("Failure getting SM count"); - return false; - } else { - if(smCount!=oldSMCount) { - LOG("smCount: %d",smCount); - oldSMCount = smCount; - } - } - Thread::wait(500); - } - if(smCount<mailBoxSize) { - LOG("Timeout waiting for SMSs, got to %d",smCount); - return false; - } - - LOG("dumping SMS"); - for(int i=0; i<mailBoxSize; i++) { - if(_modem->getSM(_senderNumber,_smsIn,_smsLen)!=0) { - LOG("Error reading SMS %d",i); - return false; - } else { - LOG("Got SMS: \"%s\" (%s)",_smsIn,_senderNumber); - } - } - - // wait for next 25 to arrive and then read them as quickly as possible - smCount = 0, oldSMCount = 0; - t.start(); - // wait a maximum of 10 minutes - while(smCount<mailBoxSize&&t.read_ms()<600000) { - if(_modem->getSMCount(&smCount)!=0) { - LOG("Failure getting SM count"); - return false; - } else { - if(smCount!=oldSMCount) { - LOG("smCount: %d",smCount); - oldSMCount = smCount; - } - } - Thread::wait(500); - } - if(smCount!=mailBoxSize) { - LOG("Timeout waiting for SMSs, got to %d",smCount); - return false; - } - - LOG("dumping SMS"); - for(int i=0; i<mailBoxSize; i++) { - if(_modem->getSM(_senderNumber,_smsIn,_smsLen)!=0) { - LOG("Error reading SMS %d",i); - return false; - } else { - LOG("Got SMS: \"%s\" (%s)",_smsIn,_senderNumber); - } - } - - return true; - } - - void allocStorage() { - _ownNumber = (char*)malloc(_numberLen*sizeof(char)); - _senderNumber = (char*)malloc(_numberLen*sizeof(char)); - _smsOut = (char*)malloc(_smsLen*sizeof(char)); - _smsIn = (char*)malloc(_smsLen*sizeof(char)); - _smsJunkBuffer= (char*)malloc(_smsMaxSize*sizeof(char)); - } - - void freeStorage() { - free(_ownNumber); - free(_senderNumber); - free(_smsOut); - free(_smsIn); - free(_smsJunkBuffer); - } - - char* _ownNumber; - char* _senderNumber; - char* _smsOut; - char* _smsIn; - char* _smsJunkBuffer; - int _smsLen; - int _smsMaxSize; - int _numberLen; -}; \ No newline at end of file
--- a/Tests/Test56.h Tue Oct 30 15:51:53 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,94 +0,0 @@ -#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. -extern const char* gTest56Description; - -class Test56 : public VodafoneTestCase { - public: - - Test56(VodafoneUSBModem *m) : VodafoneTestCase(m) {} - - private: - - virtual bool executeTest() { - LOG(gTest56Description); - 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("Creating GSM test buffer"); - 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]; - - // XXX What are you doing here nick? What is the size of gIrregularMessage? It's a pointer!! You're looking for strlen - // And gIrregularMessage is longer than shortBuffer so you are goign to kill someone's memory - for (int i=0; i < sizeof(gIrregularMessage); i++) - { - shortBuffer[i] = gIrregularMessage[i]; - LOG("Buffer is now: %s", shortBuffer); - LOG("Irregular message is %s", gIrregularMessage); - int ret = _modem->sendSM(gTestPhoneNumber, shortBuffer); - - } - - 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; - } - return true; - - } - - char gsm03dot38CharacterSet[127]; - - -}; \ No newline at end of file
--- a/Tests/Tests.cpp Tue Oct 30 15:51:53 2012 +0000 +++ b/Tests/Tests.cpp Thu Nov 01 11:19:47 2012 +0000 @@ -1,32 +1,32 @@ #include "Tests.h" // put all of the descriptions on one place for easy reference -const char* gTest00Description = "Test 0"; -const char* gTest01Description = "Test 1"; -const char* gTest02Description = "Test 2"; -const char* gTest03Description = "Test 3"; -const char* gTest04Description = "Test 4"; -const char* gTest05Description = "Test 5"; -const char* gTest06Description = "Test 6"; -const char* gTest07Description = "Test 7"; -const char* gTest08Description = "Test 8: Resolve 5 different DNS entries and match against IPs."; -const char* gTest09Description = "Test 9"; -const char* gTest10Description = "Test 10: Downloads files from 128 bytes to 1MB, in ^2 increments."; -const char* gTest11Description = "Test 11"; -const char* gTest12Description = "Test 12: Sends and SMS and then does something."; -const char* gTest13Description = "Test 13: Waiting for an SMS message with irregular characters and numbers"; -const char* gTest14Description = "Test 14: Send an SMS message with irregular characters and numbers..."; +const char* gTest00Description = "Test 0: Resolve 5 different DNS entries and match against IPs."; +const char* gTest01Description = "Test 1: Downloads files from 128 bytes to 1MB, in ^2 increments."; +const char* gTest02Description = "Test 2: Sends and SMS with basic alphabet and numbers."; +const char* gTest03Description = "Test 3: Waits for an SMS message with irregular characters and numbers."; +const char* gTest04Description = "Test 4: Send an SMS message with irregular characters and numbers."; +const char* gTest05Description = "Test 5: Send an SMS message with basic characters and numbers."; +const char* gTest06Description = "Test 6: Trying out USSD communication sending *#100#"; +const char* gTest07Description = "Test 7: Sending BAD USSD string \".2890\""; +const char* gTest08Description = "Test 8: Sending USSD over 150 chars \"0(0)00 ... 000(160)\""; +const char* gTest09Description = "Test 9: Retrieve signal strength and print it."; +const char* gTest10Description = "Test 10: x30 -> Retrieve signal strength and print it."; +const char* gTest11Description = "Test 11: x10 -> Retreive MSISDN and send 10 random SMS to self"; +const char* gTest12Description = "Test 12: x2 -> Send 25 SMS, wait for recv, read them quickly."; +const char* gTest13Description = "Test 13: Wait for SMS. Send a response."; +const char* gTest14Description = "Test 14"; const char* gTest15Description = "Test 15"; -const char* gTest16Description = "Test 16: Send an SMS message with basic characters and numbers..."; +const char* gTest16Description = "Test 16"; const char* gTest17Description = "Test 17"; const char* gTest18Description = "Test 18"; const char* gTest19Description = "Test 19"; const char* gTest20Description = "Test 20"; -const char* gTest21Description = "Test 21: Trying out USSD communication sending *#100#"; -const char* gTest22Description = "Test 22: Sending BAD USSD string \".2890\""; -const char* gTest23Description = "Test 23: Sending USSD over 150 chars \"0(0)00 ... 000(160)\""; +const char* gTest21Description = "Test 21"; +const char* gTest22Description = "Test 22"; +const char* gTest23Description = "Test 23"; const char* gTest24Description = "Test 24"; -const char* gTest25Description = "Test 25: Retrieve signal strength and print it."; -const char* gTest26Description = "Test 26: x30 -> Retrieve signal strength and print it."; +const char* gTest25Description = "Test 25"; +const char* gTest26Description = "Test 26"; const char* gTest27Description = "Test 27"; const char* gTest28Description = "Test 28"; const char* gTest29Description = "Test 29"; @@ -50,13 +50,13 @@ const char* gTest47Description = "Test 47"; const char* gTest48Description = "Test 48"; const char* gTest49Description = "Test 49"; -const char* gTest50Description = "Test 50: x10 -> Retreive MSISDN and send 10 random SMS to self"; -const char* gTest51Description = "Test 51: x2 -> Send 25 SMS, wait for recv, read them quickly."; +const char* gTest50Description = "Test 50"; +const char* gTest51Description = "Test 51"; const char* gTest52Description = "Test 52"; const char* gTest53Description = "Test 53"; const char* gTest54Description = "Test 54"; const char* gTest55Description = "Test 55"; -const char* gTest56Description = "Test 56: Wait for SMS. Send a response."; +const char* gTest56Description = "Test 56"; const char* gTest57Description = "Test 57"; const char* gTest58Description = "Test 58"; const char* gTest59Description = "Test 59";
--- a/Tests/Tests.h Tue Oct 30 15:51:53 2012 +0000 +++ b/Tests/Tests.h Thu Nov 01 11:19:47 2012 +0000 @@ -1,27 +1,28 @@ #pragma once +#include "Test00.h" +#include "Test01.h" +#include "Test02.h" +#include "Test03.h" +#include "Test04.h" +#include "Test05.h" +#include "Test06.h" +#include "Test07.h" #include "Test08.h" +#include "Test09.h" #include "Test10.h" +#include "Test11.h" #include "Test12.h" #include "Test13.h" #include "Test14.h" -#include "Test16.h" -#include "Test21.h" -#include "Test22.h" -#include "Test23.h" -#include "Test25.h" -#include "Test26.h" -#include "Test50.h" -#include "Test51.h" -#include "Test56.h" -const int gAllTests[] = {10,16,12,13,21,22,23,25,26,50,51}; -const int gNumAllTests = 11; -const int gAutomatedTests[] = {8,10,21,22,23,25,26,50,51}; +const int gAllTests[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13}; +const int gNumAllTests = 14; +const int gAutomatedTests[] = {0,1,6,7,8,9,10,11,12}; const int gNumAutomatedTests = 9; -const int gInteractiveTests[] = {14,13,50}; -const int gNumInteractiveTests = 3; -const int gSoakTests[] = {50}; -const int gNumSoakTests = 1; +const int gInteractiveTests[] = {2,3,4,5,13}; +const int gNumInteractiveTests = 5; +const int gSoakTests[] = {}; +const int gNumSoakTests = 0; enum TestProfile { TESTS_ALL,
--- a/main.cpp Tue Oct 30 15:51:53 2012 +0000 +++ b/main.cpp Thu Nov 01 11:19:47 2012 +0000 @@ -51,8 +51,8 @@ LOG("Running tests."); TestManager *m = new TestManager(&modem); //m->runTestProfile(TESTS_MANUAL); - m->runTest(8); - //m->runTestProfile(TESTS_AUTOMATED); + //m->runTest(8); + m->runTestProfile(TESTS_AUTOMATED); // this thread just waits and blinks leds periodically while(1) {