Skip to content

PPP: Add burst of AT commands to lock autobaudrate on begin#12314

Merged
me-no-dev merged 7 commits into
espressif:masterfrom
gonzabrusco:pppatburst
Feb 11, 2026
Merged

PPP: Add burst of AT commands to lock autobaudrate on begin#12314
me-no-dev merged 7 commits into
espressif:masterfrom
gonzabrusco:pppatburst

Conversation

@gonzabrusco
Copy link
Copy Markdown
Contributor

Description of Change

This Pull Request improves the robustness of PPPClass::begin() when used with cellular modems that boot in autobaud mode, such as SIMCom modules.

After a power-on reset, these modems often require multiple "AT\r" commands before they can lock onto the host UART baud rate. The current implementation attempts to synchronize immediately using esp_modem_sync(), which may fail if the modem is still determining the baud rate, leading to unnecessary retries and mode switching.

This change introduces a short burst of "AT\r" commands before calling esp_modem_sync(), allowing the modem to reliably lock the baud rate first. In practice, this significantly improves synchronization reliability without affecting modems that do not use autobaud.

Test Scenarios

I tested this change on a custom ESP32-based board equipped with a SIM7070 modem. Using a logic analyzer on the UART interface, I verified that the added AT command burst improves baud-rate locking and results in a more reliable initialization sequence.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 4, 2026

Warnings
⚠️

Some issues found for the commit messages in this PR:

  • the commit message "Add burst of AT to lock autobaudrate":
    • summary looks empty
    • type/action looks empty
  • the commit message "Make burst configurable":
    • summary looks empty
    • type/action looks empty

Please fix these commit messages - here are some basic tips:

  • follow Conventional Commits style
  • correct format of commit message should be: <type/action>(<scope/component>): <summary>, for example fix(esp32): Fixed startup timeout issue
  • allowed types are: change,ci,docs,feat,fix,refactor,remove,revert,test
  • sufficiently descriptive message summary should be between 10 to 72 characters and start with upper case letter
  • avoid Jira references in commit messages (unavailable/irrelevant for our customers)

TIP: Install pre-commit hooks and run this check when committing (uses the Conventional Precommit Linter).

👋 Hello gonzabrusco, we appreciate your contribution to this project!


📘 Please review the project's Contributions Guide for key guidelines on code, documentation, testing, and more.

🖊️ Please also make sure you have read and signed the Contributor License Agreement for this project.

Click to see more instructions ...


This automated output is generated by the PR linter DangerJS, which checks if your Pull Request meets the project's requirements and helps you fix potential issues.

DangerJS is triggered with each push event to a Pull Request and modify the contents of this comment.

Please consider the following:
- Danger mainly focuses on the PR structure and formatting and can't understand the meaning behind your code or changes.
- Danger is not a substitute for human code reviews; it's still important to request a code review from your colleagues.
- Resolve all warnings (⚠️ ) before requesting a review from human reviewers - they will appreciate it.
- To manually retry these Danger checks, please navigate to the Actions tab and re-run last Danger workflow.

Review and merge process you can expect ...


We do welcome contributions in the form of bug reports, feature requests and pull requests.

1. An internal issue has been created for the PR, we assign it to the relevant engineer.
2. They review the PR and either approve it or ask you for changes or clarifications.
3. Once the GitHub PR is approved we do the final review, collect approvals from core owners and make sure all the automated tests are passing.
- At this point we may do some adjustments to the proposed change, or extend it by adding tests or documentation.
4. If the change is approved and passes the tests it is merged into the default branch.

Generated by 🚫 dangerJS against 1f6eb93

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 4, 2026

Memory usage test (comparing PR against master branch)

The table below shows the summary of memory usage change (decrease - increase) in bytes and percentage for each target.

MemoryFLASH [bytes]FLASH [%]RAM [bytes]RAM [%]
TargetDECINCDECINCDECINCDECINC
ESP320⚠️ +440.00⚠️ +0.01000.000.00
ESP32C30⚠️ +360.00⚠️ +0.010⚠️ +160.00⚠️ +0.09
ESP32C50⚠️ +440.00⚠️ +0.010⚠️ +160.00⚠️ +0.07
ESP32C60⚠️ +440.00⚠️ +0.010⚠️ +160.00⚠️ +0.04
ESP32H20⚠️ +460.00⚠️ +0.01000.000.00
ESP32P40⚠️ +380.00⚠️ +0.01000.000.00
ESP32S20⚠️ +440.00⚠️ +0.01000.000.00
ESP32S30⚠️ +440.00⚠️ +0.01000.000.00
Click to expand the detailed deltas report [usage change in BYTES]
TargetESP32ESP32C3ESP32C5ESP32C6ESP32H2ESP32P4ESP32S2ESP32S3
ExampleFLASHRAMFLASHRAMFLASHRAMFLASHRAMFLASHRAMFLASHRAMFLASHRAMFLASHRAM
libraries/PPP/examples/PPP_Basic⚠️ +440⚠️ +36⚠️ +16⚠️ +44⚠️ +16⚠️ +440⚠️ +460⚠️ +380⚠️ +400⚠️ +360
libraries/PPP/examples/PPP_WIFI_BRIDGE⚠️ +400⚠️ +360⚠️ +360⚠️ +44⚠️ +16--⚠️ +360⚠️ +440⚠️ +440

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 4, 2026

Test Results

 91 files   91 suites   31m 35s ⏱️
 67 tests  67 ✅ 0 💤 0 ❌
684 runs  684 ✅ 0 💤 0 ❌

Results for commit 1f6eb93.

♻️ This comment has been updated with latest results.

Comment thread libraries/PPP/src/PPP.cpp Outdated
Comment on lines +303 to +306
// Send burst of AT to lock auto baurate on modem
for (int i = 0; i < 50; i++) {
esp_modem_at(_dce, "AT", NULL, 10);
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

IMO this should be only enabled if an argument of the constructor is set. @me-no-dev What do you think ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@lucasssvaz Just to add a data point: sending a short burst of "AT" commands is safe and has no side effects on modems that do not rely on autobaud.
In practice, this acts as a no-op for fixed-baud devices while greatly improving initialization reliability for autobaud-based modems, so I don’t think it needs to be gated behind an additional constructor option.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you please give models of modems that do require such burst?
I also agree that this should be optional or at least connected to the models that need it

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One more argument for making it optional.
When using flow-control the UART buffer may fill up and at some point may become blocking until it is able to flush its data.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

My modem is SIM7070

@gonzabrusco
Copy link
Copy Markdown
Contributor Author

I took the time to capture a few traces so you can verify this behavior yourself. I’m using a SIM7070, and this is the exact test sketch I used:

#include "Arduino.h"
#include "PPP.h"

#define UART_NUMBER 0
#define UART_RX 3
#define UART_TX 1
#define MODEM_PWRKEY 2 // IO2
#define PWRKEY_PULSE_MS 1200
#define MODEM_TURN_OFF_WAIT_MS 3300
#define MODEM_BOOT_WAIT_MS 7000

void setup() {
    pinMode(MODEM_PWRKEY, OUTPUT);
    digitalWrite(MODEM_PWRKEY, HIGH);

    // === WAIT TO BOOT ===
    delay(MODEM_BOOT_WAIT_MS);

    // === TURN OFF MODEM ===
    digitalWrite(MODEM_PWRKEY, LOW);
    delay(PWRKEY_PULSE_MS);
    digitalWrite(MODEM_PWRKEY, HIGH);

    // === WAIT TO OFF ===
    delay(MODEM_TURN_OFF_WAIT_MS);

    // === TURN ON MODEM ===
    digitalWrite(MODEM_PWRKEY, LOW);
    delay(PWRKEY_PULSE_MS);
    digitalWrite(MODEM_PWRKEY, HIGH);

    // === WAIT TO BOOT ===
    delay(MODEM_BOOT_WAIT_MS);

    PPP.setPins(UART_TX, UART_RX); // Not using control flow

    PPP.setApn("");

    PPP.setPin("");
   
    PPP.begin(PPP_MODEM_SIM7070, UART_NUMBER, 115200);
}

void loop() {
    // Nothing
}

The first capture shows the behavior without sending an initial burst of AT commands. As you can see, PPPClass struggles to synchronize with the modem because the modem does not respond until AT+CMUX=0 is issued. Most likely, the modem is still trying to lock the autobaud rate at that point.

Without burst

The second capture shows the behavior with an AT burst sent prior to synchronization. In this case, the modem synchronizes immediately, and esp_modem_sync succeeds on the first attempt.

With burst

For reference, here are the Saleae Logic capture files in case you want to dig deeper into this:
Captures.zip

@me-no-dev
Copy link
Copy Markdown
Member

we agree with all. We are just asking that this is made optional :)

@gonzabrusco
Copy link
Copy Markdown
Contributor Author

we agree with all. We are just asking that this is made optional :)

How would you suggest implementing this as an optional feature? At construction time, as an argument to begin(), or enabled by default for SIMCom modules?

I would like to emphasize that sending an initial AT command is effectively a no-op and should not have any negative impact on other modems. That said, if you prefer to keep this behavior optional, I’m happy to implement it accordingly—just let me know how you envision the option and I can update this PR.

@me-no-dev
Copy link
Copy Markdown
Member

class PPPClass {
  public:
    void sendAtBurst(bool en) {
      _sendAtBurst = en;
    }
  private:
    bool _sendAtBurst;
}

Then check in begin if _sendAtBurst is true and do the burst

@TD-er
Copy link
Copy Markdown
Contributor

TD-er commented Feb 10, 2026

bool _sendAtBurst;

And don't forget to initialize at false.

@gonzabrusco
Copy link
Copy Markdown
Contributor Author

@me-no-dev PTAL

Copy link
Copy Markdown
Member

@lucasssvaz lucasssvaz left a comment

Choose a reason for hiding this comment

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

LGTM

@me-no-dev me-no-dev added the Status: Pending Merge Pull Request is ready to be merged label Feb 10, 2026
@me-no-dev me-no-dev merged commit 6acc893 into espressif:master Feb 11, 2026
68 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status: Pending Merge Pull Request is ready to be merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants