drivers: modem: Add helper function to send data on modem cmd iface

Add helper function to send data on modem command handler interface.
This makes sure that when verbose logging is enabled all data is
actually logged.

Signed-off-by: Joakim Andersson <joerchan@gmail.com>
This commit is contained in:
Joakim Andersson 2025-02-18 10:28:24 +01:00 committed by Benjamin Cabé
parent 8cea4ce5da
commit 0617b25126
2 changed files with 26 additions and 0 deletions

View File

@ -486,6 +486,20 @@ int modem_cmd_handler_update_cmds(struct modem_cmd_handler_data *data,
return 0;
}
int modem_cmd_send_data_nolock(struct modem_iface *iface,
const uint8_t *buf, size_t len)
{
#if defined(CONFIG_MODEM_CONTEXT_VERBOSE_DEBUG)
if (len > 256) {
/* Truncate the message, since too long log messages gets dropped somewhere. */
LOG_HEXDUMP_DBG(buf, 256, "SENT DIRECT DATA (truncated)");
} else {
LOG_HEXDUMP_DBG(buf, len, "SENT DIRECT DATA");
}
#endif
return iface->write(iface, buf, len);
}
int modem_cmd_send_ext(struct modem_iface *iface,
struct modem_cmd_handler *handler,
const struct modem_cmd *handler_cmds,

View File

@ -158,6 +158,18 @@ int modem_cmd_handler_update_cmds(struct modem_cmd_handler_data *data,
size_t handler_cmds_len,
bool reset_error_flag);
/**
* @brief send data directly to interface w/o TX lock.
*
* This function just writes directly to the modem interface.
* Recommended to use to get verbose logging for all data sent to the interface.
* @param iface: interface to use
* @param buf: send buffer (not NULL terminated)
* @param len: length of send buffer.
*/
int modem_cmd_send_data_nolock(struct modem_iface *iface,
const uint8_t *buf, size_t len);
/**
* @brief send AT command to interface with behavior defined by flags
*