Vodafone Test Suite

Dependencies:   mbed-rtos mbed HTTPClient VodafoneUSBModem

Committer:
ashleymills
Date:
Thu Sep 06 15:13:38 2012 +0000
Revision:
27:0297dbc3252b
Parent:
26:9eefab9e28df
Child:
31:9231acdde9ff
Commended out dependency stuff. TestManager now prints numbers and descriptions of failed tests.

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