Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Tetr4 authored Aug 20, 2023
1 parent 117dc59 commit f8bf2af
Showing 1 changed file with 46 additions and 45 deletions.
91 changes: 46 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,49 @@
<img src="./app/src/main/ic_launcher-raw.png" alt="Logo" align="right" height="60" />

# Dive Log
This repository contains code for a dive log Android app that can read dives from
This repository contains code for a dive log Android app that can import dives from
[hwOS](https://heinrichsweikamp.com/hw-os) family of dive computers (e.g. Heinrichs Weikamp OSTC Sport) via Bluetooth
LE (BLE).

Feature Plan:
- MVP:
- Offline-first dive log
- Fetch and merge dive logs from dive computer
- Plot of dive profile
- Next steps:
- Synchronize dive logs in external cloud (e.g. Google Drive)
- Additional data (equipment, observations, tags)
- Ideas:
- Storing images
- Map with dive locations
- CSV export / import
- User defined data fields (e.g. weights, tank, etc.)
- Buddy signature via NFC
- Support for more dive computers
- In-app payments (only if there are any running server costs)
- Out of scope:
- User accounts
- Dive certificates
- Social media stuff

## Features

MVP:
- Offline-first dive log
- Fetch and merge dive logs from dive computer
- Plot of dive profile
- Add and edit notes

Tech:
- [Jetpack Compose](https://developer.android.com/jetpack/compose)
- [Material 3 Dynamic Color Support](https://m3.material.io/styles/color/dynamic-color/overview)
- CI/CD via [GitHub Actions](https://github.com/features/actions)

Next steps:
- Map of dive spots
- Synchronize dive logs in external cloud (e.g. Google Drive)
- CSV export / import
- Additional data (equipment, observations, tags, images)
- Support for more dive computers


## Modules
- `app`: The application or presentation layer. Contains compose views, viewmodels, resources, etc.
- `app`: The UI layer. Contains compose views, viewmodels, resources, etc.
- `data`: The data layer. Contains business logic components, e.g. `DiveRepository`.
- `bluetooth`: Generic bluetooth connectivity, permission and pairing handling. No domain specific code.
- `persistence`: Local SQLite database.


## Communication Concept
Bluetooth LE endpoints are called characteristics (e.g. "firmware revision" or "battery level") and are grouped into
services (e.g. "device information"). Characteristics and services are identified by UUIDs. Characteristics can allow:
- reading
- writing (with or without response, like TCP/UDP)
- notifications/indications (app gets notified by device if a value changed, with our without acknowledgement)

hwOS does not use Bluetooth LE characteristics directly as endpoints for fetching dives. Instead communication is done
through a **simulated virtual serial COM port** over four specific BLE characteristics. This is based on a
"Terminal I/O v2.0" protocol by Telit Wireless Solutions (formerly Stollmann E+V GmbH).

See [Terminal I/O Profile Client Implementation Guide](http://www.iot.com.tr/uploads/pdf/TIO_Implementation_Guide_r05.pdf).
## Bluetooth Import

### Bluetooth LE
Bluetooth LE endpoints are called characteristics (e.g. "firmware revision" or "battery level"). They are grouped into
services (e.g. "device information"). Characteristics and services are identified by UUIDs. Characteristics can allow:
- Reading
- Writing (with or without response, like TCP/UDP)
- Notifications/Indications (app gets notified by device if a value changed, with our without acknowledgement)

## BLE API
A hwOS device has these endpoints:
- Service: Generic Access (`0x1800`)
- Characteristic: Device Name (`0x2A00`, `READ`) &rarr; "OSTCs 21876"
- Characteristic: Appearance (`0x2A01`, `READ`)
Expand All @@ -58,8 +56,13 @@ See [Terminal I/O Profile Client Implementation Guide](http://www.iot.com.tr/upl
- Characteristic: UART Credits RX (`00000003-0000-1000-8000-008025000000`, `WRITE`)
- Characteristic: UART Credits TX (`00000004-0000-1000-8000-008025000000`, `INDICATE`)

### Communication Workflow
See [Terminal I/O Profile Client Implementation Guide](http://www.iot.com.tr/uploads/pdf/TIO_Implementation_Guide_r05.pdf).

hwOS does not use Bluetooth LE characteristics directly as endpoints for fetching dives. Instead communication is done
through a **simulated virtual serial COM port** over four specific BLE characteristics. This is based on the
"Terminal I/O v2.0 protocol" by Telit Wireless Solutions (formerly Stollmann E+V GmbH).

## Connection Workflow
1. App connects to (previously bonded) BLE device
2. App sets up indication to Credits TX
3. App sets up notification to Data TX
Expand All @@ -69,8 +72,9 @@ See [Terminal I/O Profile Client Implementation Guide](http://www.iot.com.tr/upl
- Send commands via Data RX
- Receive responses via Data TX

### Package Format
See [hwOS API specification](https://code.heinrichsweikamp.com/public/hwos_code/raw-file/tip/doc/hwos_interface.pdf).

## Package Format
Requests:
- Byte 0: Command ID
- Byte 1...n: Payload (variable length payloads like strings are `0x00` terminated)
Expand All @@ -80,10 +84,10 @@ Responses:
- Byte 1...(n-1): Payload
- Byte n: `0x4D`

See [hwOS API specification](https://code.heinrichsweikamp.com/public/hwos_code/raw-file/tip/doc/hwos_interface.pdf).

### Download Dives
See [OstcConnection.kt](./data/src/main/kotlin/cloud/mike/divelog/data/importer/ostc/OstcConnection.kt) for
implementation details.

## Download Dives
First off we have to enable download mode by sending the "start communication" command (`0xBB`). Afterwards we can end
communication by sending the "exit communication" command (`0xFF`). This will kill the bluetooth connection.

Expand All @@ -96,12 +100,9 @@ We have three options:
- 65536 bytes total
- Includes more information than compact headers, like surface pressure, min. temperature, gas mix, deco model, etc.
- Send "get dive profile" command (`0x66`) with dive number (0-255).
- Sends full header and dive profile
- Sends full header and dive profile)
- Profile has variable length, e.g. ~21 kB for a one-hour dive

See [OstcConnection.kt](./data/src/main/kotlin/cloud/mike/divelog/data/importer/ostc/OstcConnection.kt) for
implementation details.

- Profile contains depth and events like gas mix change

## Links
- [Mike's Android Bluetooth Guide](https://mike.cloud/android/2021/05/19/bluetooth.html)
Expand Down

0 comments on commit f8bf2af

Please sign in to comment.