drivers: modem: BG9X wait for RDY instead of polling AT.
BG9X wait for RDY instead of polling AT. Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
This commit is contained in:
parent
15dfec4df6
commit
084a8b6bf4
2 changed files with 11 additions and 31 deletions
|
@ -97,34 +97,6 @@ static inline int find_len(char *data)
|
|||
return ATOI(buf, 0, "rx_buf");
|
||||
}
|
||||
|
||||
/* Func: modem_at
|
||||
* Desc: Send "AT" command to the modem and wait for it to
|
||||
* respond. If the modem doesn't respond after some time, give
|
||||
* up and kill the driver.
|
||||
*/
|
||||
static int modem_at(struct modem_context *mctx, struct modem_data *mdata)
|
||||
{
|
||||
int counter = 0, ret = -1;
|
||||
|
||||
do {
|
||||
|
||||
/* Send "AT" command to the modem. */
|
||||
ret = modem_cmd_send(&mctx->iface, &mctx->cmd_handler,
|
||||
NULL, 0, "AT", &mdata->sem_response,
|
||||
MDM_CMD_TIMEOUT);
|
||||
|
||||
/* Check the response from the Modem. */
|
||||
if (ret < 0 && ret != -ETIMEDOUT) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
counter++;
|
||||
k_sleep(K_SECONDS(2));
|
||||
} while (counter < MDM_MAX_AT_RETRIES && ret < 0);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Func: on_cmd_sockread_common
|
||||
* Desc: Function to successfully read data from the modem on a given socket.
|
||||
*/
|
||||
|
@ -443,6 +415,13 @@ MODEM_CMD_DEFINE(on_cmd_unsol_close)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* Handler: Modem initialization ready. */
|
||||
MODEM_CMD_DEFINE(on_cmd_unsol_rdy)
|
||||
{
|
||||
k_sem_give(&mdata.sem_response);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Func: send_socket_data
|
||||
* Desc: This function will send "binary" data over the socket object.
|
||||
*/
|
||||
|
@ -941,6 +920,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, ""),
|
||||
};
|
||||
|
||||
/* Commands sent to the modem to set it up at boot time. */
|
||||
|
@ -1023,9 +1003,9 @@ restart:
|
|||
|
||||
/* Let the modem respond. */
|
||||
LOG_INF("Waiting for modem to respond");
|
||||
ret = modem_at(&mctx, &mdata);
|
||||
ret = k_sem_take(&mdata.sem_response, MDM_MAX_BOOT_TIME);
|
||||
if (ret < 0) {
|
||||
LOG_ERR("MODEM WAIT LOOP ERROR: %d", ret);
|
||||
LOG_ERR("Timeout waiting for RDY");
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#define MDM_WAIT_FOR_RSSI_COUNT 10
|
||||
#define MDM_WAIT_FOR_RSSI_DELAY K_SECONDS(2)
|
||||
#define BUF_ALLOC_TIMEOUT K_SECONDS(1)
|
||||
#define MDM_MAX_AT_RETRIES 50
|
||||
#define MDM_MAX_BOOT_TIME K_SECONDS(50)
|
||||
|
||||
/* Default lengths of certain things. */
|
||||
#define MDM_MANUFACTURER_LENGTH 10
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue