Vodafone Test Suite
Dependencies: mbed-rtos mbed HTTPClient VodafoneUSBModem
Tests/Test03.h@74:e52ac9624f7f, 2014-01-29 (annotated)
- Committer:
- ashleymills
- Date:
- Wed Jan 29 16:34:38 2014 +0000
- Revision:
- 74:e52ac9624f7f
- Parent:
- 66:6b00a764e549
Updated dependencies to latest versions.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ashleymills | 66:6b00a764e549 | 1 | #pragma once |
ashleymills | 66:6b00a764e549 | 2 | #include "VodafoneTestCase.h" |
ashleymills | 66:6b00a764e549 | 3 | |
ashleymills | 66:6b00a764e549 | 4 | #define TEST_PHONE_NUMBER "+447717275049" |
ashleymills | 66:6b00a764e549 | 5 | |
ashleymills | 66:6b00a764e549 | 6 | // this test case will wait to receive an SMS from the modem. |
ashleymills | 66:6b00a764e549 | 7 | // if the method that reports a message waiting returns an error it will fail. |
ashleymills | 66:6b00a764e549 | 8 | // if the method that returns the message from the mailbox returns an error it will fai. |
ashleymills | 66:6b00a764e549 | 9 | // it will report the test as failed if any of the above happens. |
ashleymills | 66:6b00a764e549 | 10 | // it waits forever for an SMS. |
ashleymills | 66:6b00a764e549 | 11 | // TODO: this should wait for a set time before failing. |
ashleymills | 66:6b00a764e549 | 12 | |
ashleymills | 66:6b00a764e549 | 13 | extern const char *gTest03Description; |
ashleymills | 66:6b00a764e549 | 14 | extern const char *gIrregularMessage; |
ashleymills | 66:6b00a764e549 | 15 | |
ashleymills | 66:6b00a764e549 | 16 | class Test03 : public VodafoneTestCase { |
ashleymills | 66:6b00a764e549 | 17 | public: |
ashleymills | 66:6b00a764e549 | 18 | |
ashleymills | 66:6b00a764e549 | 19 | char num[17]; |
ashleymills | 66:6b00a764e549 | 20 | char msg[160]; |
ashleymills | 66:6b00a764e549 | 21 | size_t count; |
ashleymills | 66:6b00a764e549 | 22 | |
ashleymills | 66:6b00a764e549 | 23 | Test03(VodafoneUSBModem *m) : VodafoneTestCase(m) {} |
ashleymills | 66:6b00a764e549 | 24 | |
ashleymills | 66:6b00a764e549 | 25 | private: |
ashleymills | 66:6b00a764e549 | 26 | |
ashleymills | 66:6b00a764e549 | 27 | virtual bool executeTest() { |
ashleymills | 66:6b00a764e549 | 28 | LOG(gTest03Description); |
ashleymills | 66:6b00a764e549 | 29 | LOG("Receiving SMS from test phone, waiting for response."); |
ashleymills | 66:6b00a764e549 | 30 | |
ashleymills | 66:6b00a764e549 | 31 | while(true) |
ashleymills | 66:6b00a764e549 | 32 | { |
ashleymills | 66:6b00a764e549 | 33 | LOG("Waiting for an SMS message..."); |
ashleymills | 66:6b00a764e549 | 34 | int ret = _modem->getSMCount(&count); |
ashleymills | 66:6b00a764e549 | 35 | if(ret) |
ashleymills | 66:6b00a764e549 | 36 | { |
ashleymills | 66:6b00a764e549 | 37 | LOG("getSMCount returned %d", ret); |
ashleymills | 66:6b00a764e549 | 38 | Thread::wait(3000); |
ashleymills | 66:6b00a764e549 | 39 | continue; |
ashleymills | 66:6b00a764e549 | 40 | } |
ashleymills | 66:6b00a764e549 | 41 | |
ashleymills | 66:6b00a764e549 | 42 | if( count > 0) |
ashleymills | 66:6b00a764e549 | 43 | { |
ashleymills | 66:6b00a764e549 | 44 | LOG("%d SMS to read", count); |
ashleymills | 66:6b00a764e549 | 45 | ret = _modem->getSM(num, msg, 64); |
ashleymills | 66:6b00a764e549 | 46 | |
ashleymills | 66:6b00a764e549 | 47 | if(ret) |
ashleymills | 66:6b00a764e549 | 48 | { |
ashleymills | 66:6b00a764e549 | 49 | LOG("Error receiving sms. The method getSMS returned %d", ret); |
ashleymills | 66:6b00a764e549 | 50 | return false; |
ashleymills | 66:6b00a764e549 | 51 | } |
ashleymills | 66:6b00a764e549 | 52 | LOG("The message is from number: %s and the message is: \"%s\"", num, msg); |
ashleymills | 66:6b00a764e549 | 53 | if (strcmp (msg, gIrregularMessage) ==0) |
ashleymills | 66:6b00a764e549 | 54 | { |
ashleymills | 66:6b00a764e549 | 55 | LOG("Success receiving alphabet message matches the sent message"); |
ashleymills | 66:6b00a764e549 | 56 | return true; |
ashleymills | 66:6b00a764e549 | 57 | } |
ashleymills | 66:6b00a764e549 | 58 | |
ashleymills | 66:6b00a764e549 | 59 | return true; |
ashleymills | 66:6b00a764e549 | 60 | } |
ashleymills | 66:6b00a764e549 | 61 | Thread::wait(500); |
ashleymills | 66:6b00a764e549 | 62 | } |
ashleymills | 66:6b00a764e549 | 63 | |
ashleymills | 66:6b00a764e549 | 64 | } |
ashleymills | 66:6b00a764e549 | 65 | }; |