Vodafone Test Suite
Dependencies: mbed-rtos mbed HTTPClient VodafoneUSBModem
Tests/Test13.h@66:6b00a764e549, 2012-11-01 (annotated)
- Committer:
- ashleymills
- Date:
- Thu Nov 01 11:19:47 2012 +0000
- Revision:
- 66:6b00a764e549
- Parent:
- 60:7efce4a3c26f
Renamed tests in sequential order to make it easier to manage and cleaner to follow.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nherriot | 28:c630a04a7198 | 1 | #pragma once |
nherriot | 28:c630a04a7198 | 2 | #include "VodafoneTestCase.h" |
ashleymills | 66:6b00a764e549 | 3 | //#define __DEBUG__ 1 |
nherriot | 28:c630a04a7198 | 4 | |
ashleymills | 66:6b00a764e549 | 5 | // this test case will wait to send an SMS from the modem. |
ashleymills | 66:6b00a764e549 | 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. |
ashleymills | 66:6b00a764e549 | 8 | // it does not wait after it has succesfully sent an SMS. |
ashleymills | 66:6b00a764e549 | 9 | extern const char* gTest13Description; |
nherriot | 31:9231acdde9ff | 10 | |
nherriot | 28:c630a04a7198 | 11 | class Test13 : public VodafoneTestCase { |
nherriot | 28:c630a04a7198 | 12 | public: |
nherriot | 28:c630a04a7198 | 13 | |
ashleymills | 60:7efce4a3c26f | 14 | Test13(VodafoneUSBModem *m) : VodafoneTestCase(m) {} |
ashleymills | 44:6d0ac4747f5b | 15 | |
ashleymills | 44:6d0ac4747f5b | 16 | private: |
nherriot | 28:c630a04a7198 | 17 | |
ashleymills | 44:6d0ac4747f5b | 18 | virtual bool executeTest() { |
ashleymills | 60:7efce4a3c26f | 19 | LOG(gTest13Description); |
ashleymills | 66:6b00a764e549 | 20 | LinkMonitor::REGISTRATION_STATE regState = LinkMonitor::REGISTRATION_STATE_UNKNOWN; |
ashleymills | 66:6b00a764e549 | 21 | LinkMonitor::BEARER bearer = LinkMonitor::BEARER_UNKNOWN; |
ashleymills | 66:6b00a764e549 | 22 | int rssi = -1000; |
ashleymills | 66:6b00a764e549 | 23 | if(_modem->getLinkState(&rssi, ®State, &bearer)==0) |
nherriot | 28:c630a04a7198 | 24 | { |
ashleymills | 66:6b00a764e549 | 25 | if(rssi==-1000) |
ashleymills | 66:6b00a764e549 | 26 | { LOG("Checking signal strength - RSSI: Error."); return false;} |
ashleymills | 66:6b00a764e549 | 27 | else |
ashleymills | 66:6b00a764e549 | 28 | { LOG("Signal strength is: RSSI: %d",rssi);} |
ashleymills | 66:6b00a764e549 | 29 | |
ashleymills | 66:6b00a764e549 | 30 | |
ashleymills | 66:6b00a764e549 | 31 | switch(regState) { |
ashleymills | 66:6b00a764e549 | 32 | case LinkMonitor::REGISTRATION_STATE_UNKNOWN: |
ashleymills | 66:6b00a764e549 | 33 | LOG("regState: UNKNOWN. Failing."); |
ashleymills | 66:6b00a764e549 | 34 | return false; |
ashleymills | 66:6b00a764e549 | 35 | case LinkMonitor::REGISTRATION_STATE_REGISTERING: |
ashleymills | 66:6b00a764e549 | 36 | LOG("regState: REGISTERING"); |
ashleymills | 66:6b00a764e549 | 37 | break; |
ashleymills | 66:6b00a764e549 | 38 | case LinkMonitor::REGISTRATION_STATE_DENIED: |
ashleymills | 66:6b00a764e549 | 39 | LOG("regState: DENIED"); |
ashleymills | 66:6b00a764e549 | 40 | return false; |
ashleymills | 66:6b00a764e549 | 41 | case LinkMonitor::REGISTRATION_STATE_NO_SIGNAL: |
ashleymills | 66:6b00a764e549 | 42 | LOG("regState: NO SIGNAL"); |
ashleymills | 66:6b00a764e549 | 43 | return false; |
ashleymills | 66:6b00a764e549 | 44 | case LinkMonitor::REGISTRATION_STATE_HOME_NETWORK: |
ashleymills | 66:6b00a764e549 | 45 | LOG("regState: HOME NETWORK"); |
ashleymills | 66:6b00a764e549 | 46 | break; |
ashleymills | 66:6b00a764e549 | 47 | case LinkMonitor::REGISTRATION_STATE_ROAMING: |
ashleymills | 66:6b00a764e549 | 48 | LOG("regState: ROAMING"); |
ashleymills | 66:6b00a764e549 | 49 | break; |
ashleymills | 66:6b00a764e549 | 50 | default: |
ashleymills | 66:6b00a764e549 | 51 | LOG("regState: ERROR. Failing."); |
ashleymills | 66:6b00a764e549 | 52 | return false; |
ashleymills | 66:6b00a764e549 | 53 | } |
ashleymills | 66:6b00a764e549 | 54 | } |
ashleymills | 66:6b00a764e549 | 55 | |
ashleymills | 66:6b00a764e549 | 56 | LOG("Creating GSM test buffer"); |
ashleymills | 66:6b00a764e549 | 57 | LOG("Sending SMS:' %s ' to test phone: %s , waiting for response.", gIrregularMessage, gTestPhoneNumber); |
ashleymills | 66:6b00a764e549 | 58 | |
ashleymills | 66:6b00a764e549 | 59 | // create a buffer and send each character until you can send them all |
ashleymills | 66:6b00a764e549 | 60 | char shortBuffer[30]; |
ashleymills | 66:6b00a764e549 | 61 | |
ashleymills | 66:6b00a764e549 | 62 | // XXX What are you doing here nick? What is the size of gIrregularMessage? It's a pointer!! You're looking for strlen |
ashleymills | 66:6b00a764e549 | 63 | // And gIrregularMessage is longer than shortBuffer so you are goign to kill someone's memory |
ashleymills | 66:6b00a764e549 | 64 | for (int i=0; i < sizeof(gIrregularMessage); i++) |
ashleymills | 66:6b00a764e549 | 65 | { |
ashleymills | 66:6b00a764e549 | 66 | shortBuffer[i] = gIrregularMessage[i]; |
ashleymills | 66:6b00a764e549 | 67 | LOG("Buffer is now: %s", shortBuffer); |
ashleymills | 66:6b00a764e549 | 68 | LOG("Irregular message is %s", gIrregularMessage); |
ashleymills | 66:6b00a764e549 | 69 | int ret = _modem->sendSM(gTestPhoneNumber, shortBuffer); |
ashleymills | 66:6b00a764e549 | 70 | |
ashleymills | 66:6b00a764e549 | 71 | } |
ashleymills | 66:6b00a764e549 | 72 | |
ashleymills | 66:6b00a764e549 | 73 | int ret = _modem->sendSM(gTestPhoneNumber, gIrregularMessage); |
ashleymills | 66:6b00a764e549 | 74 | |
ashleymills | 66:6b00a764e549 | 75 | if (ret) |
ashleymills | 66:6b00a764e549 | 76 | { |
ashleymills | 66:6b00a764e549 | 77 | LOG("Error in sending the SMS message. The return values is: %d", ret); |
ashleymills | 66:6b00a764e549 | 78 | |
ashleymills | 66:6b00a764e549 | 79 | switch(ret){ |
ashleymills | 66:6b00a764e549 | 80 | case(NET_INVALID): LOG("Error message is: 'phone number is invalid size, must be less than 16 digits'.");break; |
ashleymills | 66:6b00a764e549 | 81 | case(NET_PROTOCOL): LOG("Error message is: 'protocol error from the modem'.");break; |
ashleymills | 66:6b00a764e549 | 82 | default: LOG("Undefined error message."); |
ashleymills | 66:6b00a764e549 | 83 | |
nherriot | 28:c630a04a7198 | 84 | } |
ashleymills | 66:6b00a764e549 | 85 | return false; |
nherriot | 28:c630a04a7198 | 86 | } |
ashleymills | 66:6b00a764e549 | 87 | return true; |
nherriot | 28:c630a04a7198 | 88 | |
nherriot | 28:c630a04a7198 | 89 | } |
ashleymills | 66:6b00a764e549 | 90 | |
ashleymills | 66:6b00a764e549 | 91 | char gsm03dot38CharacterSet[127]; |
ashleymills | 66:6b00a764e549 | 92 | |
ashleymills | 66:6b00a764e549 | 93 | |
nherriot | 16:c89d426c6175 | 94 | }; |