Skip to content

Commit d2141d6

Browse files
committed
asterix: add shell option for silk legacy compatibility
License: GPL-3.0-or-later Signed-off-by: Joshua Wise <[email protected]>
1 parent 4ae4a49 commit d2141d6

File tree

10 files changed

+130
-7
lines changed

10 files changed

+130
-7
lines changed

src/fw/apps/system_apps/settings/settings_system.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/* SPDX-FileCopyrightText: 2024 Google LLC */
22
/* SPDX-License-Identifier: Apache-2.0 */
3+
/* SPDX-FileCopyrightText: 2025 Joshua Wise */
4+
/* SPDX-License-Identifier: GPL-3.0-or-later */
35

46
#include "settings_factory_reset.h"
57
#include "settings_menu.h"
@@ -66,6 +68,9 @@ enum {
6668
#if PLATFORM_ASTERIX || PLATFORM_OBELIX
6769
DebuggingItemMotionSensitivity,
6870
#endif
71+
#if PLATFORM_ASTERIX
72+
DebuggingItemBluetoothLegacy,
73+
#endif
6974
#if CAPABILITY_HAS_DYNAMIC_BACKLIGHT
7075
DebuggingItemDynamicBacklightMinThreshold,
7176
DebuggingItemDynamicBacklightMaxThreshold,
@@ -584,6 +589,9 @@ static const char* s_debugging_titles[DebuggingItem_Count] = {
584589
#if PLATFORM_ASTERIX || PLATFORM_OBELIX
585590
[DebuggingItemMotionSensitivity] = i18n_noop("Motion Sensitivity"),
586591
#endif
592+
#if PLATFORM_ASTERIX
593+
[DebuggingItemBluetoothLegacy] = i18n_noop("BLE compat mode"),
594+
#endif
587595
#if CAPABILITY_HAS_DYNAMIC_BACKLIGHT
588596
[DebuggingItemDynamicBacklightMinThreshold] = i18n_noop("Dyn BL Min Threshold"),
589597
[DebuggingItemDynamicBacklightMaxThreshold] = i18n_noop("Dyn BL Max Threshold"),
@@ -619,6 +627,11 @@ static void prv_debugging_draw_row_callback(GContext* ctx, const Layer *cell_lay
619627
subtitle_text = i18n_get(s_motion_sensitivity_labels[prv_motion_sensitivity_get_selection_index()], data);
620628
}
621629
#endif
630+
#if PLATFORM_ASTERIX
631+
else if (cell_index->row == DebuggingItemBluetoothLegacy) {
632+
subtitle_text = shell_prefs_bluetooth_legacy_compat() ? i18n_get("Emulate silk", data) : i18n_get("Disabled", data);
633+
}
634+
#endif
622635
#if CAPABILITY_HAS_DYNAMIC_BACKLIGHT
623636
else if (cell_index->row == DebuggingItemDynamicBacklightMinThreshold) {
624637
uint32_t min_threshold = backlight_get_dynamic_min_threshold();
@@ -669,6 +682,11 @@ static void prv_debugging_select_callback(MenuLayer *menu_layer,
669682
prv_motion_sensitivity_menu_push(data);
670683
break;
671684
#endif
685+
#if PLATFORM_ASTERIX
686+
case DebuggingItemBluetoothLegacy:
687+
shell_prefs_set_bluetooth_legacy_compat(!shell_prefs_bluetooth_legacy_compat());
688+
break;
689+
#endif
672690
#if CAPABILITY_HAS_DYNAMIC_BACKLIGHT
673691
case DebuggingItemDynamicBacklightMinThreshold:
674692
prv_dyn_bl_min_threshold_menu_push(data);

src/fw/board/boards/board_asterix.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1+
/* SPDX-FileCopyrightText: 2025 Core Devices */
2+
/* SPDX-FileCopyrightText: 2025 Joshua Wise */
3+
/* SPDX-License-Identifier: Apache-2.0 */
4+
15
#pragma once
26

37
#include "drivers/pmic/npm1300.h"
48
#include "services/imu/units.h"
59
#include "util/size.h"
610

11+
#define BT_VENDOR_ID_COMPAT 0x0154
12+
#define BT_VENDOR_NAME_COMPAT "Pebble Technology"
13+
714
#define BT_VENDOR_ID 0x0EEA
815
#define BT_VENDOR_NAME "Core Devices LLC"
916

src/fw/comm/ble/gap_le_slave_discovery.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/* SPDX-FileCopyrightText: 2024 Google LLC */
22
/* SPDX-License-Identifier: Apache-2.0 */
3+
/* SPDX-FileCopyrightText: 2025 Joshua Wise */
4+
/* SPDX-License-Identifier: GPL-3.0-or-later */
35

46
#include "board/board.h"
57

@@ -29,6 +31,17 @@
2931
#include <btutil/bt_uuid.h>
3032
#include <util/attributes.h>
3133
#include <util/size.h>
34+
#include "shell/prefs.h"
35+
36+
#if PLATFORM_ASTERIX && !RECOVERY_FW
37+
static bool prv_should_override() { return shell_prefs_bluetooth_legacy_compat(); }
38+
#else
39+
static bool prv_should_override() { return false; }
40+
#endif
41+
42+
#ifndef BT_VENDOR_ID_COMPAT
43+
#define BT_VENDOR_ID_COMPAT BT_VENDOR_ID
44+
#endif
3245

3346
static GAPLEAdvertisingJobRef s_discovery_advert_job;
3447

@@ -103,8 +116,8 @@ static void prv_schedule_ad_job(void) {
103116
};
104117
} mfg_data = {
105118
.payload_type = 0 /* For future proofing. Only one type for now.*/,
106-
.hw_platform = TINTIN_METADATA.hw_platform,
107-
.color = mfg_info_get_watch_color(),
119+
.hw_platform = prv_should_override() ? FirmwareMetadataPlatformPebbleSilk : TINTIN_METADATA.hw_platform,
120+
.color = prv_should_override() ? WATCH_INFO_COLOR_PEBBLE_2_SE_BLACK : mfg_info_get_watch_color(),
108121
.fw_version = {
109122
.major = GIT_MAJOR_VERSION,
110123
.minor = GIT_MINOR_VERSION,
@@ -118,7 +131,7 @@ static void prv_schedule_ad_job(void) {
118131
MFG_SERIAL_NUMBER_SIZE);
119132

120133
ble_ad_set_manufacturer_specific_data(ad,
121-
BT_VENDOR_ID,
134+
prv_should_override() ? BT_VENDOR_ID_COMPAT : BT_VENDOR_ID,
122135
(const uint8_t *) &mfg_data,
123136
sizeof(struct ManufacturerSpecificData));
124137

src/fw/kernel/system_versions.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/* SPDX-FileCopyrightText: 2024 Google LLC */
22
/* SPDX-License-Identifier: Apache-2.0 */
3+
/* SPDX-FileCopyrightText: 2025 Joshua Wise */
4+
/* SPDX-License-Identifier: GPL-3.0-or-later */
35

46
#include "console/prompt.h"
57
#include "drivers/fpc_pinstrap.h"
@@ -29,6 +31,14 @@
2931

3032
#include <string.h>
3133

34+
#include "shell/prefs.h"
35+
36+
#if PLATFORM_ASTERIX && !RECOVERY_FW
37+
static bool prv_should_override() { return shell_prefs_bluetooth_legacy_compat(); }
38+
#else
39+
static bool prv_should_override() { return false; }
40+
#endif
41+
3242
#define VERSION_REQUEST 0x00
3343
#define VERSION_RESPONSE 0x01
3444

@@ -64,6 +74,9 @@ static void prv_fixup_firmware_metadata(FirmwareMetadata *fw_metadata) {
6474
fw_metadata->version_timestamp = htonl(fw_metadata->version_timestamp);
6575
fixup_string(fw_metadata->version_tag, sizeof(fw_metadata->version_tag));
6676
fixup_string(fw_metadata->version_short, sizeof(fw_metadata->version_short));
77+
if (prv_should_override()) {
78+
fw_metadata->hw_platform = FirmwareMetadataPlatformPebbleSilk;
79+
}
6780
}
6881

6982
static void prv_fixup_running_firmware_metadata(FirmwareMetadata *fw_metadata) {

src/fw/mfg/asterix/mfg_info.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
/* SPDX-FileCopyrightText: 2025 Core Devices LLC */
22
/* SPDX-License-Identifier: Apache-2.0 */
3+
/* SPDX-FileCopyrightText: 2025 Joshua Wise */
4+
/* SPDX-License-Identifier: GPL-3.0-or-later */
35

46
#include "mfg/mfg_info.h"
57
#include "drivers/flash.h"
68
#include "flash_region/flash_region.h"
9+
#include "shell/prefs.h"
710

811
#define CURRENT_DATA_VERSION 0
912

src/fw/services/common/bluetooth/dis.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/* SPDX-FileCopyrightText: 2024 Google LLC */
22
/* SPDX-License-Identifier: Apache-2.0 */
3+
/* SPDX-FileCopyrightText: 2025 Joshua Wise */
4+
/* SPDX-License-Identifier: GPL-3.0-or-later */
35

46
#include <bluetooth/dis.h>
57

@@ -13,18 +15,33 @@
1315
#include "mfg/mfg_info.h"
1416
#include "mfg/mfg_serials.h"
1517
#include "system/version.h"
18+
#include "shell/prefs.h"
19+
20+
#if PLATFORM_ASTERIX && !RECOVERY_FW
21+
static bool prv_should_override() { return shell_prefs_bluetooth_legacy_compat(); }
22+
#else
23+
static bool prv_should_override() { return false; }
24+
#endif
25+
26+
#ifndef BT_VENDOR_NAME_COMPAT
27+
#define BT_VENDOR_NAME_COMPAT BT_VENDOR_NAME
28+
#endif
1629

1730
_Static_assert(MODEL_NUMBER_LEN >= MFG_HW_VERSION_SIZE + 1, "Size mismatch");
1831
_Static_assert(MANUFACTURER_LEN >= sizeof(BT_VENDOR_NAME), "Size mismatch");
1932
_Static_assert(SERIAL_NUMBER_LEN >= MFG_SERIAL_NUMBER_SIZE + 1, "Size mismatch");
2033
_Static_assert(FW_REVISION_LEN >= sizeof(TINTIN_METADATA.version_tag), "Size mismatch");
2134

2235
static void prv_set_model_number(DisInfo *info) {
23-
mfg_info_get_hw_version(info->model_number, MODEL_NUMBER_LEN);
36+
if (prv_should_override()) {
37+
strcpy(info->model_number, "silk21");
38+
} else {
39+
mfg_info_get_hw_version(info->model_number, MODEL_NUMBER_LEN);
40+
}
2441
}
2542

2643
static void prv_set_manufacturer_name(DisInfo *info) {
27-
strncpy(info->manufacturer, BT_VENDOR_NAME, MANUFACTURER_LEN);
44+
strncpy(info->manufacturer, prv_should_override() ? BT_VENDOR_NAME_COMPAT : BT_VENDOR_NAME, MANUFACTURER_LEN);
2845
}
2946

3047
static void prv_set_serial_number(DisInfo *info) {

src/fw/services/common/registry_endpoint.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,31 @@
11
/* SPDX-FileCopyrightText: 2024 Google LLC */
22
/* SPDX-License-Identifier: Apache-2.0 */
3+
/* SPDX-FileCopyrightText: 2025 Joshua Wise */
4+
/* SPDX-License-Identifier: GPL-3.0-or-later */
35

46
#include "services/common/comm_session/session.h"
57
#include "mfg/mfg_info.h"
8+
#include "shell/prefs.h"
69

710
#include <string.h>
811

912
#define MFG_COLOR_KEY "mfg_color"
1013

1114
#define FACTORY_REGISTRY_ENDPOINT 5001
1215

16+
#if PLATFORM_ASTERIX && !RECOVERY_FW
17+
static bool prv_should_override() { return shell_prefs_bluetooth_legacy_compat(); }
18+
#else
19+
static bool prv_should_override() { return false; }
20+
#endif
21+
1322
static void prv_send_response(const uint8_t *data, unsigned int length) {
1423
comm_session_send_data(comm_session_get_system_session(), FACTORY_REGISTRY_ENDPOINT,
1524
data, length, COMM_SESSION_DEFAULT_TIMEOUT);
1625
}
1726

1827
static void prv_send_color_response(void) {
19-
const uint8_t response[] = { 0x01, 0x04, 0x0, 0x0, 0x0, mfg_info_get_watch_color() };
28+
const uint8_t response[] = { 0x01, 0x04, 0x0, 0x0, 0x0, prv_should_override() ? WATCH_INFO_COLOR_PEBBLE_2_SE_BLACK : mfg_info_get_watch_color() };
2029
prv_send_response(response, sizeof(response));
2130
}
2231

src/fw/shell/normal/prefs.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/* SPDX-FileCopyrightText: 2024 Google LLC */
22
/* SPDX-License-Identifier: Apache-2.0 */
3+
/* SPDX-FileCopyrightText: 2025 Joshua Wise */
4+
/* SPDX-License-Identifier: GPL-3.0-or-later */
35

46
#include "quick_launch.h"
57
#include "shell/normal/quick_launch.h"
@@ -12,6 +14,7 @@
1214
#include "apps/system_apps/toggle/quiet_time.h"
1315
#include "board/board.h"
1416
#include "applib/graphics/gtypes.h"
17+
#include "comm/ble/gap_le_slave_discovery.h"
1518
#include "drivers/ambient_light.h"
1619
#include "drivers/backlight.h"
1720
#include "mfg/mfg_info.h"
@@ -224,6 +227,11 @@ static uint8_t s_legacy_app_render_mode = 0; // Default to bezel mode
224227
static GColor s_settings_menu_highlight_color = GColorCobaltBlue;
225228
static GColor s_apps_menu_highlight_color = GColorVividCerulean;
226229

230+
#if PLATFORM_ASTERIX
231+
#define PREF_KEY_BLUETOOTH_LEGACY_COMPAT "bluetoothLegacyCompat"
232+
static bool s_bluetooth_legacy_compat = false;
233+
#endif
234+
227235

228236
// ============================================================================================
229237
// Handlers for each pref that validate the new setting and store the new value in our globals.
@@ -575,6 +583,16 @@ static bool prv_set_s_coredump_on_request_enabled(bool *enabled) {
575583
return true;
576584
}
577585

586+
#if PLATFORM_ASTERIX
587+
static bool prv_set_s_bluetooth_legacy_compat(bool *enabled) {
588+
s_bluetooth_legacy_compat = *enabled;
589+
if (gap_le_slave_is_discoverable()) {
590+
gap_le_slave_set_discoverable(true); // recompute the advertising data
591+
}
592+
return true;
593+
}
594+
#endif
595+
578596
#if PLATFORM_OBELIX
579597
static bool prv_set_s_legacy_app_render_mode(uint8_t *mode) {
580598
if (*mode >= LegacyAppRenderModeCount) {
@@ -1563,3 +1581,13 @@ GColor shell_prefs_get_apps_menu_highlight_color(void){
15631581
void shell_prefs_set_apps_menu_highlight_color(GColor color) {
15641582
prv_pref_set(PREF_KEY_APPS_MENU_HIGHLIGHT_COLOR, &color, sizeof(GColor));
15651583
}
1584+
1585+
#if PLATFORM_ASTERIX
1586+
bool shell_prefs_bluetooth_legacy_compat(void) {
1587+
return s_bluetooth_legacy_compat;
1588+
}
1589+
1590+
void shell_prefs_set_bluetooth_legacy_compat(bool enabled) {
1591+
prv_pref_set(PREF_KEY_BLUETOOTH_LEGACY_COMPAT, &enabled, sizeof(enabled));
1592+
}
1593+
#endif

src/fw/shell/normal/prefs_values.h.inc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/* SPDX-FileCopyrightText: 2024 Google LLC */
2+
/* SPDX-License-Identifier: Apache-2.0 */
3+
/* SPDX-FileCopyrightText: 2025 Joshua Wise */
4+
/* SPDX-License-Identifier: GPL-3.0-or-later */
5+
16
// Included by prefs.c to declare the list of preferences and their keys
27
PREFS_MACRO(PREF_KEY_CLOCK_24H, s_clock_24h)
38
PREFS_MACRO(PREF_KEY_CLOCK_TIMEZONE_SOURCE_IS_MANUAL, s_clock_timezone_source_is_manual)
@@ -57,3 +62,6 @@
5762

5863
PREFS_MACRO(PREF_KEY_SETTINGS_MENU_HIGHLIGHT_COLOR, s_settings_menu_highlight_color)
5964
PREFS_MACRO(PREF_KEY_APPS_MENU_HIGHLIGHT_COLOR, s_apps_menu_highlight_color)
65+
#if PLATFORM_ASTERIX
66+
PREFS_MACRO(PREF_KEY_BLUETOOTH_LEGACY_COMPAT, s_bluetooth_legacy_compat)
67+
#endif

src/fw/shell/prefs.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/* SPDX-FileCopyrightText: 2024 Google LLC */
22
/* SPDX-License-Identifier: Apache-2.0 */
3+
/* SPDX-FileCopyrightText: 2025 Joshua Wise */
4+
/* SPDX-License-Identifier: GPL-3.0-or-later */
35

46
#pragma once
57

@@ -148,4 +150,9 @@ GColor shell_prefs_get_settings_menu_highlight_color(void);
148150
void shell_prefs_set_settings_menu_highlight_color(GColor color);
149151

150152
GColor shell_prefs_get_apps_menu_highlight_color(void);
151-
void shell_prefs_set_apps_menu_highlight_color(GColor color);
153+
void shell_prefs_set_apps_menu_highlight_color(GColor color);
154+
155+
#if PLATFORM_ASTERIX
156+
bool shell_prefs_bluetooth_legacy_compat(void);
157+
void shell_prefs_set_bluetooth_legacy_compat(bool enabled);
158+
#endif

0 commit comments

Comments
 (0)