Skip to content

Add overloaded constructors for optional apn, login and pass in NBConnectionHandler #12

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/Arduino_NBConnectionHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ static const unsigned long NETWORK_CONNECTION_INTERVAL = 30000;
/******************************************************************************
CTOR/DTOR
******************************************************************************/
NBConnectionHandler::NBConnectionHandler(const char *pin, const char *apn, const char *login, const char *pass, bool _keepAlive) :
login(login),
pass(pass) {
NBConnectionHandler(pin, apn, _keepAlive);
}

NBConnectionHandler::NBConnectionHandler(const char *pin, const char *apn, bool _keepAlive) :
apn(apn) {
NBConnectionHandler(pin, _keepAlive);
}

NBConnectionHandler::NBConnectionHandler(const char *pin, bool _keepAlive) :
pin(pin),
Expand All @@ -58,7 +68,7 @@ NBConnectionHandler::NBConnectionHandler(const char *pin, bool _keepAlive) :

void NBConnectionHandler::init() {
char msgBuffer[120];
if (nbAccess.begin(pin) == NB_READY) {
if (nbAccess.begin(pin, apn, login, pass) == NB_READY) {
Debug.print(DBG_INFO, "SIM card ok");
nbAccess.setTimeout(CHECK_INTERVAL_RETRYING);
changeConnectionState(NetworkConnectionState::CONNECTING);
Expand Down Expand Up @@ -113,7 +123,7 @@ void NBConnectionHandler::update() {
case NetworkConnectionState::CONNECTING: {
// NOTE: Blocking Call when 4th parameter == true
NB_NetworkStatus_t networkStatus;
networkStatus = gprs.attachGPRS();
networkStatus = gprs.attachGPRS(true);
Debug.print(DBG_DEBUG, "GPRS.attachGPRS(): %d", networkStatus);
if (networkStatus == NB_NetworkStatus_t::ERROR) {
// NO FURTHER ACTION WILL FOLLOW THIS
Expand Down
2 changes: 2 additions & 0 deletions src/Arduino_NBConnectionHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
class NBConnectionHandler : public ConnectionHandler {
public:
NBConnectionHandler(const char *pin, const bool keepAlive = true);
NBConnectionHandler(const char *pin, const char *apn, const bool keepAlive = true);
NBConnectionHandler(const char *pin, const char *apn, const char *login, const char *pass, const bool keepAlive = true);

virtual void init();
virtual unsigned long getTime();
Expand Down