kopia lustrzana https://github.com/SP8EBC/ParaTNC
do not try to do anything with gprs module before usart will be reinitialized after micro had woken up
rodzic
4429c67e9d
commit
2cd9c2f597
11
src/main.c
11
src/main.c
|
@ -610,9 +610,14 @@ int main(int argc, char* argv[]){
|
|||
wx_pwr_switch_periodic_handle();
|
||||
|
||||
#if defined(PARAMETEO)
|
||||
// clear all previous powersave indication bits
|
||||
backup_reg_reset_all_powersave_states();
|
||||
|
||||
// swtich power to M4. turn on sensors but keep GSM modem turned off
|
||||
pwr_save_switch_mode_to_c1();
|
||||
|
||||
rte_main_reset_gsm_modem = 0;
|
||||
|
||||
delay_fixed(300);
|
||||
|
||||
#endif
|
||||
|
@ -1515,7 +1520,7 @@ int main(int argc, char* argv[]){
|
|||
gsm_sim800_initialization_pool(main_gsm_srl_ctx_ptr, &main_gsm_state);
|
||||
}
|
||||
|
||||
if (main_config_data_mode->gsm == 1 && io_get_cntrl_vbat_g() == 1) {
|
||||
if (main_config_data_mode->gsm == 1 && io_get_cntrl_vbat_g() == 1 && rte_main_woken_up == 0) {
|
||||
|
||||
// check if GSM modem must be power-cycled / restarted like after
|
||||
// waking up from deep sleep or chaning power saving mode
|
||||
|
@ -1523,6 +1528,8 @@ int main(int argc, char* argv[]){
|
|||
// rest the flag
|
||||
rte_main_reset_gsm_modem = 0;
|
||||
|
||||
srl_init(main_gsm_srl_ctx_ptr, USART3, srl_usart3_rx_buffer, RX_BUFFER_3_LN, srl_usart3_tx_buffer, TX_BUFFER_3_LN, 115200, 1);
|
||||
|
||||
// reset gsm modem
|
||||
gsm_sim800_reset(&main_gsm_state);
|
||||
|
||||
|
@ -1651,7 +1658,7 @@ int main(int argc, char* argv[]){
|
|||
backup_reg_set_monitor(9);
|
||||
|
||||
#ifdef PARAMETEO
|
||||
if (main_config_data_mode->gsm == 1 && io_get_cntrl_vbat_g() == 1) {
|
||||
if (main_config_data_mode->gsm == 1 && io_get_cntrl_vbat_g() == 1 && rte_main_woken_up == 0) {
|
||||
gsm_sim800_poolers_ten_seconds(main_gsm_srl_ctx_ptr, &main_gsm_state);
|
||||
|
||||
packet_tx_tcp_handler();
|
||||
|
|
|
@ -350,6 +350,9 @@ int pwr_save_switch_mode_to_c1(void) {
|
|||
// disconnect APRS-IS connection if it is established
|
||||
aprsis_disconnect();
|
||||
|
||||
// close and deconfigure port used for communication with GPRS module
|
||||
srl_close(main_gsm_srl_ctx_ptr);
|
||||
|
||||
// turn ON +5V_S (and internal VHF radio module in HW-RevB)
|
||||
io___cntrl_vbat_s_enable();
|
||||
|
||||
|
@ -394,6 +397,9 @@ void pwr_save_switch_mode_to_c2(void) {
|
|||
// disconnect APRS-IS connection if it is established
|
||||
aprsis_disconnect();
|
||||
|
||||
// close and deconfigure port used for communication with GPRS module
|
||||
srl_close(main_gsm_srl_ctx_ptr);
|
||||
|
||||
// turn OFF +5V_S (and internal VHF radio module in HW-RevB)
|
||||
io___cntrl_vbat_s_disable();
|
||||
|
||||
|
@ -472,6 +478,9 @@ int pwr_save_switch_mode_to_m4(void) {
|
|||
// disconnect APRS-IS connection if it is established
|
||||
aprsis_disconnect();
|
||||
|
||||
// close and deconfigure port used for communication with GPRS module
|
||||
srl_close(main_gsm_srl_ctx_ptr);
|
||||
|
||||
// turn ON +5V_S (and internal VHF radio module in HW-RevB)
|
||||
io___cntrl_vbat_s_enable();
|
||||
|
||||
|
@ -551,6 +560,9 @@ void pwr_save_switch_mode_to_i5(void) {
|
|||
// disconnect APRS-IS connection if it is established
|
||||
aprsis_disconnect();
|
||||
|
||||
// close and deconfigure port used for communication with GPRS module
|
||||
srl_close(main_gsm_srl_ctx_ptr);
|
||||
|
||||
// turn OFF +5V_S (and internal VHF radio module in HW-RevB)
|
||||
io___cntrl_vbat_s_disable();
|
||||
|
||||
|
@ -616,6 +628,9 @@ void pwr_save_switch_mode_to_l6(uint16_t sleep_time) {
|
|||
// disconnect APRS-IS connection if it is established
|
||||
aprsis_disconnect();
|
||||
|
||||
NVIC_DisableIRQ( USART3_IRQn );
|
||||
|
||||
// close and deconfigure port used for communication with GPRS module
|
||||
srl_close(main_gsm_srl_ctx_ptr);
|
||||
|
||||
// disable ADC used for vbat measurement
|
||||
|
@ -711,6 +726,7 @@ void pwr_save_switch_mode_to_l7(uint16_t sleep_time) {
|
|||
// disconnect APRS-IS connection if it is established
|
||||
aprsis_disconnect();
|
||||
|
||||
// close and deconfigure port used for communication with GPRS module
|
||||
srl_close(main_gsm_srl_ctx_ptr);
|
||||
|
||||
// disable ADC used for vbat measurement
|
||||
|
@ -814,8 +830,6 @@ void pwr_save_init(config_data_powersave_mode_t mode) {
|
|||
|
||||
}
|
||||
|
||||
//pwr_save_unclock_rtc_backup_regs();
|
||||
|
||||
// reset a status register
|
||||
backup_reg_reset_all_powersave_states();
|
||||
backup_reg_reset_inhibit_periodic_pwr_switch();
|
||||
|
@ -1006,6 +1020,8 @@ config_data_powersave_mode_t pwr_save_pooling_handler( const config_data_mode_t
|
|||
if (timers->wx_transmit_period >= 5) {
|
||||
if (minutes_to_wx > 1) {
|
||||
pwr_save_switch_mode_to_c2();
|
||||
|
||||
//reinit_gprs = 1;
|
||||
}
|
||||
else {
|
||||
reinit_sensors = pwr_save_switch_mode_to_c0();
|
||||
|
@ -1024,6 +1040,8 @@ config_data_powersave_mode_t pwr_save_pooling_handler( const config_data_mode_t
|
|||
if (minutes_to_wx > 1) {
|
||||
if (config->powersave_keep_gsm_always_enabled == 0){
|
||||
reinit_sensors = pwr_save_switch_mode_to_m4();
|
||||
|
||||
//reinit_gprs = 1;
|
||||
}
|
||||
else {
|
||||
reinit_sensors = pwr_save_switch_mode_to_m4a();
|
||||
|
@ -1082,6 +1100,8 @@ config_data_powersave_mode_t pwr_save_pooling_handler( const config_data_mode_t
|
|||
if (config->digi == 1) { // DIGI + WX + GSM
|
||||
if (minutes_to_wx > 1) {
|
||||
pwr_save_switch_mode_to_c2();
|
||||
|
||||
//reinit_gprs = 1;
|
||||
}
|
||||
else {
|
||||
reinit_sensors = pwr_save_switch_mode_to_c0();
|
||||
|
@ -1110,6 +1130,8 @@ config_data_powersave_mode_t pwr_save_pooling_handler( const config_data_mode_t
|
|||
// if there is 30 to 60 seconds to next wx packet
|
||||
if (config->powersave_keep_gsm_always_enabled == 0){
|
||||
reinit_sensors = pwr_save_switch_mode_to_m4();
|
||||
|
||||
//reinit_gprs = 1;
|
||||
}
|
||||
else {
|
||||
reinit_sensors = pwr_save_switch_mode_to_m4a();
|
||||
|
|
Ładowanie…
Reference in New Issue