Vodafone Test Suite
Dependencies: mbed-rtos mbed HTTPClient VodafoneUSBModem
Diff: Tests/Test13.h
- Revision:
- 66:6b00a764e549
- Parent:
- 60:7efce4a3c26f
diff -r ef3357b6ce97 -r 6b00a764e549 Tests/Test13.h --- a/Tests/Test13.h Tue Oct 30 15:51:53 2012 +0000 +++ b/Tests/Test13.h Thu Nov 01 11:19:47 2012 +0000 @@ -1,65 +1,94 @@ #pragma once #include "VodafoneTestCase.h" - -#define TEST_PHONE_NUMBER "+447717275049" +//#define __DEBUG__ 1 -// 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. +// this test case will wait to send an SMS from the modem. +// if the method that sends a message returns an error it will fail. // 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; +// it does not wait after it has succesfully sent an SMS. +extern const char* gTest13Description; class Test13 : public VodafoneTestCase { public: - char num[17]; - char msg[160]; - size_t count; - Test13(VodafoneUSBModem *m) : VodafoneTestCase(m) {} private: virtual bool executeTest() { LOG(gTest13Description); - LOG("Receiving SMS from test phone, waiting for response."); - - while(true) + LinkMonitor::REGISTRATION_STATE regState = LinkMonitor::REGISTRATION_STATE_UNKNOWN; + LinkMonitor::BEARER bearer = LinkMonitor::BEARER_UNKNOWN; + int rssi = -1000; + if(_modem->getLinkState(&rssi, ®State, &bearer)==0) { - LOG("Waiting for an SMS message..."); - int ret = _modem->getSMCount(&count); - if(ret) - { - LOG("getSMCount returned %d", ret); - Thread::wait(3000); - continue; + if(rssi==-1000) + { LOG("Checking signal strength - RSSI: Error."); return false;} + else + { LOG("Signal strength is: RSSI: %d",rssi);} + + + switch(regState) { + case LinkMonitor::REGISTRATION_STATE_UNKNOWN: + LOG("regState: UNKNOWN. Failing."); + return false; + case LinkMonitor::REGISTRATION_STATE_REGISTERING: + LOG("regState: REGISTERING"); + break; + case LinkMonitor::REGISTRATION_STATE_DENIED: + LOG("regState: DENIED"); + return false; + case LinkMonitor::REGISTRATION_STATE_NO_SIGNAL: + LOG("regState: NO SIGNAL"); + return false; + case LinkMonitor::REGISTRATION_STATE_HOME_NETWORK: + LOG("regState: HOME NETWORK"); + break; + case LinkMonitor::REGISTRATION_STATE_ROAMING: + LOG("regState: ROAMING"); + break; + default: + LOG("regState: ERROR. Failing."); + return false; + } + } + + LOG("Creating GSM test buffer"); + LOG("Sending SMS:' %s ' to test phone: %s , waiting for response.", gIrregularMessage, gTestPhoneNumber); + + // create a buffer and send each character until you can send them all + char shortBuffer[30]; + + // XXX What are you doing here nick? What is the size of gIrregularMessage? It's a pointer!! You're looking for strlen + // And gIrregularMessage is longer than shortBuffer so you are goign to kill someone's memory + for (int i=0; i < sizeof(gIrregularMessage); i++) + { + shortBuffer[i] = gIrregularMessage[i]; + LOG("Buffer is now: %s", shortBuffer); + LOG("Irregular message is %s", gIrregularMessage); + int ret = _modem->sendSM(gTestPhoneNumber, shortBuffer); + + } + + int ret = _modem->sendSM(gTestPhoneNumber, gIrregularMessage); + + if (ret) + { + LOG("Error in sending the SMS message. The return values is: %d", ret); + + switch(ret){ + case(NET_INVALID): LOG("Error message is: 'phone number is invalid size, must be less than 16 digits'.");break; + case(NET_PROTOCOL): LOG("Error message is: 'protocol error from the modem'.");break; + default: LOG("Undefined error message."); + } - - 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); + return false; } + return true; } + + char gsm03dot38CharacterSet[127]; + + }; \ No newline at end of file