Metadata-Version: 2.5
Name: brownie1
Version: 2.1.0
Summary: A minimalistic chat clone
Requires-Python: >=3.10
Requires-Dist: bleak>=0.21.1
Requires-Dist: bless>=0.2.6
Requires-Dist: rich>=13.0.0
Requires-Dist: typer>=0.9.0
Provides-Extra: dev
Requires-Dist: pytest-asyncio>=0.21.1; extra == 'dev'
Requires-Dist: pytest>=7.0; extra == 'dev'
Description-Content-Type: text/markdown

# Brownie

Brownie is a minimalistic Bluetooth Low Energy (BLE) chat application supporting both **Server (Peripheral)** and **Client (Central)** roles over the standard Nordic UART Service (NUS).

It allows two people on BLE-capable computers or devices to communicate directly over Bluetooth without requiring internet or local Wi-Fi.

---

## Features

- **Server Mode (Peripheral)**: Host a chat room by advertising the Nordic UART Service (`brownie server`).
- **Client Mode (Central)**: Connect to a running server by address or auto-discovery (`brownie client`).
- **Device Discovery**: Scan and list nearby BLE devices (`brownie devices`).
- **Standard Protocol**: Compatible with any device or app implementing Nordic UART Service (NUS), including *nRF Connect* and *Serial Bluetooth Terminal*.
- **Rich Terminal UI**: Formatted output and interactive prompt powered by `rich` and `typer`.

---

## Installation

```bash
pip install -e .
```

To install development dependencies (testing):

```bash
pip install -e ".[dev]"
```

---

## How Two People Can Communicate

### 1. Person A: Start the Server (Host)

On the first machine, start the server:

```bash
brownie server
```

*(Options: `--name` / `-n` to change the advertised name, default is `Brownie`)*

The server will display its local Bluetooth MAC address:
```text
╭─ Brownie BLE Chat Server ──────────────────────╮
│ Device Name: Brownie                           │
│ Local Address: 6C:2F:80:C8:1A:94               │
│                                                │
│ Clients can connect using:                     │
│   brownie client 6C:2F:80:C8:1A:94             │
╰────────────────────────────────────────────────╯
```

---

### 2. Person B: Connect as a Client

On the second machine, connect directly to Person A's address:

```bash
brownie client 6C:2F:80:C8:1A:94
```

Or auto-discover the running `Brownie` server:

```bash
brownie client
```

Or scan for all nearby devices first:

```bash
brownie devices
```

---

### 3. Start Chatting

Once connected, both Person A and Person B can type into their terminal prompt `> ` and press Enter. Incoming messages will appear in real time:

```text
Peer: Hello from the server!
> Hi, message received loud and clear!
```

Press `Ctrl+C` at any time to disconnect or stop the server cleanly.

---

## CLI Reference

### Commands

| Command | Description |
|---|---|
| `brownie server [--name NAME]` | Host a BLE chat server |
| `brownie client [ADDRESS] [--name NAME] [--timeout SECONDS]` | Connect to a BLE chat server |
| `brownie join <ADDRESS>` | Alias for `client` |
| `brownie devices [--timeout SECONDS]` | Scan nearby BLE devices |

### Flags / Options

You can also use top-level flags:

```bash
brownie --server                       # Run server mode
brownie --client <MAC_ADDRESS>         # Run client mode
brownie --devices                      # Scan devices
```

---

## Testing

Run unit tests with pytest:

```bash
pytest
```
