kopia lustrzana https://github.com/SP8EBC/ParaTNC
inhibit GSM mdoule reset for few minutes if few errors in the row is detected, like SIM card is not working or it cannot register into the network
rodzic
4102d7495b
commit
45d02a7486
|
@ -19,7 +19,9 @@ typedef enum gsm_sim800_state_t {
|
|||
SIM800_ALIVE,
|
||||
SIM800_ALIVE_SENDING_TO_MODEM,
|
||||
SIM800_ALIVE_WAITING_MODEM_RESP,
|
||||
SIM800_TCP_CONNECTED
|
||||
SIM800_TCP_CONNECTED,
|
||||
SIM800_INHIBITED,
|
||||
SIM800_INHIBITED_RESET_COUNTER,
|
||||
}gsm_sim800_state_t;
|
||||
|
||||
#endif /* INCLUDE_GSM_SIM800_STATE_T_H_ */
|
||||
|
|
|
@ -36,4 +36,6 @@ uint16_t gsm_sim800_get_response_start_idx(void);
|
|||
|
||||
void gsm_sim800_create_status(char * buffer, int ln);
|
||||
|
||||
void gsm_sim800_decrease_counter(void);
|
||||
|
||||
#endif /* INCLUDE_GSM_SIM800C_H_ */
|
||||
|
|
|
@ -53,6 +53,18 @@ static const char * TRANSPARENT_MODE_ON = "AT+CIPMODE=1\r\0";
|
|||
|
||||
uint32_t gsm_time_of_last_command_send_to_module = 0;
|
||||
|
||||
//! Counter used to inhibit too frequent module resets, if it has no no sense
|
||||
static int16_t gsm_reset_counter = 0;
|
||||
|
||||
//!< how much reset counter is incremented each reset
|
||||
#define GSM_RESET_COUNTER_INCREMENT 50u
|
||||
|
||||
//!< how much reset counter is decremented in 10 seconds pooler
|
||||
#define GSM_RESET_COUNTER_DECREMENT 2u
|
||||
|
||||
//! A limit above which next reset attempts will be inhibited until counter will be decreased
|
||||
#define GSM_RESET_COUNTER_LIMIT 151u
|
||||
|
||||
//! let's the library know if gsm module echoes every AT command send through serial port
|
||||
static uint8_t gsm_at_comm_echo = 1;
|
||||
|
||||
|
@ -90,6 +102,7 @@ sim800_network_status_t gsm_sim800_network_status = NETWORK_STATUS_UNKNOWN;
|
|||
//! A delay in seconds between requesting for SIM card status and a request for network status
|
||||
int8_t gsm_sim800_registration_delay_seconds = 8;
|
||||
|
||||
//! Signal level in dBm obtained from engineering AT command
|
||||
int8_t gsm_sim800_signal_level_dbm = 0;
|
||||
|
||||
float gsm_sim800_bcch_frequency = 0;
|
||||
|
@ -280,7 +293,17 @@ void gsm_sim800_initialization_pool(srl_context_t * srl_context, gsm_sim800_stat
|
|||
// turn power off
|
||||
gsm_sim800_power_off();
|
||||
|
||||
*state = SIM800_POWERED_OFF;
|
||||
if (gsm_reset_counter > GSM_RESET_COUNTER_LIMIT) {
|
||||
*state = SIM800_INHIBITED_RESET_COUNTER;
|
||||
}
|
||||
else {
|
||||
*state = SIM800_POWERED_OFF;
|
||||
}
|
||||
}
|
||||
else if (*state == SIM800_INHIBITED_RESET_COUNTER) {
|
||||
if (gsm_reset_counter < GSM_RESET_COUNTER_LIMIT) {
|
||||
*state = SIM800_POWERED_OFF;
|
||||
}
|
||||
}
|
||||
else if (*state == SIM800_POWERED_OFF) {
|
||||
gsm_sim800_power_on();
|
||||
|
@ -881,6 +904,8 @@ void gsm_sim800_reset(gsm_sim800_state_t * state) {
|
|||
sim800_gprs_reset();
|
||||
|
||||
gsm_sim800_tcpip_reset();
|
||||
|
||||
gsm_reset_counter += GSM_RESET_COUNTER_INCREMENT;
|
||||
}
|
||||
|
||||
void gsm_sim800_create_status(char * buffer, int ln) {
|
||||
|
@ -896,7 +921,7 @@ void gsm_sim800_create_status(char * buffer, int ln) {
|
|||
snprintf(
|
||||
buffer,
|
||||
ln,
|
||||
">[GSM status][network: %s][signal: %ddBm][freq: %s][cellid: %s][lac: %s]",
|
||||
">[GSM status][network: %s][signal: %ddBm][freq: %sMHz][cellid: %s][lac: %s]",
|
||||
gsm_sim800_registered_network,
|
||||
gsm_sim800_signal_level_dbm,
|
||||
freq,
|
||||
|
@ -904,3 +929,12 @@ void gsm_sim800_create_status(char * buffer, int ln) {
|
|||
gsm_sim800_lac);
|
||||
}
|
||||
}
|
||||
|
||||
void gsm_sim800_decrease_counter(void) {
|
||||
if (gsm_reset_counter > 0) {
|
||||
gsm_reset_counter -= GSM_RESET_COUNTER_DECREMENT;
|
||||
}
|
||||
else if (gsm_reset_counter < 0) {
|
||||
gsm_reset_counter = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -204,6 +204,6 @@ void sim800_gprs_reset(void){
|
|||
void sim800_gprs_create_status(char * buffer, int ln) {
|
||||
// check if output buffer has been provided
|
||||
if (buffer != 0) {
|
||||
snprintf(buffer, ln, "[IP: %s]", gsm_sim800_ip_address);
|
||||
snprintf(buffer, ln, "[IP addr: %s]", gsm_sim800_ip_address);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,8 @@ void gsm_sim800_poolers_ten_seconds(srl_context_t * srl_context, gsm_sim800_stat
|
|||
aprsis_connect_and_login_default(1);
|
||||
}
|
||||
|
||||
gsm_sim800_decrease_counter();
|
||||
|
||||
}
|
||||
|
||||
void gsm_sim800_poolers_one_second(srl_context_t * srl_context, gsm_sim800_state_t * state, const config_data_gsm_t * config) {
|
||||
|
|
Ładowanie…
Reference in New Issue