> ## Documentation Index
> Fetch the complete documentation index at: https://docs.omi.me/llms.txt
> Use this file to discover all available pages before exploring further.

# DevKit 2 Testing

> Test storage, button, and SD card functionality on the Omi DevKit 2.

## Overview

Two areas to test on DevKit 2: **SD card storage** (offline audio recording) and **button behavior** (tap events via BLE).

<Warning>
  **Never remove the SD card while the device is on.** It is not hot-swappable. Use the safe removal process described below.
</Warning>

***

## SD Card Storage

When the device is disconnected from the phone (LED is red), audio data is written to the SD card instead of streaming over Bluetooth.

### SD Card Commands

Commands are sent as 6-byte packets: `[command, file_number, offset_byte0, offset_byte1, offset_byte2, offset_byte3]`

| Command | Action                              |
| ------- | ----------------------------------- |
| `0`     | Read specified file from offset     |
| `1`     | Clear all bytes in specified file   |
| `2`     | Clear all files in directory        |
| `3`     | Stop transmission of specified file |

**Example:** Read file 1 starting at byte 255:

```
[0, 1, 255, 0, 0, 0]
```

### Response Codes

| Code  | Meaning                                              |
| ----- | ---------------------------------------------------- |
| `0`   | Command successful                                   |
| `100` | End of file transmission (last byte)                 |
| `200` | Delete process finished                              |
| `3`   | Invalid file (file 0 never exists; files start at 1) |
| `4`   | File size is 0                                       |
| `6`   | Invalid command                                      |

<Note>
  If you don't receive code `100` or `200`, the command was not completed.
</Note>

***

## Testing Process

<Info>
  **Prerequisites:** Python packages from `requirements.txt`, plus `ffmpeg` and `opus` for audio decoding.
</Info>

Run these scripts in order:

<Steps>
  <Step title="Discover Devices" icon="bluetooth">
    Run `discover_devices.py` to list all nearby Bluetooth devices. Look for **"Omi"** or **"Omi Devkit 2"** and note the device ID.
  </Step>

  <Step title="Check File Sizes" icon="list">
    Run `get_info_list.py` — replace line 6 with your device ID. This lists the size of each audio file on the SD card.
  </Step>

  <Step title="Download Audio" icon="download">
    Run `get_audio_file.py` — replace line 9 with your device ID. Audio data streams to `my_file.txt` in the current directory.
  </Step>

  <Step title="Decode Audio" icon="file-audio">
    Run `decode_audio.py` to convert the downloaded data into a WAV file. If successful, you'll have a playable recording of what was spoken near the mic.
  </Step>

  <Step title="(Optional) Delete Audio" icon="trash">
    Run `delete_audio_file.py` — replace line 6 with your device ID. This clears audio data from the specified file.
  </Step>
</Steps>

***

## Safe SD Card Removal

<Steps>
  <Step title="Reset the device">
    Double-tap the reset button inside the kit
  </Step>

  <Step title="Remove the SD card">
    Remove the card to inspect contents on your computer
  </Step>

  <Step title="Reinsert and restart">
    Put the SD card back and tap the button to restart
  </Step>
</Steps>

***

## Device Behavior

| Connection State    | LED  | SD Card                         |
| ------------------- | ---- | ------------------------------- |
| No Bluetooth        | Red  | Writing audio to SD card        |
| Bluetooth connected | Blue | Stops writing; streams over BLE |

### App-Side SD Card Import

When the device connects to the app with stored audio:

1. A green banner appears showing estimated download time
2. Tap the banner (or go to **Settings → Device Settings → Storage**) to open the import screen
3. Press the download button to start importing — a progress bar shows completion

<Note>
  The green banner only appears for DevKit 2 devices. DevKit 1 devices do not support SD card import.
</Note>

***

## Button Events

After connecting to the BLE notification service, these events fire:

| Event Code | Action                   |
| ---------- | ------------------------ |
| `1`        | Single tap               |
| `2`        | Double tap               |
| `3`        | Long press (\~3 seconds) |
| `4`        | Button pressed down      |
| `5`        | Button released          |

Verify that each physical action sends the correct BLE packet.

***

## Known Issues

<Accordion title="Empty audio file on SD card (v2.0.1)" icon="bug">
  Some devices create an empty `a01.txt` file, preventing audio from being written.

  **Fix:**

  1. Delete the audio file
  2. Press the reset button to reboot
  3. The device will auto-generate the required files on startup
</Accordion>
