Skip to content
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

Add getters and setters to GPRS, GSM, GSMClient for custom inherited classes #86

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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: 14 additions & 0 deletions src/GPRS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,10 @@ IPAddress GPRS::getIPAddress()
return IPAddress(0, 0, 0, 0);
}

unsigned long GPRS::timeout() {
return _timeout;
}

void GPRS::setTimeout(unsigned long timeout)
{
_timeout = timeout;
Expand Down Expand Up @@ -398,6 +402,16 @@ GSM3_NetworkStatus_t GPRS::status()
return _status;
}

int GPRS::state()
{
return _state;
}

void GPRS::setState(int state)
{
_state = state;
}

void GPRS::handleUrc(const String& urc)
{
if (urc.startsWith("+UUPINGER: ")) {
Expand Down
3 changes: 3 additions & 0 deletions src/GPRS.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class GPRS : public ModemUrcHandler {
*/
IPAddress getIPAddress();

unsigned long timeout();
void setTimeout(unsigned long timeout);

int hostByName(const char* hostname, IPAddress& result);
Expand All @@ -90,6 +91,8 @@ class GPRS : public ModemUrcHandler {
int ping(IPAddress ip, uint8_t ttl = 128);

GSM3_NetworkStatus_t status();
int state();
void setState(int state);

void handleUrc(const String& urc);

Expand Down
14 changes: 14 additions & 0 deletions src/GSM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,10 @@ int GSM::ready()
return ready;
}

unsigned long GSM::timeout() {
return _timeout;
}

void GSM::setTimeout(unsigned long timeout)
{
_timeout = timeout;
Expand Down Expand Up @@ -388,3 +392,13 @@ GSM3_NetworkStatus_t GSM::status()
{
return _state;
}

GSM3_NetworkStatus_t GSM::state()
{
return _state;
}

void GSM::setState(GSM3_NetworkStatus_t state)
{
_state = state;
}
3 changes: 3 additions & 0 deletions src/GSM.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class GSM {
*/
int ready();

unsigned long timeout();
void setTimeout(unsigned long timeout);

unsigned long getTime();
Expand All @@ -75,6 +76,8 @@ class GSM {
int noLowPowerMode();

GSM3_NetworkStatus_t status();
GSM3_NetworkStatus_t state();
void setState(GSM3_NetworkStatus_t state);

private:
GSM3_NetworkStatus_t _state;
Expand Down
30 changes: 16 additions & 14 deletions src/GSMClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,6 @@

#include "GSMClient.h"

enum {
CLIENT_STATE_IDLE,
CLIENT_STATE_CREATE_SOCKET,
CLIENT_STATE_WAIT_CREATE_SOCKET_RESPONSE,
CLIENT_STATE_ENABLE_SSL,
CLIENT_STATE_WAIT_ENABLE_SSL_RESPONSE,
CLIENT_STATE_MANAGE_SSL_PROFILE,
CLIENT_STATE_WAIT_MANAGE_SSL_PROFILE_RESPONSE,
CLIENT_STATE_CONNECT,
CLIENT_STATE_WAIT_CONNECT_RESPONSE,
CLIENT_STATE_CLOSE_SOCKET,
CLIENT_STATE_WAIT_CLOSE_SOCKET
};

GSMClient::GSMClient(bool synch) :
GSMClient(-1, synch)
{
Expand Down Expand Up @@ -446,3 +432,19 @@ void GSMClient::handleUrc(const String& urc)
}
}
}

int GSMClient::state() {
return _state;
}

void GSMClient::setState(int state) {
_state = state;
}

int GSMClient::socket() {
return _socket;
}

const char* GSMClient::host() {
return _host;
}
19 changes: 19 additions & 0 deletions src/GSMClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@

#include <Client.h>

enum {
CLIENT_STATE_IDLE,
CLIENT_STATE_CREATE_SOCKET,
CLIENT_STATE_WAIT_CREATE_SOCKET_RESPONSE,
CLIENT_STATE_ENABLE_SSL,
CLIENT_STATE_WAIT_ENABLE_SSL_RESPONSE,
CLIENT_STATE_MANAGE_SSL_PROFILE,
CLIENT_STATE_WAIT_MANAGE_SSL_PROFILE_RESPONSE,
CLIENT_STATE_CONNECT,
CLIENT_STATE_WAIT_CONNECT_RESPONSE,
CLIENT_STATE_CLOSE_SOCKET,
CLIENT_STATE_WAIT_CLOSE_SOCKET
};

class GSMClient : public Client, public ModemUrcHandler {

public:
Expand Down Expand Up @@ -130,6 +144,11 @@ class GSMClient : public Client, public ModemUrcHandler {

virtual void handleUrc(const String& urc);

int state();
void setState(int state);
int socket();
const char* host();

private:
int connect();

Expand Down