Vodafone Test Suite

Dependencies:   mbed-rtos mbed HTTPClient VodafoneUSBModem

Committer:
nherriot
Date:
Fri Sep 14 13:23:29 2012 +0000
Revision:
54:30062a67e8bb
Parent:
37:847f5f86e9ff
type name changes to follow with coding convention

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
ashleymills 37:847f5f86e9ff 13 extern const char *gTest12Description;
nherriot 13:8b69853966f8 14
nherriot 5:b68400bd0738 15 class Test12 : public VodafoneTestCase {
nherriot 5:b68400bd0738 16 public:
nherriot 7:ec0db221f897 17
nherriot 5:b68400bd0738 18 char num[17];
nherriot 31:9231acdde9ff 19 char msg[160];
nherriot 5:b68400bd0738 20 size_t count;
nherriot 5:b68400bd0738 21
ashleymills 33:16126e029d58 22 Test12(VodafoneUSBModem *m) : VodafoneTestCase(m) {
ashleymills 33:16126e029d58 23 _description = gTest12Description;
ashleymills 33:16126e029d58 24 _testCaseNumber = 12;
nherriot 5:b68400bd0738 25 }
nherriot 5:b68400bd0738 26
ashleymills 34:d9e45aad85f2 27 virtual bool execute() {
ashleymills 25:55b865c41f21 28 LOG("Test: %d",_testCaseNumber);
ashleymills 25:55b865c41f21 29 LOG(gTest12Description);
nherriot 5:b68400bd0738 30 LOG("Receiving SMS from test phone, waiting for response.");
nherriot 5:b68400bd0738 31
nherriot 7:ec0db221f897 32 while(true)
nherriot 5:b68400bd0738 33 {
nherriot 13:8b69853966f8 34 LOG("Waiting for an SMS message...");
nherriot 7:ec0db221f897 35 int ret = _modem->getSMCount(&count);
nherriot 5:b68400bd0738 36 if(ret)
nherriot 5:b68400bd0738 37 {
nherriot 5:b68400bd0738 38 LOG("getSMCount returned %d", ret);
nherriot 5:b68400bd0738 39 Thread::wait(3000);
nherriot 5:b68400bd0738 40 continue;
nherriot 5:b68400bd0738 41 }
nherriot 5:b68400bd0738 42
nherriot 5:b68400bd0738 43 if( count > 0)
nherriot 5:b68400bd0738 44 {
nherriot 5:b68400bd0738 45 LOG("%d SMS to read", count);
nherriot 7:ec0db221f897 46 ret = _modem->getSM(num, msg, 64);
nherriot 31:9231acdde9ff 47 if(ret)
nherriot 31:9231acdde9ff 48 {
nherriot 31:9231acdde9ff 49 LOG("Error receiving sms. The method getSMS returned %d", ret);
nherriot 31:9231acdde9ff 50 return false;
nherriot 31:9231acdde9ff 51 }
nherriot 31:9231acdde9ff 52 LOG("The message is from number: %s and the message is: \"%s\"", num, msg);
nherriot 54:30062a67e8bb 53 if (strcmp (msg, gAlphabetNumbersMessage) ==0)
nherriot 31:9231acdde9ff 54 {
nherriot 31:9231acdde9ff 55 LOG("Success receiving alphabet message matches the sent message");
nherriot 31:9231acdde9ff 56 return true;
nherriot 31:9231acdde9ff 57 }
nherriot 31:9231acdde9ff 58
nherriot 31:9231acdde9ff 59 return false;
nherriot 5:b68400bd0738 60 }
nherriot 5:b68400bd0738 61 Thread::wait(500);
nherriot 5:b68400bd0738 62 }
nherriot 5:b68400bd0738 63
nherriot 5:b68400bd0738 64 }
nherriot 31:9231acdde9ff 65 };