Vodafone Test Suite
Dependencies: mbed-rtos mbed HTTPClient VodafoneUSBModem
Tests/Test02.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 | // this test case will wait to receive an SMS from the modem. |
ashleymills | 66:6b00a764e549 | 5 | // if the method that reports a message waiting returns an error it will fail. |
ashleymills | 66:6b00a764e549 | 6 | // if the method that returns the message from the mailbox returns an error it will fai. |
ashleymills | 66:6b00a764e549 | 7 | // it will report the test as failed if any of the above happens. |
ashleymills | 66:6b00a764e549 | 8 | // it waits forever for an SMS. |
ashleymills | 66:6b00a764e549 | 9 | // TODO: this should wait for a set time before failing. |
ashleymills | 66:6b00a764e549 | 10 | |
ashleymills | 66:6b00a764e549 | 11 | extern const char *gTest02Description; |
ashleymills | 66:6b00a764e549 | 12 | extern const char *gAlphabetNumbersMessage; |
ashleymills | 66:6b00a764e549 | 13 | |
ashleymills | 66:6b00a764e549 | 14 | class Test02 : public VodafoneTestCase { |
ashleymills | 66:6b00a764e549 | 15 | public: |
ashleymills | 66:6b00a764e549 | 16 | |
ashleymills | 66:6b00a764e549 | 17 | char num[17]; |
ashleymills | 66:6b00a764e549 | 18 | char msg[160]; |
ashleymills | 66:6b00a764e549 | 19 | size_t count; |
ashleymills | 66:6b00a764e549 | 20 | |
ashleymills | 66:6b00a764e549 | 21 | Test02(VodafoneUSBModem *m) : VodafoneTestCase(m) {} |
ashleymills | 66:6b00a764e549 | 22 | |
ashleymills | 66:6b00a764e549 | 23 | private: |
ashleymills | 66:6b00a764e549 | 24 | |
ashleymills | 66:6b00a764e549 | 25 | virtual bool executeTest() { |
ashleymills | 66:6b00a764e549 | 26 | LOG(gTest02Description); |
ashleymills | 66:6b00a764e549 | 27 | LOG("Receiving SMS from test phone, waiting for response."); |
ashleymills | 66:6b00a764e549 | 28 | |
ashleymills | 66:6b00a764e549 | 29 | while(true) |
ashleymills | 66:6b00a764e549 | 30 | { |
ashleymills | 66:6b00a764e549 | 31 | LOG("Waiting for an SMS message..."); |
ashleymills | 66:6b00a764e549 | 32 | int ret = _modem->getSMCount(&count); |
ashleymills | 66:6b00a764e549 | 33 | if(ret) |
ashleymills | 66:6b00a764e549 | 34 | { |
ashleymills | 66:6b00a764e549 | 35 | LOG("getSMCount returned %d", ret); |
ashleymills | 66:6b00a764e549 | 36 | Thread::wait(3000); |
ashleymills | 66:6b00a764e549 | 37 | continue; |
ashleymills | 66:6b00a764e549 | 38 | } |
ashleymills | 66:6b00a764e549 | 39 | |
ashleymills | 66:6b00a764e549 | 40 | if( count > 0) |
ashleymills | 66:6b00a764e549 | 41 | { |
ashleymills | 66:6b00a764e549 | 42 | LOG("%d SMS to read", count); |
ashleymills | 66:6b00a764e549 | 43 | ret = _modem->getSM(num, msg, 64); |
ashleymills | 66:6b00a764e549 | 44 | if(ret) |
ashleymills | 66:6b00a764e549 | 45 | { |
ashleymills | 66:6b00a764e549 | 46 | LOG("Error receiving sms. The method getSMS returned %d", ret); |
ashleymills | 66:6b00a764e549 | 47 | return false; |
ashleymills | 66:6b00a764e549 | 48 | } |
ashleymills | 66:6b00a764e549 | 49 | LOG("The message is from number: %s and the message is: \"%s\"", num, msg); |
ashleymills | 66:6b00a764e549 | 50 | if (strcmp (msg, gAlphabetNumbersMessage) ==0) |
ashleymills | 66:6b00a764e549 | 51 | { |
ashleymills | 66:6b00a764e549 | 52 | LOG("Success receiving alphabet message matches the sent message"); |
ashleymills | 66:6b00a764e549 | 53 | return true; |
ashleymills | 66:6b00a764e549 | 54 | } |
ashleymills | 66:6b00a764e549 | 55 | |
ashleymills | 66:6b00a764e549 | 56 | return false; |
ashleymills | 66:6b00a764e549 | 57 | } |
ashleymills | 66:6b00a764e549 | 58 | Thread::wait(500); |
ashleymills | 66:6b00a764e549 | 59 | } |
ashleymills | 66:6b00a764e549 | 60 | |
ashleymills | 66:6b00a764e549 | 61 | } |
ashleymills | 66:6b00a764e549 | 62 | }; |