mirror of
https://github.com/espressif/esp-protocols.git
synced 2025-11-16 23:39:47 +01:00
feat(modem): Add enhanced URC observer API
This commit is contained in:
@@ -38,6 +38,15 @@ work with commands differently. This might be useful to add some custom preproce
|
||||
Please check the ``modem_console`` example with ``CONFIG_EXAMPLE_MODEM_DEVICE_SHINY=y`` configuration which demonstrates
|
||||
overriding default ``command()`` method to implement URC processing in user space.
|
||||
|
||||
Enhanced URC (Unsolicited Result Code) Handling
|
||||
------------------------------------------------
|
||||
|
||||
The ESP modem library provides two interfaces for handling URCs: a legacy callback-based interface and an enhanced interface with granular buffer consumption control. The enhanced interface, available through :cpp:func:`esp_modem::DCE_T::set_enhanced_urc`, provides complete buffer visibility and allows URC handlers to make precise decisions about buffer consumption. This is particularly useful for processing multi-part responses or when you need to consume only specific portions of the buffer while preserving other data for command processing.
|
||||
|
||||
The enhanced URC handler receives a :cpp:struct:`esp_modem::DTE::UrcBufferInfo` structure containing the complete buffer context, including what data has been processed, what's new, and whether a command is currently active. The handler returns a :cpp:struct:`esp_modem::DTE::UrcConsumeInfo` structure specifying how much of the buffer to consume: none (wait for more data), partial (consume specific amount), or all (consume entire buffer). This granular control enables sophisticated URC processing scenarios such as line-by-line parsing of chunked HTTP responses or selective processing based on command state.
|
||||
|
||||
For applications migrating from the legacy URC interface, the enhanced interface maintains backward compatibility while providing significantly more control over buffer management. The legacy :cpp:func:`esp_modem::DCE_T::set_urc` method continues to work as before, but new applications should consider using the enhanced interface for better buffer control and processing flexibility.
|
||||
|
||||
Create new communication interface
|
||||
----------------------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user