-
Notifications
You must be signed in to change notification settings - Fork 151
Improvements to library #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
boylesg
wants to merge
8
commits into
MarcoMartines:GSMSHIELD
Choose a base branch
from
boylesg:GSMSHIELD
base: GSMSHIELD
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Examples sketches modified for library changes
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){}; --------------------------------------------------------------------------------------------------------------------------------------------------------
Added flash string versions of SendSMS(...) and changed char* to const char* to eliminate compiler warning "deprecated conversion of const char* to char*" int8_t SendSMS(const char *strNumber, const char *strMessage); int8_t SendSMS(const __FlashStringHelper *fstrNumber, const __FlashStringHelper *fstrMessage); int8_t SendSMS(const char *strNumber, const __FlashStringHelper *fstrMessage); int8_t SendSMS(const __FlashStringHelper *fstrNumber, const char *strMessage); int8_t SendSMS(const uint8_t nSIMBookPos, const char *strMessage); int8_t SendSMS(const uint8_t nSIMBookPos, const __FlashStringHelper *fstrMessage);
Modified sketch to use CSMS::GetSMS rather than deprecated (and removed) CGSM::GetSMS(...)
Removed redundant SMS and call functions - correct functions are in CCall (call.cpp/h)
Changed some for char* parameters to const char* to eliminate compiler warning "deprecated conversion of const char* to char*"
Changed function return types to bool - more appropriate according to the way they were being used. Also altered debug output because it was incorrectly informing me in serial monitor that the sms was successfully sent. Now outputs this: Sending "Arduino SMS" to 61414318470...failed (3)!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 to Hungarian notation.
Changed int to int16_t etc
Changed some function return types to bool