Vodafone Test Suite
Dependencies: mbed-rtos mbed HTTPClient VodafoneUSBModem
Tests/Test56.h@31:9231acdde9ff, 2012-09-12 (annotated)
- Committer:
- nherriot
- Date:
- Wed Sep 12 16:55:00 2012 +0000
- Revision:
- 31:9231acdde9ff
- Parent:
- 29:c0e6f198db84
- Child:
- 33:16126e029d58
adding new sms test cases for send/receive irregular chars. changing auto run list, and adding descriptions.
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. |
nherriot | 29:c0e6f198db84 | 9 | |
nherriot | 29:c0e6f198db84 | 10 | |
nherriot | 29:c0e6f198db84 | 11 | class Test56 : public VodafoneTestCase { |
nherriot | 29:c0e6f198db84 | 12 | public: |
nherriot | 29:c0e6f198db84 | 13 | |
nherriot | 29:c0e6f198db84 | 14 | |
nherriot | 29:c0e6f198db84 | 15 | Test56(VodafoneUSBModem *m, int tcNumber) : VodafoneTestCase(m, tcNumber) { |
nherriot | 29:c0e6f198db84 | 16 | } |
nherriot | 29:c0e6f198db84 | 17 | |
nherriot | 29:c0e6f198db84 | 18 | |
nherriot | 29:c0e6f198db84 | 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, ®State, &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 | LOG("Creating GSM test buffer"); |
nherriot | 29:c0e6f198db84 | 58 | LOG("Test %d sending an SMS message...", _testCaseNumber); |
nherriot | 31:9231acdde9ff | 59 | LOG("Sending SMS:' %s ' to test phone: %s , waiting for response.", irregularMessage, testPhoneNumber); |
nherriot | 29:c0e6f198db84 | 60 | |
nherriot | 29:c0e6f198db84 | 61 | // create a buffer and send each character until you can send them all |
nherriot | 29:c0e6f198db84 | 62 | char shortBuffer[30]; |
nherriot | 29:c0e6f198db84 | 63 | |
nherriot | 29:c0e6f198db84 | 64 | for (int i=0; i < sizeof(irregularMessage); i++) |
nherriot | 29:c0e6f198db84 | 65 | { |
nherriot | 29:c0e6f198db84 | 66 | shortBuffer[i] = irregularMessage[i]; |
nherriot | 29:c0e6f198db84 | 67 | LOG("Buffer is now: %s", shortBuffer); |
nherriot | 29:c0e6f198db84 | 68 | LOG("Irregular message is %s", irregularMessage); |
nherriot | 31:9231acdde9ff | 69 | int ret = _modem->sendSM(testPhoneNumber, shortBuffer); |
nherriot | 31:9231acdde9ff | 70 | |
nherriot | 29:c0e6f198db84 | 71 | } |
nherriot | 29:c0e6f198db84 | 72 | |
nherriot | 29:c0e6f198db84 | 73 | int ret = _modem->sendSM(testPhoneNumber, irregularMessage); |
nherriot | 29:c0e6f198db84 | 74 | |
nherriot | 29:c0e6f198db84 | 75 | if (ret) |
nherriot | 29:c0e6f198db84 | 76 | { |
nherriot | 29:c0e6f198db84 | 77 | LOG("Error in sending the SMS message. The return values is: %d", ret); |
nherriot | 29:c0e6f198db84 | 78 | |
nherriot | 29:c0e6f198db84 | 79 | switch(ret){ |
nherriot | 29:c0e6f198db84 | 80 | case(NET_INVALID): LOG("Error message is: 'phone number is invalid size, must be less than 16 digits'.");break; |
nherriot | 29:c0e6f198db84 | 81 | case(NET_PROTOCOL): LOG("Error message is: 'protocol error from the modem'.");break; |
nherriot | 29:c0e6f198db84 | 82 | default: LOG("Undefined error message."); |
nherriot | 29:c0e6f198db84 | 83 | |
nherriot | 29:c0e6f198db84 | 84 | } |
nherriot | 29:c0e6f198db84 | 85 | return false; |
nherriot | 29:c0e6f198db84 | 86 | } |
nherriot | 29:c0e6f198db84 | 87 | LOG("Test %d passed...", _testCaseNumber); |
nherriot | 29:c0e6f198db84 | 88 | return true; |
nherriot | 29:c0e6f198db84 | 89 | |
nherriot | 29:c0e6f198db84 | 90 | } |
nherriot | 29:c0e6f198db84 | 91 | |
nherriot | 29:c0e6f198db84 | 92 | private: |
nherriot | 29:c0e6f198db84 | 93 | char gsm03dot38CharacterSet[127]; |
nherriot | 29:c0e6f198db84 | 94 | |
nherriot | 29:c0e6f198db84 | 95 | |
nherriot | 29:c0e6f198db84 | 96 | }; |