Vodafone Test Suite
Dependencies: mbed-rtos mbed HTTPClient VodafoneUSBModem
Tests/Test50.h
- Committer:
- ashleymills
- Date:
- 2012-08-24
- Revision:
- 8:6c30647f75d7
- Parent:
- 4:1f8e079924ba
- Child:
- 10:65ee3973594e
File content as of revision 8:6c30647f75d7:
#pragma once #include "VodafoneTestCase.h" class Test50 : public VodafoneTestCase { public: Test50(VodafoneUSBModem *m) : VodafoneTestCase(m) { _smsLen = 32; _numberLen = 16; } virtual void setupTest() { allocStorage(); } virtual bool endTest(bool state) { freeStorage(); return state; } virtual bool runTest() { size_t smCount; int numMessages = 10; LOG("Getting MSISDN"); _modem->sendUSSD("*#100#",_ownNumber,_numberLen); LOG("Got MSISDN %s",_ownNumber); for(int i=0; i<numMessages; i++) { LOG("Creating random string"); createRandomString(_smsOut,_smsLen); LOG("Created: %s",_smsOut); if(_modem->sendSM(_ownNumber,_smsOut)!=0) { LOG("Failure to send short message"); } bool gotMessage = false; while(!gotMessage) { if(_modem->getSMCount(&smCount)!=0) { LOG("Faiure getting SM count"); return false; } if(smCount>0) { if(_modem->getSM(_senderNumber,_smsIn,_smsLen)!=0) { LOG("Failure getting SM"); return false; } LOG("Got SMS: %s",_smsIn); gotMessage = true; } Thread::wait(50); } } return true; } private: void createRandomString(char *target, int len) { for(int i=0; i<len; i++) { target[i] = 65+rand()%16; } target[len-1] = 0x00; } void allocStorage() { _ownNumber = (char*)malloc(_numberLen*sizeof(char)); _senderNumber = (char*)malloc(_numberLen*sizeof(char)); _smsOut = (char*)malloc(_smsLen*sizeof(char)); _smsIn = (char*)malloc(_smsLen*sizeof(char)); } void freeStorage() { free(_ownNumber); free(_senderNumber); free(_smsOut); free(_smsIn); } char* _ownNumber; char* _senderNumber; char* _smsOut; char* _smsIn; int _smsLen; int _numberLen; };