# impinj-iot

[![PyPI - Version](https://img.shields.io/pypi/v/impinj-iot.svg)](https://pypi.org/project/impinj-iot)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/impinj-iot.svg)](https://pypi.org/project/impinj-iot)

Python driver for Impinj R700 RAIN RFID readers using the IoT Device Interface (REST API).

## Features

- Connect to Impinj R700 readers over HTTPS
- Start/stop inventory with configurable antenna ports, TX power, and RF modes
- Real-time tag streaming via NDJSON with callback-based notifications
- Query reader info (model, firmware, region, antenna count, power limits)
- Full RF mode enumeration with modulation details
- Authentication support (default: `root` / `impinj`)

## Installation

```console
pip install impinj-iot
```

## Quick Start

```python
from impinj_iot import ImpinjIot, ImpinjIotTagReport

reader = ImpinjIot()

def on_tag(report: ImpinjIotTagReport):
    print(f"EPC: {report.epc}  RSSI: {report.peak_rssi_cdbm / 100:.1f} dBm")

reader.set_notification_callback(on_tag)
reader.connect("192.168.1.100")
reader.set_tx_power(30.0)  # dBm
reader.start()

# ... tags arrive via callback ...

reader.stop()
reader.disconnect()
```

## API Reference

### `ImpinjIot`

| Method | Description |
|--------|-------------|
| `connect(ip, user, password)` | Connect to reader via HTTPS |
| `disconnect()` | Stop inventory and disconnect |
| `is_connected()` | Check connection status |
| `set_notification_callback(fn)` | Register tag report callback |
| `get_reader_info()` | Get reader model, firmware, region, antenna count, power limits |
| `start()` | Start inventory and tag stream |
| `stop()` | Stop inventory |
| `get_tx_power()` / `set_tx_power(dbm)` | Get/set TX power in dBm |
| `get_antenna_config()` / `set_antenna_config(list[bool])` | Get/set active antennas |
| `get_rf_mode()` / `set_rf_mode(mode)` | Get/set RF mode |
| `get_supported_rf_modes()` | Query reader for available RF modes |

### `ImpinjIotTagReport`

| Field | Type | Description |
|-------|------|-------------|
| `epc` | `str` | Tag EPC (hex string) |
| `antenna_port` | `int` | Antenna port number |
| `peak_rssi_cdbm` | `int` | Peak RSSI in centi-dBm |
| `frequency` | `int` | Frequency in kHz |
| `transmit_power_cdbm` | `int` | TX power in centi-dBm |

### `RfMode`

Enum with all supported Impinj R700 RF modes: `MAX_THROUGHPUT`, `HYBRID`, `DENSE_READER_M4`, `DENSE_READER_M8`, `AUTOSET`, and more. See source for full list.

## License

`impinj-iot` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
