Vodafone Test Suite
Dependencies: mbed-rtos mbed HTTPClient VodafoneUSBModem
Diff: Tests/Test02.h
- Revision:
- 66:6b00a764e549
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Tests/Test02.h Thu Nov 01 11:19:47 2012 +0000 @@ -0,0 +1,62 @@ +#pragma once +#include "VodafoneTestCase.h" + +// 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 *gTest02Description; +extern const char *gAlphabetNumbersMessage; + +class Test02 : public VodafoneTestCase { + public: + + char num[17]; + char msg[160]; + size_t count; + + Test02(VodafoneUSBModem *m) : VodafoneTestCase(m) {} + + private: + + virtual bool executeTest() { + LOG(gTest02Description); + 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, gAlphabetNumbersMessage) ==0) + { + LOG("Success receiving alphabet message matches the sent message"); + return true; + } + + return false; + } + Thread::wait(500); + } + + } +};