1. Discover
Find an available sensor
Scan both transports automatically, or target BLE and USB serial individually when a workflow needs explicit device selection.
flex scan --transport auto FlexTail developer workflow
Flex CLI connects to FlexTail over Bluetooth Low Energy or USB serial, then streams measurements, converts recordings, and calculates metrics without requiring a custom application.
1. Discover
Scan both transports automatically, or target BLE and USB serial individually when a workflow needs explicit device selection.
flex scan --transport auto 2. Stream
Run flex connect to stream raw CSV measurements directly into a Python script. This example parses each row with flexlib and calculates lumbar bend.
Stream command
flex connect | python analyze_live.py analyze_live.py
import flexlib
import sys
for line in sys.stdin:
measurement = flexlib.CSVReader.parse_string(line).measurements[0]
lumbar_bend = measurement.angles.bend
print(f"lumbar bend: {lumbar_bend:.1f}") 3. Publish
Pipe the same stream into a small Python publisher to send every measurement to an MQTT topic. This example expects a broker on localhost:1883 and the paho-mqtt package.
Stream command
flex connect | python publish_mqtt.py publish_mqtt.py
import csv
import json
import sys
import paho.mqtt.client as mqtt
from paho.mqtt.enums import CallbackAPIVersion
client = mqtt.Client(CallbackAPIVersion.VERSION2)
client.connect("localhost", 1883)
client.loop_start()
for sample in csv.DictReader(sys.stdin):
client.publish("flextail/live", json.dumps(sample))
client.disconnect()
client.loop_stop() 4. Transform
Batch workflows can export CSV, JSON, Arrow, Parquet, or RSF. Add angles and three-dimensional coordinates for downstream analysis, then emit posture and movement aggregates as JSON.
flex convert session.rsf session.parquet --angles --coordinates flex stats session.csv --json Python SDK path
The bundled Python BLE example also accepts packet hex on stdin. This lower-level route is useful for replaying captured packets through the native FlexTail SDK without opening a Bluetooth connection.
cat captured_packets.hex | python examples/python/ble-stream/flex_ble_stream.py --stdin-hex --no-ble