@@ -41,22 +41,28 @@ static const unsigned long NETWORK_CONNECTION_INTERVAL = 30000;
4141/* *****************************************************************************
4242 CTOR/DTOR
4343 ******************************************************************************/
44- NBConnectionHandler::NBConnectionHandler (const char *pin, bool _keepAlive) :
45- NBConnectionHandler(pin, " " , _keepAlive) {
44+ NBConnectionHandler::NBConnectionHandler (char const * pin, bool const keep_alive)
45+ : NBConnectionHandler(pin, " " , keep_alive)
46+ {
47+
4648}
4749
48- NBConnectionHandler::NBConnectionHandler (const char *pin, const char *apn, bool _keepAlive) :
49- NBConnectionHandler(pin, apn, " " , " " , _keepAlive) {
50+ NBConnectionHandler::NBConnectionHandler (char const * pin, char const * apn, bool const keep_alive)
51+ : NBConnectionHandler(pin, apn, " " , " " , keep_alive)
52+ {
53+
5054}
5155
52- NBConnectionHandler::NBConnectionHandler (const char *pin, const char *apn, const char *login, const char *pass, bool _keepAlive) :
53- pin(pin),
54- apn(apn),
55- login(login),
56- pass(pass),
57- lastConnectionTickTime(millis()),
58- connectionTickTimeInterval(CHECK_INTERVAL_IDLE),
59- keepAlive(_keepAlive) {
56+ NBConnectionHandler::NBConnectionHandler (char const * pin, char const * apn, char const * login, char const * pass, bool const keep_alive)
57+ : _pin(pin)
58+ , _apn(apn)
59+ , _login(login)
60+ , _pass(pass)
61+ , lastConnectionTickTime(millis())
62+ , connectionTickTimeInterval(CHECK_INTERVAL_IDLE)
63+ , _keep_alive(keep_alive)
64+ {
65+
6066}
6167
6268/* *****************************************************************************
@@ -65,22 +71,22 @@ NBConnectionHandler::NBConnectionHandler(const char *pin, const char *apn, const
6571
6672void NBConnectionHandler::init () {
6773 char msgBuffer[120 ];
68- if (nbAccess .begin (pin, apn, login, pass ) == NB_READY) {
74+ if (_nb .begin (_pin, _apn, _login, _pass ) == NB_READY) {
6975 Debug.print (DBG_INFO, " SIM card ok" );
70- nbAccess .setTimeout (CHECK_INTERVAL_RETRYING);
76+ _nb .setTimeout (CHECK_INTERVAL_RETRYING);
7177 changeConnectionState (NetworkConnectionState::CONNECTING);
7278 } else {
7379 Debug.print (DBG_ERROR, " SIM not present or wrong PIN" );
7480 }
7581}
7682
7783unsigned long NBConnectionHandler::getTime () {
78- return nbAccess .getTime ();
84+ return _nb .getTime ();
7985}
8086
8187NetworkConnectionState NBConnectionHandler::check () {
8288 unsigned long const now = millis ();
83- int nbAccessAlive ;
89+ int _nbAlive ;
8490 if (now - lastConnectionTickTime > connectionTickTimeInterval) {
8591 switch (_netConnectionState) {
8692 case NetworkConnectionState::INIT: {
@@ -91,7 +97,7 @@ NetworkConnectionState NBConnectionHandler::check() {
9197 case NetworkConnectionState::CONNECTING: {
9298 // NOTE: Blocking Call when 4th parameter == true
9399 NB_NetworkStatus_t networkStatus;
94- networkStatus = _gprs .attachGPRS (true );
100+ networkStatus = _nb_gprs .attachGPRS (true );
95101 Debug.print (DBG_DEBUG, " GPRS.attachGPRS(): %d" , networkStatus);
96102 if (networkStatus == NB_NetworkStatus_t::ERROR) {
97103 // NO FURTHER ACTION WILL FOLLOW THIS
@@ -100,7 +106,7 @@ NetworkConnectionState NBConnectionHandler::check() {
100106 }
101107 Debug.print (DBG_INFO, " Sending PING to outer space..." );
102108 int pingResult;
103- // pingResult = _gprs .ping("time.arduino.cc");
109+ // pingResult = _nb_gprs .ping("time.arduino.cc");
104110 // Debug.print(DBG_INFO, "NB.ping(): %d", pingResult);
105111 // if (pingResult < 0) {
106112 if (pingResult < 0 ) {
@@ -115,18 +121,18 @@ NetworkConnectionState NBConnectionHandler::check() {
115121 }
116122 break ;
117123 case NetworkConnectionState::CONNECTED: {
118- nbAccessAlive = nbAccess .isAccessAlive ();
119- Debug.print (DBG_VERBOSE, " GPRS.isAccessAlive(): %d" , nbAccessAlive );
120- if (nbAccessAlive != 1 ) {
124+ _nbAlive = _nb .isAccessAlive ();
125+ Debug.print (DBG_VERBOSE, " GPRS.isAccessAlive(): %d" , _nbAlive );
126+ if (_nbAlive != 1 ) {
121127 changeConnectionState (NetworkConnectionState::DISCONNECTED);
122128 return _netConnectionState;
123129 }
124130 Debug.print (DBG_VERBOSE, " Connected to Cellular Network" );
125131 }
126132 break ;
127133 case NetworkConnectionState::DISCONNECTED: {
128- // _gprs .detachGPRS();
129- if (keepAlive ) {
134+ // _nb_gprs .detachGPRS();
135+ if (_keep_alive ) {
130136 Debug.print (DBG_VERBOSE, " keep alive > INIT" );
131137 changeConnectionState (NetworkConnectionState::INIT);
132138 } else {
@@ -168,14 +174,14 @@ void NBConnectionHandler::changeConnectionState(NetworkConnectionState _newState
168174 break ;
169175 case NetworkConnectionState::DISCONNECTING: {
170176 Debug.print (DBG_VERBOSE, " Disconnecting from Cellular Network" );
171- nbAccess .shutdown ();
177+ _nb .shutdown ();
172178 }
173179 case NetworkConnectionState::DISCONNECTED: {
174180 if (_netConnectionState == NetworkConnectionState::CONNECTED) {
175181 execCallback (NetworkConnectionEvent::DISCONNECTED);
176182 Debug.print (DBG_ERROR, " Disconnected from Cellular Network" );
177183 Debug.print (DBG_ERROR, " Attempting reconnection" );
178- if (keepAlive ) {
184+ if (_keep_alive ) {
179185 Debug.print (DBG_ERROR, " Attempting reconnection" );
180186 }
181187 }
@@ -198,15 +204,15 @@ void NBConnectionHandler::connect() {
198204 if (_netConnectionState == NetworkConnectionState::INIT || _netConnectionState == NetworkConnectionState::CONNECTING) {
199205 return ;
200206 }
201- keepAlive = true ;
207+ _keep_alive = true ;
202208 changeConnectionState (NetworkConnectionState::INIT);
203209
204210}
205211void NBConnectionHandler::disconnect () {
206212 // WiFi.end();
207213
208214 changeConnectionState (NetworkConnectionState::DISCONNECTING);
209- keepAlive = false ;
215+ _keep_alive = false ;
210216}
211217
212218#endif /* #ifdef BOARD_HAS_NB */
0 commit comments