Vodafone Test Suite

Dependencies:   mbed-rtos mbed HTTPClient VodafoneUSBModem

Committer:
ashleymills
Date:
Mon Sep 17 13:28:39 2012 +0000
Revision:
44:6d0ac4747f5b
Parent:
40:32b0558320ea
Child:
60:7efce4a3c26f
Refactored names. Privatised virtuals to avoid bugs (bitten).

Who changed what in which revision?

UserRevisionLine numberNew 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 }
ashleymills 44:6d0ac4747f5b 25
ashleymills 44:6d0ac4747f5b 26 private:
nherriot 5:b68400bd0738 27
ashleymills 44:6d0ac4747f5b 28 virtual bool executeTest() {
ashleymills 25:55b865c41f21 29 LOG("Test: %d",_testCaseNumber);
ashleymills 25:55b865c41f21 30 LOG(gTest12Description);
nherriot 5:b68400bd0738 31 LOG("Receiving SMS from test phone, waiting for response.");
nherriot 5:b68400bd0738 32
nherriot 7:ec0db221f897 33 while(true)
nherriot 5:b68400bd0738 34 {
nherriot 13:8b69853966f8 35 LOG("Waiting for an SMS message...");
nherriot 7:ec0db221f897 36 int ret = _modem->getSMCount(&count);
nherriot 5:b68400bd0738 37 if(ret)
nherriot 5:b68400bd0738 38 {
nherriot 5:b68400bd0738 39 LOG("getSMCount returned %d", ret);
nherriot 5:b68400bd0738 40 Thread::wait(3000);
nherriot 5:b68400bd0738 41 continue;
nherriot 5:b68400bd0738 42 }
nherriot 5:b68400bd0738 43
nherriot 5:b68400bd0738 44 if( count > 0)
nherriot 5:b68400bd0738 45 {
nherriot 5:b68400bd0738 46 LOG("%d SMS to read", count);
nherriot 7:ec0db221f897 47 ret = _modem->getSM(num, msg, 64);
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, gAlphabetNumbersMessage) ==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 false;
nherriot 5:b68400bd0738 61 }
nherriot 5:b68400bd0738 62 Thread::wait(500);
nherriot 5:b68400bd0738 63 }
nherriot 5:b68400bd0738 64
nherriot 5:b68400bd0738 65 }
nherriot 31:9231acdde9ff 66 };