Vodafone Test Suite

Dependencies:   mbed-rtos mbed HTTPClient VodafoneUSBModem

Tests/Test13.h

Committer:
nherriot
Date:
2012-10-19
Revision:
59:b091324302b4
Parent:
44:6d0ac4747f5b
Child:
60:7efce4a3c26f

File content as of revision 59:b091324302b4:

#pragma once
#include "VodafoneTestCase.h"

#define TEST_PHONE_NUMBER "+447717275049"

// this test case will wait to receive an SMS from the modem.
// if the method that reports a message waiting returns an error it will fail.
// if the method that returns the message from the mailbox returns an error it will fai.
// it will report the test as failed if any of the above happens.
// it waits forever for an SMS.
// TODO: this should wait for a set time before failing.

extern const char *gTest13Description;
extern const char *gIrregularMessage;

class Test13 : public VodafoneTestCase {
   public: 

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

      Test13(VodafoneUSBModem *m) : VodafoneTestCase(m) {
         _description = gTest13Description;
         _testCaseNumber = 13;
      }
      
   private:
   
      virtual bool executeTest() {
         LOG("Test %d wait for an irregular SMS message...", _testCaseNumber);
         LOG("Receiving SMS from test phone, waiting for response.");
      
         while(true)
            {
             LOG("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);
                    if (strcmp (msg, gIrregularMessage) ==0)
                        {
                            LOG("Success receiving alphabet message matches the sent message");
                            return true;
                        }
                    
                    return true;
                }
                Thread::wait(500);
            }
                  
      }
};