Vodafone Test Suite
Dependencies: mbed-rtos mbed HTTPClient VodafoneUSBModem
Test13.h
00001 #pragma once 00002 #include "VodafoneTestCase.h" 00003 //#define __DEBUG__ 1 00004 00005 // this test case will wait to send an SMS from the modem. 00006 // if the method that sends a message returns an error it will fail. 00007 // it will report the test as failed if any of the above happens. 00008 // it does not wait after it has succesfully sent an SMS. 00009 extern const char* gTest13Description; 00010 00011 class Test13 : public VodafoneTestCase { 00012 public: 00013 00014 Test13(VodafoneUSBModem *m) : VodafoneTestCase(m) {} 00015 00016 private: 00017 00018 virtual bool executeTest() { 00019 LOG(gTest13Description); 00020 LinkMonitor::REGISTRATION_STATE regState = LinkMonitor::REGISTRATION_STATE_UNKNOWN; 00021 LinkMonitor::BEARER bearer = LinkMonitor::BEARER_UNKNOWN; 00022 int rssi = -1000; 00023 if(_modem->getLinkState(&rssi, ®State, &bearer)==0) 00024 { 00025 if(rssi==-1000) 00026 { LOG("Checking signal strength - RSSI: Error."); return false;} 00027 else 00028 { LOG("Signal strength is: RSSI: %d",rssi);} 00029 00030 00031 switch(regState) { 00032 case LinkMonitor::REGISTRATION_STATE_UNKNOWN: 00033 LOG("regState: UNKNOWN. Failing."); 00034 return false; 00035 case LinkMonitor::REGISTRATION_STATE_REGISTERING: 00036 LOG("regState: REGISTERING"); 00037 break; 00038 case LinkMonitor::REGISTRATION_STATE_DENIED: 00039 LOG("regState: DENIED"); 00040 return false; 00041 case LinkMonitor::REGISTRATION_STATE_NO_SIGNAL: 00042 LOG("regState: NO SIGNAL"); 00043 return false; 00044 case LinkMonitor::REGISTRATION_STATE_HOME_NETWORK: 00045 LOG("regState: HOME NETWORK"); 00046 break; 00047 case LinkMonitor::REGISTRATION_STATE_ROAMING: 00048 LOG("regState: ROAMING"); 00049 break; 00050 default: 00051 LOG("regState: ERROR. Failing."); 00052 return false; 00053 } 00054 } 00055 00056 LOG("Creating GSM test buffer"); 00057 LOG("Sending SMS:' %s ' to test phone: %s , waiting for response.", gIrregularMessage, gTestPhoneNumber); 00058 00059 // create a buffer and send each character until you can send them all 00060 char shortBuffer[30]; 00061 00062 // XXX What are you doing here nick? What is the size of gIrregularMessage? It's a pointer!! You're looking for strlen 00063 // And gIrregularMessage is longer than shortBuffer so you are goign to kill someone's memory 00064 for (int i=0; i < sizeof(gIrregularMessage); i++) 00065 { 00066 shortBuffer[i] = gIrregularMessage[i]; 00067 LOG("Buffer is now: %s", shortBuffer); 00068 LOG("Irregular message is %s", gIrregularMessage); 00069 int ret = _modem->sendSM(gTestPhoneNumber, shortBuffer); 00070 00071 } 00072 00073 int ret = _modem->sendSM(gTestPhoneNumber, gIrregularMessage); 00074 00075 if (ret) 00076 { 00077 LOG("Error in sending the SMS message. The return values is: %d", ret); 00078 00079 switch(ret){ 00080 case(NET_INVALID): LOG("Error message is: 'phone number is invalid size, must be less than 16 digits'.");break; 00081 case(NET_PROTOCOL): LOG("Error message is: 'protocol error from the modem'.");break; 00082 default: LOG("Undefined error message."); 00083 00084 } 00085 return false; 00086 } 00087 return true; 00088 00089 } 00090 00091 char gsm03dot38CharacterSet[127]; 00092 00093 00094 };
Generated on Sun Jul 17 2022 01:04:13 by 1.7.2