Skip to content

Commit c0eb263

Browse files
committed
Refactor DFU module, add English docs, normalize localization text
1 parent 474f919 commit c0eb263

4 files changed

Lines changed: 125 additions & 126 deletions

File tree

iOS/ESP32-DFU/ESP32-DFU/App/Localization.swift

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ enum AppLanguage: String, CaseIterable, Identifiable {
1515
switch self {
1616
case .system: return L("language.system")
1717
case .english: return "English"
18-
case .russian: return "Русский"
18+
case .russian: return "Russian"
1919
case .spanish: return "Español"
2020
case .german: return "Deutsch"
2121
case .french: return "Français"
@@ -92,67 +92,67 @@ private enum LocalizationTable {
9292
],
9393
"ru": [
9494
"app.title": "ESP32 DFU",
95-
"header.title": "Legacy DFU для ESP32",
96-
"status.scan_on": "Сканирование BLE",
97-
"status.scan_off": "Сканирование остановлено",
98-
"status.dfu_running": "DFU выполняется",
99-
"status.idle": "Ожидание",
100-
"device.not_selected": "Устройство не выбрано",
101-
"firmware.not_selected": "Файл не выбран",
102-
"device.subtitle": "Выберите ESP32 в режиме DFU",
103-
"firmware.subtitle": "Выберите firmware.bin",
104-
"button.devices": "Устройства",
105-
"button.file": "Файл",
106-
"button.start_dfu": "Старт DFU",
107-
"button.cancel": "Отмена",
108-
"timeline.title": "Стадии прошивки",
109-
"picker.title": "Выбор устройства",
110-
"picker.scan_timeout": "Поиск завершится через %d сек",
111-
"settings.title": "Настройки",
95+
"header.title": "Legacy DFU for ESP32",
96+
"status.scan_on": "BLE Scan On",
97+
"status.scan_off": "BLE Scan Off",
98+
"status.dfu_running": "DFU Running",
99+
"status.idle": "Idle",
100+
"device.not_selected": "No device selected",
101+
"firmware.not_selected": "No file selected",
102+
"device.subtitle": "Select ESP32 in DFU mode",
103+
"firmware.subtitle": "Select firmware.bin",
104+
"button.devices": "Devices",
105+
"button.file": "File",
106+
"button.start_dfu": "Start DFU",
107+
"button.cancel": "Cancel",
108+
"timeline.title": "Firmware stages",
109+
"picker.title": "Device selection",
110+
"picker.scan_timeout": "Scan will stop in %d sec",
111+
"settings.title": "Settings",
112112
"settings.section.dfu": "DFU",
113-
"settings.section.scan": "Сканирование BLE",
114-
"settings.section.behavior": "Поведение",
115-
"settings.section.language": "Язык",
116-
"settings.section.info": "Инфо",
113+
"settings.section.scan": "BLE Scanning",
114+
"settings.section.behavior": "Behavior",
115+
"settings.section.language": "Language",
116+
"settings.section.info": "Info",
117117
"settings.prn": "PRN: %d",
118118
"settings.mtu": "MTU: %d",
119-
"settings.scan_seconds": "Длительность поиска: %d сек",
120-
"settings.auto_reconnect": "Авто-переподключение",
121-
"settings.keep_screen_awake": "Не блокировать экран",
122-
"settings.profile": "Профиль: Nordic Legacy DFU",
123-
"settings.target": "Цель: ESP32 BLE OTA",
124-
"settings.language_picker": "Язык приложения",
125-
"language.system": "Системный",
126-
"msg.select_device_file": "Выберите устройство и файл",
127-
"msg.scan_finished_found": "Поиск завершен: найдено устройств %d",
128-
"msg.scan_in_progress": "Сканируем BLE-устройства (до %d сек)",
129-
"msg.need_device_and_firmware": "Нужно выбрать устройство и файл firmware",
130-
"msg.bluetooth_unavailable": "Bluetooth выключен или недоступен",
131-
"msg.unable_open_firmware": "Не удалось открыть файл прошивки: %@",
132-
"msg.cancelled": "Операция отменена пользователем",
133-
"msg.ble_retry": "Обрыв BLE. Повтор %d/%d",
134-
"msg.dfu_error": "DFU завершился с ошибкой: %@",
135-
"stage.idle.title": "Готово к DFU",
136-
"stage.idle.details": "Выберите устройство и файл прошивки",
137-
"stage.scanning.title": "Поиск устройства",
138-
"stage.scanning.details": "Сканируем BLE-устройства поблизости",
139-
"stage.connecting.title": "Подключение",
140-
"stage.connecting.details": "Устанавливаем стабильное BLE-соединение",
141-
"stage.bootloader.title": "Загрузка загрузчика DFU",
142-
"stage.bootloader.details": "Переход устройства в режим обновления",
143-
"stage.init.title": "Инициализация пакета",
144-
"stage.init.details": "Передаем служебные метаданные DFU",
145-
"stage.fw.title": "Загрузка firmware",
146-
"stage.fw.details": "Отправляем бинарный файл по BLE",
147-
"stage.validate.title": "Проверка пакета",
148-
"stage.validate.details": "Проверяем целостность и размер",
149-
"stage.activate.title": "Активация и перезапуск",
150-
"stage.activate.details": "Переключаем слот прошивки и перезагружаем",
151-
"stage.completed.title": "Обновление завершено",
152-
"stage.completed.details": "Устройство готово с новой прошивкой",
153-
"stage.failed.title": "Ошибка обновления",
154-
"stage.failed.details": "Проверьте подключение и повторите",
155-
"device.unknown": "Неизвестный ESP32"
119+
"settings.scan_seconds": "Scan duration: %d sec",
120+
"settings.auto_reconnect": "Auto reconnect",
121+
"settings.keep_screen_awake": "Keep screen awake",
122+
"settings.profile": "Profile: Nordic Legacy DFU",
123+
"settings.target": "Target: ESP32 BLE OTA",
124+
"settings.language_picker": "App language",
125+
"language.system": "System",
126+
"msg.select_device_file": "Select a device and firmware file",
127+
"msg.scan_finished_found": "Scan finished: found %d devices",
128+
"msg.scan_in_progress": "Scanning BLE devices (up to %d sec)",
129+
"msg.need_device_and_firmware": "You need to select a device and a firmware file",
130+
"msg.bluetooth_unavailable": "Bluetooth is off or unavailable",
131+
"msg.unable_open_firmware": "Unable to open firmware file: %@",
132+
"msg.cancelled": "Operation cancelled by user",
133+
"msg.ble_retry": "BLE disconnected. Retry %d/%d",
134+
"msg.dfu_error": "DFU failed: %@",
135+
"stage.idle.title": "Ready for DFU",
136+
"stage.idle.details": "Select a device and firmware file",
137+
"stage.scanning.title": "Scanning devices",
138+
"stage.scanning.details": "Scanning nearby BLE devices",
139+
"stage.connecting.title": "Connecting",
140+
"stage.connecting.details": "Establishing stable BLE connection",
141+
"stage.bootloader.title": "Bootloader switch",
142+
"stage.bootloader.details": "Switching device to update mode",
143+
"stage.init.title": "Init packet",
144+
"stage.init.details": "Sending DFU metadata",
145+
"stage.fw.title": "Firmware upload",
146+
"stage.fw.details": "Sending firmware binary over BLE",
147+
"stage.validate.title": "Validation",
148+
"stage.validate.details": "Checking firmware size and integrity",
149+
"stage.activate.title": "Activate and reboot",
150+
"stage.activate.details": "Switching OTA slot and rebooting",
151+
"stage.completed.title": "Update complete",
152+
"stage.completed.details": "Device is running new firmware",
153+
"stage.failed.title": "Update failed",
154+
"stage.failed.details": "Check connection and retry",
155+
"device.unknown": "Unknown ESP32"
156156
],
157157
"es": [
158158
"app.title": "ESP32 DFU",

iOS/ESP32-DFU/ESP32-DFU/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
<string>bluetooth-central</string>
3535
</array>
3636
<key>NSBluetoothAlwaysUsageDescription</key>
37-
<string>Приложение использует Bluetooth для поиска ESP32 и передачи DFU-прошивки.</string>
37+
<string>The app uses Bluetooth to discover ESP32 devices and transfer DFU firmware.</string>
3838
<key>NSBluetoothPeripheralUsageDescription</key>
39-
<string>Bluetooth нужен для подключения к ESP32 и обновления прошивки.</string>
39+
<string>Bluetooth is required to connect to ESP32 and perform firmware updates.</string>
4040
<key>UILaunchStoryboardName</key>
4141
<string>LaunchScreen</string>
4242
<key>UISupportedInterfaceOrientations</key>

iOS/ESP32-DFU/README.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
# ESP32-DFU iOS App
1+
# ESP32-DFU iOS Client
22

3-
SwiftUI-приложение для iPhone под BLE DFU обновление ESP32 (Legacy DFU профиль).
3+
SwiftUI iPhone application for BLE DFU firmware updates of ESP32 devices using the Legacy DFU profile.
44

5-
## Что реализовано
5+
## Implemented
66

7-
- Выбор BLE-устройства
8-
- Выбор файла прошивки (`firmware.bin`)
9-
- Индикатор прогресса
10-
- Таймлайн стадий прошивки:
11-
- Поиск устройства
12-
- Подключение
13-
- Загрузка загрузчика DFU
14-
- Инициализация пакета
15-
- Загрузка firmware
16-
- Проверка пакета
17-
- Активация и перезапуск
18-
- Экран настроек (кнопка сверху справа)
19-
- Современный UI: градиентный фон, карточки, SF Symbols
7+
- BLE device discovery and selection
8+
- Firmware file selection (binary image)
9+
- DFU progress tracking
10+
- Stage timeline for the update pipeline
11+
- Cancellation and retry behavior
12+
- Localization and settings screen
2013

21-
## Структура
14+
## Main Stack
2215

23-
- `ESP32-DFU/App` — точка входа приложения
24-
- `ESP32-DFU/Models` — модели устройства и этапов DFU
25-
- `ESP32-DFU/Services` — BLE сканер и менеджер DFU с состояниями
26-
- `ESP32-DFU/Views` — UI-экраны
27-
- `ESP32-DFU/Resources` — ассеты и `Info.plist`
16+
- SwiftUI (UI)
17+
- CoreBluetooth (BLE transport)
18+
- Background restoration for more resilient sessions
2819

29-
## Важно
20+
## Typical Flow
3021

31-
Текущая версия содержит полный UX-флоу и состояние DFU. Транспортный слой можно подключить в `DFUSessionManager` в месте, отмеченном комментарием, для фактической отправки пакетов в характеристики Legacy DFU ESP32.
22+
1. Scan and select target ESP32 DFU device.
23+
2. Select firmware binary file.
24+
3. Start DFU session.
25+
4. Wait for transfer, validation, and activation.
26+
5. Observe completion or error diagnostics.
27+
28+
## Notes
29+
30+
This app is intended as a companion client for the firmware project in the repository root.
31+
For production releases, publish mobile client and firmware as separate versioned artifacts.
Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,53 @@
1-
# REAL DFU Test Plan (ESP32)
1+
# Real DFU Test Plan (ESP32 + iOS)
22

3-
Этот чеклист нужен для реальной проверки прошивки вашего ESP32 через iOS-приложение ESP32-DFU.
3+
## Goal
44

5-
## 1. Подготовка
5+
Validate stable and repeatable BLE DFU updates from iOS app to ESP32 firmware target.
66

7-
1. Собрать новую прошивку устройства:
8-
- `pio run`
9-
2. Залить по USB базовую прошивку с DFU-сервисом:
10-
- `pio run -t upload`
11-
3. Открыть UART-лог:
12-
- `pio device monitor -b 115200`
13-
4. Собрать и запустить iOS-приложение на iPhone (не симулятор).
14-
5. Выбрать подписанную Team в Xcode для target `ESP32-DFU`.
7+
## Preconditions
158

16-
## 2. Базовый успешный сценарий
9+
- ESP32 is flashed with BLE DFU firmware.
10+
- iOS app has Bluetooth permissions granted.
11+
- Known-good firmware binary is available.
12+
- Device battery and phone battery are above safe thresholds.
1713

18-
1. В приложении нажать `Устройства` и выбрать ESP32-DFU.
19-
2. Выбрать файл `.pio/build/esp32dev/firmware.bin`.
20-
3. Нажать `Старт DFU`.
21-
4. Убедиться, что стадии доходят до `Активация и перезапуск` и затем `Обновление завершено`.
22-
5. После перезагрузки ESP32 снова появляется в списке и реклама DFU активна.
14+
## Test Cases
2315

24-
## 3. Проверка CRC/size валидации
16+
1. Happy path update
17+
- Discover device
18+
- Select valid firmware
19+
- Complete update to 100%
20+
- Verify reboot and new firmware behavior
2521

26-
1. Создать поврежденную копию файла прошивки (изменить 1 байт в конце).
27-
2. Повторить запуск DFU с поврежденным файлом.
28-
3. Ожидаемый результат:
29-
- DFU останавливается на стадии `Проверка пакета`.
30-
- Приложение получает ошибку ответа Validate.
31-
- ESP32 не переключает OTA слот (остается на рабочей прошивке).
22+
2. Wrong file handling
23+
- Select invalid/non-firmware file
24+
- Verify graceful error handling and no crash
3225

33-
## 4. Проверка retry при обрыве BLE
26+
3. Interrupted transfer
27+
- Move out of BLE range during transfer
28+
- Verify timeout/failure handling and ability to retry
3429

35-
1. Запустить DFU.
36-
2. Во время `Загрузка firmware` отойти с телефоном от устройства или временно выключить BLE на iPhone.
37-
3. Ожидаемый результат:
38-
- Приложение показывает сообщение `Обрыв BLE. Повтор X/3`.
39-
- Выполняется до 3 попыток переподключения.
30+
4. Cancellation
31+
- Start update and cancel mid-transfer
32+
- Verify progress reset and consistent state recovery
4033

41-
## 5. Проверка фонового восстановления
34+
5. Reconnect and retry
35+
- After failure, reconnect and rerun update
36+
- Verify successful completion
4237

43-
1. Запустить DFU и свернуть приложение.
44-
2. Через 10-20 секунд вернуть приложение на экран.
45-
3. Ожидаемый результат:
46-
- Центральный менеджер восстанавливает состояние.
47-
- DFU продолжается, если BLE-сессия не была потеряна.
38+
6. Multiple sequential updates
39+
- Run several updates in a row
40+
- Verify no memory growth symptoms and stable behavior
4841

49-
## 6. Если обновление не стартует
42+
## Pass Criteria
5043

51-
1. Проверить, что ESP32 рекламирует сервис UUID `00001530-1212-EFDE-1523-785FEABCD123`.
52-
2. Проверить, что выбран именно `firmware.bin` от текущей сборки.
53-
3. Перезапустить BLE на iPhone.
54-
4. Перезапустить ESP32 и повторить тест.
44+
- No app crashes
45+
- Deterministic stage transitions
46+
- Correct success/failure reporting
47+
- Firmware boots after successful update
48+
49+
## Logging Recommendations
50+
51+
- Capture serial logs from ESP32
52+
- Capture iOS debug logs for BLE and DFU states
53+
- Keep timestamps for correlation of events

0 commit comments

Comments
 (0)