Skip to content

drivers: modem_cellular: added APP RDY signal handling #93052

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

petrosyan-van
Copy link
Contributor

@petrosyan-van petrosyan-van commented Jul 12, 2025

Some modems, such as the Quectel BG95/EG25-G, emit an APP RDY message when the application core has fully initialized and is ready to process AT commands. By listening for this signal, the state machine can proceed earlier than the configured startup_time_ms, improving connection setup time.

This patch:

  • Adds a new MODEM_CELLULAR_EVENT_MODEM_READY event and a corresponding unsolicited chat match.
  • Opens the UART and attaches the chat parser in the AWAIT_POWER_ON state, so that APP RDY can be captured immediately.
  • Transitions to SET_BAUDRATE or RUN_INIT_SCRIPT as soon as APP RDY is seen, while keeping the existing timeout as a fallback for modems that don't emit this message.

Tested on a Quectel BG95-M3 on a custom board, where this change consistently advances the flow by several seconds, especially valuable for battery-powered applications where the modem is power-cycled frequently for short bursts of activity (e.g., uplink and shutdown). Over time, this can lead to noticeable energy savings :)

Modems that do not emit APP RDY will follow the same timeout-driven path as before. No behavioral regressions expected.

@petrosyan-van petrosyan-van marked this pull request as ready for review July 12, 2025 14:47
@github-actions github-actions bot requested a review from rerickson1 July 12, 2025 14:47
Copy link
Member

@rerickson1 rerickson1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nice change. I think it would be better to rename this to modem ready so it's better suited to use on other modems. For example, the HL7800 will emit a +KSUP message when it is ready. This even could be reused for that modem by simply matching on +KSUP received.

@bjarki-andreasen
Copy link
Contributor

bjarki-andreasen commented Jul 14, 2025

This is a nice change. I think it would be better to rename this to modem ready so it's better suited to use on other modems. For example, the HL7800 will emit a +KSUP message when it is ready. This even could be reused for that modem by simply matching on +KSUP received.

I agree, naming the unsol handler and event "modem ready", we can easily extend support for more modems by adding

MODEM_CHAT_MATCHES_DEFINE(unsol_matches,
			  MODEM_CHAT_MATCH("+CREG: ", ",", modem_cellular_chat_on_cxreg),
			  MODEM_CHAT_MATCH("+CEREG: ", ",", modem_cellular_chat_on_cxreg),
                          ...
			  MODEM_CHAT_MATCH("APP RDY", "", modem_cellular_chat_on_modem_ready),
                          MODEM_CHAT_MATCH("+KSUP", "", modem_cellular_chat_on_modem_ready),
                          ...);

@petrosyan-van petrosyan-van force-pushed the cellular_modem_app_rdy branch 2 times, most recently from e56db8a to c165fa0 Compare July 14, 2025 13:43
@petrosyan-van
Copy link
Contributor Author

Thanks a lot for the feedback :)

I implemented the changes

@petrosyan-van petrosyan-van force-pushed the cellular_modem_app_rdy branch from c165fa0 to de100c0 Compare July 14, 2025 13:46
Some modems (e.g. Quectel BG95/EG25-G, several SIMCom parts) print
“APP RDY” when the application core is ready.  Parse this line and
proceed from AWAIT_POWER_ON immediately, while keeping the existing
startup timeout as a fall-back.

* add MODEM_CELLULAR_EVENT_MODEM_READY + chat match
* open UART and attach chat in AWAIT_POWER_ON
* jump to SET_BAUDRATE / RUN_INIT_SCRIPT on event

Signed-off-by: Van Petrosyan <van.petrosyan@sensirion.com>
@petrosyan-van petrosyan-van force-pushed the cellular_modem_app_rdy branch from de100c0 to 39ceed4 Compare July 14, 2025 14:01
Copy link

Copy link
Contributor

@bjarki-andreasen bjarki-andreasen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants