kopia lustrzana https://github.com/SP8EBC/ParaTNC
added M4a powersave mode which allows to keep gsm modem enabled in normal powersave modes, added missing api fields
rodzic
ee69308488
commit
00e4adbbdd
|
@ -57,6 +57,6 @@
|
|||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="4"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList context="Context string"/> "/>
|
||||
<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList context="Context string"> <memoryBlockExpression address="536876736" label="api_buffer"/> </memoryBlockExpressionList> "/>
|
||||
<stringAttribute key="process_factory_id" value="org.eclipse.cdt.dsf.gdb.GdbProcessFactory"/>
|
||||
</launchConfiguration>
|
||||
|
|
|
@ -45,14 +45,15 @@
|
|||
ENTRY(rte_wx_temperature_average_internal, temperature_internal)\
|
||||
ENTRY(rte_wx_temperature_average_modbus, temperature_modbus)\
|
||||
ENTRY(rte_wx_pressure_average, pressure) \
|
||||
ENTRY(rte_wx_humidity_valid, humidity) \
|
||||
ENTRY(rte_wx_humidity, humidity) \
|
||||
ENTRY(rte_wx_average_winddirection, wind_direction) \
|
||||
ENTRY(rte_wx_average_windspeed, wind_average) \
|
||||
ENTRY(rte_wx_max_windspeed, wind_gust) \
|
||||
ENTRY(rte_wx_windspeed[rte_wx_windspeed_it], wind_current) \
|
||||
ENTRY(rte_wx_get_minimum_windspeed(), wind_minimal) \
|
||||
ENTRY(rte_wx_pm2_5, rte_wx_pm2_5) \
|
||||
ENTRY(rte_wx_pm10, rte_wx_pm10) \
|
||||
ENTRY(rte_wx_pm2_5, pm2_5) \
|
||||
ENTRY(rte_wx_pm10, pm10) \
|
||||
ENTRY(main_config_data_basic->ssid, ssid) \
|
||||
|
||||
#define ENTRIES_32INT_WEATHER(ENTRY) \
|
||||
ENTRY(master_time, master_time) \
|
||||
|
@ -60,6 +61,7 @@
|
|||
|
||||
#define ENTRIES_STRING_WEATHER(ENTRY) \
|
||||
ENTRY(main_config_data_basic->callsign, callsign) \
|
||||
ENTRY(api_mac, api_mac) \
|
||||
|
||||
|
||||
#endif /* API_STATUS_CONTENT_H_ */
|
||||
|
|
|
@ -70,6 +70,9 @@ typedef struct config_data_mode_t {
|
|||
// only for ParaMETEO
|
||||
config_data_powersave_mode_t powersave;
|
||||
|
||||
// only for ParaMETEO - keeps GSM modem always on if GSM is configured to be used
|
||||
uint8_t powersave_keep_gsm_always_enabled;
|
||||
|
||||
// only for ParaMETEO
|
||||
uint8_t gsm;
|
||||
|
||||
|
|
|
@ -15,4 +15,6 @@
|
|||
#define API_STATUS_CALL_CYCLE_INTERVAL 20
|
||||
#define API_MEASUREMENTS_CALL_CYCLE_INTERVAL 5
|
||||
|
||||
#define API_SHARED_SECRET {0x64, 0x75, 0x70, 0x61, 0x6A, 0x61, 0x73, 0x69, 0x61, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x00}
|
||||
|
||||
#endif /* API_CONFIGURATION_H_ */
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "config_data.h"
|
||||
|
||||
#define SW_VER "EA07"
|
||||
#define SW_DATE "08062022"
|
||||
#define SW_DATE "09062022"
|
||||
|
||||
#define SYSTICK_TICKS_PER_SECONDS 100
|
||||
#define SYSTICK_TICKS_PERIOD 10
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
* | C2 |Running| OFF | ON | OFF | ON |
|
||||
* | C3 |Running| OFF | ON | ON | ON |
|
||||
* | M4 |Running| ON | OFF | OFF | OFF |
|
||||
* | M4a |Running| ON | OFF | ON | OFF |
|
||||
* | I5 |Running| OFF | OFF | OFF | OFF |
|
||||
* | L6 | Stop2 | OFF | OFF | ON | OFF |
|
||||
* | L7 | Stop2 | OFF | OFF | OFF | OFF |
|
||||
|
@ -76,7 +77,8 @@
|
|||
*
|
||||
*
|
||||
*
|
||||
* Transitions between states depends on configuration and value of config_data_powersave_mode_t
|
||||
* Transitions between states depends on configuration and value of config_data_powersave_mode_t.
|
||||
* If 'powersave_keep_gsm_always_enabled' is set to one, the controller will swtich to modem M4a instead of M4
|
||||
*
|
||||
* ====================================================================================================================================|
|
||||
* | Mode | Powersave Mode | |
|
||||
|
@ -117,6 +119,7 @@ int pwr_save_switch_mode_to_c1(void);
|
|||
void pwr_save_switch_mode_to_c2(void);
|
||||
void pwr_save_switch_mode_to_c3(void);
|
||||
int pwr_save_switch_mode_to_m4(void);
|
||||
int pwr_save_switch_mode_to_m4a(void);
|
||||
void pwr_save_switch_mode_to_i5(void);
|
||||
void pwr_save_switch_mode_to_l6(uint16_t sleep_time);
|
||||
void pwr_save_switch_mode_to_l7(uint16_t sleep_time);
|
||||
|
|
20
src/api.c
20
src/api.c
|
@ -14,6 +14,7 @@
|
|||
#include "http_client/http_client.h"
|
||||
|
||||
#include "stdint.h"
|
||||
#include "aes.h"
|
||||
|
||||
/**
|
||||
* Buffers for generating JSON and URL
|
||||
|
@ -38,6 +39,22 @@ uint8_t api_retval = 0xFF;
|
|||
*/
|
||||
int8_t api_cycle_counter = 0;
|
||||
|
||||
/**
|
||||
* Message authentication code encrypted by AES128 and converted to hex string
|
||||
*/
|
||||
char api_mac[33];
|
||||
|
||||
/**
|
||||
* Buffer to perform encryption of the MAC
|
||||
*/
|
||||
uint8_t api_aes_mac_buffer[16];
|
||||
|
||||
struct AES_ctx api_aes_context;
|
||||
|
||||
const uint8_t api_shared_secret[] = API_SHARED_SECRET;
|
||||
|
||||
const uint8_t api_iv[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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
|
||||
|
@ -89,6 +106,9 @@ static void api_callback(uint16_t http_code, char * content, uint16_t content_le
|
|||
void api_init(const char * api_base, const char * station_name) {
|
||||
api_base_url = api_base;
|
||||
api_station_name = station_name;
|
||||
AES_init_ctx_iv(&api_aes_context, api_shared_secret, api_iv);
|
||||
memset(api_mac, 0x00, 33);
|
||||
memset(api_mac, '0', 32);
|
||||
}
|
||||
|
||||
void api_send_json_status(void) {
|
||||
|
|
|
@ -117,9 +117,15 @@ const config_data_mode_t __attribute__((section(".config_section_default.mode"))
|
|||
#endif
|
||||
|
||||
#if (defined _GSM)
|
||||
.gsm = 1
|
||||
.gsm = 1,
|
||||
#else
|
||||
.gsm = 0
|
||||
.gsm = 0,
|
||||
#endif
|
||||
|
||||
#if (defined _GSM_KEEP_MODEM_ALWAYS_ON)
|
||||
.powersave_keep_gsm_always_enabled = 1
|
||||
#else
|
||||
.powersave_keep_gsm_always_enabled = 0
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -121,9 +121,15 @@ const config_data_mode_t __attribute__((section(".config_section_first.mode")))
|
|||
#endif
|
||||
|
||||
#if (defined _GSM)
|
||||
.gsm = 1
|
||||
.gsm = 1,
|
||||
#else
|
||||
.gsm = 0
|
||||
.gsm = 0,
|
||||
#endif
|
||||
|
||||
#if (defined _GSM_KEEP_MODEM_ALWAYS_ON)
|
||||
.powersave_keep_gsm_always_enabled = 1
|
||||
#else
|
||||
.powersave_keep_gsm_always_enabled = 0
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -115,9 +115,15 @@ const config_data_mode_t __attribute__((section(".config_section_second.mode")))
|
|||
#endif
|
||||
|
||||
#if (defined _GSM)
|
||||
.gsm = 1
|
||||
.gsm = 1,
|
||||
#else
|
||||
.gsm = 0
|
||||
.gsm = 0,
|
||||
#endif
|
||||
|
||||
#if (defined _GSM_KEEP_MODEM_ALWAYS_ON)
|
||||
.powersave_keep_gsm_always_enabled = 1
|
||||
#else
|
||||
.powersave_keep_gsm_always_enabled = 0
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -460,6 +460,38 @@ int pwr_save_switch_mode_to_m4(void) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int pwr_save_switch_mode_to_m4a(void) {
|
||||
if ((REGISTER & ALL_STATES_BITMASK) == IN_M4_STATE) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// turn ON +5V_S (and internal VHF radio module in HW-RevB)
|
||||
io___cntrl_vbat_s_enable();
|
||||
|
||||
// turn OFF +5V_R and VBATT_SW_R
|
||||
io___cntrl_vbat_r_disable();
|
||||
|
||||
// turn OFF +4V_G
|
||||
io___cntrl_vbat_g_enable();
|
||||
|
||||
// turn ON +5V_C (SD card, PT100 interface and Op Amplifier)
|
||||
io___cntrl_vbat_c_enable();
|
||||
|
||||
// unlock access to backup registers
|
||||
pwr_save_unclock_rtc_backup_regs();
|
||||
|
||||
// clear all previous powersave indication bits
|
||||
REGISTER &= (0xFFFFFFFF ^ ALL_STATES_BITMASK);
|
||||
|
||||
// set for C3 mode
|
||||
REGISTER |= IN_M4_STATE;
|
||||
|
||||
// lock access to backup
|
||||
pwr_save_lock_rtc_backup_regs();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void pwr_save_switch_mode_to_i5(void) {
|
||||
|
||||
if ((REGISTER & ALL_STATES_BITMASK) == IN_I5_STATE) {
|
||||
|
@ -717,7 +749,12 @@ void pwr_save_pooling_handler(const config_data_mode_t * config, const config_da
|
|||
}
|
||||
else { // WX
|
||||
if (minutes_to_wx > 2) {
|
||||
reinit_sensors = pwr_save_switch_mode_to_m4();
|
||||
if (config->powersave_keep_gsm_always_enabled == 0){
|
||||
reinit_sensors = pwr_save_switch_mode_to_m4();
|
||||
}
|
||||
else {
|
||||
reinit_sensors = pwr_save_switch_mode_to_m4a();
|
||||
}
|
||||
}
|
||||
else {
|
||||
reinit_sensors = pwr_save_switch_mode_to_c0();
|
||||
|
@ -768,7 +805,12 @@ void pwr_save_pooling_handler(const config_data_mode_t * config, const config_da
|
|||
}
|
||||
else { // WX + GSM
|
||||
if (minutes_to_wx > 1) {
|
||||
reinit_sensors = pwr_save_switch_mode_to_m4();
|
||||
if (config->powersave_keep_gsm_always_enabled == 0){
|
||||
reinit_sensors = pwr_save_switch_mode_to_m4();
|
||||
}
|
||||
else {
|
||||
reinit_sensors = pwr_save_switch_mode_to_m4a();
|
||||
}
|
||||
}
|
||||
else {
|
||||
reinit_sensors = pwr_save_switch_mode_to_c0();
|
||||
|
@ -843,7 +885,12 @@ void pwr_save_pooling_handler(const config_data_mode_t * config, const config_da
|
|||
}
|
||||
else {
|
||||
// if there is 30 to 60 seconds to next wx packet
|
||||
reinit_sensors = pwr_save_switch_mode_to_m4();
|
||||
if (config->powersave_keep_gsm_always_enabled == 0){
|
||||
reinit_sensors = pwr_save_switch_mode_to_m4();
|
||||
}
|
||||
else {
|
||||
reinit_sensors = pwr_save_switch_mode_to_m4a();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -888,7 +935,12 @@ void pwr_save_pooling_handler(const config_data_mode_t * config, const config_da
|
|||
reinit_sensors = 0;
|
||||
}
|
||||
else {
|
||||
reinit_sensors= pwr_save_switch_mode_to_m4();
|
||||
if (config->powersave_keep_gsm_always_enabled == 0){
|
||||
reinit_sensors = pwr_save_switch_mode_to_m4();
|
||||
}
|
||||
else {
|
||||
reinit_sensors = pwr_save_switch_mode_to_m4a();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
#include "wx_handler_pressure.h"
|
||||
#include "wx_handler_temperature.h"
|
||||
#include "wx_handler.h"
|
||||
|
||||
#include "rte_wx.h"
|
||||
|
@ -25,7 +26,7 @@ int32_t wx_get_pressure_measurement(const config_data_wx_sources_t * const confi
|
|||
float pressure_average_sum = 0.0f;
|
||||
umb_qf_t umb_quality_factor = UMB_QF_UNITIALIZED; // quality factor for UMB communication
|
||||
|
||||
switch(config_sources->temperature) {
|
||||
switch(config_sources->pressure) {
|
||||
case WX_SOURCE_INTERNAL: {
|
||||
|
||||
// switch between MS5611 and BME280 depends on user configuration
|
||||
|
@ -41,6 +42,14 @@ int32_t wx_get_pressure_measurement(const config_data_wx_sources_t * const confi
|
|||
// BME280 measures all three things at one call to the driver
|
||||
output |= WX_HANDLER_PARAMETER_RESULT_PRESSURE;
|
||||
|
||||
// get internal temperature
|
||||
if (config_mode->wx_ms5611_or_bme == 1) {
|
||||
measurement_retval = wx_get_temperature_bme280(&rte_wx_temperature_internal);
|
||||
}
|
||||
else {
|
||||
measurement_retval = wx_get_temperature_ms5611(&rte_wx_temperature_internal);
|
||||
}
|
||||
|
||||
// add the current pressure into buffer for average calculation
|
||||
rte_wx_pressure_history[rte_wx_pressure_it++] = rte_wx_pressure;
|
||||
|
||||
|
@ -115,6 +124,11 @@ int32_t wx_get_pressure_measurement(const config_data_wx_sources_t * const confi
|
|||
break;
|
||||
}
|
||||
|
||||
#if defined(STM32L471xx)
|
||||
rte_wx_pressure_average = (uint16_t)(rte_wx_pressure_valid * 10.0f);
|
||||
|
||||
#endif
|
||||
|
||||
return output;
|
||||
|
||||
}
|
||||
|
|
|
@ -126,6 +126,8 @@ int32_t wx_get_temperature_measurement(const config_data_wx_sources_t * const co
|
|||
if (config_sources->temperature != WX_SOURCE_INTERNAL) {
|
||||
wx_get_temperature_dallas();
|
||||
}
|
||||
|
||||
rte_wx_temperature_average_internal = (int16_t)(rte_wx_temperature_internal * 10.0f);
|
||||
#endif
|
||||
|
||||
return parameter_result;
|
||||
|
|
Ładowanie…
Reference in New Issue