Metadata-Version: 2.2
Name: plmn2mccmnc
Version: 0.1.1
Summary: convert decimal mcc mnc network id to heximal string used in 3GPP AVP like cases; and vise versa
Requires-Python: >=3.11
Description-Content-Type: text/markdown
Requires-Dist: loguru>=0.7.3
Requires-Dist: typer>=0.15.1
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"

# 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.

```sh
# 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.

```python
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.

```python
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:

```sh
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:

```sh
python -m plmn2mccmnc decode 40f510
```

This will output:

```
405 01
```

### CLI Help

To see the available options and usage instructions, use the `--help` flag:

```sh
python -m plmn2mccmnc --help
```

## Contributing

Contributions are welcome! Please follow these steps to contribute:

1. Fork the repository.
2. Create a new branch for your feature or bug fix.
3. Make your changes and commit them.
4. Push your changes to your fork.
5. Create a pull request to the main repository.

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
