Vodafone Test Suite

Dependencies:   mbed-rtos mbed HTTPClient VodafoneUSBModem

Tests/Test12.h

Committer:
nherriot
Date:
2012-08-23
Revision:
5:b68400bd0738
Child:
7:ec0db221f897

File content as of revision 5:b68400bd0738:

#pragma once
#include "VodafoneTestCase.h"

#define TEST_PHONE_NUMBER "+447717275049"

class Test12 : public VodafoneTestCase {
   public: 
      int test_number = 12;
      char num[17];
      char msg[64];
      size_t count;

      Test12(VodafoneUSBModem *m) : VodafoneTestCase(m) {
      }
   
      virtual bool runTest() {
         _lastRunTime = time(NULL);
         LOG("Receiving SMS from test phone, waiting for response.");
         char smsResponse[64];
      
         while(TRUE)
            {
             LOG("Test %d waiting for an SMS message...", test_number);
             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);
                        _lastRunOutcome = true;
                        return false;
                    }
                LOG("The message is from number: %s and the message is: \"%s\"", num, msg);
                _lastRunOutcome = true;
                return true;
                }
                Thread::wait(500);
            }
                  
      }
};