From 3cf92bce1107bccaba1eebe66719e1379231ecaa Mon Sep 17 00:00:00 2001 From: Andrei Hutanu Date: Sat, 22 Apr 2023 11:24:01 +0200 Subject: [PATCH] drivers: modem: quectel-bg9x: mdm unsol ready Using bg9x driver with bg95 specifically has the issue that BG95 modem replies with "RDY" when it's not fully initialized and AT commands sent to the modem after this point would result in modem reply of "ERROR". This commit adds a new prj.conf field in the build configuration for custom unsolicited app ready string, with the default being BG96 one ("RDY"). Signed-off-by: Andrei Hutanu --- drivers/modem/Kconfig.quectel-bg9x | 8 ++++++++ drivers/modem/quectel-bg9x.c | 2 +- drivers/modem/quectel-bg9x.h | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/modem/Kconfig.quectel-bg9x b/drivers/modem/Kconfig.quectel-bg9x index a71dc280567..ec6a3efa20d 100644 --- a/drivers/modem/Kconfig.quectel-bg9x +++ b/drivers/modem/Kconfig.quectel-bg9x @@ -54,6 +54,14 @@ config MODEM_QUECTEL_BG9X_PASSWORD context. This value is specific to the network provider and may need to be changed. +config MODEM_QUECTEL_BG9X_UNSOL_RDY + string "Unsolicited response string expected from the modem" + default "RDY" + help + This string is used to determine when modem powered and ready + to accept AT commands. If this value is not matching the modem + response, the init will fail with timeout. + config MODEM_QUECTEL_BG9X_INIT_PRIORITY int "quectel BG9X driver init priority" default 80 diff --git a/drivers/modem/quectel-bg9x.c b/drivers/modem/quectel-bg9x.c index 2513a8fae38..55c12282fd1 100644 --- a/drivers/modem/quectel-bg9x.c +++ b/drivers/modem/quectel-bg9x.c @@ -921,7 +921,7 @@ static const struct modem_cmd response_cmds[] = { static const struct modem_cmd unsol_cmds[] = { MODEM_CMD("+QIURC: \"recv\",", on_cmd_unsol_recv, 1U, ""), MODEM_CMD("+QIURC: \"closed\",", on_cmd_unsol_close, 1U, ""), - MODEM_CMD("RDY", on_cmd_unsol_rdy, 0U, ""), + MODEM_CMD(MDM_UNSOL_RDY, on_cmd_unsol_rdy, 0U, ""), }; /* Commands sent to the modem to set it up at boot time. */ diff --git a/drivers/modem/quectel-bg9x.h b/drivers/modem/quectel-bg9x.h index be5cd69b5e1..7fe51ef747e 100644 --- a/drivers/modem/quectel-bg9x.h +++ b/drivers/modem/quectel-bg9x.h @@ -53,6 +53,7 @@ #define MDM_APN_LENGTH 32 #define RSSI_TIMEOUT_SECS 30 +#define MDM_UNSOL_RDY CONFIG_MODEM_QUECTEL_BG9X_UNSOL_RDY #define MDM_APN CONFIG_MODEM_QUECTEL_BG9X_APN #define MDM_USERNAME CONFIG_MODEM_QUECTEL_BG9X_USERNAME #define MDM_PASSWORD CONFIG_MODEM_QUECTEL_BG9X_PASSWORD