kopia lustrzana https://github.com/SP8EBC/ParaTNC
http client rx callback fix for empty response body
rodzic
a284074f74
commit
a4b1486f9c
|
@ -12,6 +12,7 @@
|
|||
#include <string.h>
|
||||
|
||||
#define BEGIN \
|
||||
LN = 0; \
|
||||
memset(OUT, 0x00, sizeof(OUT)); \
|
||||
LN = sprintf(OUT + LN, "{\r\n"); \
|
||||
|
||||
|
|
10
src/aprsis.c
10
src/aprsis.c
|
@ -157,16 +157,16 @@ uint8_t aprsis_connect_and_login(char * address, uint8_t address_ln, uint16_t po
|
|||
}
|
||||
else {
|
||||
// if authoruzation wasn't successfull drop a connection
|
||||
gsm_sim800_tcpip_close(aprsis_serial_port, aprsis_gsm_modem_state);
|
||||
gsm_sim800_tcpip_close(aprsis_serial_port, aprsis_gsm_modem_state, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
gsm_sim800_tcpip_close(aprsis_serial_port, aprsis_gsm_modem_state);
|
||||
gsm_sim800_tcpip_close(aprsis_serial_port, aprsis_gsm_modem_state, 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
gsm_sim800_tcpip_close(aprsis_serial_port, aprsis_gsm_modem_state);
|
||||
gsm_sim800_tcpip_close(aprsis_serial_port, aprsis_gsm_modem_state, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ uint8_t aprsis_connect_and_login_default(void) {
|
|||
}
|
||||
|
||||
void aprsis_disconnect(void) {
|
||||
gsm_sim800_tcpip_close(aprsis_serial_port, aprsis_gsm_modem_state);
|
||||
gsm_sim800_tcpip_close(aprsis_serial_port, aprsis_gsm_modem_state, 0);
|
||||
|
||||
aprsis_logged = 0;
|
||||
|
||||
|
@ -215,7 +215,7 @@ void aprsis_check_alive(void) {
|
|||
// reset the flag
|
||||
aprsis_logged = 0;
|
||||
|
||||
gsm_sim800_tcpip_close(aprsis_serial_port, aprsis_gsm_modem_state);
|
||||
gsm_sim800_tcpip_close(aprsis_serial_port, aprsis_gsm_modem_state, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ uint8_t gsm_sim800_tcpip_async_receive(srl_context_t * srl_context, gsm_sim800_s
|
|||
uint8_t gsm_sim800_tcpip_receive(uint8_t * buffer, uint16_t buffer_size, srl_context_t * srl_context, gsm_sim800_state_t * state, srl_rx_termination_callback_t rx_callback, uint32_t timeout);
|
||||
uint8_t gsm_sim800_tcpip_async_write(uint8_t * data, uint16_t data_len, srl_context_t * srl_context, gsm_sim800_state_t * state);
|
||||
uint8_t gsm_sim800_tcpip_write(uint8_t * data, uint16_t data_len, srl_context_t * srl_context, gsm_sim800_state_t * state);
|
||||
void gsm_sim800_tcpip_close(srl_context_t * srl_context, gsm_sim800_state_t * state);
|
||||
void gsm_sim800_tcpip_close(srl_context_t * srl_context, gsm_sim800_state_t * state, uint8_t force);
|
||||
|
||||
void gsm_sim800_tcpip_rx_done_callback(srl_context_t * srl_context, gsm_sim800_state_t * state);
|
||||
void gsm_sim800_tcpip_tx_done_callback(srl_context_t * srl_context, gsm_sim800_state_t * state);
|
||||
|
|
|
@ -224,11 +224,11 @@ uint8_t gsm_sim800_tcpip_write(uint8_t * data, uint16_t data_len, srl_context_t
|
|||
return out;
|
||||
}
|
||||
|
||||
void gsm_sim800_tcpip_close(srl_context_t * srl_context, gsm_sim800_state_t * state) {
|
||||
void gsm_sim800_tcpip_close(srl_context_t * srl_context, gsm_sim800_state_t * state, uint8_t force) {
|
||||
|
||||
uint8_t receive_result = 0;
|
||||
|
||||
if (*state == SIM800_TCP_CONNECTED) {
|
||||
if (*state == SIM800_TCP_CONNECTED || force == 1) {
|
||||
// send escape sequence to exit connection mode
|
||||
srl_send_data(srl_context, (const uint8_t*) ESCAPE, SRL_MODE_ZERO, strlen(ESCAPE), SRL_INTERNAL);
|
||||
|
||||
|
|
|
@ -68,6 +68,8 @@ static char http_client_port[PORT_LN];
|
|||
*/
|
||||
static void http_client_response_done_callback(srl_context_t* context) {
|
||||
|
||||
gsm_sim800_tcpip_close(context, http_client_deticated_sim800_state, 1);
|
||||
|
||||
if (http_client_on_response_callback != 0) {
|
||||
// execute a callback. addition '+1' is requires because 'http_client_content_end_index' points to the last character of response
|
||||
http_client_on_response_callback(http_client_http_code, (char *)(context->srl_rx_buf_pointer + http_client_content_start_index), http_client_content_end_index - http_client_content_start_index + 1);
|
||||
|
@ -229,7 +231,7 @@ uint8_t http_client_async_get(char * url, uint8_t url_ln, uint16_t response_ln_l
|
|||
// check if module is busy on other TCP/IP connection
|
||||
if (*http_client_deticated_sim800_state == SIM800_TCP_CONNECTED && force_disconnect_on_busy != 0) {
|
||||
// if client is connected end a user wants to force disconnect
|
||||
gsm_sim800_tcpip_close(http_client_deticated_serial_context, http_client_deticated_sim800_state);
|
||||
gsm_sim800_tcpip_close(http_client_deticated_serial_context, http_client_deticated_sim800_state, 0);
|
||||
}
|
||||
else if (*http_client_deticated_sim800_state == SIM800_TCP_CONNECTED && force_disconnect_on_busy == 0) {
|
||||
out = HTTP_CLIENT_RET_TCPIP_BSY;
|
||||
|
@ -315,7 +317,7 @@ uint8_t http_client_async_post(char * url, uint8_t url_ln, char * data_to_post,
|
|||
// check if module is busy on other TCP/IP connection
|
||||
if (*http_client_deticated_sim800_state == SIM800_TCP_CONNECTED && force_disconnect_on_busy != 0) {
|
||||
// if client is connected end a user wants to force disconnect
|
||||
gsm_sim800_tcpip_close(http_client_deticated_serial_context, http_client_deticated_sim800_state);
|
||||
gsm_sim800_tcpip_close(http_client_deticated_serial_context, http_client_deticated_sim800_state, 0);
|
||||
}
|
||||
else if (*http_client_deticated_sim800_state == SIM800_TCP_CONNECTED && force_disconnect_on_busy == 0) {
|
||||
out = HTTP_CLIENT_RET_TCPIP_BSY;
|
||||
|
|
|
@ -233,6 +233,10 @@ uint8_t http_client_rx_done_callback(uint8_t current_data, const uint8_t * const
|
|||
}
|
||||
}
|
||||
|
||||
// check if this response doesn't have a content
|
||||
if (http_client_response_header_processing == 0 && http_client_content_lenght == 0) {
|
||||
out = 1;
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue