Setting APN Details
Dan Williams
dan at ioncontrol.co
Thu Jul 31 14:16:19 UTC 2025
> On Jul 28, 2025, at 11:26 AM, Mark Corbin <mcorbin at lunarenergy.com> wrote:
>
> On Sat, 26 Jul 2025 at 16:47, Dan Williams <dan at ioncontrol.co> wrote:
>>
>> On Wed, 2025-07-23 at 15:29 +0100, Mark Corbin wrote:
>>> Hello
>>>
>>> I'm using ModemManager together with NetworkManager to control a
>>> Quectel BG95 modem. We have 2 versions of SIM with different APNs.
>>> When trying to update from the old APN to the new APN I've come
>>> across an issue where the modem PDP context doesn't get updated.
>>>
>>> Where we have modems that report:
>>> +CGDCONT: 1,"IP","OldAPN","0.0.0.0",0,0,0
>>> they don't get updated by MM to 'NewAPN'.
>>>
>>> If the modem reports:
>>> +CGDCONT: 1,"IP","","0.0.0.0",0,0,0
>>> or
>>> +CGDCONT: 1,"IP","","0.0.0.0",0,0,0
>>> +CGDCONT: 2,"IP","OldAPN","0.0.0.0",0,0,0
>>> then MM adds the 'NewAPN' PDP context to the end of the list and
>>> everything works.
>>
>> It might have to do with the initial EPS bearer context ID. When you
>> are running with --debug, do you see these messages at all?
>>
>> mm_obj_dbg (self, "initial EPS bearer context cid found: %u", min_cid);
>>
>> and also:
>>
>> mm_obj_dbg (self, "context definition format: minimum %d, maximum %d",
>
> I can't see any messages like that in the debug output.
>
>>
>> It might be that for your device profile #1 is considered the EPS
>> initial bearer.
>
> I'm beginning to think that profile #1 is the EPS initial bearer and
> needs to be 'blank' to work. It seems that because we have previously
> overwritten it with the old APN entry it now won't work/update to the
> new APN.
Yeah, I think you’re right. I tried and failed to find any documentation for the BG95 about default bearers or initial PDP contexts.
If the modem does in fact use PDP #1 as the default bearer APN, and the network knows that’s not what your SIM is supposed to be using, it may well prevent network registration. That seems to be the problem in the second log; the modem always gets denied registration.
Are you able to use the mmcli commands for —3gpp-profile-manager to clear out the #1 APN?
mmcli -m 0 —3gpp-profile-manager-delete=“profile-id=1”
Should do it. Then add a new one for #2 with the new APN, and after that MM should automatically choose that one instead of setting #1 again:
mmcli -m 0 —3gpp-profile-manager-set=“profile-id=2,apn=<apn>,ip-type=v4v6"
Dan
>
>>
>>>
>>> Looking at the debug logs it seems that the modem needs to be
>>> registered to the network before MM will add the new context for the
>>> new APN (I guess that this is what the +CGDCONT:
>>> 1,"IP","","0.0.0.0",0,0,0 is allowing to happen). Is this correct?
>>> And will a 'blank' entry always allow you to register to a network?
>>
>> When asked to connect, MM waits until the modem is registered with the
>> network before doing the APN configuration and starting the data
>> connection. The APN configuration doesn't actually affect network
>> registration itself, but does affect bearer creation after.
>>
>> The modem and network will usually auto-activate the EPS initial bearer
>> and use an APN that is either specified in the CGDCONT configuration
>> manually or if empty uses the default APN from the network. Which
>> profile # the initial bearer uses can be different depending on the
>> modem firmware and vendor.
>>
>>>
>>> I was hoping to upgrade systems in the field just by updating the
>>> 'apn=...' entry in the NetworkManager 'nmconnection' file, but it
>>> looks like I will also have to manually delete the existing PDP
>>> contexts and add a blank one too.
>>
>> You shouldn't have to. When the APN is specified in the configuration,
>> MM is supposed to look for an existing profile/context that matches the
>> configuration (including APN) and use that, otherwise create a new one
>> to use. If MM is not using the APN you give, that's a bug.
>>
>> Would you be able to provide (privately, if you prefer) the --debug
>> logs from ModemManager during an activation where the problem occurs?
>>
>
> Please see the attached log files as follows:
>
> 1) mm-wrong-context-not-registering.log
> Modem starts with the wrong APN configured in the first profile
> (+CGDCONT: 1,"IP","eapn1.net","0.0.0.0",0,0,0) and it never registers
> or updates the APN to 'wlapn.com'.
>
> 2) mm-blank-context-registers.log
> Modem starts with an empty APN in the first profile (+CGDCONT:
> 1,"IP","","0.0.0.0",0,0,0) and it registers, updates and connects.
>
> Thanks
>
> Mark
>
>> Thanks,
>> Dan
>>
>>>
>>> Thanks
>>>
>>> Mark
>>> --
>>> ModemManager is v1.18.8
>>> NetworkManager is v1.36.2
>>>
>>> --
>>>
>>> Mark Corbin
>>> Senior Software Engineer |
>>> lunarenergy.com | LinkedIn | Instagram
>>> Lunar Energy Logo
>>>
>>> C2:Restricted unless otherwise stated.
>>>
>>> Lunar Energy Limited is a company registered in England and
>>> Wales, authorised and regulated by the Financial Conduct Authority
>>> under reference number 767876. Company registration number: 05631091.
>>> Registered office: 55 Baker Street, London, England, W1U 7EU
>>
>
>
> --
>
> Mark Corbin
> Senior Software Engineer | lunarenergy.com | LinkedIn | Instagram
>
> --
> C2:Restricted unless otherwise stated.
>
> --
>
>
>
>
>
>
>
>
> Lunar Energy Limited is a company registered in England and Wales,
> authorised and regulated by the Financial Conduct Authority under reference
> number 767876. Company registration number: 05631091. Registered office: 55
> Baker Street, London, England, W1U 7EU
> <mm-blank-context-registers.log><mm-wrong-context-not-registering.log>
More information about the ModemManager-devel
mailing list