kopia lustrzana https://github.com/SP8EBC/ParaTNC
daily
rodzic
ef312e6af5
commit
b5d0a25ffc
|
@ -51,6 +51,7 @@
|
|||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor.822266293" name="Use preprocessor" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.include.paths.925232361" name="Include paths (-I)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.include.paths" useByScannerDiscovery="false" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""../include""/>
|
||||
<listOptionValue builtIn="false" value=""../include/etc""/>
|
||||
<listOptionValue builtIn="false" value=""../system/include""/>
|
||||
<listOptionValue builtIn="false" value=""../system/include/cmsis""/>
|
||||
<listOptionValue builtIn="false" value=""../system/include/stm32f1-stdperiph""/>
|
||||
|
@ -67,6 +68,7 @@
|
|||
<tool command="${cross_prefix}${cross_c}${cross_suffix}" id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.1002686397" name="Cross ARM C Compiler" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler">
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.include.paths.550212459" name="Include paths (-I)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.include.paths" useByScannerDiscovery="false" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""../include""/>
|
||||
<listOptionValue builtIn="false" value=""../include/etc""/>
|
||||
<listOptionValue builtIn="false" value=""../system/include/tiny-aes""/>
|
||||
<listOptionValue builtIn="false" value=""../system/include/aprs""/>
|
||||
<listOptionValue builtIn="false" value=""../system/include""/>
|
||||
|
@ -87,6 +89,7 @@
|
|||
<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler.204317376" name="Cross ARM C++ Compiler" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler">
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.include.paths.312663181" name="Include paths (-I)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.include.paths" useByScannerDiscovery="false" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""../include""/>
|
||||
<listOptionValue builtIn="false" value=""../include/etc""/>
|
||||
<listOptionValue builtIn="false" value=""../system/include/aprs""/>
|
||||
<listOptionValue builtIn="false" value=""../system/include""/>
|
||||
<listOptionValue builtIn="false" value=""../system/include/cmsis""/>
|
||||
|
@ -298,6 +301,7 @@
|
|||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor.714026364" name="Use preprocessor" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.include.paths.1580258863" name="Include paths (-I)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.include.paths" useByScannerDiscovery="false" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""../include""/>
|
||||
<listOptionValue builtIn="false" value=""../include/etc""/>
|
||||
<listOptionValue builtIn="false" value=""../system/include""/>
|
||||
<listOptionValue builtIn="false" value=""../system/include/cmsis/stm32l4xx""/>
|
||||
<listOptionValue builtIn="false" value=""../system/include/cmsis/stm32l4xx/device""/>
|
||||
|
@ -318,6 +322,7 @@
|
|||
<tool command="${cross_prefix}${cross_c}${cross_suffix}" id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.270124285" name="Cross ARM C Compiler" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler">
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.include.paths.1201867945" name="Include paths (-I)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.include.paths" useByScannerDiscovery="false" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""../include""/>
|
||||
<listOptionValue builtIn="false" value=""../include/etc""/>
|
||||
<listOptionValue builtIn="false" value=""../system/include/tiny-aes""/>
|
||||
<listOptionValue builtIn="false" value=""../system/include/aprs""/>
|
||||
<listOptionValue builtIn="false" value=""../system/include""/>
|
||||
|
@ -345,6 +350,7 @@
|
|||
<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler.1656265940" name="Cross ARM C++ Compiler" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler">
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.include.paths.1267602053" name="Include paths (-I)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.include.paths" useByScannerDiscovery="false" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""../include""/>
|
||||
<listOptionValue builtIn="false" value=""../include/etc""/>
|
||||
<listOptionValue builtIn="false" value=""../system/include/aprs""/>
|
||||
<listOptionValue builtIn="false" value=""../system/include""/>
|
||||
<listOptionValue builtIn="false" value=""../system/include/cmsis/stm32l4xx""/>
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
#include "rte_main.h"
|
||||
#include "rte_wx.h"
|
||||
|
||||
#define ENTRIES_STRING(ENTRY) \
|
||||
ENTRY(main_config_data_basic->callsign, callsign) \
|
||||
|
||||
#define ENTRIES_32INT_STATUS(ENTRY) \
|
||||
ENTRY(master_time, master_time) \
|
||||
ENTRY(rte_main_rx_total, rx_total) \
|
||||
|
@ -30,6 +33,7 @@
|
|||
ENTRY(rte_main_average_battery_voltage, average_battery_voltage) \
|
||||
ENTRY(rte_main_wakeup_count, wakeup_count) \
|
||||
ENTRY(rte_main_going_sleep_count, going_sleep_count) \
|
||||
ENTRY(main_config_data_basic->ssid, ssid) \
|
||||
|
||||
|
||||
#define ENTRIES_16INT_WEATHER(ENTRY) \
|
||||
|
@ -38,7 +42,7 @@
|
|||
ENTRY(rte_wx_temperature_average_internal, temperature_internal)\
|
||||
ENTRY(rte_wx_pressure_average, pressure) \
|
||||
ENTRY(rte_wx_average_winddirection, wind_direction) \
|
||||
ENTRY(rte_wx_average_windspeed, wind_gust) \
|
||||
ENTRY(rte_wx_average_windspeed, wind_speed) \
|
||||
ENTRY(rte_wx_max_windspeed, wind_gust) \
|
||||
|
||||
#endif /* API_STATUS_CONTENT_H_ */
|
||||
|
|
|
@ -16,14 +16,18 @@
|
|||
LN = sprintf(OUT + LN, "{\r\n"); \
|
||||
|
||||
|
||||
#define PRINT_32INT(integer, name) LN += sprintf(OUT + LN, "" #name ":%ld,", integer);
|
||||
#define PRINT_16INT(integer, name) LN += sprintf(OUT + LN, "" #name ":%d,", integer);
|
||||
#define PRINT_STRING(integer, name) LN += sprintf(OUT + LN, "" #name ":%s,", integer);
|
||||
#define PRINT_32INT(integer, name) LN += sprintf(OUT + LN, "\"" #name "\":%ld,", integer);
|
||||
#define PRINT_16INT(integer, name) LN += sprintf(OUT + LN, "\"" #name "\":%d,", integer);
|
||||
#define PRINT_STRING(string, name) LN += sprintf(OUT + LN, "\"" #name "\":\"%s\",", string);
|
||||
#define END LN += sprintf(OUT + LN - 1, "}\r\n");
|
||||
|
||||
|
||||
#define PRINT_ALL_STATUS \
|
||||
ENTRIES_32INT_STATUS(PRINT_32INT); \
|
||||
ENTRIES_16INT_STATUS(PRINT_16INT); \
|
||||
ENTRIES_STRING(PRINT_STRING); \
|
||||
|
||||
#define PRINT_ALL_MEASUREMENTS \
|
||||
ENTRIES_16INT_WEATHER(PRINT_16INT) \
|
||||
|
||||
#endif /* API_XMACRO_HELPERS_H_ */
|
||||
|
|
|
@ -13,8 +13,10 @@
|
|||
|
||||
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);
|
||||
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);
|
||||
void aprsis_disconnect(void);
|
||||
void aprsis_receive_callback(srl_context_t* srl_context);
|
||||
void aprsis_check_alive(void);
|
||||
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* api_configuration.h
|
||||
*
|
||||
* Created on: Apr 30, 2022
|
||||
* Author: mateusz
|
||||
*/
|
||||
|
||||
#ifndef API_CONFIGURATION_H_
|
||||
#define API_CONFIGURATION_H_
|
||||
|
||||
// API cycle are fired once every minute and counts from zero
|
||||
// up to 100 and then starts again. These defines controls how
|
||||
// often in minutes API communication is triggered
|
||||
|
||||
#define API_STATUS_CALL_CYCLE_INTERVAL 20
|
||||
#define API_MEASUREMENTS_CALL_CYCLE_INTERVAL 5
|
||||
|
||||
#endif /* API_CONFIGURATION_H_ */
|
72
src/api.c
72
src/api.c
|
@ -8,7 +8,8 @@
|
|||
* 19 maja, Krszystof Binek, miedy 12 a 13
|
||||
*/
|
||||
|
||||
#include <api/api_status_content.h>
|
||||
#include "api/api_status_content.h"
|
||||
#include "etc/api_configuration.h"
|
||||
|
||||
#include "http_client/http_client.h"
|
||||
|
||||
|
@ -17,14 +18,38 @@
|
|||
/**
|
||||
* Buffers for generating JSON and URL
|
||||
*/
|
||||
#define API_BUFFER_LN 256
|
||||
#define API_BUFFER_LN 384
|
||||
char api_buffer[API_BUFFER_LN];
|
||||
#define URL_BUFFER_LN 96
|
||||
char api_url_buffer[URL_BUFFER_LN];
|
||||
|
||||
int api_buffer_idx = 0;
|
||||
/**
|
||||
* Index to move around a buffer with request body
|
||||
*/
|
||||
uint32_t api_buffer_idx = 0;
|
||||
|
||||
/**
|
||||
* Value returned from http client
|
||||
*/
|
||||
uint8_t api_retval = 0xFF;
|
||||
|
||||
/**
|
||||
* Cycle counter to control the frequency of api calls
|
||||
*/
|
||||
int8_t api_cycle_counter = 0;
|
||||
|
||||
/**
|
||||
* This is used to retrigger specific api communication in case of any request
|
||||
* appears on the same call to `api_pooler` function. For code simplicity only one
|
||||
* API request is possible in the single 'api_pooler' cycle
|
||||
*/
|
||||
#define API_TRIGGER_STATUS (1 << 1)
|
||||
#define API_TRIGGER_MEASUREMENTS (1 << 2)
|
||||
int8_t api_retrigger_api_call = 0;
|
||||
|
||||
/**
|
||||
* Pointers to base url and station name (stored within flash)
|
||||
*/
|
||||
const char * api_base_url;
|
||||
const char * api_station_name;
|
||||
|
||||
|
@ -34,6 +59,8 @@ typedef enum api_endpoint{
|
|||
PARAMETEO_WX
|
||||
} api_endpoint_t;
|
||||
|
||||
#define LN api_buffer_idx
|
||||
#define OUT api_buffer
|
||||
|
||||
static void api_construct_url_status(api_endpoint_t endpoint) {
|
||||
|
||||
|
@ -42,10 +69,10 @@ static void api_construct_url_status(api_endpoint_t endpoint) {
|
|||
|
||||
switch (endpoint) {
|
||||
case PARAMETEO_STATUS:
|
||||
snprintf(api_url_buffer, API_BUFFER_LN - 1, "%s/parameteo/%s/status", api_base_url, api_station_name);
|
||||
snprintf(api_url_buffer, URL_BUFFER_LN - 1, "%s/parameteo/%s/status", api_base_url, api_station_name);
|
||||
break;
|
||||
case PARAMETEO_WX:
|
||||
snprintf(api_url_buffer, API_BUFFER_LN - 1, "%s/parameteo/%s/wx", api_base_url, api_station_name);
|
||||
snprintf(api_url_buffer, URL_BUFFER_LN - 1, "%s/parameteo/%s/wx", api_base_url, api_station_name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -54,6 +81,7 @@ static void api_construct_url_status(api_endpoint_t endpoint) {
|
|||
|
||||
static void api_callback(uint16_t http_code, char * content, uint16_t content_lenght) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
void api_init(const char * api_base, const char * station_name) {
|
||||
|
@ -62,16 +90,44 @@ void api_init(const char * api_base, const char * station_name) {
|
|||
}
|
||||
|
||||
void api_send_json_status(void) {
|
||||
#define LN api_buffer_idx
|
||||
#define OUT api_buffer
|
||||
BEGIN
|
||||
PRINT_ALL_STATUS
|
||||
END
|
||||
|
||||
if (api_buffer_idx < 256) {
|
||||
if (api_buffer_idx < API_BUFFER_LN) {
|
||||
api_construct_url_status(PARAMETEO_STATUS);
|
||||
|
||||
api_retval = http_client_async_post(api_url_buffer, strlen("http://pogoda.cc:8080/meteo_backend/parameteo/skrzyczne/status"), OUT, strlen(OUT), 0, api_callback);
|
||||
}
|
||||
}
|
||||
|
||||
void api_send_json_measuremenets(void) {
|
||||
BEGIN
|
||||
PRINT_ALL_MEASUREMENTS
|
||||
END
|
||||
|
||||
if (api_buffer_idx < API_BUFFER_LN) {
|
||||
api_construct_url_status(PARAMETEO_STATUS);
|
||||
|
||||
api_retval = http_client_async_post(api_url_buffer, strlen("http://pogoda.cc:8080/meteo_backend/parameteo/skrzyczne/status"), OUT, strlen(OUT), 0, api_callback);
|
||||
}
|
||||
}
|
||||
|
||||
void api_pooler(void) {
|
||||
|
||||
api_cycle_counter++;
|
||||
|
||||
if (api_cycle_counter > 100) {
|
||||
api_cycle_counter = 0;
|
||||
}
|
||||
|
||||
if ((api_cycle_counter % API_STATUS_CALL_CYCLE_INTERVAL) == 0) {
|
||||
api_send_json_status();
|
||||
}
|
||||
|
||||
if ((api_cycle_counter % API_MEASUREMENTS_CALL_CYCLE_INTERVAL) == 0) {
|
||||
api_send_json_measuremenets();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
41
src/aprsis.c
41
src/aprsis.c
|
@ -40,17 +40,35 @@ int32_t aprsis_passcode;
|
|||
*/
|
||||
char aprsis_login_string[64];
|
||||
|
||||
/**
|
||||
* Default APRS-IS address to be used by
|
||||
*/
|
||||
const char * aprsis_default_server_address;
|
||||
|
||||
uint16_t aprsis_default_server_address_ln = 0;
|
||||
|
||||
uint16_t aprsis_default_server_port;
|
||||
|
||||
/**
|
||||
* Set to one if connections is established AND user is logged
|
||||
*/
|
||||
uint8_t aprsis_logged = 0;
|
||||
|
||||
/**
|
||||
* Set to one if connection to server is established (but maybe not logged)
|
||||
*/
|
||||
uint8_t aprsis_connected = 0;
|
||||
|
||||
const char * aprsis_sucessfull_login = "# logresp\0";
|
||||
|
||||
/**
|
||||
* A timestamp when server has send anything
|
||||
*/
|
||||
uint32_t aprsis_last_keepalive_ts = 0;
|
||||
|
||||
#define APRSIS_TIMEOUT_MS 123000//123000
|
||||
|
||||
void aprsis_init(srl_context_t * context, gsm_sim800_state_t * gsm_modem_state, char * callsign, uint8_t ssid, uint32_t passcode) {
|
||||
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) {
|
||||
aprsis_serial_port = context;
|
||||
|
||||
aprsis_gsm_modem_state = gsm_modem_state;
|
||||
|
@ -65,10 +83,16 @@ void aprsis_init(srl_context_t * context, gsm_sim800_state_t * gsm_modem_state,
|
|||
|
||||
aprsis_logged = 0;
|
||||
|
||||
aprsis_default_server_port = default_port;
|
||||
|
||||
aprsis_default_server_address = default_server;
|
||||
|
||||
aprsis_default_server_address_ln = strlen(aprsis_default_server_address);
|
||||
|
||||
}
|
||||
|
||||
uint8_t aprsis_connect_and_login(char * address, uint8_t address_ln, uint16_t port) {
|
||||
|
||||
// this function has blocking io
|
||||
uint8_t out = 2;
|
||||
|
||||
if (aprsis_serial_port == 0 || aprsis_gsm_modem_state == 0 || aprsis_logged == 1) {
|
||||
|
@ -151,6 +175,19 @@ uint8_t aprsis_connect_and_login(char * address, uint8_t address_ln, uint16_t po
|
|||
|
||||
}
|
||||
|
||||
uint8_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);
|
||||
}
|
||||
|
||||
void aprsis_disconnect(void) {
|
||||
gsm_sim800_tcpip_close(aprsis_serial_port, aprsis_gsm_modem_state);
|
||||
|
||||
aprsis_logged = 0;
|
||||
|
||||
aprsis_connected = 0;
|
||||
}
|
||||
|
||||
void aprsis_receive_callback(srl_context_t* srl_context) {
|
||||
|
||||
// if something was actually received
|
||||
|
|
15
src/main.c
15
src/main.c
|
@ -958,7 +958,8 @@ int main(int argc, char* argv[]){
|
|||
http_client_init(&main_gsm_state, main_gsm_srl_ctx_ptr, 0);
|
||||
|
||||
api_init("http://pogoda.cc:8080/meteo_backend\0", "skrzyczne\0");
|
||||
//aprsis_init(&main_gsm_srl_ctx, &main_gsm_state, "SP8EBC", 10, 23220);
|
||||
|
||||
aprsis_init(&main_gsm_srl_ctx, &main_gsm_state, "SP8EBC", 10, 23220, TEST_IP, 14580);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1230,6 +1231,9 @@ int main(int argc, char* argv[]){
|
|||
main_wx_sensors_pool_timer = 65500;
|
||||
}
|
||||
|
||||
/**
|
||||
* ONE MINUTE POOLING
|
||||
*/
|
||||
if (main_one_minute_pool_timer < 10) {
|
||||
|
||||
main_set_monitor(4);
|
||||
|
@ -1258,6 +1262,9 @@ int main(int argc, char* argv[]){
|
|||
main_one_minute_pool_timer = 60000;
|
||||
}
|
||||
|
||||
/**
|
||||
* ONE SECOND POOLING
|
||||
*/
|
||||
if (main_one_second_pool_timer < 10) {
|
||||
|
||||
main_set_monitor(6);
|
||||
|
@ -1302,6 +1309,9 @@ int main(int argc, char* argv[]){
|
|||
main_one_second_pool_timer = 1000;
|
||||
}
|
||||
|
||||
/**
|
||||
* TWO SECOND POOLING
|
||||
*/
|
||||
if (main_two_second_pool_timer < 10) {
|
||||
|
||||
wx_check_force_i2c_reset();
|
||||
|
@ -1315,6 +1325,9 @@ int main(int argc, char* argv[]){
|
|||
main_two_second_pool_timer = 2000;
|
||||
}
|
||||
|
||||
/**
|
||||
* TEN SECOND POOLING
|
||||
*/
|
||||
if (main_ten_second_pool_timer < 10) {
|
||||
|
||||
main_set_monitor(8);
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include "config_data.h"
|
||||
|
||||
void gsm_sim800_poolers_one_minute(srl_context_t * srl_context, gsm_sim800_state_t * state);
|
||||
void gsm_sim800_poolers_five_minutes(srl_context_t * srl_context, gsm_sim800_state_t * state);
|
||||
void gsm_sim800_poolers_one_second(srl_context_t * srl_context, gsm_sim800_state_t * state, const config_data_gsm_t * config);
|
||||
|
||||
#endif /* INCLUDE_GSM_SIM800C_POOLERS_H_ */
|
||||
|
|
|
@ -26,16 +26,6 @@ void gsm_sim800_poolers_one_minute(srl_context_t * srl_context, gsm_sim800_state
|
|||
|
||||
}
|
||||
|
||||
|
||||
void gsm_sim800_poolers_five_minutes(srl_context_t * srl_context, gsm_sim800_state_t * state) {
|
||||
sim800_poolers_five++;
|
||||
|
||||
if (sim800_poolers_five == 5) {
|
||||
sim800_poolers_five = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void gsm_sim800_poolers_one_second(srl_context_t * srl_context, gsm_sim800_state_t * state, const config_data_gsm_t * config) {
|
||||
|
||||
if (*state == SIM800_ALIVE) {
|
||||
|
|
Ładowanie…
Reference in New Issue