kopia lustrzana https://github.com/SP8EBC/ParaTNC
rodzic
c219a6b7d6
commit
3c602102fa
|
@ -70,6 +70,8 @@ void aprsis_send_beacon(uint8_t async,
|
|||
char symbol_s,
|
||||
const config_data_basic_t * config_data_basic);
|
||||
void aprsis_igate_to_aprsis(AX25Msg *msg, const char * callsign_with_ssid);
|
||||
void aprsis_send_server_conn_status(const char * callsign_with_ssid);
|
||||
void aprsis_send_loginstring(const char * callsign_with_ssid);
|
||||
|
||||
char * aprsis_get_tx_buffer(void);
|
||||
uint8_t aprsis_get_aprsis_logged(void);
|
||||
|
|
|
@ -14,6 +14,10 @@
|
|||
//!< Set after everything was reinitialized from
|
||||
#define RTE_MAIN_WOKEN_UP_EXITED 4u
|
||||
|
||||
extern uint8_t rte_main_trigger_gsm_status_packet;
|
||||
|
||||
extern uint8_t rte_main_trigger_gsm_loginstring_packet;
|
||||
|
||||
//!< Trigger some reinitialization after waking up from deep sleep
|
||||
extern uint8_t rte_main_woken_up;
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#define SOFTWARE_VERSION_H_
|
||||
|
||||
#define SW_VER "EB00"
|
||||
#define SW_DATE "07102023"
|
||||
#define SW_DATE "13102023"
|
||||
#define SW_KISS_PROTO "B"
|
||||
|
||||
extern const char software_version_str[5];
|
||||
|
|
98
src/aprsis.c
98
src/aprsis.c
|
@ -110,6 +110,32 @@ uint32_t aprsis_last_keepalive_ts = 0;
|
|||
*/
|
||||
uint32_t aprsis_reset_on_timeout = 0;
|
||||
|
||||
/**
|
||||
* Number of RF packets igated to APRS-IS system
|
||||
*/
|
||||
uint16_t aprsis_igated_counter = 0;
|
||||
|
||||
/**
|
||||
* Counter of all packets originated from the station transmitted to APRS-IS server.
|
||||
* This doesn't include igated packets!
|
||||
*/
|
||||
uint16_t aprsis_tx_counter = 0;
|
||||
|
||||
/**
|
||||
* Amount of keepalive packet received from the server. It is reset to zero
|
||||
* every connect event
|
||||
*/
|
||||
uint16_t aprsis_keepalive_received_counter = 0;
|
||||
|
||||
/**
|
||||
* Amount of packets which are not keepalive
|
||||
*/
|
||||
uint16_t aprsis_another_received_counter = 0;
|
||||
|
||||
#define APRSIS_LOGIN_STRING_RECEIVED_LN 64
|
||||
|
||||
char aprsis_login_string_reveived[APRSIS_LOGIN_STRING_RECEIVED_LN];
|
||||
|
||||
#define APRSIS_TIMEOUT_MS 123000//123000
|
||||
|
||||
/**
|
||||
|
@ -181,8 +207,18 @@ aprsis_return_t aprsis_connect_and_login(const char * address, uint8_t address_l
|
|||
|
||||
int offset = 0;
|
||||
|
||||
aprsis_tx_counter = 0;
|
||||
|
||||
aprsis_keepalive_received_counter = 0;
|
||||
|
||||
aprsis_another_received_counter = 0;
|
||||
|
||||
aprsis_igated_counter = 0;
|
||||
|
||||
memset(port_str, 0x00, 0x6);
|
||||
|
||||
memset(aprsis_login_string_reveived, 0x00, APRSIS_LOGIN_STRING_RECEIVED_LN);
|
||||
|
||||
snprintf(port_str, 6, "%d", port);
|
||||
|
||||
// result of a disconnecting from APRS-IS server
|
||||
|
@ -208,6 +244,9 @@ aprsis_return_t aprsis_connect_and_login(const char * address, uint8_t address_l
|
|||
// send long string to server
|
||||
gsm_sim800_tcpip_write((uint8_t *)aprsis_login_string, strlen(aprsis_login_string), aprsis_serial_port, aprsis_gsm_modem_state);
|
||||
|
||||
// store received login string (with an information about which server is connected now)
|
||||
strncpy(aprsis_login_string_reveived, receive_buff + offset, APRSIS_LOGIN_STRING_RECEIVED_LN);
|
||||
|
||||
// wait for server response
|
||||
retval = gsm_sim800_tcpip_receive(0, 0, aprsis_serial_port, aprsis_gsm_modem_state, 0, 2000);
|
||||
|
||||
|
@ -231,6 +270,9 @@ aprsis_return_t aprsis_connect_and_login(const char * address, uint8_t address_l
|
|||
aprsis_send_beacon(0, aprsis_callsign_with_ssid, main_string_latitude, main_symbol_f, main_string_longitude, main_symbol_s, main_config_data_basic);
|
||||
}
|
||||
|
||||
// trigger GSM status packet
|
||||
rte_main_trigger_gsm_loginstring_packet = 1;
|
||||
|
||||
// set timeout for aprs-is server
|
||||
srl_switch_timeout(aprsis_serial_port, 1, APRSIS_TIMEOUT_MS);
|
||||
|
||||
|
@ -318,9 +360,13 @@ void aprsis_receive_callback(srl_context_t* srl_context) {
|
|||
if (*(srl_get_rx_buffer(srl_context)) == '#') {
|
||||
aprsis_last_keepalive_ts = main_get_master_time();
|
||||
|
||||
aprsis_keepalive_received_counter++;
|
||||
|
||||
gsm_sim800_tcpip_async_receive(aprsis_serial_port, aprsis_gsm_modem_state, 0, 61000, aprsis_receive_callback);
|
||||
}
|
||||
else {
|
||||
aprsis_another_received_counter++;
|
||||
|
||||
gsm_sim800_tcpip_async_receive(aprsis_serial_port, aprsis_gsm_modem_state, 0, 61000, aprsis_receive_callback);
|
||||
|
||||
}
|
||||
|
@ -390,6 +436,8 @@ void aprsis_send_wx_frame(
|
|||
return;
|
||||
}
|
||||
|
||||
aprsis_tx_counter++;
|
||||
|
||||
float max_wind_speed = 0.0f, temp = 0.0f;
|
||||
uint8_t wind_speed_mph = 0, wind_gusts_mph = 0;
|
||||
uint32_t pressure = 0;
|
||||
|
@ -420,8 +468,9 @@ void aprsis_send_wx_frame(
|
|||
|
||||
memset(aprsis_packet_tx_buffer, 0x00, sizeof(aprsis_packet_tx_buffer));
|
||||
// main_own_aprs_msg_len = sprintf(main_own_aprs_msg, "=%s%c%c%s%c%c %s", main_string_latitude, main_config_data_basic->n_or_s, main_symbol_f, main_string_longitude, main_config_data_basic->e_or_w, main_symbol_s, main_config_data_basic->comment);
|
||||
aprsis_packet_tx_message_size = sprintf(
|
||||
aprsis_packet_tx_message_size = snprintf(
|
||||
aprsis_packet_tx_buffer,
|
||||
APRSIS_TX_BUFFER_LN,
|
||||
"%s>AKLPRZ,qAR,%s:!%s%c%c%s%c%c%03d/%03dg%03dt%03dr...p...P...b%05ldh%02d\r\n",
|
||||
callsign_with_ssid,
|
||||
callsign_with_ssid,
|
||||
|
@ -461,8 +510,11 @@ void aprsis_send_beacon(
|
|||
return;
|
||||
}
|
||||
|
||||
aprsis_packet_tx_message_size = sprintf(
|
||||
aprsis_tx_counter++;
|
||||
|
||||
aprsis_packet_tx_message_size = snprintf(
|
||||
aprsis_packet_tx_buffer,
|
||||
APRSIS_TX_BUFFER_LN,
|
||||
"%s>AKLPRZ,qAR,%s:=%s%c%c%s%c%c %s\r\n",
|
||||
callsign_with_ssid,
|
||||
callsign_with_ssid,
|
||||
|
@ -498,6 +550,8 @@ void aprsis_igate_to_aprsis(AX25Msg *msg, const char * callsign_with_ssid) {
|
|||
return;
|
||||
}
|
||||
|
||||
aprsis_igated_counter++;
|
||||
|
||||
// prepare buffer for message
|
||||
memset(aprsis_packet_tx_buffer, 0x00, APRSIS_TX_BUFFER_LN);
|
||||
|
||||
|
@ -571,6 +625,46 @@ void aprsis_igate_to_aprsis(AX25Msg *msg, const char * callsign_with_ssid) {
|
|||
|
||||
}
|
||||
|
||||
void aprsis_send_server_conn_status(const char * callsign_with_ssid) {
|
||||
|
||||
if (aprsis_logged == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
memset (aprsis_packet_tx_buffer, 0x00, APRSIS_TX_BUFFER_LN);
|
||||
|
||||
aprsis_tx_counter++;
|
||||
|
||||
aprsis_packet_tx_message_size = snprintf(
|
||||
aprsis_packet_tx_buffer,
|
||||
APRSIS_TX_BUFFER_LN - 1,
|
||||
"%s>AKLPRZ,qAR,%s:>[aprsis][igated: %d][transmited: %d][keepalive: %d][another: %d]\r\n",
|
||||
callsign_with_ssid,
|
||||
callsign_with_ssid,
|
||||
aprsis_igated_counter,
|
||||
aprsis_tx_counter,
|
||||
aprsis_keepalive_received_counter,
|
||||
aprsis_another_received_counter);
|
||||
|
||||
gsm_sim800_tcpip_async_write((uint8_t *)aprsis_packet_tx_buffer, aprsis_packet_tx_message_size, aprsis_serial_port, aprsis_gsm_modem_state);
|
||||
}
|
||||
|
||||
void aprsis_send_loginstring(const char * callsign_with_ssid) {
|
||||
|
||||
if (aprsis_logged == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
memset (aprsis_packet_tx_buffer, 0x00, APRSIS_TX_BUFFER_LN);
|
||||
|
||||
aprsis_tx_counter++;
|
||||
|
||||
aprsis_packet_tx_message_size = snprintf(aprsis_packet_tx_buffer, APRSIS_TX_BUFFER_LN - 1, "%s>AKLPRZ,qAR,%s:>[aprsis][]%s\r\n", callsign_with_ssid, callsign_with_ssid, aprsis_login_string_reveived);
|
||||
|
||||
gsm_sim800_tcpip_async_write((uint8_t *)aprsis_packet_tx_buffer, aprsis_packet_tx_message_size, aprsis_serial_port, aprsis_gsm_modem_state);
|
||||
|
||||
}
|
||||
|
||||
char * aprsis_get_tx_buffer(void) {
|
||||
return aprsis_packet_tx_buffer;
|
||||
}
|
||||
|
|
23
src/main.c
23
src/main.c
|
@ -1188,7 +1188,7 @@ int main(int argc, char* argv[]){
|
|||
rte_main_rx_total++;
|
||||
|
||||
// if aprsis is logged
|
||||
if (aprsis_connected == 1) {
|
||||
if (aprsis_connected == 1 && gsm_sim800_tcpip_tx_busy() == 0) {
|
||||
aprsis_igate_to_aprsis(&ax25_rxed_frame, (const char *)&main_callsign_with_ssid);
|
||||
}
|
||||
|
||||
|
@ -1212,6 +1212,18 @@ int main(int argc, char* argv[]){
|
|||
gsm_sim800_tx_done_event_handler(main_gsm_srl_ctx_ptr, &main_gsm_state);
|
||||
}
|
||||
|
||||
if (rte_main_trigger_gsm_status_packet == 1 && gsm_sim800_tcpip_tx_busy() == 0) {
|
||||
rte_main_trigger_gsm_status_packet = 0;
|
||||
|
||||
aprsis_send_server_conn_status((const char *)&main_callsign_with_ssid);
|
||||
}
|
||||
|
||||
if (rte_main_trigger_gsm_loginstring_packet == 1 && gsm_sim800_tcpip_tx_busy() == 0) {
|
||||
rte_main_trigger_gsm_loginstring_packet = 0;
|
||||
|
||||
aprsis_send_loginstring((const char *)&main_callsign_with_ssid);
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1410,15 +1422,6 @@ int main(int argc, char* argv[]){
|
|||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
//aprsis_connect_and_login_default(1);
|
||||
|
||||
// if (gsm_sim800_gprs_ready == 1) {
|
||||
//
|
||||
// //api_send_json_status();
|
||||
// api_send_json_measuremenets();
|
||||
// // retval = http_client_async_get("http://pogoda.cc:8080/meteo_backend/status", strlen("http://pogoda.cc:8080/meteo_backend/status"), 0xFFF0, 0x1, 0);
|
||||
// }
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -57,8 +57,12 @@ uint8_t packet_tx_modbus_status = (uint8_t)(_TELEM_DESCR_INTERVAL - _WX_INTERVAL
|
|||
|
||||
uint8_t packet_tx_more_than_one = 0;
|
||||
|
||||
#ifdef STM32L471xx
|
||||
#ifdef PARAMETEO
|
||||
uint8_t packet_tx_trigger_tcp = 0;
|
||||
|
||||
uint8_t packet_tx_meteo_gsm_interval = 2;
|
||||
uint8_t packet_tx_meteo_gsm_counter = 0;
|
||||
|
||||
#define API_TRIGGER_STATUS (1 << 1)
|
||||
#define API_TRIGGER_METEO (1 << 2)
|
||||
#define APRSIS_TRIGGER_METEO (1 << 3)
|
||||
|
@ -120,10 +124,27 @@ void packet_tx_tcp_handler(void) {
|
|||
|
||||
if ((packet_tx_trigger_tcp & APRSIS_TRIGGER_METEO) != 0) {
|
||||
// TODO: fixme
|
||||
if (aprsis_connected == 0) {
|
||||
aprsis_result = aprsis_connect_and_login_default(0);
|
||||
if (gsm_sim800_tcpip_tx_busy() == 0) {
|
||||
|
||||
if (aprsis_result == APRSIS_OK) {
|
||||
if (aprsis_connected == 0) {
|
||||
aprsis_result = aprsis_connect_and_login_default(0);
|
||||
|
||||
if (aprsis_result == APRSIS_OK) {
|
||||
// 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,
|
||||
main_callsign_with_ssid,
|
||||
main_string_latitude,
|
||||
main_string_longitude,
|
||||
main_config_data_basic);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// send APRS-IS frame, if APRS-IS is not connected this function will return immediately
|
||||
aprsis_send_wx_frame(
|
||||
rte_wx_average_windspeed,
|
||||
|
@ -137,26 +158,10 @@ void packet_tx_tcp_handler(void) {
|
|||
main_string_longitude,
|
||||
main_config_data_basic);
|
||||
}
|
||||
// TODO: fixme
|
||||
// clear the bit
|
||||
packet_tx_trigger_tcp ^= APRSIS_TRIGGER_METEO;
|
||||
}
|
||||
else {
|
||||
// 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,
|
||||
main_callsign_with_ssid,
|
||||
main_string_latitude,
|
||||
main_string_longitude,
|
||||
main_config_data_basic);
|
||||
}
|
||||
// TODO: fixme
|
||||
|
||||
|
||||
// clear the bit
|
||||
packet_tx_trigger_tcp ^= APRSIS_TRIGGER_METEO;
|
||||
}
|
||||
else if ((packet_tx_trigger_tcp & API_TRIGGER_STATUS) != 0) {
|
||||
|
||||
|
@ -231,6 +236,7 @@ void packet_tx_handler(const config_data_basic_t * const config_basic, const con
|
|||
// increase these counters only when WX is enabled
|
||||
packet_tx_meteo_counter++;
|
||||
packet_tx_meteo_kiss_counter++;
|
||||
packet_tx_meteo_gsm_counter++;
|
||||
}
|
||||
|
||||
// check if there is a time to send own beacon
|
||||
|
@ -290,19 +296,6 @@ void packet_tx_handler(const config_data_basic_t * const config_basic, const con
|
|||
// service external watchdog while sending weather frame
|
||||
io_ext_watchdog_service();
|
||||
|
||||
#ifdef STM32L471xx
|
||||
if (main_config_data_gsm->aprsis_enable == 0 && main_config_data_gsm->api_enable == 1) {
|
||||
// and trigger API wx packet transmission
|
||||
packet_tx_trigger_tcp |= API_TRIGGER_METEO;
|
||||
}
|
||||
else if (main_config_data_gsm->aprsis_enable == 1 && main_config_data_gsm->api_enable == 0) {
|
||||
packet_tx_trigger_tcp |= APRSIS_TRIGGER_METEO;
|
||||
}
|
||||
else {
|
||||
packet_tx_trigger_tcp = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
// check if user want's to send two wx packets one after another
|
||||
if (main_config_data_basic->wx_double_transmit == 1) {
|
||||
rte_main_trigger_wx_packet = 1;
|
||||
|
@ -341,6 +334,23 @@ void packet_tx_handler(const config_data_basic_t * const config_basic, const con
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef PARAMETEO
|
||||
if (packet_tx_meteo_gsm_counter >= packet_tx_meteo_gsm_interval) {
|
||||
if (main_config_data_gsm->aprsis_enable == 0 && main_config_data_gsm->api_enable == 1) {
|
||||
// and trigger API wx packet transmission
|
||||
packet_tx_trigger_tcp |= API_TRIGGER_METEO;
|
||||
}
|
||||
else if (main_config_data_gsm->aprsis_enable == 1 && main_config_data_gsm->api_enable == 0) {
|
||||
packet_tx_trigger_tcp |= APRSIS_TRIGGER_METEO;
|
||||
}
|
||||
else {
|
||||
packet_tx_trigger_tcp = 0;
|
||||
}
|
||||
|
||||
packet_tx_meteo_gsm_counter = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
// send wx frame to KISS host once every two minutes
|
||||
if (packet_tx_meteo_kiss_counter >= packet_tx_meteo_kiss_interval && main_kiss_enabled == 1) {
|
||||
|
||||
|
@ -497,6 +507,7 @@ void packet_tx_handler(const config_data_basic_t * const config_basic, const con
|
|||
if (packet_tx_telemetry_descr_counter >= packet_tx_telemetry_descr_interval) {
|
||||
|
||||
#ifdef PARAMETEO
|
||||
rte_main_trigger_gsm_status_packet = 1;
|
||||
status_send_powersave_registers(REGISTER_LAST_SLEEP, REGISTER_LAST_WKUP, REGISTER_COUNTERS, REGISTER_MONITOR, REGISTER_LAST_SLTIM);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -19,6 +19,11 @@ uint8_t rte_main_trigger_modbus_status = 0;
|
|||
uint8_t rte_main_trigger_wx_packet = 0;
|
||||
|
||||
#ifdef PARAMETEO
|
||||
uint8_t rte_main_trigger_gsm_status_packet = 0;
|
||||
|
||||
//!< Trigger sending status packet with received APRS is login string
|
||||
uint8_t rte_main_trigger_gsm_loginstring_packet = 0;
|
||||
|
||||
//!< Trigger some reinitialization after waking up from deep sleep
|
||||
uint8_t rte_main_woken_up = 0;
|
||||
|
||||
|
|
|
@ -34,6 +34,8 @@ sim800_return_t gsm_sim800_tcpip_close(srl_context_t * srl_context, gsm_sim800_s
|
|||
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);
|
||||
|
||||
uint8_t gsm_sim800_tcpip_tx_busy(void);
|
||||
|
||||
uint8_t gsm_sim800_newline_terminating_callback(uint8_t current_data, const uint8_t * const rx_buffer, uint16_t rx_bytes_counter);
|
||||
|
||||
void gsm_sim800_tcpip_reset(void);
|
||||
|
|
|
@ -44,6 +44,9 @@ uint8_t gsm_sim800_tcpip_connection_died = 0;
|
|||
*/
|
||||
uint8_t gsm_sim800_tcpip_receiving = 0;
|
||||
|
||||
/**
|
||||
* If modem is busy with transmitting something
|
||||
*/
|
||||
uint8_t gsm_sim800_tcpip_transmitting = 0;
|
||||
|
||||
/**
|
||||
|
@ -411,6 +414,10 @@ void gsm_sim800_tcpip_tx_done_callback(srl_context_t * srl_context, gsm_sim800_s
|
|||
gsm_sim800_tcpip_transmitting = 0;
|
||||
}
|
||||
|
||||
uint8_t gsm_sim800_tcpip_tx_busy(void) {
|
||||
return gsm_sim800_tcpip_transmitting;
|
||||
}
|
||||
|
||||
uint8_t gsm_sim800_newline_terminating_callback(uint8_t current_data, const uint8_t * const rx_buffer, uint16_t rx_bytes_counter) {
|
||||
|
||||
sim800_return_t out = SIM800_OK;
|
||||
|
|
Ładowanie…
Reference in New Issue