Vodafone Test Suite

Dependencies:   mbed-rtos mbed HTTPClient VodafoneUSBModem

Committer:
ashleymills
Date:
Tue Oct 23 14:22:53 2012 +0000
Revision:
60:7efce4a3c26f
Parent:
44:6d0ac4747f5b
Child:
66:6b00a764e549
Added new SMS bulk test (incomplete).

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 60:7efce4a3c26f 21 Test12(VodafoneUSBModem *m) : VodafoneTestCase(m) {}
ashleymills 44:6d0ac4747f5b 22
ashleymills 44:6d0ac4747f5b 23 private:
nherriot 5:b68400bd0738 24
ashleymills 44:6d0ac4747f5b 25 virtual bool executeTest() {
ashleymills 25:55b865c41f21 26 LOG(gTest12Description);
nherriot 5:b68400bd0738 27 LOG("Receiving SMS from test phone, waiting for response.");
nherriot 5:b68400bd0738 28
nherriot 7:ec0db221f897 29 while(true)
nherriot 5:b68400bd0738 30 {
nherriot 13:8b69853966f8 31 LOG("Waiting for an SMS message...");
nherriot 7:ec0db221f897 32 int ret = _modem->getSMCount(&count);
nherriot 5:b68400bd0738 33 if(ret)
nherriot 5:b68400bd0738 34 {
nherriot 5:b68400bd0738 35 LOG("getSMCount returned %d", ret);
nherriot 5:b68400bd0738 36 Thread::wait(3000);
nherriot 5:b68400bd0738 37 continue;
nherriot 5:b68400bd0738 38 }
nherriot 5:b68400bd0738 39
nherriot 5:b68400bd0738 40 if( count > 0)
nherriot 5:b68400bd0738 41 {
nherriot 5:b68400bd0738 42 LOG("%d SMS to read", count);
nherriot 7:ec0db221f897 43 ret = _modem->getSM(num, msg, 64);
nherriot 31:9231acdde9ff 44 if(ret)
nherriot 31:9231acdde9ff 45 {
nherriot 31:9231acdde9ff 46 LOG("Error receiving sms. The method getSMS returned %d", ret);
nherriot 31:9231acdde9ff 47 return false;
nherriot 31:9231acdde9ff 48 }
nherriot 31:9231acdde9ff 49 LOG("The message is from number: %s and the message is: \"%s\"", num, msg);
ashleymills 40:32b0558320ea 50 if (strcmp (msg, gAlphabetNumbersMessage) ==0)
nherriot 31:9231acdde9ff 51 {
nherriot 31:9231acdde9ff 52 LOG("Success receiving alphabet message matches the sent message");
nherriot 31:9231acdde9ff 53 return true;
nherriot 31:9231acdde9ff 54 }
nherriot 31:9231acdde9ff 55
nherriot 31:9231acdde9ff 56 return false;
nherriot 5:b68400bd0738 57 }
nherriot 5:b68400bd0738 58 Thread::wait(500);
nherriot 5:b68400bd0738 59 }
nherriot 5:b68400bd0738 60
nherriot 5:b68400bd0738 61 }
nherriot 31:9231acdde9ff 62 };