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

AT+CFUN=0/AT+CFUN=4 is not confirned with "OK".(NCS1.3.0)

I add lte_lc_init_and_connect() to the application "Serial LTE Modem" (SLM) v1.3.0. And then there's no reaction to AT+CFUN=0 or AT+CFUN=4.

static int modem_configure(void){
#if defined(CONFIG_BSD_LIBRARY)
	if (IS_ENABLED(CONFIG_LTE_AUTO_INIT_AND_CONNECT)) {
		/* Do nothing, modem is already turned on */
		/* and connected */
		goto connected;
	}

	LOG_INF("Connecting to LTE network.");
	LOG_INF("This may take several minutes.");

#if defined(CONFIG_LWM2M_CARRIER)
	/* Wait for the LWM2M carrier library to configure the */
	/* modem and set up the LTE connection. */
	k_sem_take(&lte_connected, K_FOREVER);
#else /* defined(CONFIG_LWM2M_CARRIER) */
	int err = lte_lc_init_and_connect();
	if (err) {
		LOG_ERR("LTE link could not be established.");
		return err;
	}
#endif /* defined(CONFIG_LWM2M_CARRIER) */

connected:
	LOG_INF("Connected to LTE network.");

#endif /* defined(CONFIG_BSD_LIBRARY) */
	return 0;
}

void start_execute(void)
{
	int err;

	LOG_INF("Serial LTE Modem");

+	while (modem_configure() != 0) {
+		LOG_WRN("Failed to establish LTE connection.");
+		LOG_WRN("Will retry in %d seconds.", 10);
+		k_sleep(K_SECONDS(10));
+	}

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

	modem_info_params_init(&modem_param);

	/* Initialize AT Parser */
	err = at_params_list_init(&at_param_list, CONFIG_SLM_AT_MAX_PARAM);
	if (err) {
		LOG_ERR("Failed to init AT Parser: %d", err);
		return;
	}

	err = slm_at_host_init();
	if (err) {
		LOG_ERR("Failed to init at_host: %d", err);
		return;
	}

	k_work_q_start(&slm_work_q, slm_wq_stack_area,
		K_THREAD_STACK_SIZEOF(slm_wq_stack_area), SLM_WQ_PRIORITY);
	k_work_init(&exit_idle_work, exit_idle);
}

I find that the socket_thread_fn() in at_cmd.c does not respond "OK\r\n".

It returns "+CSCON: 1\r\n" and  "+CEREG: 0,"1D2C","0D61D950",9,0,0,"11100000","11100000"\r\n"

        

So no messages are put on the queue. The program is blocked at_write().

static inline int at_write(const char *const cmd, enum at_cmd_state *state)
{
	int bytes_sent;
	int bytes_to_send = strlen(cmd);
	struct return_state_object ret;

	LOG_DBG("Sending command %s", log_strdup(cmd));

	bytes_sent = send(common_socket_fd, cmd, bytes_to_send, 0);

	if (bytes_sent == -1) {
		LOG_ERR("Failed to send AT command (err:%d)", errno);
		ret.code  = -errno;
		ret.state = AT_CMD_ERROR;
	} else {
		LOG_DBG("Awaiting response for %s", log_strdup(cmd));
		k_msgq_get(&return_code_msq, &ret, K_FOREVER);   //It's blocked here
		LOG_DBG("Bytes sent: %d", bytes_sent);

		if (bytes_sent != bytes_to_send) {
			LOG_ERR("Bytes sent (%d) was not the "
				"same as expected (%d)",
				bytes_sent, bytes_to_send);
		}
	}

	if (state) {
		*state = ret.state;
	}

	return ret.code;
}

Parents Reply Children
No Data
Related