Vodafone Test Suite

Dependencies:   mbed-rtos mbed HTTPClient VodafoneUSBModem

Committer:
ashleymills
Date:
Fri Sep 14 12:16:09 2012 +0000
Revision:
40:32b0558320ea
Parent:
37:847f5f86e9ff
Child:
44:6d0ac4747f5b
Refactoring.

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 31:9231acdde9ff 9 // this test basic characters and numbers can be sent via SMS.
nherriot 28:c630a04a7198 10
nherriot 28:c630a04a7198 11
ashleymills 37:847f5f86e9ff 12 extern const char *gTest16Description;
nherriot 31:9231acdde9ff 13
nherriot 28:c630a04a7198 14 class Test16 : public VodafoneTestCase {
nherriot 28:c630a04a7198 15 public:
nherriot 28:c630a04a7198 16
nherriot 28:c630a04a7198 17
ashleymills 33:16126e029d58 18 Test16(VodafoneUSBModem *m) : VodafoneTestCase(m) {
ashleymills 33:16126e029d58 19 _description = gTest16Description;
ashleymills 33:16126e029d58 20 _testCaseNumber = 16;
nherriot 28:c630a04a7198 21 }
nherriot 29:c0e6f198db84 22
nherriot 28:c630a04a7198 23
ashleymills 34:d9e45aad85f2 24 virtual bool execute() {
nherriot 29:c0e6f198db84 25
nherriot 29:c0e6f198db84 26 LinkMonitor::REGISTRATION_STATE regState = LinkMonitor::REGISTRATION_STATE_UNKNOWN;
nherriot 29:c0e6f198db84 27 LinkMonitor::BEARER bearer = LinkMonitor::BEARER_UNKNOWN;
nherriot 29:c0e6f198db84 28 int rssi = -1000;
nherriot 29:c0e6f198db84 29 if(_modem->getLinkState(&rssi, &regState, &bearer)==0)
nherriot 29:c0e6f198db84 30 {
nherriot 29:c0e6f198db84 31 if(rssi==-1000)
nherriot 29:c0e6f198db84 32 { LOG("Checking signal strength - RSSI: Error."); return false;}
nherriot 29:c0e6f198db84 33 else
nherriot 29:c0e6f198db84 34 { LOG("Signal strength is: RSSI: %d",rssi);}
nherriot 29:c0e6f198db84 35
nherriot 29:c0e6f198db84 36
nherriot 29:c0e6f198db84 37 switch(regState) {
nherriot 29:c0e6f198db84 38 case LinkMonitor::REGISTRATION_STATE_UNKNOWN:
nherriot 29:c0e6f198db84 39 LOG("regState: UNKNOWN. Failing.");
nherriot 29:c0e6f198db84 40 return false;
nherriot 29:c0e6f198db84 41 case LinkMonitor::REGISTRATION_STATE_REGISTERING:
nherriot 29:c0e6f198db84 42 LOG("regState: REGISTERING");
nherriot 29:c0e6f198db84 43 break;
nherriot 29:c0e6f198db84 44 case LinkMonitor::REGISTRATION_STATE_DENIED:
nherriot 29:c0e6f198db84 45 LOG("regState: DENIED");
nherriot 29:c0e6f198db84 46 return false;
nherriot 29:c0e6f198db84 47 case LinkMonitor::REGISTRATION_STATE_NO_SIGNAL:
nherriot 29:c0e6f198db84 48 LOG("regState: NO SIGNAL");
nherriot 29:c0e6f198db84 49 return false;
nherriot 29:c0e6f198db84 50 case LinkMonitor::REGISTRATION_STATE_HOME_NETWORK:
nherriot 29:c0e6f198db84 51 LOG("regState: HOME NETWORK");
nherriot 29:c0e6f198db84 52 break;
nherriot 29:c0e6f198db84 53 case LinkMonitor::REGISTRATION_STATE_ROAMING:
nherriot 29:c0e6f198db84 54 LOG("regState: ROAMING");
nherriot 29:c0e6f198db84 55 break;
nherriot 29:c0e6f198db84 56 default:
nherriot 29:c0e6f198db84 57 LOG("regState: ERROR. Failing.");
nherriot 29:c0e6f198db84 58 return false;
nherriot 29:c0e6f198db84 59 }
nherriot 29:c0e6f198db84 60 }
nherriot 29:c0e6f198db84 61
nherriot 29:c0e6f198db84 62
nherriot 28:c630a04a7198 63 LOG("Test %d sending an SMS message...", _testCaseNumber);
ashleymills 40:32b0558320ea 64 LOG("Sending SMS:' %s ' to test phone: %s , waiting for response.", gAlphabetNumbersMessage, gTestPhoneNumber);
nherriot 28:c630a04a7198 65
ashleymills 40:32b0558320ea 66 int ret = _modem->sendSM(gTestPhoneNumber, gAlphabetNumbersMessage);
nherriot 28:c630a04a7198 67
nherriot 28:c630a04a7198 68 if (ret)
nherriot 28:c630a04a7198 69 {
nherriot 28:c630a04a7198 70 LOG("Error in sending the SMS message. The return values is: %d", ret);
nherriot 28:c630a04a7198 71
nherriot 28:c630a04a7198 72 switch(ret){
nherriot 28:c630a04a7198 73 case(NET_INVALID): LOG("Error message is: 'phone number is invalid size, must be less than 16 digits'.");break;
nherriot 28:c630a04a7198 74 case(NET_PROTOCOL): LOG("Error message is: 'protocol error from the modem'.");break;
nherriot 28:c630a04a7198 75 default: LOG("Undefined error message.");
nherriot 28:c630a04a7198 76
nherriot 28:c630a04a7198 77 }
nherriot 28:c630a04a7198 78 return false;
nherriot 28:c630a04a7198 79 }
nherriot 28:c630a04a7198 80 LOG("Test %d passed...", _testCaseNumber);
nherriot 31:9231acdde9ff 81 return true;
nherriot 28:c630a04a7198 82 }
nherriot 28:c630a04a7198 83
nherriot 28:c630a04a7198 84 private:
nherriot 31:9231acdde9ff 85
nherriot 28:c630a04a7198 86
nherriot 28:c630a04a7198 87 };