Vodafone Test Suite
Dependencies: mbed-rtos mbed HTTPClient VodafoneUSBModem
Tests/Test56.h@60:7efce4a3c26f, 2012-10-23 (annotated)
- Committer:
- ashleymills
- Date:
- Tue Oct 23 14:22:53 2012 +0000
- Revision:
- 60:7efce4a3c26f
- Parent:
- 44:6d0ac4747f5b
Added new SMS bulk test (incomplete).
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 | 60:7efce4a3c26f | 14 | Test56(VodafoneUSBModem *m) : VodafoneTestCase(m) {} |
nherriot | 29:c0e6f198db84 | 15 | |
ashleymills | 44:6d0ac4747f5b | 16 | private: |
nherriot | 29:c0e6f198db84 | 17 | |
ashleymills | 44:6d0ac4747f5b | 18 | virtual bool executeTest() { |
ashleymills | 60:7efce4a3c26f | 19 | LOG(gTest56Description); |
nherriot | 29:c0e6f198db84 | 20 | LinkMonitor::REGISTRATION_STATE regState = LinkMonitor::REGISTRATION_STATE_UNKNOWN; |
nherriot | 29:c0e6f198db84 | 21 | LinkMonitor::BEARER bearer = LinkMonitor::BEARER_UNKNOWN; |
nherriot | 29:c0e6f198db84 | 22 | int rssi = -1000; |
nherriot | 29:c0e6f198db84 | 23 | if(_modem->getLinkState(&rssi, ®State, &bearer)==0) |
nherriot | 29:c0e6f198db84 | 24 | { |
nherriot | 29:c0e6f198db84 | 25 | if(rssi==-1000) |
nherriot | 29:c0e6f198db84 | 26 | { LOG("Checking signal strength - RSSI: Error."); return false;} |
nherriot | 29:c0e6f198db84 | 27 | else |
nherriot | 29:c0e6f198db84 | 28 | { LOG("Signal strength is: RSSI: %d",rssi);} |
nherriot | 29:c0e6f198db84 | 29 | |
nherriot | 29:c0e6f198db84 | 30 | |
nherriot | 29:c0e6f198db84 | 31 | switch(regState) { |
nherriot | 29:c0e6f198db84 | 32 | case LinkMonitor::REGISTRATION_STATE_UNKNOWN: |
nherriot | 29:c0e6f198db84 | 33 | LOG("regState: UNKNOWN. Failing."); |
nherriot | 29:c0e6f198db84 | 34 | return false; |
nherriot | 29:c0e6f198db84 | 35 | case LinkMonitor::REGISTRATION_STATE_REGISTERING: |
nherriot | 29:c0e6f198db84 | 36 | LOG("regState: REGISTERING"); |
nherriot | 29:c0e6f198db84 | 37 | break; |
nherriot | 29:c0e6f198db84 | 38 | case LinkMonitor::REGISTRATION_STATE_DENIED: |
nherriot | 29:c0e6f198db84 | 39 | LOG("regState: DENIED"); |
nherriot | 29:c0e6f198db84 | 40 | return false; |
nherriot | 29:c0e6f198db84 | 41 | case LinkMonitor::REGISTRATION_STATE_NO_SIGNAL: |
nherriot | 29:c0e6f198db84 | 42 | LOG("regState: NO SIGNAL"); |
nherriot | 29:c0e6f198db84 | 43 | return false; |
nherriot | 29:c0e6f198db84 | 44 | case LinkMonitor::REGISTRATION_STATE_HOME_NETWORK: |
nherriot | 29:c0e6f198db84 | 45 | LOG("regState: HOME NETWORK"); |
nherriot | 29:c0e6f198db84 | 46 | break; |
nherriot | 29:c0e6f198db84 | 47 | case LinkMonitor::REGISTRATION_STATE_ROAMING: |
nherriot | 29:c0e6f198db84 | 48 | LOG("regState: ROAMING"); |
nherriot | 29:c0e6f198db84 | 49 | break; |
nherriot | 29:c0e6f198db84 | 50 | default: |
nherriot | 29:c0e6f198db84 | 51 | LOG("regState: ERROR. Failing."); |
nherriot | 29:c0e6f198db84 | 52 | return false; |
nherriot | 29:c0e6f198db84 | 53 | } |
nherriot | 29:c0e6f198db84 | 54 | } |
nherriot | 29:c0e6f198db84 | 55 | |
nherriot | 29:c0e6f198db84 | 56 | LOG("Creating GSM test buffer"); |
ashleymills | 40:32b0558320ea | 57 | LOG("Sending SMS:' %s ' to test phone: %s , waiting for response.", gIrregularMessage, gTestPhoneNumber); |
nherriot | 29:c0e6f198db84 | 58 | |
nherriot | 29:c0e6f198db84 | 59 | // create a buffer and send each character until you can send them all |
nherriot | 29:c0e6f198db84 | 60 | char shortBuffer[30]; |
nherriot | 29:c0e6f198db84 | 61 | |
ashleymills | 40:32b0558320ea | 62 | // 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 | 63 | // And gIrregularMessage is longer than shortBuffer so you are goign to kill someone's memory |
ashleymills | 40:32b0558320ea | 64 | for (int i=0; i < sizeof(gIrregularMessage); i++) |
nherriot | 29:c0e6f198db84 | 65 | { |
ashleymills | 40:32b0558320ea | 66 | shortBuffer[i] = gIrregularMessage[i]; |
nherriot | 29:c0e6f198db84 | 67 | LOG("Buffer is now: %s", shortBuffer); |
ashleymills | 40:32b0558320ea | 68 | LOG("Irregular message is %s", gIrregularMessage); |
ashleymills | 40:32b0558320ea | 69 | int ret = _modem->sendSM(gTestPhoneNumber, shortBuffer); |
nherriot | 31:9231acdde9ff | 70 | |
nherriot | 29:c0e6f198db84 | 71 | } |
nherriot | 29:c0e6f198db84 | 72 | |
ashleymills | 40:32b0558320ea | 73 | int ret = _modem->sendSM(gTestPhoneNumber, gIrregularMessage); |
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 | return true; |
nherriot | 29:c0e6f198db84 | 88 | |
nherriot | 29:c0e6f198db84 | 89 | } |
nherriot | 29:c0e6f198db84 | 90 | |
nherriot | 29:c0e6f198db84 | 91 | char gsm03dot38CharacterSet[127]; |
nherriot | 29:c0e6f198db84 | 92 | |
nherriot | 29:c0e6f198db84 | 93 | |
nherriot | 29:c0e6f198db84 | 94 | }; |