/* Performs the autobaud sequence until modem answers or limit is reached. */
static int modem_autobaud(void)
/* Performs the autobaud sequence until modem answers or limit is reached. */
static int modem_autobaud(void)
{
	int boot_tries = 0;
	int counter = 0;
	int ret;
	while (boot_tries++ <= MDM_BOOT_TRIES) {
		modem_pwrkey();
		counter = 0;
		while (counter < MDM_MAX_AUTOBAUD) {
			ret = modem_cmd_send(&mctx.iface, &mctx.cmd_handler, NULL, 0U, "AT",
					     &mdata.sem_response, K_MSEC(500));
			if (ret == 0) {
				return modem_cmd_send(&mctx.iface, &mctx.cmd_handler, NULL, 0U,
						      "ATE0", &mdata.sem_response, K_SECONDS(2));
			}
			counter++;
		}
	}
	return -1;
}