Vodafone Test Suite

Dependencies:   mbed-rtos mbed HTTPClient VodafoneUSBModem

Files at this revision

API Documentation at this revision

Comitter:
ashleymills
Date:
Wed Oct 24 08:56:17 2012 +0000
Parent:
60:7efce4a3c26f
Child:
62:e4a094aabbbc
Child:
63:a80753cdd091
Commit message:
Made the SMS test quicker for debugging

Changed in this revision

Tests/Test51.h Show annotated file Show diff for this revision Revisions of this file
--- a/Tests/Test51.h	Tue Oct 23 14:22:53 2012 +0000
+++ b/Tests/Test51.h	Wed Oct 24 08:56:17 2012 +0000
@@ -1,161 +1,162 @@
-#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;
+#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,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 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