adds iccid, u-sim and firmware commands#1034
adds iccid, u-sim and firmware commands#1034fjuliofontes wants to merge 6 commits intoespressif:masterfrom
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
|
You have used all of your free Bugbot PR reviews. To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial. |
david-cermak
left a comment
There was a problem hiding this comment.
Thanks for this contribution and nice work overall!
The null-pointer hardening across the C API.
AT+CRSM (restricted USIM access) commands are a welcome addition, as well as tge set_operator fix.
And good catch on the free -> delete in ap_to_pppos.
A couple of small things I'd like to suggest before merging:
-
Rebase and cleanup git history
-
Update git commit messages according to the contribution guidelines (or just run pre-commit hook)
-
Quectel-specific AT commands in the generic library
get_iccid uses AT+QCCID and get_module_firmware uses AT+QGMR -- both are Quectel-proprietary commands. Since these live in the generic command library (and get added to GenericModule), they won't work on non-Quectel modems.
Use the standard AT commands: AT+CCID for ICCID and AT+CGMR for firmware version (these are supported broadly across vendors), or
If you specifically need the Quectel variants, add them as overrides in a Quectel-specific module (similar to how SIM7070_gnss extends the base module), keeping the generic library vendor-neutral.
- Regenerating the API files
I see you've edited both the generate/include/esp_modem_command_declare.inc (which is the source of truth) and the command/ directory files. Our development workflow asks that after modifying the .inc file, you run the generate.sh script to regenerate the production files, rather than editing them by hand. This ensures consistency and catches any subtle differences. See our development docs -- specifically the "Developer Workflow > Adding New AT Commands" section and "Generate Script Usage".
Could you re-run:
./scripts/generate.sh
and include any updated generated files? That way CI can also validate they stay in sync.
Everything else looks good -- the helper macro extension (ESP_MODEM_HELPER6), the IDF v6 compat fix, and the nullable output parameter improvements are all welcome changes!

Description
This PR extends the
esp_modemcommand library with new AT commands for SIM card and module information retrieval, as well as a fix for the operator selection command.New commands added:
get_iccid— Reads the SIM card's ICCID number viaAT+QCCID(Quectel modules). Parses the+QCCID:response prefix and returns the trimmed value.get_module_firmware— Reads the module firmware version viaAT+QGMR(Quectel modules).get_restricted_usim_access— Reads data from the (U)SIM using the standardAT+CRSMcommand, exposing command, file ID, P1/P2/P3 parameters and returning the raw+CRSM:response payload.set_restricted_usim_access— Writes data to the (U)SIM usingAT+CRSM, accepting command, file ID, P1/P2/P3 parameters and a data string.Bug fix:
set_operator— Fixed the command to support automatic operator selection (mode only, no format/operator string) when an emptyoperstring is passed, issuingAT+COPS=<mode>instead of a malformed command.All new commands are declared in
esp_modem_command_declare.inc, implemented inesp_modem_command_library.cpp, and exposed through the C API inesp_modem_c_api.cpp.Related
N/A
Testing
Commands were tested on Quectel EC21/EC25 modules.
get_iccidandget_module_firmwareuse Quectel-specific AT commands (AT+QCCID,AT+QGMR).get_restricted_usim_access/set_restricted_usim_accessuse the standard 3GPPAT+CRSMcommand, which is broadly supported across modem vendors.Checklist
Before submitting a Pull Request, please ensure the following:
Note
Medium Risk
Expands the public C/C++ modem APIs (including SIM read/write via
AT+CRSM), which could affect compatibility and has potential for vendor/parameter edge cases, but changes are additive and localized.Overview
Adds new esp-modem commands to retrieve SIM/module info and access the SIM filesystem:
get_iccid(viaAT+QCCID),get_module_firmware(viaAT+QGMR), andget_restricted_usim_access/set_restricted_usim_access(viaAT+CRSM). These are wired through the command library,GenericModule/DCEC++ wrappers, generated command declarations (adding a 6-arg helper macro), and exposed in the C API.Also fixes
set_operatorto emitAT+COPS=<mode>when no operator string is provided, enabling proper automatic operator selection.Written by Cursor Bugbot for commit 170d8e6. This will update automatically on new commits. Configure here.