kopia lustrzana https://github.com/SP8EBC/ParaTNC
both api added
rodzic
6eded06c6c
commit
a284074f74
|
@ -10,5 +10,6 @@
|
|||
|
||||
void api_init(char * api_base, char * station_name);
|
||||
void api_send_json_status(void);
|
||||
void api_send_json_measuremenets(void);
|
||||
|
||||
#endif /* API_H_ */
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "main.h"
|
||||
#include "rte_main.h"
|
||||
#include "rte_wx.h"
|
||||
#include "drivers/l4/pwm_input_stm32l4x.h"
|
||||
|
||||
#define ENTRIES_STRING(ENTRY) \
|
||||
ENTRY(main_config_data_basic->callsign, callsign) \
|
||||
|
@ -45,6 +46,10 @@
|
|||
ENTRY(rte_wx_average_windspeed, wind_speed) \
|
||||
ENTRY(rte_wx_max_windspeed, wind_gust) \
|
||||
|
||||
#define ENTRIES_32INT_WEATHER(ENTRY) \
|
||||
ENTRY(pwm_first_channel, pwm_first) \
|
||||
ENTRY(pwm_second_channel, pwm_second) \
|
||||
|
||||
#endif /* API_STATUS_CONTENT_H_ */
|
||||
|
||||
/**
|
||||
|
|
|
@ -29,5 +29,6 @@
|
|||
|
||||
#define PRINT_ALL_MEASUREMENTS \
|
||||
ENTRIES_16INT_WEATHER(PRINT_16INT) \
|
||||
ENTRIES_32INT_WEATHER(PRINT_32INT) \
|
||||
|
||||
#endif /* API_XMACRO_HELPERS_H_ */
|
||||
|
|
25
src/api.c
25
src/api.c
|
@ -72,7 +72,7 @@ static void api_construct_url_status(api_endpoint_t endpoint) {
|
|||
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, URL_BUFFER_LN - 1, "%s/parameteo/%s/wx", api_base_url, api_station_name);
|
||||
snprintf(api_url_buffer, URL_BUFFER_LN - 1, "%s/parameteo/%s/measurements", api_base_url, api_station_name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ void api_send_json_status(void) {
|
|||
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);
|
||||
api_retval = http_client_async_post(api_url_buffer, strlen(api_url_buffer), OUT, strlen(OUT), 0, api_callback);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -107,27 +107,10 @@ void api_send_json_measuremenets(void) {
|
|||
END
|
||||
|
||||
if (api_buffer_idx < API_BUFFER_LN) {
|
||||
api_construct_url_status(PARAMETEO_STATUS);
|
||||
api_construct_url_status(PARAMETEO_WX);
|
||||
|
||||
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);
|
||||
api_retval = http_client_async_post(api_url_buffer, strlen(api_url_buffer), 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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1250,7 +1250,8 @@ int main(int argc, char* argv[]){
|
|||
|
||||
if (gsm_sim800_gprs_ready == 1) {
|
||||
|
||||
api_send_json_status();
|
||||
//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);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,9 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
extern uint32_t pwm_first_channel;
|
||||
extern uint32_t pwm_second_channel;
|
||||
|
||||
void pwm_input_io_init(void);
|
||||
void pwm_input_init(uint8_t channel);
|
||||
void pwm_input_pool(void);
|
||||
|
|
Ładowanie…
Reference in New Issue