convert decimal mcc mnc network id to heximal string used in 3GPP AVP like cases; and vise versa
Project description
PLMN to MCC and MNC Converter
This package provides tools to encode and decode PLMN (Public Land Mobile Network) identifiers to and from MCC (Mobile Country Code) and MNC (Mobile Network Code). The package includes a command-line interface (CLI) for easy usage.
Installation
You can install the plmn2mccmnc package using pip. It is recommended to use a virtual environment to avoid conflicts with other packages.
# Create a virtual environment (optional but recommended)
python -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`
# Install the package
pip install plmn2mccmnc
Usage
Encoding
To encode MCC and MNC to a 3-byte hexadecimal PLMN, you can use the encode_mcc_mnc function.
from plmn2mccmnc.bitscoder import encode_mcc_mnc
mcc = "405"
mnc = "01"
plmn = encode_mcc_mnc(mcc, mnc)
print(plmn.hex()) # Output: 40f510
Decoding
To decode a 3-byte hexadecimal PLMN to MCC and MNC, you can use the decode_mcc_mnc function.
from plmn2mccmnc.bitscoder import decode_mcc_mnc
plmn = bytes.fromhex("40f510")
mcc, mnc = decode_mcc_mnc(plmn)
print(mcc, mnc) # Output: 405 01
CLI Usage
The package includes a command-line interface (CLI) for encoding and decoding PLMN identifiers.
Encoding with CLI
To encode MCC and MNC using the CLI, run the following command:
python -m plmn2mccmnc encode 405 01
This will output:
40f510
Decoding with CLI
To decode a 3-byte hexadecimal PLMN using the CLI, run the following command:
python -m plmn2mccmnc decode 40f510
This will output:
405 01
CLI Help
To see the available options and usage instructions, use the --help flag:
python -m plmn2mccmnc --help
Contributing
Contributions are welcome! Please follow these steps to contribute:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Make your changes and commit them.
- Push your changes to your fork.
- Create a pull request to the main repository.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file plmn2mccmnc-0.1.1.tar.gz.
File metadata
- Download URL: plmn2mccmnc-0.1.1.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8805699e0359c32edbb1b8ff0a92af987fbb90119edf61fb8098c0a8b5bfe5f1
|
|
| MD5 |
99a160fbfed32d23a14d0d9e4051169f
|
|
| BLAKE2b-256 |
406d250e81eb31d6b9c8f59116ae79f9a9cb8101e232644a033d994ecd71dcd0
|
File details
Details for the file plmn2mccmnc-0.1.1-py3-none-any.whl.
File metadata
- Download URL: plmn2mccmnc-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
48890a84c2ada40049092bf9296f67f1e8836cef9f0b58711ef90aceb4a06a66
|
|
| MD5 |
34659eab6f15c64560bf50d96c11a8ae
|
|
| BLAKE2b-256 |
83c96330fffadac63bf000b0e1b2225ec5e24665683cd1064d9be225e19696e9
|