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