GPRS, TCP and MQTT functions' prototypes and definition of related parameters.
More...
Go to the source code of this file.
|
uint8_t | enable_gprs () |
| enables the GPRS connection. GPRS must be enabled before trying to establish TCP connection. This function goes through a series of the tests below. action is taken depending on the test result More...
|
|
uint8_t | disable_gprs () |
| disables the GPRS functionality and the whole radio module. More...
|
|
uint8_t | open_tcp_connection (char *ip_address, char *tcp_port) |
| opens a new TCP connection. if the function is called when there is already an open TCP connection then it closes it and opens a new connection. More...
|
|
uint8_t | send_tcp_data (uint8_t *data, uint8_t data_length) |
| sends data over an open TCP connection. More...
|
|
uint8_t | close_tcp_connection () |
| closes an open TCP connection. More...
|
|
uint8_t | publish_mqtt_msg (char *ip_address, char *tcp_port, char *topic, char *client_id, char *message) |
| publishes a message to an MQTT topic with QoS 1 by default. More...
|
|
GPRS, TCP and MQTT functions' prototypes and definition of related parameters.
- Author
- Mohamed Boubaker
- Bug:
- issue #9
#define APN_LENGTH 2 /* Length of the APN string */ |
#define ERR_GPRS_ATTACH 52 |
#define ERR_MQTT_EMPTY_PARAM 100 |
#define ERR_PDP_ACTIVATE 55 |
#define ERR_PDP_DEACTIVATED 53 |
#define ERR_PDP_DEFINE 54 |
#define ERR_PHONE_FUNCTION 48 |
#define ERR_REGISTRATION 52 |
#define ERR_SIM_PRESENCE 49 |
#define ERR_WEAK_SIGNAL 51 |
#define MAX_LENGTH_MQTT_PACKET 128 |
#define MQTT_KEEP_ALIVE 15 |
uint8_t close_tcp_connection |
( |
| ) |
|
closes an open TCP connection.
- Returns
- SUCCESS if the connection was successfully closed, FAIL otherwise.
disables the GPRS functionality and the whole radio module.
- Returns
- 1 if the GPRS is successfully disabled, 0 otherwise.
enables the GPRS connection. GPRS must be enabled before trying to establish TCP connection. This function goes through a series of the tests below. action is taken depending on the test result
- Checks if the SIM card is detected
- Checks if the SIM card requires PIN code
- Checks the signal stregth. If it is very low, it returns an error value.
- Checks if the Mobile Equipement (ME) is registered to the Network. If not, it tries to register.
- Checks if ME is attached to GPRS service. if not it tries to attach.
- Checks if GPRS PDP context is defined, if not it tries to define it, enable it, and get IP address.
- Returns
- 1 if gprs is active, 2 if SIM card is not detected, 3 if SIM PIN is incorrect, 4 if the signal is weak, 0 otherwise
enables the GPRS connection. GPRS must be enabled before trying to establish TCP connection. This function goes through a series of the tests below. action is taken depending on the test result
- Checks if the SIM card is detected
- Checks if the SIM card requires PIN code
- Checks the signal stregth. If it is very low, it returns an error value.
- Checks if the Mobile Equipement (ME) is registered to the Network. If not, it tries to register.
- Checks if ME is attached to GPRS service. if not it tries to attach.
- Checks if GPRS PDP context is defined, if not it tries to define it, enable it, and get IP address.
- Returns
- 1 if gprs is active, 2 if SIM card is not detected, 3 if SIM PIN is incorrect, 4 if the signal is weak, 0 otherwise
uint8_t open_tcp_connection |
( |
char * |
ip_address, |
|
|
char * |
tcp_port |
|
) |
| |
opens a new TCP connection. if the function is called when there is already an open TCP connection then it closes it and opens a new connection.
- Parameters
-
ip_address | is the IP address of the server. it can be an IP adress or DNS hostname. |
tcp_port | is the remote TCP port. |
- Returns
- SUCCESS if the connection was successfully opened, FAIL otherwise
uint8_t publish_mqtt_msg |
( |
char * |
ip_address, |
|
|
char * |
tcp_port, |
|
|
char * |
topic, |
|
|
char * |
client_id, |
|
|
char * |
message |
|
) |
| |
publishes a message to an MQTT topic with QoS 1 by default.
- Parameters
-
ip_address | is the MQTT server IP address or DNS hostname. |
tcp_port | is the MQTT server port |
client_id | is the MQTT client ID. |
topic | is the MQTT topic name. |
message | is the message to be sent. |
- Returns
- SUCCESS if the message is successfully delivered, 0 otherwise.
uint8_t send_tcp_data |
( |
uint8_t * |
data, |
|
|
uint8_t |
data_length |
|
) |
| |
sends data over an open TCP connection.
- Parameters
-
data | is the byte array to be sent |
data_length | is the length of the byte array to be sent. |
- Returns
- SUCCESS if the data was successfully sent, FAIL otherwise.