Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed-rtos mbed HTTPClient VodafoneUSBModem
Revision 60:7efce4a3c26f, committed 2012-10-23
- Comitter:
- ashleymills
- Date:
- Tue Oct 23 14:22:53 2012 +0000
- Parent:
- 59:b091324302b4
- Child:
- 61:4dd870ad7749
- Commit message:
- Added new SMS bulk test (incomplete).
Changed in this revision
--- a/TestManager.cpp Fri Oct 19 15:29:06 2012 +0000
+++ b/TestManager.cpp Tue Oct 23 14:22:53 2012 +0000
@@ -59,7 +59,7 @@
case 48: break;
case 49: break;
case 50: return (VodafoneTestCase*) new Test50(_modem);
- case 51: break;
+ case 51: return (VodafoneTestCase*) new Test51(_modem);
case 52: break;
case 53: break;
case 54: break;
--- a/Tests/Test08.cpp Fri Oct 19 15:29:06 2012 +0000
+++ b/Tests/Test08.cpp Tue Oct 23 14:22:53 2012 +0000
@@ -48,10 +48,7 @@
const int gTest08NumDNSVals = 5;
-Test08::Test08(VodafoneUSBModem *m) : VodafoneTestCase(m) {
- _description = gTest08Description;
- _testCaseNumber = 8;
-}
+Test08::Test08(VodafoneUSBModem *m) : VodafoneTestCase(m) {}
void Test08::setupTest() {}
--- a/Tests/Test10.cpp Fri Oct 19 15:29:06 2012 +0000
+++ b/Tests/Test10.cpp Tue Oct 23 14:22:53 2012 +0000
@@ -52,10 +52,7 @@
};
-Test10::Test10(VodafoneUSBModem *m) : VodafoneTestCase(m) {
- _description = gTest10Description;
- _testCaseNumber = 10;
-}
+Test10::Test10(VodafoneUSBModem *m) : VodafoneTestCase(m) {}
void Test10::setupTest() {}
--- a/Tests/Test12.h Fri Oct 19 15:29:06 2012 +0000
+++ b/Tests/Test12.h Tue Oct 23 14:22:53 2012 +0000
@@ -18,15 +18,11 @@
char msg[160];
size_t count;
- Test12(VodafoneUSBModem *m) : VodafoneTestCase(m) {
- _description = gTest12Description;
- _testCaseNumber = 12;
- }
+ Test12(VodafoneUSBModem *m) : VodafoneTestCase(m) {}
private:
virtual bool executeTest() {
- LOG("Test: %d",_testCaseNumber);
LOG(gTest12Description);
LOG("Receiving SMS from test phone, waiting for response.");
--- a/Tests/Test13.h Fri Oct 19 15:29:06 2012 +0000
+++ b/Tests/Test13.h Tue Oct 23 14:22:53 2012 +0000
@@ -20,15 +20,12 @@
char msg[160];
size_t count;
- Test13(VodafoneUSBModem *m) : VodafoneTestCase(m) {
- _description = gTest13Description;
- _testCaseNumber = 13;
- }
+ Test13(VodafoneUSBModem *m) : VodafoneTestCase(m) {}
private:
virtual bool executeTest() {
- LOG("Test %d wait for an irregular SMS message...", _testCaseNumber);
+ LOG(gTest13Description);
LOG("Receiving SMS from test phone, waiting for response.");
while(true)
--- a/Tests/Test14.h Fri Oct 19 15:29:06 2012 +0000
+++ b/Tests/Test14.h Tue Oct 23 14:22:53 2012 +0000
@@ -15,14 +15,11 @@
class Test14 : public VodafoneTestCase {
public:
- Test14(VodafoneUSBModem *m) : VodafoneTestCase(m) {
- _description = gTest14Description;
- _testCaseNumber = 14;
- }
+ 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;
@@ -60,7 +57,6 @@
}
- 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);
@@ -77,7 +73,6 @@
}
return false;
}
- LOG("Test %d passed...", _testCaseNumber);
return true;
}
};
\ No newline at end of file
--- a/Tests/Test16.h Fri Oct 19 15:29:06 2012 +0000
+++ b/Tests/Test16.h Tue Oct 23 14:22:53 2012 +0000
@@ -15,15 +15,12 @@
public:
- Test16(VodafoneUSBModem *m) : VodafoneTestCase(m) {
- _description = gTest16Description;
- _testCaseNumber = 16;
- }
+ 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;
@@ -61,7 +58,6 @@
}
- LOG("Test %d sending an SMS message...", _testCaseNumber);
LOG("Sending SMS:' %s ' to test phone: %s , waiting for response.", gAlphabetNumbersMessage, gTestPhoneNumber);
int ret = _modem->sendSM(gTestPhoneNumber, gAlphabetNumbersMessage);
@@ -78,7 +74,6 @@
}
return false;
}
- LOG("Test %d passed...", _testCaseNumber);
return true;
}
};
\ No newline at end of file
--- a/Tests/Test21.h Fri Oct 19 15:29:06 2012 +0000
+++ b/Tests/Test21.h Tue Oct 23 14:22:53 2012 +0000
@@ -6,10 +6,7 @@
class Test21 : public VodafoneTestCase {
public:
- Test21(VodafoneUSBModem *m) : VodafoneTestCase(m) {
- _description = gTest21Description;
- _testCaseNumber = 21;
- }
+ Test21(VodafoneUSBModem *m) : VodafoneTestCase(m) {}
private:
@@ -18,7 +15,7 @@
}
virtual bool executeTest() {
- LOG(_description);
+ LOG(gTest21Description);
if(_modem->sendUSSD("*#100#",_ussdResponse,16)!=0) {
LOG("Error sending USSD");
--- a/Tests/Test22.h Fri Oct 19 15:29:06 2012 +0000
+++ b/Tests/Test22.h Tue Oct 23 14:22:53 2012 +0000
@@ -4,10 +4,7 @@
class Test22 : public VodafoneTestCase {
public:
- Test22(VodafoneUSBModem *m) : VodafoneTestCase(m) {
- _description = gTest22Description;
- _testCaseNumber = 22;
- }
+ Test22(VodafoneUSBModem *m) : VodafoneTestCase(m) {}
private:
virtual void setupTest() {
@@ -15,7 +12,7 @@
}
virtual bool executeTest() {
- LOG(_description);
+ LOG(gTest22Description);
if(_modem->sendUSSD(".2890",_ussdResponse,16)!=0) {
LOG("Error sending USSD");
--- a/Tests/Test23.cpp Fri Oct 19 15:29:06 2012 +0000
+++ b/Tests/Test23.cpp Tue Oct 23 14:22:53 2012 +0000
@@ -3,10 +3,7 @@
const char gTest23USSDMessage[161] = "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
-Test23::Test23(VodafoneUSBModem *m) : VodafoneTestCase(m) {
- //_description = gTest23Description;
- _testCaseNumber = 23;
-}
+Test23::Test23(VodafoneUSBModem *m) : VodafoneTestCase(m) {}
// virtual
void Test23::setupTest() {
--- a/Tests/Test25.h Fri Oct 19 15:29:06 2012 +0000
+++ b/Tests/Test25.h Tue Oct 23 14:22:53 2012 +0000
@@ -5,10 +5,7 @@
class Test25 : public VodafoneTestCase {
public:
- Test25(VodafoneUSBModem *m) : VodafoneTestCase(m) {
- _description = gTest25Description;
- _testCaseNumber = 25;
- }
+ Test25(VodafoneUSBModem *m) : VodafoneTestCase(m) {}
private:
virtual void setupTest() {
--- a/Tests/Test26.h Fri Oct 19 15:29:06 2012 +0000
+++ b/Tests/Test26.h Tue Oct 23 14:22:53 2012 +0000
@@ -5,10 +5,7 @@
class Test26 : public VodafoneTestCase {
public:
- Test26(VodafoneUSBModem *m) : VodafoneTestCase(m) {
- _description = gTest26Description;
- _testCaseNumber = 26;
- }
+ Test26(VodafoneUSBModem *m) : VodafoneTestCase(m) {}
private:
--- a/Tests/Test50.h Fri Oct 19 15:29:06 2012 +0000
+++ b/Tests/Test50.h Tue Oct 23 14:22:53 2012 +0000
@@ -9,8 +9,6 @@
_smsLen = 32;
_smsMaxSize = 160; // max size of SMS using
_numberLen = 16;
- _description = gTest50Description;
- _testCaseNumber = 50;
}
private:
@@ -27,30 +25,25 @@
LOG(gTest50Description);
int numIterations = 10;
size_t smCount;
- LOG("... Test case: %d", _testCaseNumber);
-
+
// 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");
- if(_modem->getSMCount(&smCount)!=0)
- {
- LOG("Faiure getting SM count");
- return false;
- }
+ 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->getSMCount(&smCount)!=0) {
- LOG("Faiure getting SM count");
+ 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;
}
- 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.");
}
- LOG("Got SMS: %s",_smsJunkBuffer);
- LOG("Clearing that out before running the test.");
+ Thread::wait(500);
}
LOG("Getting MSISDN");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Tests/Test51.h Tue Oct 23 14:22:53 2012 +0000
@@ -0,0 +1,161 @@
+#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 = 10, mailBoxSize = 5;
+ 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,_smsOut,smsToSend);
+ }
+ }
+ 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 5 minutes
+ while(smCount<mailBoxSize&&t.read_ms()<300000) {
+ 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");
+ while(smCount--) {
+ if(_modem->getSM(_senderNumber,_smsIn,_smsLen)!=0) {
+ LOG("Error reading SMS %d",smCount);
+ 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 5 minutes
+ while(smCount<mailBoxSize&&t.read_ms()<300000) {
+ 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");
+ while(smCount--) {
+ if(_modem->getSM(_senderNumber,_smsIn,_smsLen)!=0) {
+ LOG("Error reading SMS %d",smCount);
+ 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 Fri Oct 19 15:29:06 2012 +0000
+++ b/Tests/Test56.h Tue Oct 23 14:22:53 2012 +0000
@@ -11,15 +11,12 @@
class Test56 : public VodafoneTestCase {
public:
- Test56(VodafoneUSBModem *m) : VodafoneTestCase(m) {
- _description = gTest56Description;
- _testCaseNumber = 56;
- }
+ 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;
@@ -57,7 +54,6 @@
}
LOG("Creating GSM test buffer");
- LOG("Test %d sending an SMS message...", _testCaseNumber);
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
@@ -88,7 +84,6 @@
}
return false;
}
- LOG("Test %d passed...", _testCaseNumber);
return true;
}
--- a/Tests/Tests.cpp Fri Oct 19 15:29:06 2012 +0000 +++ b/Tests/Tests.cpp Tue Oct 23 14:22:53 2012 +0000 @@ -10,23 +10,23 @@ 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 = "Downloads files from 128 bytes to 1MB, in ^2 increments."; +const char* gTest10Description = "Test 10: Downloads files from 128 bytes to 1MB, in ^2 increments."; const char* gTest11Description = "Test 11"; -const char* gTest12Description = "Sends and SMS and then does something."; -const char* gTest13Description = "Waiting for an SMS message with irregular characters and numbers"; -const char* gTest14Description = "Send an SMS message with irregular characters and numbers..."; +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* gTest15Description = "Test 15"; -const char* gTest16Description = "Send an SMS message with basic characters and numbers..."; +const char* gTest16Description = "Test 16: Send an SMS message with basic characters and numbers..."; const char* gTest17Description = "Test 17"; const char* gTest18Description = "Test 18"; const char* gTest19Description = "Test 19"; const char* gTest20Description = "Test 20"; -const char* gTest21Description = "Trying out USSD communication sending *#100#"; -const char* gTest22Description = "Sending BAD USSD string \".2890\""; -const char* gTest23Description = "Sending USSD over 150 chars \"0(0)00 ... 000(160)\""; +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* gTest24Description = "Test 24"; -const char* gTest25Description = "Retrieve signal strength and print it."; -const char* gTest26Description = "x30 -> Retrieve signal strength and print it."; +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* 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 = "x10 -> Retreive MSISDN and send 10 random SMS to self"; -const char* gTest51Description = "Test 51"; +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* gTest52Description = "Test 52"; const char* gTest53Description = "Test 53"; const char* gTest54Description = "Test 54"; const char* gTest55Description = "Test 55"; -const char* gTest56Description = "Wait for SMS. Send a response."; +const char* gTest56Description = "Test 56: Wait for SMS. Send a response."; const char* gTest57Description = "Test 57"; const char* gTest58Description = "Test 58"; const char* gTest59Description = "Test 59";
--- a/Tests/Tests.h Fri Oct 19 15:29:06 2012 +0000
+++ b/Tests/Tests.h Tue Oct 23 14:22:53 2012 +0000
@@ -11,12 +11,13 @@
#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};
-const int gNumAllTests = 10;
-const int gAutomatedTests[] = {8,10,21,22,23,25,26,50};
-const int gNumAutomatedTests = 8;
+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 gNumAutomatedTests = 9;
const int gInteractiveTests[] = {14,13,50};
const int gNumInteractiveTests = 3;
const int gSoakTests[] = {50};
--- a/VodafoneTestCase.h Fri Oct 19 15:29:06 2012 +0000
+++ b/VodafoneTestCase.h Tue Oct 23 14:22:53 2012 +0000
@@ -34,6 +34,4 @@
public:
time_t _lastRunTime;
bool _lastRunOutcome;
- int _testCaseNumber;
- const char* _description;
};
\ No newline at end of file
--- a/VodafoneUSBModem_bleedingedge.lib Fri Oct 19 15:29:06 2012 +0000 +++ b/VodafoneUSBModem_bleedingedge.lib Tue Oct 23 14:22:53 2012 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/donatien/code/VodafoneUSBModem_bleedingedge/#bd474c9fe51e +http://mbed.org/users/donatien/code/VodafoneUSBModem_bleedingedge/#f1965f3f4504
--- a/main.cpp Fri Oct 19 15:29:06 2012 +0000
+++ b/main.cpp Tue Oct 23 14:22:53 2012 +0000
@@ -50,8 +50,8 @@
LOG("Constructing TestManager");
LOG("Running tests.");
TestManager *m = new TestManager(&modem);
- m->runTestProfile(TESTS_MANUAL);
- //m->runTest(10);
+ //m->runTestProfile(TESTS_MANUAL);
+ m->runTest(51);
// this thread just waits and blinks leds periodically

