Vodafone Test Suite

Dependencies:   mbed-rtos mbed HTTPClient VodafoneUSBModem

Committer:
nherriot
Date:
Fri Sep 14 13:23:29 2012 +0000
Revision:
54:30062a67e8bb
Parent:
37:847f5f86e9ff
type name changes to follow with coding convention

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 54:30062a67e8bb 29 LOG("Test is starting....");
nherriot 29:c0e6f198db84 30 if(_modem->getLinkState(&rssi, &regState, &bearer)==0)
nherriot 29:c0e6f198db84 31 {
nherriot 29:c0e6f198db84 32 if(rssi==-1000)
nherriot 29:c0e6f198db84 33 { LOG("Checking signal strength - RSSI: Error."); return false;}
nherriot 29:c0e6f198db84 34 else
nherriot 29:c0e6f198db84 35 { LOG("Signal strength is: RSSI: %d",rssi);}
nherriot 29:c0e6f198db84 36
nherriot 29:c0e6f198db84 37
nherriot 29:c0e6f198db84 38 switch(regState) {
nherriot 29:c0e6f198db84 39 case LinkMonitor::REGISTRATION_STATE_UNKNOWN:
nherriot 29:c0e6f198db84 40 LOG("regState: UNKNOWN. Failing.");
nherriot 29:c0e6f198db84 41 return false;
nherriot 29:c0e6f198db84 42 case LinkMonitor::REGISTRATION_STATE_REGISTERING:
nherriot 29:c0e6f198db84 43 LOG("regState: REGISTERING");
nherriot 29:c0e6f198db84 44 break;
nherriot 29:c0e6f198db84 45 case LinkMonitor::REGISTRATION_STATE_DENIED:
nherriot 29:c0e6f198db84 46 LOG("regState: DENIED");
nherriot 29:c0e6f198db84 47 return false;
nherriot 29:c0e6f198db84 48 case LinkMonitor::REGISTRATION_STATE_NO_SIGNAL:
nherriot 29:c0e6f198db84 49 LOG("regState: NO SIGNAL");
nherriot 29:c0e6f198db84 50 return false;
nherriot 29:c0e6f198db84 51 case LinkMonitor::REGISTRATION_STATE_HOME_NETWORK:
nherriot 29:c0e6f198db84 52 LOG("regState: HOME NETWORK");
nherriot 29:c0e6f198db84 53 break;
nherriot 29:c0e6f198db84 54 case LinkMonitor::REGISTRATION_STATE_ROAMING:
nherriot 29:c0e6f198db84 55 LOG("regState: ROAMING");
nherriot 29:c0e6f198db84 56 break;
nherriot 29:c0e6f198db84 57 default:
nherriot 29:c0e6f198db84 58 LOG("regState: ERROR. Failing.");
nherriot 29:c0e6f198db84 59 return false;
nherriot 29:c0e6f198db84 60 }
nherriot 29:c0e6f198db84 61 }
nherriot 29:c0e6f198db84 62
nherriot 29:c0e6f198db84 63
nherriot 28:c630a04a7198 64 LOG("Test %d sending an SMS message...", _testCaseNumber);
nherriot 54:30062a67e8bb 65 LOG("Sending SMS:' %s ' to test phone: %s , waiting for response.", gAlphabetNumbersMessage, gTestPhoneNumber);
nherriot 28:c630a04a7198 66
nherriot 54:30062a67e8bb 67 int ret = _modem->sendSM(gTestPhoneNumber, gAlphabetNumbersMessage);
nherriot 28:c630a04a7198 68
nherriot 28:c630a04a7198 69 if (ret)
nherriot 28:c630a04a7198 70 {
nherriot 28:c630a04a7198 71 LOG("Error in sending the SMS message. The return values is: %d", ret);
nherriot 28:c630a04a7198 72
nherriot 28:c630a04a7198 73 switch(ret){
nherriot 28:c630a04a7198 74 case(NET_INVALID): LOG("Error message is: 'phone number is invalid size, must be less than 16 digits'.");break;
nherriot 28:c630a04a7198 75 case(NET_PROTOCOL): LOG("Error message is: 'protocol error from the modem'.");break;
nherriot 28:c630a04a7198 76 default: LOG("Undefined error message.");
nherriot 28:c630a04a7198 77
nherriot 28:c630a04a7198 78 }
nherriot 28:c630a04a7198 79 return false;
nherriot 28:c630a04a7198 80 }
nherriot 28:c630a04a7198 81 LOG("Test %d passed...", _testCaseNumber);
nherriot 31:9231acdde9ff 82 return true;
nherriot 28:c630a04a7198 83 }
nherriot 28:c630a04a7198 84
nherriot 28:c630a04a7198 85 private:
nherriot 31:9231acdde9ff 86
nherriot 28:c630a04a7198 87
nherriot 28:c630a04a7198 88 };