This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to get the signal strength value of NB quickly after power on

I have a 9160 project, users hope to display on the screen as soon as possible in the boot of operators NB signal value, actual test when I found this problem, on the product pcba board, I use the AT command to open the modem, and then call the function, only later modem will give me back the signal value of the current environment,like this:

#if CONFIG_MODEM_INFO
/**@brief Callback handler for LTE RSRP data. */
static void modem_rsrp_handler(char rsrp_value)
{
	/* RSRP raw values that represent actual signal strength are
	 * 0 through 97 (per "nRF91 AT Commands" v1.1). If the received value
	 * falls outside this range, we should not send the value.
	 */
	LOG_INF("rsrp_value:%d\n", rsrp_value);

	if(rsrp_value > 97)
	{
		g_nb_sig = NB_SIG_LEVEL_NO;
	}
	else if(rsrp_value >= 80)
	{
		g_nb_sig = NB_SIG_LEVEL_4;
	}
	else if(rsrp_value >= 60)
	{
		g_nb_sig = NB_SIG_LEVEL_3;
	}
	else if(rsrp_value >= 40)
	{
		g_nb_sig = NB_SIG_LEVEL_2;
	}
	else if(rsrp_value >= 20)
	{
		g_nb_sig = NB_SIG_LEVEL_1;
	}
	else
	{
		g_nb_sig = NB_SIG_LEVEL_0;
	}

	nb_redraw_sig_flag = true;
}

/**brief Initialize LTE status containers. */
void modem_data_init(void)
{
	int err;

	err = modem_info_init();
	if(err)
	{
		LOG_INF("Modem info could not be established: %d", err);
		return;
	}

	modem_info_params_init(&modem_param);
	modem_info_rsrp_register(modem_rsrp_handler);
}
#endif /* CONFIG_MODEM_INFO */


void NB_init(void)
{
	u8_t tmpbuf[128] = {0};
	
	if(at_cmd_write("AT+CFUN=1", NULL, 0, NULL) != 0)
	{
		LOG_INF("Set modem on fail!\n");
		return;
	}

	modem_data_init();

	k_timer_start(&get_modem_timer, K_MSEC(2000), NULL);
}

.But I found on the development board, this effect, but there was no return signal value has always been 255, behind my reference sample code, registration and networking operation, lte_lc_init_and_connect(); so although you can get to the signal value, but Internet is very slow, and the system is in a wait state, so to the user feel very bad, why can't development board like the one above, please directly register callback function?

void NB_init(void)
{
	u8_t tmpbuf[128] = {0};
	
	lte_lc_init_and_connect();
	modem_data_init();

	k_timer_start(&get_modem_timer, K_MSEC(2000), NULL);
}

Related