diff --git a/drivers/modem/modem_cmd_handler.c b/drivers/modem/modem_cmd_handler.c index 99b15480515..2b63aed76dd 100644 --- a/drivers/modem/modem_cmd_handler.c +++ b/drivers/modem/modem_cmd_handler.c @@ -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, diff --git a/drivers/modem/modem_cmd_handler.h b/drivers/modem/modem_cmd_handler.h index 017097b2346..9ac4ba9ac00 100644 --- a/drivers/modem/modem_cmd_handler.h +++ b/drivers/modem/modem_cmd_handler.h @@ -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 *