I give up, I just added a new commit to change the comment:
This upload was simply to change the commit comment because I have no idea how to edit the comment of an existing commit.
Removed hard coding that limits you to using SoftwareSerial for Uno and Serial1 for Mega
You can now use the classes like this:
CSIMCOM900 gsm(&Serial1);
SoftwareSerial ss(8, 9);
CSIMCOM900 gsm(&Serial1);
//CSIMCOM900 gsm(&ss);
CSMSGSM sms(gsm);
void setup()
{
gsm.begin(115200);
}
Also wrapped all the literal strings in F() and added appropriate function versions to take flash strings rather than normal c strings.
Changed class, data members and variable to use Hungarian notation.
Removed commented out, and presumably no longer needed, code.
Removed deprecated function and changed example sketch accordingly.
Cleaned up code indenting to make the code easier to read.
Changed WideTextFinder to CSWSerial so as to be consistent with CHWSerial (formerly HWSerial).
If you don't want all the cosmetic code changes then the key changes to removed the hard coding are as follows:
GSMBase.h/cpp
class CGSMBase
{
public:
CGSMBase(CSIMCOM900& rSimComm900): m_rSimComm900(rSimComm900){};
protected:
CSIMCOM900& m_rSimComm900;
};
SMS.h/cpp, InetGSM.h/cpp, GPSGSM.h.cpp, call.h/cpp
class CSMSGSM: protected CGSMBase
{
public:
CSMSGSM(CSIMCOM900& rSimComm900): CGSMBase(rSimComm900){};
class CGSM
{
public:
// Constructors
CGSM(const SoftwareSerial pStream): m_nStatus(IDLE)
{
m_pStream = (Stream)pStream;
m_nSizeofStream = sizeof *pStream;
}
CGSM(const HardwareSerial pStream): m_nStatus(IDLE)
{
m_pStream = (Stream)pStream;
m_nSizeofStream = sizeof *pStream;
}
.
.
.
.
.
protected:
// Constructors
CGSM(); // Don't want this constructor to be used
void beginSerial(const uint32_t nBaud)
{
if (m_nSizeofStream == sizeof(HardwareSerial))
{
((HardwareSerial*)m_pStream)->begin(nBaud);
}
else if (m_nSizeofStream == sizeof(SoftwareSerial))
{
((SoftwareSerial*)m_pStream)->begin(nBaud);
}
}
bool isUsingSS()
{
return m_nSizeofStream == sizeof(SoftwareSerial);
}
bool isUsingHS()
{
return m_nSizeofStream == sizeof(HardwareSerial);
}
// Serial source used to communicate with GSM
Stream* m_pStream; // Either a SoftwareSerial or a HardwareSerial object passed in through the constructor.
uint16_t m_nSizeofStream; // Size of the the SoftwareSerial or a HardwareSerial object so we can tell which type was used.
HWSerial.h/cpp, SWSerial.h/cpp
These are now created as local objects so that the default empty constructor is not used.
class CHWSerial
{
private:
//Don't want this constructor to be used
CHWSerial(): _rSerial(Serial)
{
};
public:
CHWSerial(HardwareSerial& rSerial);
class CSWSerial
{
private:
SoftwareSerial& m_rSoftwareSerial;
//Don't want this constructor to be used
CSWSerial(): _rSerial(Serial)
{
};
public:
// Constructor:
CSWSerial(SoftwareSerial &rStream, int16_t nTimeout = 5); // Ethernet constructor
SIM900.h/cpp
class CSIMCOM900 : public virtual CGSM
{
protected:
CSIMCOM900(): CGSM(NULL)(); // Don't want this constructor to be used
public:
CSIMCOM900(const SoftwareSerial *pStream): CGSM(pStream){};
CSIMCOM900(const HardwareSerial *pStream): : CGSM(pStream){};