Vodafone Test Suite

Dependencies:   mbed-rtos mbed HTTPClient VodafoneUSBModem

Committer:
ashleymills
Date:
Thu Nov 01 11:19:47 2012 +0000
Revision:
66:6b00a764e549
Parent:
60:7efce4a3c26f
Child:
72:0e8e769fcf76
Renamed tests in sequential order to make it easier to manage and cleaner to follow.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nherriot 5:b68400bd0738 1 #pragma once
nherriot 5:b68400bd0738 2 #include "VodafoneTestCase.h"
nherriot 5:b68400bd0738 3
ashleymills 66:6b00a764e549 4 extern const char* gTest12Description;
nherriot 13:8b69853966f8 5
nherriot 5:b68400bd0738 6 class Test12 : public VodafoneTestCase {
ashleymills 66:6b00a764e549 7 public:
ashleymills 66:6b00a764e549 8 Test12(VodafoneUSBModem *m) : VodafoneTestCase(m) {
ashleymills 66:6b00a764e549 9 _smsLen = 32;
ashleymills 66:6b00a764e549 10 _smsMaxSize = 160; // max size of SMS using
ashleymills 66:6b00a764e549 11 _numberLen = 16;
ashleymills 66:6b00a764e549 12 }
ashleymills 44:6d0ac4747f5b 13
ashleymills 44:6d0ac4747f5b 14 private:
ashleymills 66:6b00a764e549 15
ashleymills 66:6b00a764e549 16 virtual void setupTest() {
ashleymills 66:6b00a764e549 17 allocStorage();
ashleymills 66:6b00a764e549 18 }
ashleymills 66:6b00a764e549 19
ashleymills 66:6b00a764e549 20 virtual void endTest() {
ashleymills 66:6b00a764e549 21 freeStorage();
ashleymills 66:6b00a764e549 22 }
nherriot 5:b68400bd0738 23
ashleymills 66:6b00a764e549 24 virtual bool executeTest() {
ashleymills 66:6b00a764e549 25 // locals
ashleymills 66:6b00a764e549 26 int smsToSend = 50, mailBoxSize = 25;
ashleymills 66:6b00a764e549 27 size_t smCount, oldSMCount;
ashleymills 66:6b00a764e549 28 Timer t;
ashleymills 66:6b00a764e549 29
ashleymills 66:6b00a764e549 30 LOG(gTest12Description);
ashleymills 66:6b00a764e549 31
ashleymills 66:6b00a764e549 32 // Clear out the SMS mail box before we run this test.
ashleymills 66:6b00a764e549 33 // loop 3 times with a 1/2 second break in between each
ashleymills 66:6b00a764e549 34 LOG("... Clearing out SMS mail box first");
ashleymills 66:6b00a764e549 35 for(int j=0; j<3; j++) {
ashleymills 66:6b00a764e549 36 if(_modem->getSMCount(&smCount)!=0) {
ashleymills 66:6b00a764e549 37 LOG("Faiure getting SM count");
ashleymills 66:6b00a764e549 38 return false;
ashleymills 66:6b00a764e549 39 }
ashleymills 66:6b00a764e549 40
ashleymills 66:6b00a764e549 41 for(int i=0; i<smCount; i++) {
ashleymills 66:6b00a764e549 42 if(_modem->getSM(_senderNumber,_smsJunkBuffer,_smsMaxSize)!=0) {
ashleymills 66:6b00a764e549 43 LOG("Strange! The SMS count is bigger than zero but I can't fetch the SMS?");
ashleymills 66:6b00a764e549 44 return false;
ashleymills 66:6b00a764e549 45 }
ashleymills 66:6b00a764e549 46 LOG("Deleting SMS: \"%s\"",_smsJunkBuffer);
ashleymills 66:6b00a764e549 47 }
ashleymills 66:6b00a764e549 48 Thread::wait(500);
ashleymills 66:6b00a764e549 49 }
ashleymills 66:6b00a764e549 50
ashleymills 66:6b00a764e549 51 // get own number
ashleymills 66:6b00a764e549 52 LOG("Getting MSISDN");
ashleymills 66:6b00a764e549 53 _modem->sendUSSD("*#100#",_ownNumber,_numberLen);
ashleymills 66:6b00a764e549 54 LOG("Got MSISDN %s",_ownNumber);
ashleymills 66:6b00a764e549 55
ashleymills 66:6b00a764e549 56 // send 50 SMS to self
ashleymills 66:6b00a764e549 57
ashleymills 66:6b00a764e549 58 for(int i=0; i<smsToSend; i++) {
ashleymills 66:6b00a764e549 59 if(i<mailBoxSize) {
ashleymills 66:6b00a764e549 60 sprintf(_smsOut,"A SMS %d",i);
ashleymills 66:6b00a764e549 61 } else {
ashleymills 66:6b00a764e549 62 sprintf(_smsOut,"B SMS %d",i);
ashleymills 66:6b00a764e549 63 }
ashleymills 66:6b00a764e549 64 if(_modem->sendSM(_ownNumber,_smsOut)!=0) {
ashleymills 66:6b00a764e549 65 LOG("Error sending short message");
ashleymills 66:6b00a764e549 66 return false;
ashleymills 66:6b00a764e549 67 } else {
ashleymills 66:6b00a764e549 68 LOG("Sent %d/%d: \"%s\"",i,smsToSend,_smsOut);
ashleymills 66:6b00a764e549 69 }
ashleymills 66:6b00a764e549 70 }
ashleymills 66:6b00a764e549 71 Thread::wait(5000);
ashleymills 66:6b00a764e549 72
ashleymills 66:6b00a764e549 73 // wait for 25 to arrive and then read them as quickly as possible
ashleymills 66:6b00a764e549 74 smCount = 0, oldSMCount = 0;
ashleymills 66:6b00a764e549 75 t.start();
ashleymills 66:6b00a764e549 76 // wait a maximum of 10 minutes
ashleymills 66:6b00a764e549 77 while(smCount<mailBoxSize&&t.read_ms()<600000) {
ashleymills 66:6b00a764e549 78 if(_modem->getSMCount(&smCount)!=0) {
ashleymills 66:6b00a764e549 79 LOG("Failure getting SM count");
ashleymills 66:6b00a764e549 80 return false;
ashleymills 66:6b00a764e549 81 } else {
ashleymills 66:6b00a764e549 82 if(smCount!=oldSMCount) {
ashleymills 66:6b00a764e549 83 LOG("smCount: %d",smCount);
ashleymills 66:6b00a764e549 84 oldSMCount = smCount;
ashleymills 66:6b00a764e549 85 }
nherriot 5:b68400bd0738 86 }
ashleymills 66:6b00a764e549 87 Thread::wait(500);
ashleymills 66:6b00a764e549 88 }
ashleymills 66:6b00a764e549 89 if(smCount<mailBoxSize) {
ashleymills 66:6b00a764e549 90 LOG("Timeout waiting for SMSs, got to %d",smCount);
ashleymills 66:6b00a764e549 91 return false;
ashleymills 66:6b00a764e549 92 }
ashleymills 66:6b00a764e549 93
ashleymills 66:6b00a764e549 94 LOG("dumping SMS");
ashleymills 66:6b00a764e549 95 for(int i=0; i<mailBoxSize; i++) {
ashleymills 66:6b00a764e549 96 if(_modem->getSM(_senderNumber,_smsIn,_smsLen)!=0) {
ashleymills 66:6b00a764e549 97 LOG("Error reading SMS %d",i);
ashleymills 66:6b00a764e549 98 return false;
ashleymills 66:6b00a764e549 99 } else {
ashleymills 66:6b00a764e549 100 LOG("Got SMS: \"%s\" (%s)",_smsIn,_senderNumber);
ashleymills 66:6b00a764e549 101 }
ashleymills 66:6b00a764e549 102 }
ashleymills 66:6b00a764e549 103
ashleymills 66:6b00a764e549 104 // wait for next 25 to arrive and then read them as quickly as possible
ashleymills 66:6b00a764e549 105 smCount = 0, oldSMCount = 0;
ashleymills 66:6b00a764e549 106 t.start();
ashleymills 66:6b00a764e549 107 // wait a maximum of 10 minutes
ashleymills 66:6b00a764e549 108 while(smCount<mailBoxSize&&t.read_ms()<600000) {
ashleymills 66:6b00a764e549 109 if(_modem->getSMCount(&smCount)!=0) {
ashleymills 66:6b00a764e549 110 LOG("Failure getting SM count");
ashleymills 66:6b00a764e549 111 return false;
ashleymills 66:6b00a764e549 112 } else {
ashleymills 66:6b00a764e549 113 if(smCount!=oldSMCount) {
ashleymills 66:6b00a764e549 114 LOG("smCount: %d",smCount);
ashleymills 66:6b00a764e549 115 oldSMCount = smCount;
ashleymills 66:6b00a764e549 116 }
ashleymills 66:6b00a764e549 117 }
ashleymills 66:6b00a764e549 118 Thread::wait(500);
ashleymills 66:6b00a764e549 119 }
ashleymills 66:6b00a764e549 120 if(smCount!=mailBoxSize) {
ashleymills 66:6b00a764e549 121 LOG("Timeout waiting for SMSs, got to %d",smCount);
ashleymills 66:6b00a764e549 122 return false;
ashleymills 66:6b00a764e549 123 }
ashleymills 66:6b00a764e549 124
ashleymills 66:6b00a764e549 125 LOG("dumping SMS");
ashleymills 66:6b00a764e549 126 for(int i=0; i<mailBoxSize; i++) {
ashleymills 66:6b00a764e549 127 if(_modem->getSM(_senderNumber,_smsIn,_smsLen)!=0) {
ashleymills 66:6b00a764e549 128 LOG("Error reading SMS %d",i);
ashleymills 66:6b00a764e549 129 return false;
ashleymills 66:6b00a764e549 130 } else {
ashleymills 66:6b00a764e549 131 LOG("Got SMS: \"%s\" (%s)",_smsIn,_senderNumber);
ashleymills 66:6b00a764e549 132 }
ashleymills 66:6b00a764e549 133 }
ashleymills 66:6b00a764e549 134
ashleymills 66:6b00a764e549 135 return true;
nherriot 5:b68400bd0738 136 }
ashleymills 66:6b00a764e549 137
ashleymills 66:6b00a764e549 138 void allocStorage() {
ashleymills 66:6b00a764e549 139 _ownNumber = (char*)malloc(_numberLen*sizeof(char));
ashleymills 66:6b00a764e549 140 _senderNumber = (char*)malloc(_numberLen*sizeof(char));
ashleymills 66:6b00a764e549 141 _smsOut = (char*)malloc(_smsLen*sizeof(char));
ashleymills 66:6b00a764e549 142 _smsIn = (char*)malloc(_smsLen*sizeof(char));
ashleymills 66:6b00a764e549 143 _smsJunkBuffer= (char*)malloc(_smsMaxSize*sizeof(char));
ashleymills 66:6b00a764e549 144 }
ashleymills 66:6b00a764e549 145
ashleymills 66:6b00a764e549 146 void freeStorage() {
ashleymills 66:6b00a764e549 147 free(_ownNumber);
ashleymills 66:6b00a764e549 148 free(_senderNumber);
ashleymills 66:6b00a764e549 149 free(_smsOut);
ashleymills 66:6b00a764e549 150 free(_smsIn);
ashleymills 66:6b00a764e549 151 free(_smsJunkBuffer);
ashleymills 66:6b00a764e549 152 }
ashleymills 66:6b00a764e549 153
ashleymills 66:6b00a764e549 154 char* _ownNumber;
ashleymills 66:6b00a764e549 155 char* _senderNumber;
ashleymills 66:6b00a764e549 156 char* _smsOut;
ashleymills 66:6b00a764e549 157 char* _smsIn;
ashleymills 66:6b00a764e549 158 char* _smsJunkBuffer;
ashleymills 66:6b00a764e549 159 int _smsLen;
ashleymills 66:6b00a764e549 160 int _smsMaxSize;
ashleymills 66:6b00a764e549 161 int _numberLen;
ashleymills 66:6b00a764e549 162 };