-
Notifications
You must be signed in to change notification settings - Fork 7.7k
drivers: modem_cellular: Automatic APN detection support #93390
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
base: main
Are you sure you want to change the base?
drivers: modem_cellular: Automatic APN detection support #93390
Conversation
3b2d190
to
3e9240b
Compare
* Add CONFIG_MODEM_CELLULAR_AUTO_APN and CONFIG_MODEM_CELLULAR_AUTO_APN_PROFILES Kconfig options. * Detect APN from IMSI (MCC/MNC) and select profile at run‑time. * Build APN SET script dynamically: - Always sends AT+CGDCONT=1,"IP","<apn>" - Adds AT+KCNXCFG for HL7800. * Insert new MODEM_CELLULAR_STATE_RUN_APN_SCRIPT before the dial script to apply either the static or detected APN. * Remove hard‑coded APN commands from dial scripts; all modems now share the common builder. Signed-off-by: Van Petrosyan <[email protected]>
3e9240b
to
0586cde
Compare
|
This is really interesting! A while ago I made some brute force edits to the Couple other bg95 goodies I never got time to implement are here: |
Thanks for the feedback! You have some interesting stuff there :) I've been also focused on BG95 improvements recently. Funny enough some things we did are matching, like those: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of making this a hardcoded part of a single cellular driver, I would highly recommend extending the cellular.h API with an entry like
int cellular_set_apn(const struct device *dev, const char *apn);
and allowing the application to store the list of APNs it knows of, either statically or dynamically (up to the application).
To know which APN to set, the application can already get IMSI itself using
zephyr/include/zephyr/drivers/cellular.h
Lines 215 to 217 in 6413185
static inline int cellular_get_modem_info(const struct device *dev, | |
const enum cellular_modem_info_type type, char *info, | |
size_t size) |
This PR adds run‑time APN selection to the cellular driver and the logic that programs the chosen APN into the modem before the normal dial sequence starts.
Highlights
New Kconfig options
drivers/modem/ublox‑sara‑r4.c
)APN detection flow
Dynamic “set APN” chat script
modem_cellular_build_apn_script()
builds the chat script at run time using buffers that already exist instruct modem_cellular_data
.Testing
I used this commit: fdd89ef from @hwilmers as inspiration.
My solution is not as elegant at all, as I couldn't find a really good way to handle the dynamic script build. i saw several discussions previously regarding this topic and some attempts to implement this feature, but for some reason the idea was dropped, perhaps due to the solution not being scalable. I found this discussion and PR here:
#67626
#67776
Nevertheless, I think this feature is important as it removes the need for per‑carrier firmware variants, which is a major practical gain. Feedback on improving scalability or restructuring the builder is highly appreciated :)
Note: Would be great to test the solution on other modems, especially on HL7800, which has 2 steps for APN script. Any help there would be great!