Set a custom APN for cellular imps
Device
Available from impOS release-47.0+
Name | Type | Description |
---|---|---|
apn | string |
The name of the custom APN required for the cellular connection
|
Nothing
This method introduces the ability to write a custom APN into imp’s non-volatile memory. A squirrel error is thrown if the single parameter is missing or not a string. The new settings will be used for all subsequent connections attempted by the device, including those taking place after a cold boot. When set, a custom APN overrides the internal list and persists through resets and power cycles until explicitly cleared. This helps to configure devices with any private cellular networks without being dependent on impOS firmware.
Settings applied using imp.setapn() can be overwritten by a later BlinkUp™, and care is needed when changing the APN settings, because misconfiguration can result in devices being unable to make any further cellular connections. In this case, recovery may require either Wi-Fi (to send new squirrel) or physical access (for BlinkUp™).
The currently-configured APN can be read using imp.net.info(). The associated value is a squirrel string equal to the last APN sent to the modem. This also works for internally selected APNs. Note that the APN value returned relates to the current or last cellular connection attempt and will not reflect any changes made via squirrel or BlinkUp™ until the next reconnection.
The imp.clearconfiguration() method clears any existing custom APN from persistent storage. Any subsequent cellular connection attempts will revert to using the internal list based on ICCID/IMSI prefix of the SIM card.The method can either be called with no parameters, to clear all configuration settings including custom APN, or the new parameter CONFIG_APN (integer value 4) can be provided to clear only the custom APN setting.