Skip to content

Commit

Permalink
Add more possibility argument input on method
Browse files Browse the repository at this point in the history
  • Loading branch information
frdteknikelektro committed Mar 15, 2017
1 parent 98b716d commit cd68a62
Show file tree
Hide file tree
Showing 7 changed files with 380 additions and 8 deletions.
60 changes: 52 additions & 8 deletions GSM.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,34 @@ class GSM {
*/
bool atWritePhonebookEntry(unsigned char index, const __FlashStringHelper *phoneNumber, unsigned char type, const char text[]);

/**
* Command AT+CPBW=
* @param index Location Number
* @param phoneNumber Phone Number
* @param type Type of Number:
* 129: National Number type
* 161: National Number type
* 145: International Number type
* 177: Network Specific Number
* @param text Text associated with number
* @return true: If command successful, false: Otherwise
*/
bool atWritePhonebookEntry(unsigned char index, const char phoneNumber[], unsigned char type, const __FlashStringHelper *text);

/**
* Command AT+CPBW=
* @param index Location Number
* @param phoneNumber Phone Number
* @param type Type of Number:
* 129: National Number type
* 161: National Number type
* 145: International Number type
* 177: Network Specific Number
* @param text Text associated with number
* @return true: If command successful, false: Otherwise
*/
bool atWritePhonebookEntry(unsigned char index, const __FlashStringHelper *phoneNumber, unsigned char type, const __FlashStringHelper *text);

/**
* Command AT+CPIN?
* @return true: If command successful, false: Otherwise
Expand All @@ -226,7 +254,7 @@ class GSM {
* @param pin SIM Pin
* @return true: If command successful, false: Otherwise
*/
bool atEnterPIN(const __FlashStringHelper *phoneNumber);
bool atEnterPIN(const __FlashStringHelper *pin);

/**
* Command AT+CPIN=
Expand All @@ -236,13 +264,29 @@ class GSM {
*/
bool atEnterPIN(const char pin[], const char newPin[]);

/**
* Command AT+CPIN=
* @param pin SIM Pin
* @param newPin New SIM Pin
* @return true: If command successful, false: Otherwise
*/
bool atEnterPIN(const __FlashStringHelper *pin, const __FlashStringHelper *newPin);
/**
* Command AT+CPIN=
* @param pin SIM Pin
* @param newPin New SIM Pin
* @return true: If command successful, false: Otherwise
*/
bool atEnterPIN(const __FlashStringHelper *pin, const char newPin[]);

/**
* Command AT+CPIN=
* @param pin SIM Pin
* @param newPin New SIM Pin
* @return true: If command successful, false: Otherwise
*/
bool atEnterPIN(const char pin[], const __FlashStringHelper *newPin);

/**
* Command AT+CPIN=
* @param pin SIM Pin
* @param newPin New SIM Pin
* @return true: If command successful, false: Otherwise
*/
bool atEnterPIN(const __FlashStringHelper *pin, const __FlashStringHelper *newPin);

/**
* Command AT+CREG?
Expand Down
66 changes: 66 additions & 0 deletions HTTP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,42 @@ bool HTTP::atSetHttpParametersValue(const __FlashStringHelper *paramTag, const c
return atSetHttpParametersValue(buffer, paramValue, userdataDelimiter);
}

bool HTTP::atSetHttpParametersValue(const char paramTag[], const __FlashStringHelper *paramValue, const char userdataDelimiter[]) {
char buffer[strlen_P((const char *)paramValue) + 1];
strcpy_P(buffer, (const char *)paramValue);
return atSetHttpParametersValue(paramTag, buffer, userdataDelimiter);
}

bool HTTP::atSetHttpParametersValue(const __FlashStringHelper *paramTag, const __FlashStringHelper *paramValue, const char userdataDelimiter[]) {
char buffer[strlen_P((const char *)paramValue) + 1];
strcpy_P(buffer, (const char *)paramValue);
return atSetHttpParametersValue(paramTag, buffer, userdataDelimiter);
}

bool HTTP::atSetHttpParametersValue(const char paramTag[], const char paramValue[], const __FlashStringHelper *userdataDelimiter) {
char buffer[strlen_P((const char *)userdataDelimiter) + 1];
strcpy_P(buffer, (const char *)userdataDelimiter);
return atSetHttpParametersValue(paramTag, paramValue, buffer);
}

bool HTTP::atSetHttpParametersValue(const __FlashStringHelper *paramTag, const char paramValue[], const __FlashStringHelper *userdataDelimiter) {
char buffer[strlen_P((const char *)userdataDelimiter) + 1];
strcpy_P(buffer, (const char *)userdataDelimiter);
return atSetHttpParametersValue(paramTag, paramValue, buffer);
}

bool HTTP::atSetHttpParametersValue(const char paramTag[], const __FlashStringHelper *paramValue, const __FlashStringHelper *userdataDelimiter) {
char buffer[strlen_P((const char *)userdataDelimiter) + 1];
strcpy_P(buffer, (const char *)userdataDelimiter);
return atSetHttpParametersValue(paramTag, paramValue, buffer);
}

bool HTTP::atSetHttpParametersValue(const __FlashStringHelper *paramTag, const __FlashStringHelper *paramValue, const __FlashStringHelper *userdataDelimiter) {
char buffer[strlen_P((const char *)userdataDelimiter) + 1];
strcpy_P(buffer, (const char *)userdataDelimiter);
return atSetHttpParametersValue(paramTag, paramValue, buffer);
}

bool HTTP::atInputHttpData(const char data[], unsigned int timeout) {
const __FlashStringHelper *command = F("AT+HTTPDATA=%u,%d\r");
const __FlashStringHelper *response = F("DOWNLOAD");
Expand Down Expand Up @@ -243,6 +273,18 @@ bool HTTP::setHeaders(const __FlashStringHelper *headers, const char userdataDel
return setHeaders(buffer, userdataDelimiter);
}

bool HTTP::setHeaders(const char headers[], const __FlashStringHelper *userdataDelimiter) {
char buffer[strlen_P((const char *)userdataDelimiter) + 1];
strcpy_P(buffer, (const char *)userdataDelimiter);
return setHeaders(headers, buffer);
}

bool HTTP::setHeaders(const __FlashStringHelper *headers, const __FlashStringHelper *userdataDelimiter) {
char buffer[strlen_P((const char *)userdataDelimiter) + 1];
strcpy_P(buffer, (const char *)userdataDelimiter);
return setHeaders(headers, buffer);
}

bool HTTP::action(const char method[], const char url[], const char data[]) {
if (!initialized) return false;
if (!getStatus().status == 0) return false;
Expand Down Expand Up @@ -271,12 +313,36 @@ bool HTTP::action(const __FlashStringHelper *method, const char url[], const cha
return action(buffer, url, data);
}

bool HTTP::action(const char method[], const __FlashStringHelper *url, const char data[]) {
char buffer[strlen_P((const char *)url) + 1];
strcpy_P(buffer, (const char *)url);
return action(method, buffer, data);
}

bool HTTP::action(const __FlashStringHelper *method, const __FlashStringHelper *url, const char data[]) {
char buffer[strlen_P((const char *)url) + 1];
strcpy_P(buffer, (const char *)url);
return action(method, buffer, data);
}

bool HTTP::action(const char method[], const char url[], const __FlashStringHelper *data) {
char buffer[strlen_P((const char *)data) + 1];
strcpy_P(buffer, (const char *)data);
return action(method, url, buffer);
}

bool HTTP::action(const __FlashStringHelper *method, const char url[], const __FlashStringHelper *data) {
char buffer[strlen_P((const char *)data) + 1];
strcpy_P(buffer, (const char *)data);
return action(method, url, buffer);
}

bool HTTP::action(const char method[], const __FlashStringHelper *url, const __FlashStringHelper *data) {
char buffer[strlen_P((const char *)data) + 1];
strcpy_P(buffer, (const char *)data);
return action(method, url, buffer);
}

bool HTTP::action(const __FlashStringHelper *method, const __FlashStringHelper *url, const __FlashStringHelper *data) {
char buffer[strlen_P((const char *)data) + 1];
strcpy_P(buffer, (const char *)data);
Expand Down
145 changes: 145 additions & 0 deletions HTTP.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,25 @@ class HTTP {
*/
bool atSetHttpParametersValue(const __FlashStringHelper *paramTag, const char paramValue[], const char userdataDelimiter[] = "");

/**
* Command AT+HTTPPARA
* @param paramTag Parameter Tag
* "CID": Context Identifier Used, see IP Class
* "URL": HTTP Client URL
* "UA": User Agent
* "PROIP": IP Address of HTTP Proxy Server
* "PROPORT": Port of HTTP Proxy Server
* "REDIR": If set to 1, automatic redirect, otherwis no, default is 0
* "BREAK": Integer start address. Parameter for Method GET, for resuming broken transfer, start from BREAK to BREAKEND
* "BREAKEND": Integer end address.
* "TIMEOUT": HTTP Session Timeout value, range 30 - 1000 second, default is 120
* "CONTENT": Used to set Content-Type in HTTP Header
* "USERDATA": Used to set user's data in HTTP Header
* @param paramValue Parameter Value
* @return true: If command successful, false: Otherwise
*/
bool atSetHttpParametersValue(const char paramTag[], const __FlashStringHelper *paramValue, const char userdataDelimiter[] = "");

/**
* Command AT+HTTPPARA
* @param paramTag Parameter Tag
Expand All @@ -110,6 +129,82 @@ class HTTP {
*/
bool atSetHttpParametersValue(const __FlashStringHelper *paramTag, const __FlashStringHelper *paramValue, const char userdataDelimiter[] = "");

/**
* Command AT+HTTPPARA
* @param paramTag Parameter Tag
* "CID": Context Identifier Used, see IP Class
* "URL": HTTP Client URL
* "UA": User Agent
* "PROIP": IP Address of HTTP Proxy Server
* "PROPORT": Port of HTTP Proxy Server
* "REDIR": If set to 1, automatic redirect, otherwis no, default is 0
* "BREAK": Integer start address. Parameter for Method GET, for resuming broken transfer, start from BREAK to BREAKEND
* "BREAKEND": Integer end address.
* "TIMEOUT": HTTP Session Timeout value, range 30 - 1000 second, default is 120
* "CONTENT": Used to set Content-Type in HTTP Header
* "USERDATA": Used to set user's data in HTTP Header
* @param paramValue Parameter Value
* @return true: If command successful, false: Otherwise
*/
bool atSetHttpParametersValue(const char paramTag[], const char paramValue[], const __FlashStringHelper *userdataDelimiter);

/**
* Command AT+HTTPPARA
* @param paramTag Parameter Tag
* "CID": Context Identifier Used, see IP Class
* "URL": HTTP Client URL
* "UA": User Agent
* "PROIP": IP Address of HTTP Proxy Server
* "PROPORT": Port of HTTP Proxy Server
* "REDIR": If set to 1, automatic redirect, otherwis no, default is 0
* "BREAK": Integer start address. Parameter for Method GET, for resuming broken transfer, start from BREAK to BREAKEND
* "BREAKEND": Integer end address.
* "TIMEOUT": HTTP Session Timeout value, range 30 - 1000 second, default is 120
* "CONTENT": Used to set Content-Type in HTTP Header
* "USERDATA": Used to set user's data in HTTP Header
* @param paramValue Parameter Value
* @return true: If command successful, false: Otherwise
*/
bool atSetHttpParametersValue(const __FlashStringHelper *paramTag, const char paramValue[], const __FlashStringHelper *userdataDelimiter);

/**
* Command AT+HTTPPARA
* @param paramTag Parameter Tag
* "CID": Context Identifier Used, see IP Class
* "URL": HTTP Client URL
* "UA": User Agent
* "PROIP": IP Address of HTTP Proxy Server
* "PROPORT": Port of HTTP Proxy Server
* "REDIR": If set to 1, automatic redirect, otherwis no, default is 0
* "BREAK": Integer start address. Parameter for Method GET, for resuming broken transfer, start from BREAK to BREAKEND
* "BREAKEND": Integer end address.
* "TIMEOUT": HTTP Session Timeout value, range 30 - 1000 second, default is 120
* "CONTENT": Used to set Content-Type in HTTP Header
* "USERDATA": Used to set user's data in HTTP Header
* @param paramValue Parameter Value
* @return true: If command successful, false: Otherwise
*/
bool atSetHttpParametersValue(const char paramTag[], const __FlashStringHelper *paramValue, const __FlashStringHelper *userdataDelimiter);

/**
* Command AT+HTTPPARA
* @param paramTag Parameter Tag
* "CID": Context Identifier Used, see IP Class
* "URL": HTTP Client URL
* "UA": User Agent
* "PROIP": IP Address of HTTP Proxy Server
* "PROPORT": Port of HTTP Proxy Server
* "REDIR": If set to 1, automatic redirect, otherwis no, default is 0
* "BREAK": Integer start address. Parameter for Method GET, for resuming broken transfer, start from BREAK to BREAKEND
* "BREAKEND": Integer end address.
* "TIMEOUT": HTTP Session Timeout value, range 30 - 1000 second, default is 120
* "CONTENT": Used to set Content-Type in HTTP Header
* "USERDATA": Used to set user's data in HTTP Header
* @param paramValue Parameter Value
* @return true: If command successful, false: Otherwise
*/
bool atSetHttpParametersValue(const __FlashStringHelper *paramTag, const __FlashStringHelper *paramValue, const __FlashStringHelper *userdataDelimiter);

/**
* Command AT+HTTPDATA
* @param data POST data
Expand Down Expand Up @@ -209,6 +304,20 @@ class HTTP {
*/
bool setHeaders(const __FlashStringHelper *header, const char userdataDelimiter[] = "");

/**
* Set Header
* @param header Header string with semicolon demiliter
* @return true: If success, false: Otherwise
*/
bool setHeaders(const char header[], const __FlashStringHelper *userdataDelimiter);

/**
* Set Header
* @param header Header string with semicolon demiliter
* @return true: If success, false: Otherwise
*/
bool setHeaders(const __FlashStringHelper *header, const __FlashStringHelper *userdataDelimiter);

/**
* Submit HTTP Action
* @param method Method "GET", "POST", or "HEAD"
Expand All @@ -227,6 +336,15 @@ class HTTP {
*/
bool action(const __FlashStringHelper *method, const char url[], const char data[] = NULL);

/**
* Submit HTTP Action
* @param method Method "GET", "POST", or "HEAD"
* @param url HTTP Client URL
* @param data POST data, if action is POST
* @return true: If success, false: Otherwise
*/
bool action(const char method[], const __FlashStringHelper *url, const char data[] = NULL);

/**
* Submit HTTP Action
* @param method Method "GET", "POST", or "HEAD"
Expand All @@ -236,6 +354,33 @@ class HTTP {
*/
bool action(const __FlashStringHelper *method, const __FlashStringHelper *url, const char data[] = NULL);

/**
* Submit HTTP Action
* @param method Method "GET", "POST", or "HEAD"
* @param url HTTP Client URL
* @param data POST data, if action is POST
* @return true: If success, false: Otherwise
*/
bool action(const char method[], const char url[], const __FlashStringHelper *data);

/**
* Submit HTTP Action
* @param method Method "GET", "POST", or "HEAD"
* @param url HTTP Client URL
* @param data POST data, if action is POST
* @return true: If success, false: Otherwise
*/
bool action(const __FlashStringHelper *method, const char url[], const __FlashStringHelper *data);

/**
* Submit HTTP Action
* @param method Method "GET", "POST", or "HEAD"
* @param url HTTP Client URL
* @param data POST data, if action is POST
* @return true: If success, false: Otherwise
*/
bool action(const char method[], const __FlashStringHelper *url, const __FlashStringHelper *data);

/**
* Submit HTTP Action
* @param method Method "GET", "POST", or "HEAD"
Expand Down
Loading

0 comments on commit cd68a62

Please sign in to comment.