stdnum.meid

MEID (Mobile Equipment Identifier).

The Mobile Equipment Identifier is used to identify a physical piece of CDMA mobile station equipment.

>>> validate('AF 01 23 45 0A BC DE C')
'AF0123450ABCDE'
>>> validate('29360 87365 0070 3710 0')
'AF0123450ABCDE'
>>> validate('29360 87365 0070 3710 0', strip_check_digit=False)
'AF0123450ABCDEC'
>>> validate('29360 87365 0070 3710 1')
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> format('af0123450abcDEC', add_check_digit=True)
'AF 01 23 45 0A BC DE C'
>>> format('af0123450abcDEC', format='dec', add_check_digit=True)
'29360 87365 0070 3710 0'
stdnum.meid.calc_check_digit(number: str) str

Calculate the check digit for the number. The number should not already have a check digit.

stdnum.meid.compact(number: str, strip_check_digit: bool = True) str

Convert the MEID number to the minimal (hexadecimal) representation. This strips grouping information, removes surrounding whitespace and converts to hexadecimal if needed. If the check digit is to be preserved and conversion is done a new check digit is recalculated.

stdnum.meid.format(number: str, separator: str = ' ', format: str | None = None, add_check_digit: bool = False) str

Reformat the number to the standard presentation format. The separator used can be provided. If the format is specified (either ‘hex’ or ‘dec’) the number is reformatted in that format, otherwise the current representation is kept. If add_check_digit is True a check digit will be added if it is not present yet.

stdnum.meid.is_valid(number: str) bool

Check if the number is a valid MEID number.

stdnum.meid.to_binary(number: str) bytes

Convert the number to its binary representation (without the check digit).

stdnum.meid.to_pseudo_esn(number: str) str

Convert the provided MEID to a pseudo ESN (pESN). The ESN is returned in compact hexadecimal representation.

stdnum.meid.validate(number: str, strip_check_digit: bool = True) str

Check if the number is a valid MEID number. This converts the representation format of the number (if it is decimal it is not converted to hexadecimal).