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