Vodafone Test Suite

Dependencies:   mbed-rtos mbed HTTPClient VodafoneUSBModem

Committer:
nherriot
Date:
Wed Aug 29 14:13:49 2012 +0000
Revision:
13:8b69853966f8
Parent:
9:3ff68422f4d7
Child:
25:55b865c41f21
adding test number to base class, init lists and changing constructors for test cases

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 5:b68400bd0738 4 #define TEST_PHONE_NUMBER "+447717275049"
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 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 5:b68400bd0738 18 char msg[64];
nherriot 5:b68400bd0738 19 size_t count;
nherriot 5:b68400bd0738 20
nherriot 13:8b69853966f8 21 Test12(VodafoneUSBModem *m, int tcNumber) : VodafoneTestCase(m, tcNumber) {
nherriot 5:b68400bd0738 22 }
nherriot 5:b68400bd0738 23
nherriot 5:b68400bd0738 24 virtual bool runTest() {
nherriot 13:8b69853966f8 25 LOG("Test %d waiting for an SMS message...", _testCaseNumber);
nherriot 5:b68400bd0738 26 LOG("Receiving SMS from test phone, waiting for response.");
nherriot 5:b68400bd0738 27
nherriot 7:ec0db221f897 28 while(true)
nherriot 5:b68400bd0738 29 {
nherriot 13:8b69853966f8 30 LOG("Waiting for an SMS message...");
nherriot 7:ec0db221f897 31 int ret = _modem->getSMCount(&count);
nherriot 5:b68400bd0738 32 if(ret)
nherriot 5:b68400bd0738 33 {
nherriot 5:b68400bd0738 34 LOG("getSMCount returned %d", ret);
nherriot 5:b68400bd0738 35 Thread::wait(3000);
nherriot 5:b68400bd0738 36 continue;
nherriot 5:b68400bd0738 37 }
nherriot 5:b68400bd0738 38
nherriot 5:b68400bd0738 39 if( count > 0)
nherriot 5:b68400bd0738 40 {
nherriot 5:b68400bd0738 41 LOG("%d SMS to read", count);
nherriot 7:ec0db221f897 42 ret = _modem->getSM(num, msg, 64);
nherriot 5:b68400bd0738 43 if(ret)
nherriot 5:b68400bd0738 44 {
nherriot 5:b68400bd0738 45 LOG("Error receiving sms. The method getSMS returned %d", ret);
nherriot 5:b68400bd0738 46 return false;
nherriot 5:b68400bd0738 47 }
nherriot 5:b68400bd0738 48 LOG("The message is from number: %s and the message is: \"%s\"", num, msg);
nherriot 5:b68400bd0738 49 return true;
nherriot 5:b68400bd0738 50 }
nherriot 5:b68400bd0738 51 Thread::wait(500);
nherriot 5:b68400bd0738 52 }
nherriot 5:b68400bd0738 53
nherriot 5:b68400bd0738 54 }
nherriot 5:b68400bd0738 55 };