fix: revert SDK 36 bump, fix NimBLE setMTU crash, add --no-stub for OPI flash

This commit is contained in:
eddy 2026-07-30 23:38:32 +02:00
commit 84503f3a24
9 changed files with 165 additions and 180 deletions

View file

@ -19,7 +19,8 @@ ESP32-S3-PICO-1-N8R8 (Atom S3R Voice), 2 relais, 2 touch sensors (JR223B), BLE,
- PlatformIO, `platform = espressif32@6.7.0`, board `esp32-s3-devkitc-1`
- CDC USB serial (`ARDUINO_USB_CDC_ON_BOOT=1`), QIO OPI flash
- Upload laptop: `pio run -t upload`, port `/dev/ttyACM0`, 115200 baud
- **Upload:** `pio run -t upload` (via `--no-stub`, OPI flash vereist dit). Poort: **NOOIT `/dev/ttyACM0`** (dat is het Atreus toetsenbord). ESP32 herkennen via `ls /dev/serial/by-id/ | grep -i espressif` en die poort gebruiken. PlatformIO: pas `upload_port` in `platformio.ini` aan naar de gevonden poort.
- **Direct flashen (handmatig):** `~/.platformio/packages/tool-esptoolpy/esptool.py --no-stub --chip esp32s3 --port /dev/ttyACM1 --baud 115200 --before default_reset --after hard_reset write_flash --flash_mode keep --flash_size keep 0x0 .pio/build/m5stack-atoms3r/bootloader.bin 0x8000 .pio/build/m5stack-atoms3r/partitions.bin 0xE000 ~/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin 0x10000 .pio/build/m5stack-atoms3r/firmware.bin`
- NVS: namespace "hmac", key "key" (32 bytes HMAC)
- BLE advertising "SylDa_Server", HMAC-verified relay commands

View file

@ -11,7 +11,7 @@ android {
// compileSdk/targetSdk stays on 34 (Android 14) by deliberate choice. The target audience
// consists of physically disabled users who are very reluctant to update their phones. Staying
// on API 34 maximises device compatibility. Re-evaluate when the user base has migrated.
compileSdk 36
compileSdk 34
if (hasSigningConfig) {
def props = new Properties()
@ -30,7 +30,7 @@ android {
defaultConfig {
applicationId "nl.eddydevink.sylda"
minSdk 26
targetSdk 36
targetSdk 34
versionCode 1
versionName "1.0"
buildConfigField "String", "BUILD_NUMBER", "\"${new java.text.SimpleDateFormat("yyyyMMddHHmmss").format(new Date())}\""

View file

@ -23,7 +23,7 @@ class MainActivity : AppCompatActivity(), BleCallbacks {
private const val REQUEST_SETTINGS = 1
private const val POST_SETTINGS_RESCAN_MS = 500L
private const val ON_RESUME_SCAN_DELAY_MS = 300L
private const val BUNDLED_FIRMWARE_VERSION = "5"
private const val BUNDLED_FIRMWARE_VERSION = "6"
}
private lateinit var manager: BleRelayManager

View file

@ -64,7 +64,7 @@ class SettingsActivity : AppCompatActivity() {
private const val REBOOT_WAIT_MS = 5000L
private const val REBOOT_POLL_MS = 500L
private const val REBOOT_MAX_WAIT_MS = 15000L
private const val EXPECTED_FIRMWARE_VERSION = "5"
private const val EXPECTED_FIRMWARE_VERSION = "6"
}
private enum class UsbAction { NONE, EXCHANGE_KEY, FLASH }

View file

@ -2,77 +2,69 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp">
android:padding="16dp">
<LinearLayout
android:id="@+id/settingsContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|top"
android:layout_marginTop="8dp"
android:orientation="horizontal"
android:gravity="center_vertical"
android:background="?android:attr/selectableItemBackground"
android:clickable="true"
android:focusable="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/settings_label"
android:textSize="14sp"
android:layout_marginEnd="4dp" />
<ImageButton
android:id="@+id/settingsButton"
android:layout_width="40dp"
android:layout_height="40dp"
android:src="@drawable/ic_settings"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/cd_settings" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal"
android:gravity="center">
<Button
android:id="@+id/relay1Button"
android:layout_width="150dp"
android:layout_height="200dp"
android:text="1"
android:textSize="24sp"
android:textAllCaps="false"
android:enabled="false" />
<Button
android:id="@+id/relay2Button"
android:layout_width="150dp"
android:layout_height="200dp"
android:layout_marginStart="16dp"
android:text="2"
android:textSize="24sp"
android:textAllCaps="false"
android:enabled="false" />
</LinearLayout>
<TextView
android:id="@+id/statusText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|start"
android:text="@string/status_default"
android:textSize="14sp" />
android:text="@string/settings_label"
android:textSize="14sp"
android:layout_marginEnd="4dp" />
</FrameLayout>
<ImageButton
android:id="@+id/settingsButton"
android:layout_width="40dp"
android:layout_height="40dp"
android:src="@drawable/ic_settings"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/cd_settings" />
</LinearLayout>
</FrameLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal"
android:gravity="center">
<Button
android:id="@+id/relay1Button"
android:layout_width="150dp"
android:layout_height="200dp"
android:text="1"
android:textSize="24sp"
android:textAllCaps="false"
android:enabled="false" />
<Button
android:id="@+id/relay2Button"
android:layout_width="150dp"
android:layout_height="200dp"
android:layout_marginStart="16dp"
android:text="2"
android:textSize="24sp"
android:textAllCaps="false"
android:enabled="false" />
</LinearLayout>
<TextView
android:id="@+id/statusText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|start"
android:text="@string/status_default"
android:textSize="14sp" />
</FrameLayout>

View file

@ -3,147 +3,138 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fitsSystemWindows="true">
android:padding="24dp">
<RadioGroup
android:id="@+id/flashMethodGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="8dp"
android:checkedButton="@id/methodBluetooth">
<RadioButton
android:id="@+id/methodBluetooth"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="@string/method_bluetooth" />
<RadioButton
android:id="@+id/methodUsb"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="@string/method_usb" />
</RadioGroup>
<Button
android:id="@+id/updateModuleButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/button_update_module" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?android:attr/listDivider"
android:layout_marginTop="24dp"
android:layout_marginBottom="16dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/section_labels"
android:textSize="14sp"
android:textStyle="bold"
android:layout_marginBottom="8dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="24dp"
android:layout_marginTop="8dp">
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="16dp">
<RadioGroup
android:id="@+id/flashMethodGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="8dp"
android:checkedButton="@id/methodBluetooth">
<RadioButton
android:id="@+id/methodBluetooth"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="@string/method_bluetooth" />
<RadioButton
android:id="@+id/methodUsb"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="@string/method_usb" />
</RadioGroup>
<Button
android:id="@+id/updateModuleButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/button_update_module" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?android:attr/listDivider"
android:layout_marginTop="24dp"
android:layout_marginBottom="16dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/section_labels"
android:textSize="14sp"
android:textStyle="bold"
android:layout_marginBottom="8dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="16dp">
<EditText
android:id="@+id/labelRelay1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="@string/hint_label_relay1"
android:maxLines="1"
android:inputType="text"
android:imeOptions="actionDone"
android:gravity="center" />
<EditText
android:id="@+id/labelRelay2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="@string/hint_label_relay2"
android:maxLines="1"
android:inputType="text"
android:imeOptions="actionDone"
android:gravity="center" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?android:attr/listDivider"
android:layout_marginBottom="16dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/section_theme"
android:textSize="14sp"
android:textStyle="bold"
android:layout_marginBottom="8dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="3">
<RadioGroup
android:id="@+id/themeGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RadioButton
android:id="@+id/themeSystem"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="@string/theme_system" />
<RadioButton
android:id="@+id/themeLight"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="@string/theme_light" />
<RadioButton
android:id="@+id/themeDark"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="@string/theme_dark" />
</RadioGroup>
</LinearLayout>
<View
<EditText
android:id="@+id/labelRelay1"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1" />
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="@string/hint_label_relay1"
android:maxLines="1"
android:inputType="text"
android:imeOptions="actionDone"
android:gravity="center" />
<EditText
android:id="@+id/labelRelay2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="@string/hint_label_relay2"
android:maxLines="1"
android:inputType="text"
android:imeOptions="actionDone"
android:gravity="center" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?android:attr/listDivider"
android:layout_marginBottom="16dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/section_theme"
android:textSize="14sp"
android:textStyle="bold"
android:layout_marginBottom="8dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="3">
<RadioGroup
android:id="@+id/themeGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RadioButton
android:id="@+id/themeSystem"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="@string/theme_system" />
<RadioButton
android:id="@+id/themeLight"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="@string/theme_light" />
<RadioButton
android:id="@+id/themeDark"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="@string/theme_dark" />
</RadioGroup>
</LinearLayout>
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>

View file

@ -14,4 +14,5 @@ build_flags =
lib_deps =
h2zero/NimBLE-Arduino@^2
upload_port = /dev/ttyACM1
upload_speed = 115200
upload_speed = 115200
upload_flags = --no-stub

View file

@ -35,7 +35,7 @@
#define NVS_NAMESPACE "hmac"
#define NVS_KEY_NAME "key"
#define NVS_UUID_NAME "uuid"
#define FIRMWARE_VERSION "5"
#define FIRMWARE_VERSION "6"
NimBLECharacteristic *pCharacteristic;
bool deviceConnected = false;
@ -338,8 +338,8 @@ void setup() {
}
Serial.println("LED blink done, starting BLE...");
NimBLEDevice::setMTU(512);
NimBLEDevice::init("SylDa_Server");
NimBLEDevice::setMTU(248);
NimBLEServer *pServer = NimBLEDevice::createServer();
pServer->setCallbacks(new MyServerCallbacks());