Vodafone Test Suite

Dependencies:   mbed-rtos mbed HTTPClient VodafoneUSBModem

Committer:
ashleymills
Date:
Thu Sep 13 10:14:49 2012 +0000
Revision:
34:d9e45aad85f2
Parent:
33:16126e029d58
Child:
37:847f5f86e9ff
Refactoring.

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 31:9231acdde9ff 4
nherriot 5:b68400bd0738 5
nherriot 13:8b69853966f8 6 // this test case will wait to receive an SMS from the modem.
nherriot 13:8b69853966f8 7 // if the method that reports a message waiting returns an error it will fail.
nherriot 13:8b69853966f8 8 // if the method that returns the message from the mailbox returns an error it will fai.
nherriot 13:8b69853966f8 9 // it will report the test as failed if any of the above happens.
nherriot 13:8b69853966f8 10 // it waits forever for an SMS.
nherriot 13:8b69853966f8 11 // TODO: this should wait for a set time before failing.
nherriot 13:8b69853966f8 12
nherriot 31:9231acdde9ff 13 static const char *gTest12Description = "Waiting for an SMS message with basic characters and numbers...";
nherriot 31:9231acdde9ff 14
nherriot 13:8b69853966f8 15
nherriot 5:b68400bd0738 16 class Test12 : public VodafoneTestCase {
nherriot 5:b68400bd0738 17 public:
nherriot 7:ec0db221f897 18
nherriot 5:b68400bd0738 19 char num[17];
nherriot 31:9231acdde9ff 20 char msg[160];
nherriot 5:b68400bd0738 21 size_t count;
nherriot 5:b68400bd0738 22
ashleymills 33:16126e029d58 23 Test12(VodafoneUSBModem *m) : VodafoneTestCase(m) {
ashleymills 33:16126e029d58 24 _description = gTest12Description;
ashleymills 33:16126e029d58 25 _testCaseNumber = 12;
nherriot 5:b68400bd0738 26 }
nherriot 5:b68400bd0738 27
ashleymills 34:d9e45aad85f2 28 virtual bool execute() {
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);
nherriot 31:9231acdde9ff 54 if (strcmp (msg, alphabetNumbersMessage) ==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 };