Vodafone Test Suite

Dependencies:   mbed-rtos mbed HTTPClient VodafoneUSBModem

Tests/Test12.h

Committer:
ashleymills
Date:
2012-08-24
Revision:
9:3ff68422f4d7
Parent:
7:ec0db221f897
Child:
13:8b69853966f8

File content as of revision 9:3ff68422f4d7:

#pragma once
#include "VodafoneTestCase.h"

#define TEST_PHONE_NUMBER "+447717275049"

class Test12 : public VodafoneTestCase {
   public: 

      char num[17];
      char msg[64];
      size_t count;

      Test12(VodafoneUSBModem *m) : VodafoneTestCase(m) {
      }
   
      virtual bool runTest() {
         LOG("Receiving SMS from test phone, waiting for response.");
         char smsResponse[64];
      
         while(true)
            {
             LOG("Test 12 waiting for an SMS message...");
             int ret = _modem->getSMCount(&count);
             if(ret)
                {
                    LOG("getSMCount returned %d", ret);
                    Thread::wait(3000);
                    continue;
                }
    
             if( count > 0)
                {
                    LOG("%d SMS to read", count);
                    ret = _modem->getSM(num, msg, 64);
                if(ret)
                    {
                        LOG("Error receiving sms. The method getSMS  returned %d", ret);
                        return false;
                    }
                LOG("The message is from number: %s and the message is: \"%s\"", num, msg);
                return true;
                }
                Thread::wait(500);
            }
                  
      }
};