Skip to content

Commit

Permalink
drivers: modem: introducing config for cereg/creg for gsm
Browse files Browse the repository at this point in the history
This contribution addresses the support for various types of modems in
gsm driver. As some 4G modems have failed to return correct output
from AT+CREG?, so AT+CEREG? is the right AT command in such situation.
This commit provides the possibility for user to select one type of
AT command. This PR fixes #63917

Signed-off-by: Tahir Akram <mtahirbutt@hotmail.com>
  • Loading branch information
mtahirbutt authored and carlescufi committed Oct 20, 2023
1 parent adf6d0e commit 7c7c8f1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
19 changes: 19 additions & 0 deletions drivers/modem/Kconfig.gsm
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,25 @@ config MODEM_GSM_QUECTEL

endchoice

choice MODEM_GSM_STATUS_COMMAND
prompt "Select status command Type"
default MODEM_GSM_STATUS_CMD_USE_CREG
help
Use particular type of AT command for cell tower registration status.

config MODEM_GSM_STATUS_CMD_USE_CREG
bool "CREG command"

config MODEM_GSM_STATUS_CMD_USE_CEREG
bool "CEREG command"

endchoice

config MODEM_GSM_STATUS_COMMAND
string "Status Command"
default "CREG" if MODEM_GSM_STATUS_CMD_USE_CREG
default "CEREG" if MODEM_GSM_STATUS_CMD_USE_CEREG

config MODEM_GSM_RX_STACK_SIZE
int "Size of the stack allocated for receiving data from modem"
default 512
Expand Down
4 changes: 2 additions & 2 deletions drivers/modem/gsm_ppp.c
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ static const struct modem_cmd read_cops_cmd =
MODEM_CMD_ARGS_MAX("+COPS:", on_cmd_atcmdinfo_cops, 1U, 4U, ",");

static const struct modem_cmd check_net_reg_cmd =
MODEM_CMD("+CREG: ", on_cmd_net_reg_sts, 2U, ",");
MODEM_CMD("+" CONFIG_MODEM_GSM_STATUS_COMMAND, on_cmd_net_reg_sts, 2U, ",");

static const struct modem_cmd check_attached_cmd =
MODEM_CMD("+CGATT:", on_cmd_atcmdinfo_attached, 1U, ",");
Expand Down Expand Up @@ -751,7 +751,7 @@ static void gsm_finalize_connection(struct k_work *work)
ret = modem_cmd_send_nolock(&gsm->context.iface,
&gsm->context.cmd_handler,
&check_net_reg_cmd, 1,
"AT+CREG?",
"AT+" CONFIG_MODEM_GSM_STATUS_COMMAND "?",
&gsm->sem_response,
GSM_CMD_SETUP_TIMEOUT);
if ((ret < 0) || ((gsm->net_state != GSM_NET_ROAMING) &&
Expand Down

0 comments on commit 7c7c8f1

Please sign in to comment.