Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions Apps/MediaKeys/main/Source/MediaKeys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
namespace {

const char* TAG = "MediaKeys";
const char* DEVICE_NAME = "Tactility Media Keys";

// Button layout: two rows of three media-control buttons
const char* BTN_MAP[] = {
Expand Down Expand Up @@ -268,16 +269,21 @@ void handleSwitchToggle(Context* ctx, bool enabled) {
return;
}

bluetooth_set_device_name(ctx->btDevice, "Tactility Media Keys");

enum BtRadioState radioState;
bluetooth_get_radio_state(ctx->btDevice, &radioState);

if (radioState == BT_RADIO_STATE_ON) {
// Radio already up - start HID immediately.
ctx->radioWasOff = false;
startHid(ctx);
// Rename only after HID is up: with the radio on, a rename restarts advertising
// right away, and the GATT profile switch in bluetooth_hid_device_start() asserts in
// NimBLE (ble_svc_gap_init) if it runs while that advertising is still active.
// Once HID is active, the rename just restarts HID advertising with the new name.
if (ctx->hidDevice) bluetooth_set_device_name(ctx->btDevice, DEVICE_NAME);
} else {
// Radio off: renaming stores the name without touching advertising
bluetooth_set_device_name(ctx->btDevice, DEVICE_NAME);
// Turn the radio on; startHid() will be called from handleBtEvent()
// once BT_RADIO_STATE_ON fires. Our BT event subscription (mediaKeysInitBt())
// was already claimed before the app's main loop started waiting, so that
Expand Down
4 changes: 2 additions & 2 deletions Apps/MediaKeys/manifest.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ manifest.version=0.3
target.sdk=0.8.0-dev
target.platforms=esp32s3,esp32p4
id=tactility.mediakeys
version.name=0.17.0
version.code=17
version.name=0.18.0
version.code=18
name=Media Keys
description=Bluetooth media keys. Touch or Physical Keyboard control\nB - previous, P - play/pause, N - next, M - mute, D - volume down, U - volume up.\nQ or ESC to exit focus.
app.0.id=tactility.mediakeys
Expand Down
Loading