Vodafone Test Suite
Dependencies: mbed-rtos mbed HTTPClient VodafoneUSBModem
Tests/Test56.h@44:6d0ac4747f5b, 2012-09-17 (annotated)
- Committer:
- ashleymills
- Date:
- Mon Sep 17 13:28:39 2012 +0000
- Revision:
- 44:6d0ac4747f5b
- Parent:
- 40:32b0558320ea
- Child:
- 60:7efce4a3c26f
Refactored names. Privatised virtuals to avoid bugs (bitten).
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 | 37:847f5f86e9ff | 9 | extern const char* gTest56Description; |
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 | |
ashleymills | 44:6d0ac4747f5b | 19 | private: |
nherriot | 29:c0e6f198db84 | 20 | |
ashleymills | 44:6d0ac4747f5b | 21 | virtual bool executeTest() { |
nherriot | 29:c0e6f198db84 | 22 | |
nherriot | 29:c0e6f198db84 | 23 | LinkMonitor::REGISTRATION_STATE regState = LinkMonitor::REGISTRATION_STATE_UNKNOWN; |
nherriot | 29:c0e6f198db84 | 24 | LinkMonitor::BEARER bearer = LinkMonitor::BEARER_UNKNOWN; |
nherriot | 29:c0e6f198db84 | 25 | int rssi = -1000; |
nherriot | 29:c0e6f198db84 | 26 | if(_modem->getLinkState(&rssi, ®State, &bearer)==0) |
nherriot | 29:c0e6f198db84 | 27 | { |
nherriot | 29:c0e6f198db84 | 28 | if(rssi==-1000) |
nherriot | 29:c0e6f198db84 | 29 | { LOG("Checking signal strength - RSSI: Error."); return false;} |
nherriot | 29:c0e6f198db84 | 30 | else |
nherriot | 29:c0e6f198db84 | 31 | { LOG("Signal strength is: RSSI: %d",rssi);} |
nherriot | 29:c0e6f198db84 | 32 | |
nherriot | 29:c0e6f198db84 | 33 | |
nherriot | 29:c0e6f198db84 | 34 | switch(regState) { |
nherriot | 29:c0e6f198db84 | 35 | case LinkMonitor::REGISTRATION_STATE_UNKNOWN: |
nherriot | 29:c0e6f198db84 | 36 | LOG("regState: UNKNOWN. Failing."); |
nherriot | 29:c0e6f198db84 | 37 | return false; |
nherriot | 29:c0e6f198db84 | 38 | case LinkMonitor::REGISTRATION_STATE_REGISTERING: |
nherriot | 29:c0e6f198db84 | 39 | LOG("regState: REGISTERING"); |
nherriot | 29:c0e6f198db84 | 40 | break; |
nherriot | 29:c0e6f198db84 | 41 | case LinkMonitor::REGISTRATION_STATE_DENIED: |
nherriot | 29:c0e6f198db84 | 42 | LOG("regState: DENIED"); |
nherriot | 29:c0e6f198db84 | 43 | return false; |
nherriot | 29:c0e6f198db84 | 44 | case LinkMonitor::REGISTRATION_STATE_NO_SIGNAL: |
nherriot | 29:c0e6f198db84 | 45 | LOG("regState: NO SIGNAL"); |
nherriot | 29:c0e6f198db84 | 46 | return false; |
nherriot | 29:c0e6f198db84 | 47 | case LinkMonitor::REGISTRATION_STATE_HOME_NETWORK: |
nherriot | 29:c0e6f198db84 | 48 | LOG("regState: HOME NETWORK"); |
nherriot | 29:c0e6f198db84 | 49 | break; |
nherriot | 29:c0e6f198db84 | 50 | case LinkMonitor::REGISTRATION_STATE_ROAMING: |
nherriot | 29:c0e6f198db84 | 51 | LOG("regState: ROAMING"); |
nherriot | 29:c0e6f198db84 | 52 | break; |
nherriot | 29:c0e6f198db84 | 53 | default: |
nherriot | 29:c0e6f198db84 | 54 | LOG("regState: ERROR. Failing."); |
nherriot | 29:c0e6f198db84 | 55 | return false; |
nherriot | 29:c0e6f198db84 | 56 | } |
nherriot | 29:c0e6f198db84 | 57 | } |
nherriot | 29:c0e6f198db84 | 58 | |
nherriot | 29:c0e6f198db84 | 59 | LOG("Creating GSM test buffer"); |
nherriot | 29:c0e6f198db84 | 60 | LOG("Test %d sending an SMS message...", _testCaseNumber); |
ashleymills | 40:32b0558320ea | 61 | LOG("Sending SMS:' %s ' to test phone: %s , waiting for response.", gIrregularMessage, gTestPhoneNumber); |
nherriot | 29:c0e6f198db84 | 62 | |
nherriot | 29:c0e6f198db84 | 63 | // create a buffer and send each character until you can send them all |
nherriot | 29:c0e6f198db84 | 64 | char shortBuffer[30]; |
nherriot | 29:c0e6f198db84 | 65 | |
ashleymills | 40:32b0558320ea | 66 | // XXX What are you doing here nick? What is the size of gIrregularMessage? It's a pointer!! You're looking for strlen |
ashleymills | 40:32b0558320ea | 67 | // And gIrregularMessage is longer than shortBuffer so you are goign to kill someone's memory |
ashleymills | 40:32b0558320ea | 68 | for (int i=0; i < sizeof(gIrregularMessage); i++) |
nherriot | 29:c0e6f198db84 | 69 | { |
ashleymills | 40:32b0558320ea | 70 | shortBuffer[i] = gIrregularMessage[i]; |
nherriot | 29:c0e6f198db84 | 71 | LOG("Buffer is now: %s", shortBuffer); |
ashleymills | 40:32b0558320ea | 72 | LOG("Irregular message is %s", gIrregularMessage); |
ashleymills | 40:32b0558320ea | 73 | int ret = _modem->sendSM(gTestPhoneNumber, shortBuffer); |
nherriot | 31:9231acdde9ff | 74 | |
nherriot | 29:c0e6f198db84 | 75 | } |
nherriot | 29:c0e6f198db84 | 76 | |
ashleymills | 40:32b0558320ea | 77 | int ret = _modem->sendSM(gTestPhoneNumber, gIrregularMessage); |
nherriot | 29:c0e6f198db84 | 78 | |
nherriot | 29:c0e6f198db84 | 79 | if (ret) |
nherriot | 29:c0e6f198db84 | 80 | { |
nherriot | 29:c0e6f198db84 | 81 | LOG("Error in sending the SMS message. The return values is: %d", ret); |
nherriot | 29:c0e6f198db84 | 82 | |
nherriot | 29:c0e6f198db84 | 83 | switch(ret){ |
nherriot | 29:c0e6f198db84 | 84 | case(NET_INVALID): LOG("Error message is: 'phone number is invalid size, must be less than 16 digits'.");break; |
nherriot | 29:c0e6f198db84 | 85 | case(NET_PROTOCOL): LOG("Error message is: 'protocol error from the modem'.");break; |
nherriot | 29:c0e6f198db84 | 86 | default: LOG("Undefined error message."); |
nherriot | 29:c0e6f198db84 | 87 | |
nherriot | 29:c0e6f198db84 | 88 | } |
nherriot | 29:c0e6f198db84 | 89 | return false; |
nherriot | 29:c0e6f198db84 | 90 | } |
nherriot | 29:c0e6f198db84 | 91 | LOG("Test %d passed...", _testCaseNumber); |
nherriot | 29:c0e6f198db84 | 92 | return true; |
nherriot | 29:c0e6f198db84 | 93 | |
nherriot | 29:c0e6f198db84 | 94 | } |
nherriot | 29:c0e6f198db84 | 95 | |
nherriot | 29:c0e6f198db84 | 96 | char gsm03dot38CharacterSet[127]; |
nherriot | 29:c0e6f198db84 | 97 | |
nherriot | 29:c0e6f198db84 | 98 | |
nherriot | 29:c0e6f198db84 | 99 | }; |