Vodafone Test Suite

Dependencies:   mbed-rtos mbed HTTPClient VodafoneUSBModem

Committer:
nherriot
Date:
Wed Sep 12 09:53:40 2012 +0000
Revision:
29:c0e6f198db84
Parent:
28:c630a04a7198
Child:
31:9231acdde9ff
adding some 'error' scenario test cases and many small changes to the test suite

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nherriot 28:c630a04a7198 1 #pragma once
nherriot 28:c630a04a7198 2 #include "VodafoneTestCase.h"
nherriot 28:c630a04a7198 3 //#define __DEBUG__ 1
nherriot 28:c630a04a7198 4
nherriot 28:c630a04a7198 5 // this test case will wait to send an SMS from the modem.
nherriot 28:c630a04a7198 6 // if the method that sends a message returns an error it will fail.
nherriot 28:c630a04a7198 7 // it will report the test as failed if any of the above happens.
nherriot 28:c630a04a7198 8 // it does not wait after it has succesfully sent an SMS.
nherriot 28:c630a04a7198 9
nherriot 28:c630a04a7198 10
nherriot 28:c630a04a7198 11 class Test16 : public VodafoneTestCase {
nherriot 28:c630a04a7198 12 public:
nherriot 28:c630a04a7198 13
nherriot 28:c630a04a7198 14
nherriot 28:c630a04a7198 15 Test16(VodafoneUSBModem *m, int tcNumber) : VodafoneTestCase(m, tcNumber) {
nherriot 28:c630a04a7198 16 }
nherriot 29:c0e6f198db84 17
nherriot 28:c630a04a7198 18
nherriot 28:c630a04a7198 19 virtual bool runTest() {
nherriot 29:c0e6f198db84 20
nherriot 29:c0e6f198db84 21 LinkMonitor::REGISTRATION_STATE regState = LinkMonitor::REGISTRATION_STATE_UNKNOWN;
nherriot 29:c0e6f198db84 22 LinkMonitor::BEARER bearer = LinkMonitor::BEARER_UNKNOWN;
nherriot 29:c0e6f198db84 23 int rssi = -1000;
nherriot 29:c0e6f198db84 24 if(_modem->getLinkState(&rssi, &regState, &bearer)==0)
nherriot 29:c0e6f198db84 25 {
nherriot 29:c0e6f198db84 26 if(rssi==-1000)
nherriot 29:c0e6f198db84 27 { LOG("Checking signal strength - RSSI: Error."); return false;}
nherriot 29:c0e6f198db84 28 else
nherriot 29:c0e6f198db84 29 { LOG("Signal strength is: RSSI: %d",rssi);}
nherriot 29:c0e6f198db84 30
nherriot 29:c0e6f198db84 31
nherriot 29:c0e6f198db84 32 switch(regState) {
nherriot 29:c0e6f198db84 33 case LinkMonitor::REGISTRATION_STATE_UNKNOWN:
nherriot 29:c0e6f198db84 34 LOG("regState: UNKNOWN. Failing.");
nherriot 29:c0e6f198db84 35 return false;
nherriot 29:c0e6f198db84 36 case LinkMonitor::REGISTRATION_STATE_REGISTERING:
nherriot 29:c0e6f198db84 37 LOG("regState: REGISTERING");
nherriot 29:c0e6f198db84 38 break;
nherriot 29:c0e6f198db84 39 case LinkMonitor::REGISTRATION_STATE_DENIED:
nherriot 29:c0e6f198db84 40 LOG("regState: DENIED");
nherriot 29:c0e6f198db84 41 return false;
nherriot 29:c0e6f198db84 42 case LinkMonitor::REGISTRATION_STATE_NO_SIGNAL:
nherriot 29:c0e6f198db84 43 LOG("regState: NO SIGNAL");
nherriot 29:c0e6f198db84 44 return false;
nherriot 29:c0e6f198db84 45 case LinkMonitor::REGISTRATION_STATE_HOME_NETWORK:
nherriot 29:c0e6f198db84 46 LOG("regState: HOME NETWORK");
nherriot 29:c0e6f198db84 47 break;
nherriot 29:c0e6f198db84 48 case LinkMonitor::REGISTRATION_STATE_ROAMING:
nherriot 29:c0e6f198db84 49 LOG("regState: ROAMING");
nherriot 29:c0e6f198db84 50 break;
nherriot 29:c0e6f198db84 51 default:
nherriot 29:c0e6f198db84 52 LOG("regState: ERROR. Failing.");
nherriot 29:c0e6f198db84 53 return false;
nherriot 29:c0e6f198db84 54 }
nherriot 29:c0e6f198db84 55 }
nherriot 29:c0e6f198db84 56
nherriot 29:c0e6f198db84 57
nherriot 28:c630a04a7198 58 LOG("Test %d sending an SMS message...", _testCaseNumber);
nherriot 29:c0e6f198db84 59 LOG("Sending SMS:' %s ' to test phone: %s , waiting for response.", allCharsMessage, testPhoneNumber);
nherriot 28:c630a04a7198 60
nherriot 29:c0e6f198db84 61 int ret = _modem->sendSM(testPhoneNumber, allCharsMessage);
nherriot 28:c630a04a7198 62
nherriot 28:c630a04a7198 63 if (ret)
nherriot 28:c630a04a7198 64 {
nherriot 28:c630a04a7198 65 LOG("Error in sending the SMS message. The return values is: %d", ret);
nherriot 28:c630a04a7198 66
nherriot 28:c630a04a7198 67 switch(ret){
nherriot 28:c630a04a7198 68 case(NET_INVALID): LOG("Error message is: 'phone number is invalid size, must be less than 16 digits'.");break;
nherriot 28:c630a04a7198 69 case(NET_PROTOCOL): LOG("Error message is: 'protocol error from the modem'.");break;
nherriot 28:c630a04a7198 70 default: LOG("Undefined error message.");
nherriot 28:c630a04a7198 71
nherriot 28:c630a04a7198 72 }
nherriot 28:c630a04a7198 73 return false;
nherriot 28:c630a04a7198 74 }
nherriot 28:c630a04a7198 75 LOG("Test %d passed...", _testCaseNumber);
nherriot 28:c630a04a7198 76 return true;
nherriot 28:c630a04a7198 77
nherriot 28:c630a04a7198 78 }
nherriot 28:c630a04a7198 79
nherriot 28:c630a04a7198 80 private:
nherriot 28:c630a04a7198 81 char gsm03dot38CharacterSet[127];
nherriot 28:c630a04a7198 82
nherriot 28:c630a04a7198 83
nherriot 28:c630a04a7198 84 };