Vodafone Test Suite

Dependencies:   mbed-rtos mbed HTTPClient VodafoneUSBModem

Committer:
nherriot
Date:
Thu Aug 23 16:02:34 2012 +0000
Revision:
7:ec0db221f897
Parent:
5:b68400bd0738
Child:
9:3ff68422f4d7
updating Nick's test case 12 for receiving SMS message.....

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 5:b68400bd0738 6 class Test12 : public VodafoneTestCase {
nherriot 5:b68400bd0738 7 public:
nherriot 7:ec0db221f897 8
nherriot 5:b68400bd0738 9 char num[17];
nherriot 5:b68400bd0738 10 char msg[64];
nherriot 5:b68400bd0738 11 size_t count;
nherriot 5:b68400bd0738 12
nherriot 5:b68400bd0738 13 Test12(VodafoneUSBModem *m) : VodafoneTestCase(m) {
nherriot 5:b68400bd0738 14 }
nherriot 5:b68400bd0738 15
nherriot 5:b68400bd0738 16 virtual bool runTest() {
nherriot 5:b68400bd0738 17 _lastRunTime = time(NULL);
nherriot 5:b68400bd0738 18 LOG("Receiving SMS from test phone, waiting for response.");
nherriot 5:b68400bd0738 19 char smsResponse[64];
nherriot 5:b68400bd0738 20
nherriot 7:ec0db221f897 21 while(true)
nherriot 5:b68400bd0738 22 {
nherriot 7:ec0db221f897 23 LOG("Test 12 waiting for an SMS message...");
nherriot 7:ec0db221f897 24 int ret = _modem->getSMCount(&count);
nherriot 5:b68400bd0738 25 if(ret)
nherriot 5:b68400bd0738 26 {
nherriot 5:b68400bd0738 27 LOG("getSMCount returned %d", ret);
nherriot 5:b68400bd0738 28 Thread::wait(3000);
nherriot 5:b68400bd0738 29 continue;
nherriot 5:b68400bd0738 30 }
nherriot 5:b68400bd0738 31
nherriot 5:b68400bd0738 32 if( count > 0)
nherriot 5:b68400bd0738 33 {
nherriot 5:b68400bd0738 34 LOG("%d SMS to read", count);
nherriot 7:ec0db221f897 35 ret = _modem->getSM(num, msg, 64);
nherriot 5:b68400bd0738 36 if(ret)
nherriot 5:b68400bd0738 37 {
nherriot 5:b68400bd0738 38 LOG("Error receiving sms. The method getSMS returned %d", ret);
nherriot 5:b68400bd0738 39 _lastRunOutcome = true;
nherriot 5:b68400bd0738 40 return false;
nherriot 5:b68400bd0738 41 }
nherriot 5:b68400bd0738 42 LOG("The message is from number: %s and the message is: \"%s\"", num, msg);
nherriot 5:b68400bd0738 43 _lastRunOutcome = true;
nherriot 5:b68400bd0738 44 return true;
nherriot 5:b68400bd0738 45 }
nherriot 5:b68400bd0738 46 Thread::wait(500);
nherriot 5:b68400bd0738 47 }
nherriot 5:b68400bd0738 48
nherriot 5:b68400bd0738 49 }
nherriot 5:b68400bd0738 50 };