Metadata-Version: 2.4
Name: feetme
Version: 0.2.0
Summary: Async Python client for FeetMe BLE pressure insoles
Author: Elesdes
Author-email: Elesdes <elesdes404@gmail.com>
License-Expression: Apache-2.0
License-File: LICENSE
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Classifier: Framework :: AsyncIO
Requires-Dist: bleak>=0.22
Requires-Dist: pydantic>=2.7
Requires-Python: >=3.10
Project-URL: Repository, https://github.com/Elesdes/FeetMe-py
Project-URL: Issues, https://github.com/Elesdes/FeetMe-py/issues
Description-Content-Type: text/markdown

# FeetMe-py -- Unofficial SDK

[![GitHub License](https://img.shields.io/github/license/Elesdes/FeetMe-py)](LICENSE)
[![PyPI](https://img.shields.io/pypi/v/feetme)](https://pypi.org/project/feetme/)

> [!IMPORTANT]
> **Unofficial SDK.** This is an independent, community-made client. It is not
> affiliated with, endorsed by or supported by FeetMe SAS. It contains no FeetMe code or
> data; see [Sensor layouts and pressure maps](#sensor-layouts-and-pressure-maps) for the
> optional parts that read them from your own copy of the FeetMe app.

## Overview

Python SDK for FeetMe BLE pressure insoles (protocol 3), built on [bleak](https://github.com/hbldh/bleak).
It scans for insoles, reads device info, and streams pressure, IMU and stride data.

## Setup

### Requirements

- Python 3.10+
- FeetMe insoles
- Optional, recommended: your own copy of the FeetMe Evaluation app (APK), for pressure
  maps, center of pressure and load estimates (see below)

### Recommended Setup

```bash
uv add feetme   # or: pip install feetme
```

## Usage

CLI:

```bash
feetme scan
feetme info 1441
feetme stream 1441 --mode raw16 --seconds 10 --csv out.csv
```

`TARGET` is a BLE address or the insole number printed in its name ("FeetMe 1441 44R").

Library:

```python
import asyncio
from feetme import Mode, find_insole

async def main():
    async with await find_insole("1441") as insole:
        print(await insole.get_battery())
        insole.add_listener(print)
        await insole.set_mode(Mode.RAW16)
        await asyncio.sleep(5)

asyncio.run(main())
```

Every record (`Stride`, `PressureSample`, `BatteryStatus`, ...) is an immutable, validated
[pydantic](https://docs.pydantic.dev) model: use `record.model_dump()` / `model_dump_json()`, and
`Stride.model_json_schema()` to generate types for a UI.

Strides recorded while the insole was offline:

```python
records = await insole.download_flash(progress=lambda done, total: print(done, total))
# Stride/Event records, each with host_time_ms on your clock. Flash is not erased;
# insole.clear_flash() does that (irreversible).
```

Two-foot gait metrics (step time/length, single/double support, asymmetry) and distance:

```python
from feetme.gait import DistanceTracker, GaitProcessor

gait, distance = GaitProcessor(), DistanceTracker()
for m in gait.feed(stride):  # strides from both insoles, any order
    print(m.step_time_ms, m.double_support_percent, distance.add(m.stride))
```

Both insoles at once (records merged in host-time order):

```python
records = await pair.download_flash(progress=lambda side, done, total: print(side.name, done, total))
```

### Sensor layouts and pressure maps

Pressure maps, centre of pressure and load estimates need sensor geometry that this
project does not include. For the best experience and the most accurate values, provide
**your own copy** of the FeetMe Evaluation app (APK). Everything else works without it.

This project does not provide the app or its data, and does not explain how to obtain
them. Issues or pull requests asking for, linking to or attaching them will be closed.

Point the library at your copy, or extract the geometry once into a local file:

```bash
export FEETME_APK=path/to/app.apk
# or
feetme export-layouts path/to/app.apk layouts.json
export FEETME_LAYOUTS=layouts.json
```

Do not commit or share the APK or `layouts.json`.

The insole reports its own size, so no size needs to be entered:

```python
pmap = insole.pressure_map()             # layout for the advertised size
grid = pmap.interpolate(sample.pressures)  # 50 x 150, row-major, None outside the insole
print(pmap.weight(sample.pressures), pmap.centre_of_pressure(grid))
print(pmap.geometry())                   # grid coordinates and outlines, for drawing
```

Geometry is a left foot; mirror x to draw a right one.

### Live streaming (DeviceManager / StreamHub)

Besides raw records, `DeviceManager` publishes `gait_metrics` (both feet, with running
`distance`). Interpolated `pressure_map` records (grid, `weight_kg`, `cop`) are sent at up to
10 Hz per insole, only to subscribers that list that kind: `hub.subscribe(kinds=["pressure_map"])`.
`manager.geometry(address)` gives the matching grid geometry and side.

## Maintainers

### Releasing a new version

1. Bump the version in `pyproject.toml` and commit it to `main`:

   ```bash
   uv version --bump patch   # or minor / major
   git commit -am "chore: release v$(uv version --short)"
   git push origin main
   ```

2. Tag the commit and push the tag:

   ```bash
   git tag v$(uv version --short)
   git push origin v$(uv version --short)
   ```

3. The `release` workflow checks the tag matches the version, publishes the
   package to [PyPI](https://pypi.org/project/feetme/), and creates a GitHub
   Release with the wheel and sdist attached.

## License

This project is licensed under the Apache License (Version 2.0).

See the [LICENSE](LICENSE) file for details.

## AI Usage Transparency

This project uses AI tools to assist with development.
For more details, see the [AI Usage Disclosure](AI_USAGE.md) file.
