module SIM7672

This module provides the modem class for the SIM7672 LTE modem on MicroCat.1. It manages power control, network registration, and a PPP session over UART, providing internet connectivity over a cellular network using a SIM card.

The modem class is not normally instantiated directly — use microcat1.modem() instead.

Recommended usage:

import microcat1

m = microcat1.modem()
m.active(True)
m.connect('your_apn', 'your_apn_username', 'your_apn_password')
print(m.ifconfig())
m.disconnect()
class SIM7672.modem(uart=machine.UART, baudrate=115200, handshake=True, led=machine.Pin, debug=False)

Bases: object

Control the SIM7672 LTE modem on MicroCat.1.

Manages the full lifecycle of a cellular connection: power on/off, network registration, and PPP session establishment over UART.

__init__(uart=machine.UART, baudrate=115200, handshake=True, led=machine.Pin, debug=False)

Initialize the modem.

Parameters:
  • uart – UART instance for communication (default: UART(1))

  • baudrate – Baud rate for UART communication (default: 115200)

  • handshake – Enable hardware handshake (default: True)

  • led – LED pin for modem status indication (default: Pin(34))

  • debug – Enable debug output (default: False)

active(activate=None, reset=True)

Control or query the modem’s power state.

Returns the current state if no argument is provided.

Parameters:
  • activateTrue to power on, False to power off

  • reset – Reset modem if powering on and already active (default: True)

Returns:

True if modem is active, False otherwise

config(param=None, apn=None, user=None, key=None, pdp=None, security=None)

Get or set modem parameters.

For querying, parameters name should be quoted as a str, and only one parameter can be queries at time.

Parameters:
  • param – Specific parameter to get (default: None)

  • apn – Access Point Name (default: None)

  • user – Username for authentication (default: None)

  • key – Password for authentication (default: None)

  • pdp – PDP type (default: None)

  • security – Security type (default: None)

Returns:

Value of specified parameter if param is given, otherwise None

connect(apn=None, user=None, key=None, pdp=None, security=None, detach=False, retries=60, delay=500, transition_timeout=10000)

Connect to the cellular network.

Parameters:
  • apn – Access Point Name (default: None)

  • user – Username for authentication (default: None)

  • key – Password for authentication (default: None)

  • pdp – PDP type (default: None)

  • security – Security type (default: None)

  • detach – Detach before connecting (default: False)

  • retries – Number of connection attempts (default: 60)

  • delay – Delay between attempts in milliseconds (default: 500)

  • transition_timeout – Maximum wait time for state transition in milliseconds (default: 10000)

disconnect(retries=2, delay=10000, transition_timeout=20000)

Disconnect from the cellular network.

Parameters:
  • retries – Number of disconnection attempts (default: 2)

  • delay – Delay between attempts in milliseconds (default: 10000)

  • transition_timeout – Maximum wait time for state transition in milliseconds (default: 20000)

Note

Stable connection pattern

Call connect() before each request and disconnect() immediately after. On failure, call machine.reset() — this is the only reliable recovery method (disconnect()/connect() alone does not recover a wedged PPP stack). After reset, allow a few seconds for the modem to warm up before the first connect() call to avoid a false 0.0.0.0 result triggering another reset.

ifconfig()

Get network interface configuration.

Returns:

Network configuration tuple (ip, subnet, gateway, dns)

isconnected()

Check if the PPP session is established.

Returns:

True if the PPP session is established, False otherwise

Note

This reflects the PPP session state, not end-to-end network reachability. The PDP context can be terminated by the carrier while the PPP session remains alive; in that case this method returns True but data transfer will fail (e.g., OSError ECONNABORTED or EHOSTUNREACH).

To detect this state, check ifconfig() — if it returns ('0.0.0.0', ...), the IP stack is no longer functional. Recovery via disconnect()/connect() alone is not reliable; call machine.reset() to recover from a clean boot sequence.

status()

Get PPP connection status.

Returns:

PPP connection status

Constants

SIM7672.SEC_NONE = 0

No authentication (alias of network.PPP.SEC_NONE).

SIM7672.SEC_PAP = 1

PAP authentication (alias of network.PPP.SEC_PAP).

SIM7672.SEC_CHAP = 2

CHAP authentication (alias of network.PPP.SEC_CHAP).

SIM7672.PDP_IP = 'IP'

IPv4 PDP context type ('IP').

SIM7672.PDP_IPV6 = 'IPV6'

IPv6 PDP context type ('IPV6').

SIM7672.PDP_IPV4V6 = 'IPV4V6'

Dual-stack IPv4/IPv6 PDP context type ('IPV4V6').

SIM7672.PDP_NONIP = 'Non-IP'

Non-IP PDP context type ('Non-IP').