Persistent setting default APN

My custom device uses nRF9151 and we're using SDK 2.6.0 with modem firmware 2.0.1.

When the device connects to the LTE network it derives a default APN, however, my provider recommends that I use a different APN. I'm trying to find a way to make that alternate APN be the default and persist in the device.

Case 334155 indicates several prj.conf items which can be used to pre-configure the APN in the device firmware.

CONFIG_PDN=y
CONFIG_PDN_ESM_STRERROR=y
CONFIG_PDN_DEFAULTS_OVERRIDE=y
CONFIG_PDN_INIT_PRIORITY=89
CONFIG_PDN_DEFAULT_FAM_IPV4V6=y
CONFIG_PDN_DEFAULT_APN="my-apn"

This does work for me, however, it means that a given firmware build is tied to work with a certain cellular provider. We may have a population of devices using a different cellular provider and it would be ideal to use the same firmware for both cases.

Is there a way to persist an APN setting in the modem itself rather than app firmware?

Failing that, I suppose in app firmware we might be able to discover which carrier the SIM is configured for and make modem_lib calls to set APN accordingly.

Related