gsm tcpip close function bugfix, comments and hashdefines cleaned

sr9wxz_new_configuration_for_ZZ06
Mateusz Lubecki 2022-05-08 13:48:10 +02:00
rodzic 4f301c6bc8
commit 85296d51ad
11 zmienionych plików z 52 dodań i 39 usunięć

Wyświetl plik

@ -11,16 +11,20 @@
#include "drivers/serial.h"
#include "gsm/sim800c_tcpip.h"
#define APRSIS_OK 0
#define APRSIS_NOT_CONFIGURED 1
#define APRSIS_WRONG_STATE 2
#define APRSIS_ALREADY_CONNECTED 3
typedef enum aprsis_return {
APRSIS_OK = 0,
APRSIS_NOT_CONFIGURED = 1,
APRSIS_WRONG_STATE = 2,
APRSIS_ALREADY_CONNECTED = 3
}aprsis_return_t;
extern uint8_t aprsis_connected;
void aprsis_init(srl_context_t * context, gsm_sim800_state_t * gsm_modem_state, char * callsign, uint8_t ssid, uint32_t passcode, char * default_server, uint16_t default_port);
uint8_t aprsis_connect_and_login(char * address, uint8_t address_ln, uint16_t port);
uint8_t aprsis_connect_and_login_default(void);
aprsis_return_t aprsis_connect_and_login(char * address, uint8_t address_ln, uint16_t port);
aprsis_return_t aprsis_connect_and_login_default(void);
void aprsis_disconnect(void);
void aprsis_receive_callback(srl_context_t* srl_context);
void aprsis_check_alive(void);

Wyświetl plik

@ -8,22 +8,5 @@
#ifndef STATION_CONFIG_TARGET_HW_H_
#define STATION_CONFIG_TARGET_HW_H_
//#define PARATNC_HWREV_A
//#define PARATNC_HWREV_B
//#define PARATNC_HWREV_C
#ifndef PARAMETEO
#define PARAMETEO
#endif
#ifdef PARAMETEO
// // those defines and an undef are only required for shitty Eclipse indexer to see anything from STM32L471xx target
#undef STM32F10X_MD_VL
#ifndef STM32L471xx
#define STM32L471xx
#endif
#ifndef USE_FULL_LL_DRIVER
#define USE_FULL_LL_DRIVER
#endif
#endif
#endif /* STATION_CONFIG_TARGET_HW_H_ */

Wyświetl plik

@ -81,6 +81,8 @@ static void api_construct_url_status(api_endpoint_t endpoint) {
static void api_callback(uint16_t http_code, char * content, uint16_t content_lenght) {
http_client_close();
}

Wyświetl plik

@ -75,7 +75,12 @@ void aprsis_init(srl_context_t * context, gsm_sim800_state_t * gsm_modem_state,
aprsis_passcode = (int32_t)passcode;
sprintf(aprsis_callsign_with_ssid, "%s-%d", callsign, ssid);
if (ssid != 0) {
sprintf(aprsis_callsign_with_ssid, "%s-%d", callsign, ssid);
}
else {
sprintf(aprsis_callsign_with_ssid, "%s", callsign);
}
memset(aprsis_login_string, 0x00, 0x40);
@ -91,7 +96,7 @@ void aprsis_init(srl_context_t * context, gsm_sim800_state_t * gsm_modem_state,
}
uint8_t aprsis_connect_and_login(char * address, uint8_t address_ln, uint16_t port) {
aprsis_return_t aprsis_connect_and_login(char * address, uint8_t address_ln, uint16_t port) {
// this function has blocking io
uint8_t out = APRSIS_WRONG_STATE;
@ -181,7 +186,7 @@ uint8_t aprsis_connect_and_login(char * address, uint8_t address_ln, uint16_t po
}
uint8_t aprsis_connect_and_login_default(void) {
aprsis_return_t aprsis_connect_and_login_default(void) {
return aprsis_connect_and_login(aprsis_default_server_address, aprsis_default_server_address_ln, aprsis_default_server_port);
}

Wyświetl plik

@ -79,29 +79,19 @@ void io_pwr_init(void) {
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
#if (defined PARATNC_HWREV_A || defined PARATNC_HWREV_B)
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD;
#elif (defined PARATNC_HWREV_C)
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
#else
#error ("Hardware Revision not chosen.")
#endif
GPIO_Init(GPIOB, &GPIO_InitStructure);
#if (defined PARATNC_HWREV_C)
// +12V PWR_CNTRL
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
GPIO_Init(GPIOA, &GPIO_InitStructure);
#endif
wx_pwr_state = WX_PWR_OFF;
GPIO_ResetBits(GPIOB, GPIO_Pin_8);
#if (defined PARATNC_HWREV_C)
// +12V_SW PWR_CNTRL
GPIO_ResetBits(GPIOA, GPIO_Pin_6);
#endif
#endif

Wyświetl plik

@ -119,6 +119,23 @@
#define CONFIG_SECOND_FAIL_RESTORING (1 << 4)
#define CONFIG_SECOND_CRC_OK (1 << 5)
/**
* A foreword about '#define' mess. This software is indented to run on at least two
* different hardware platform. First which is ParaTNC basing on STM32F100 and second
* ParaMETEO using STM32L476. In future more platforms may appear. Like ParaTNC2 which
* will be a ParaMETEO without battery charging and in form factor similar to ParaTNC.
*
* To obtain such compatibility a lot of #defines and different makefiles has to be used.
* Some parts of the code are 'included' per target CPU basis, as are independent from
* target platform either directly (like handling serial port or GPIO configuration), or
* as a result of an assumption that all target plaforms with STML476 will have GSM modem.
*
* Some platforms had or may have in the future few hadware revisions. ParaTNC had
* revisions A, B and C. Currently A and B are abandoned an assumption is that all ParaTNC
* builds applies to C. A choose of hardware revision is done in file 'station_config_target_hw.h'
* which is currently empty
*/
// ----- main() ---------------------------------------------------------------
// Sample pragmas to cope with warnings. Please note the related line at

Wyświetl plik

@ -104,6 +104,8 @@ inline void packet_tx_multi_per_call_handler(void) {
void packet_tx_tcp_handler(void) {
#ifdef STM32L471xx
uint8_t result = 0;
if ((packet_tx_trigger_tcp & APRSIS_TRIGGER_METEO) != 0) {
// send APRS-IS frame, if APRS-IS is not connected this function will return immediately
aprsis_send_wx_frame(rte_wx_average_windspeed, rte_wx_max_windspeed, rte_wx_average_winddirection, rte_wx_temperature_average_external_valid, rte_wx_pressure_valid, rte_wx_humidity_valid);
@ -147,9 +149,11 @@ void packet_tx_tcp_handler(void) {
packet_tx_trigger_tcp ^= API_TRIGGER_METEO;
}
else if ((packet_tx_trigger_tcp & RECONNECT_APRSIS) != 0) {
aprsis_connect_and_login_default();
result = aprsis_connect_and_login_default();
packet_tx_trigger_tcp ^= RECONNECT_APRSIS;
if (result == APRSIS_OK) {
packet_tx_trigger_tcp ^= RECONNECT_APRSIS;
}
}
#endif
}

Wyświetl plik

@ -76,7 +76,7 @@ void wx_pwr_switch_case_off_parameteo() {
}
void wx_pwr_switch_case_off_paratnc() {
#if (defined PARATNC_HWREV_C)
#if (defined STM32F10X_MD_VL)
// Turn on the +12V_SW voltage
GPIO_SetBits(GPIOA, GPIO_Pin_6);
#endif

Wyświetl plik

@ -50,6 +50,7 @@ extern uint16_t http_client_max_content_ln;
void http_client_init(gsm_sim800_state_t * state, srl_context_t * serial_context, uint8_t ignore_content_on_http_error);
uint8_t http_client_async_get(char * url, uint8_t url_ln, uint16_t response_ln_limit, uint8_t force_disconnect_on_busy, http_client_response_available_t callback_on_response);
uint8_t http_client_async_post(char * url, uint8_t url_ln, char * data_to_post, uint16_t data_ln, uint8_t force_disconnect_on_busy, http_client_response_available_t callback_on_response);
void http_client_close(void);
char * http_client_get_server_response();
uint16_t http_client_get_latest_http_code();

Wyświetl plik

@ -238,6 +238,9 @@ void gsm_sim800_tcpip_close(srl_context_t * srl_context, gsm_sim800_state_t * st
// wait for OK to be received
srl_receive_data_with_callback(srl_context, gsm_sim800_escape_terminating_callback);
// start timeout calculation
srl_context->srl_rx_timeout_calc_started = 1;
// wait for it to finish
srl_wait_for_rx_completion_or_timeout(srl_context, & receive_result);

Wyświetl plik

@ -382,6 +382,10 @@ uint8_t http_client_async_post(char * url, uint8_t url_ln, char * data_to_post,
return out;
}
void http_client_close(void) {
gsm_sim800_tcpip_close(http_client_deticated_serial_context, http_client_deticated_sim800_state, 1);
}
char * http_client_get_server_response() {
return 0;