Vodafone Test Suite
Dependencies: mbed-rtos mbed HTTPClient VodafoneUSBModem
Tests/Test56.h@33:16126e029d58, 2012-09-13 (annotated)
- Committer:
- ashleymills
- Date:
- Thu Sep 13 10:05:31 2012 +0000
- Revision:
- 33:16126e029d58
- Parent:
- 31:9231acdde9ff
- Child:
- 34:d9e45aad85f2
Changed test framework.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nherriot | 29:c0e6f198db84 | 1 | #pragma once |
nherriot | 29:c0e6f198db84 | 2 | #include "VodafoneTestCase.h" |
nherriot | 29:c0e6f198db84 | 3 | //#define __DEBUG__ 1 |
nherriot | 29:c0e6f198db84 | 4 | |
nherriot | 29:c0e6f198db84 | 5 | // this test case will wait to send an SMS from the modem. |
nherriot | 29:c0e6f198db84 | 6 | // if the method that sends a message returns an error it will fail. |
nherriot | 29:c0e6f198db84 | 7 | // it will report the test as failed if any of the above happens. |
nherriot | 29:c0e6f198db84 | 8 | // it does not wait after it has succesfully sent an SMS. |
ashleymills | 33:16126e029d58 | 9 | static const char* gTest56Description = "Wait for SMS. Send a response."; |
nherriot | 29:c0e6f198db84 | 10 | |
nherriot | 29:c0e6f198db84 | 11 | class Test56 : public VodafoneTestCase { |
nherriot | 29:c0e6f198db84 | 12 | public: |
nherriot | 29:c0e6f198db84 | 13 | |
ashleymills | 33:16126e029d58 | 14 | Test56(VodafoneUSBModem *m) : VodafoneTestCase(m) { |
ashleymills | 33:16126e029d58 | 15 | _description = gTest56Description; |
ashleymills | 33:16126e029d58 | 16 | _testCaseNumber = 56; |
nherriot | 29:c0e6f198db84 | 17 | } |
nherriot | 29:c0e6f198db84 | 18 | |
nherriot | 29:c0e6f198db84 | 19 | |
nherriot | 29:c0e6f198db84 | 20 | virtual bool runTest() { |
nherriot | 29:c0e6f198db84 | 21 | |
nherriot | 29:c0e6f198db84 | 22 | LinkMonitor::REGISTRATION_STATE regState = LinkMonitor::REGISTRATION_STATE_UNKNOWN; |
nherriot | 29:c0e6f198db84 | 23 | LinkMonitor::BEARER bearer = LinkMonitor::BEARER_UNKNOWN; |
nherriot | 29:c0e6f198db84 | 24 | int rssi = -1000; |
nherriot | 29:c0e6f198db84 | 25 | if(_modem->getLinkState(&rssi, ®State, &bearer)==0) |
nherriot | 29:c0e6f198db84 | 26 | { |
nherriot | 29:c0e6f198db84 | 27 | if(rssi==-1000) |
nherriot | 29:c0e6f198db84 | 28 | { LOG("Checking signal strength - RSSI: Error."); return false;} |
nherriot | 29:c0e6f198db84 | 29 | else |
nherriot | 29:c0e6f198db84 | 30 | { LOG("Signal strength is: RSSI: %d",rssi);} |
nherriot | 29:c0e6f198db84 | 31 | |
nherriot | 29:c0e6f198db84 | 32 | |
nherriot | 29:c0e6f198db84 | 33 | switch(regState) { |
nherriot | 29:c0e6f198db84 | 34 | case LinkMonitor::REGISTRATION_STATE_UNKNOWN: |
nherriot | 29:c0e6f198db84 | 35 | LOG("regState: UNKNOWN. Failing."); |
nherriot | 29:c0e6f198db84 | 36 | return false; |
nherriot | 29:c0e6f198db84 | 37 | case LinkMonitor::REGISTRATION_STATE_REGISTERING: |
nherriot | 29:c0e6f198db84 | 38 | LOG("regState: REGISTERING"); |
nherriot | 29:c0e6f198db84 | 39 | break; |
nherriot | 29:c0e6f198db84 | 40 | case LinkMonitor::REGISTRATION_STATE_DENIED: |
nherriot | 29:c0e6f198db84 | 41 | LOG("regState: DENIED"); |
nherriot | 29:c0e6f198db84 | 42 | return false; |
nherriot | 29:c0e6f198db84 | 43 | case LinkMonitor::REGISTRATION_STATE_NO_SIGNAL: |
nherriot | 29:c0e6f198db84 | 44 | LOG("regState: NO SIGNAL"); |
nherriot | 29:c0e6f198db84 | 45 | return false; |
nherriot | 29:c0e6f198db84 | 46 | case LinkMonitor::REGISTRATION_STATE_HOME_NETWORK: |
nherriot | 29:c0e6f198db84 | 47 | LOG("regState: HOME NETWORK"); |
nherriot | 29:c0e6f198db84 | 48 | break; |
nherriot | 29:c0e6f198db84 | 49 | case LinkMonitor::REGISTRATION_STATE_ROAMING: |
nherriot | 29:c0e6f198db84 | 50 | LOG("regState: ROAMING"); |
nherriot | 29:c0e6f198db84 | 51 | break; |
nherriot | 29:c0e6f198db84 | 52 | default: |
nherriot | 29:c0e6f198db84 | 53 | LOG("regState: ERROR. Failing."); |
nherriot | 29:c0e6f198db84 | 54 | return false; |
nherriot | 29:c0e6f198db84 | 55 | } |
nherriot | 29:c0e6f198db84 | 56 | } |
nherriot | 29:c0e6f198db84 | 57 | |
nherriot | 29:c0e6f198db84 | 58 | LOG("Creating GSM test buffer"); |
nherriot | 29:c0e6f198db84 | 59 | LOG("Test %d sending an SMS message...", _testCaseNumber); |
nherriot | 31:9231acdde9ff | 60 | LOG("Sending SMS:' %s ' to test phone: %s , waiting for response.", irregularMessage, testPhoneNumber); |
nherriot | 29:c0e6f198db84 | 61 | |
nherriot | 29:c0e6f198db84 | 62 | // create a buffer and send each character until you can send them all |
nherriot | 29:c0e6f198db84 | 63 | char shortBuffer[30]; |
nherriot | 29:c0e6f198db84 | 64 | |
nherriot | 29:c0e6f198db84 | 65 | for (int i=0; i < sizeof(irregularMessage); i++) |
nherriot | 29:c0e6f198db84 | 66 | { |
nherriot | 29:c0e6f198db84 | 67 | shortBuffer[i] = irregularMessage[i]; |
nherriot | 29:c0e6f198db84 | 68 | LOG("Buffer is now: %s", shortBuffer); |
nherriot | 29:c0e6f198db84 | 69 | LOG("Irregular message is %s", irregularMessage); |
nherriot | 31:9231acdde9ff | 70 | int ret = _modem->sendSM(testPhoneNumber, shortBuffer); |
nherriot | 31:9231acdde9ff | 71 | |
nherriot | 29:c0e6f198db84 | 72 | } |
nherriot | 29:c0e6f198db84 | 73 | |
nherriot | 29:c0e6f198db84 | 74 | int ret = _modem->sendSM(testPhoneNumber, irregularMessage); |
nherriot | 29:c0e6f198db84 | 75 | |
nherriot | 29:c0e6f198db84 | 76 | if (ret) |
nherriot | 29:c0e6f198db84 | 77 | { |
nherriot | 29:c0e6f198db84 | 78 | LOG("Error in sending the SMS message. The return values is: %d", ret); |
nherriot | 29:c0e6f198db84 | 79 | |
nherriot | 29:c0e6f198db84 | 80 | switch(ret){ |
nherriot | 29:c0e6f198db84 | 81 | case(NET_INVALID): LOG("Error message is: 'phone number is invalid size, must be less than 16 digits'.");break; |
nherriot | 29:c0e6f198db84 | 82 | case(NET_PROTOCOL): LOG("Error message is: 'protocol error from the modem'.");break; |
nherriot | 29:c0e6f198db84 | 83 | default: LOG("Undefined error message."); |
nherriot | 29:c0e6f198db84 | 84 | |
nherriot | 29:c0e6f198db84 | 85 | } |
nherriot | 29:c0e6f198db84 | 86 | return false; |
nherriot | 29:c0e6f198db84 | 87 | } |
nherriot | 29:c0e6f198db84 | 88 | LOG("Test %d passed...", _testCaseNumber); |
nherriot | 29:c0e6f198db84 | 89 | return true; |
nherriot | 29:c0e6f198db84 | 90 | |
nherriot | 29:c0e6f198db84 | 91 | } |
nherriot | 29:c0e6f198db84 | 92 | |
nherriot | 29:c0e6f198db84 | 93 | private: |
nherriot | 29:c0e6f198db84 | 94 | char gsm03dot38CharacterSet[127]; |
nherriot | 29:c0e6f198db84 | 95 | |
nherriot | 29:c0e6f198db84 | 96 | |
nherriot | 29:c0e6f198db84 | 97 | }; |