mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-07-23 01:18:12 -07:00
Format
This commit is contained in:
+1
-3
@@ -19,9 +19,7 @@ App(
|
||||
Lib(
|
||||
name="base64",
|
||||
),
|
||||
Lib(
|
||||
name="linked_list"
|
||||
),
|
||||
Lib(name="linked_list"),
|
||||
Lib(
|
||||
name="timezone_utils",
|
||||
),
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
#define BAD_KB_SETTINGS_PATH BAD_KB_APP_BASE_FOLDER "/" BAD_KB_SETTINGS_FILE_NAME
|
||||
|
||||
// this is the MAC address used when we do not forget paired device (BOUND STATE)
|
||||
const uint8_t BAD_KB_BOUND_MAC_ADDRESS[BAD_KB_MAC_ADDRESS_LEN] = {0x41, 0x4a, 0xef, 0xb6, 0xa9, 0xd4};
|
||||
const uint8_t BAD_KB_BOUND_MAC_ADDRESS[BAD_KB_MAC_ADDRESS_LEN] =
|
||||
{0x41, 0x4a, 0xef, 0xb6, 0xa9, 0xd4};
|
||||
|
||||
static bool bad_kb_app_custom_event_callback(void* context, uint32_t event) {
|
||||
furi_assert(context);
|
||||
@@ -36,7 +37,10 @@ static void bad_kb_app_tick_event_callback(void* context) {
|
||||
static void bad_kb_load_settings(BadKbApp* app) {
|
||||
furi_string_reset(app->keyboard_layout);
|
||||
strcpy(app->config.bt_name, "");
|
||||
memcpy(app->config.bt_mac, furi_hal_bt_get_profile_mac_addr(FuriHalBtProfileHidKeyboard), BAD_KB_MAC_ADDRESS_LEN);
|
||||
memcpy(
|
||||
app->config.bt_mac,
|
||||
furi_hal_bt_get_profile_mac_addr(FuriHalBtProfileHidKeyboard),
|
||||
BAD_KB_MAC_ADDRESS_LEN);
|
||||
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
FlipperFormat* file = flipper_format_file_alloc(storage);
|
||||
@@ -50,8 +54,12 @@ static void bad_kb_load_settings(BadKbApp* app) {
|
||||
} else {
|
||||
strcpy(app->config.bt_name, "");
|
||||
}
|
||||
if(!flipper_format_read_hex(file, "Bt_Mac", (uint8_t*)&app->config.bt_mac, BAD_KB_MAC_ADDRESS_LEN)) {
|
||||
memcpy(app->config.bt_mac, furi_hal_bt_get_profile_mac_addr(FuriHalBtProfileHidKeyboard), BAD_KB_MAC_ADDRESS_LEN);
|
||||
if(!flipper_format_read_hex(
|
||||
file, "Bt_Mac", (uint8_t*)&app->config.bt_mac, BAD_KB_MAC_ADDRESS_LEN)) {
|
||||
memcpy(
|
||||
app->config.bt_mac,
|
||||
furi_hal_bt_get_profile_mac_addr(FuriHalBtProfileHidKeyboard),
|
||||
BAD_KB_MAC_ADDRESS_LEN);
|
||||
}
|
||||
furi_string_free(tmp_str);
|
||||
flipper_format_file_close(file);
|
||||
@@ -80,7 +88,8 @@ static void bad_kb_save_settings(BadKbApp* app) {
|
||||
if(flipper_format_file_open_always(file, BAD_KB_SETTINGS_PATH)) {
|
||||
flipper_format_write_string(file, "Keyboard_Layout", app->keyboard_layout);
|
||||
flipper_format_write_string_cstr(file, "Bt_Name", app->config.bt_name);
|
||||
flipper_format_write_hex(file, "Bt_Mac", (uint8_t*)&app->config.bt_mac, BAD_KB_MAC_ADDRESS_LEN);
|
||||
flipper_format_write_hex(
|
||||
file, "Bt_Mac", (uint8_t*)&app->config.bt_mac, BAD_KB_MAC_ADDRESS_LEN);
|
||||
flipper_format_file_close(file);
|
||||
}
|
||||
flipper_format_free(file);
|
||||
@@ -106,7 +115,8 @@ void bad_kb_config_switch_mode(BadKbApp* app) {
|
||||
|
||||
void bad_kb_config_switch_remember_mode(BadKbApp* app) {
|
||||
if(app->bt_remember) {
|
||||
furi_hal_bt_set_profile_pairing_method(FuriHalBtProfileHidKeyboard, GapPairingPinCodeVerifyYesNo);
|
||||
furi_hal_bt_set_profile_pairing_method(
|
||||
FuriHalBtProfileHidKeyboard, GapPairingPinCodeVerifyYesNo);
|
||||
bt_set_profile_mac_address(app->bt, (uint8_t*)&BAD_KB_BOUND_MAC_ADDRESS);
|
||||
bt_enable_peer_key_update(app->bt);
|
||||
} else {
|
||||
@@ -121,8 +131,12 @@ int32_t bad_kb_connection_init(BadKbApp* app) {
|
||||
app->prev_config.usb_mode = furi_hal_usb_get_config();
|
||||
furi_hal_usb_set_config(NULL, NULL);
|
||||
|
||||
strcpy(app->prev_config.bt_name, furi_hal_bt_get_profile_adv_name(FuriHalBtProfileHidKeyboard));
|
||||
memcpy(app->prev_config.bt_mac, furi_hal_bt_get_profile_mac_addr(FuriHalBtProfileHidKeyboard), BAD_KB_MAC_ADDRESS_LEN);
|
||||
strcpy(
|
||||
app->prev_config.bt_name, furi_hal_bt_get_profile_adv_name(FuriHalBtProfileHidKeyboard));
|
||||
memcpy(
|
||||
app->prev_config.bt_mac,
|
||||
furi_hal_bt_get_profile_mac_addr(FuriHalBtProfileHidKeyboard),
|
||||
BAD_KB_MAC_ADDRESS_LEN);
|
||||
app->prev_config.bt_mode = furi_hal_bt_get_profile_pairing_method(FuriHalBtProfileHidKeyboard);
|
||||
|
||||
bt_timeout = bt_hid_delays[LevelRssi39_0];
|
||||
@@ -132,8 +146,10 @@ int32_t bad_kb_connection_init(BadKbApp* app) {
|
||||
furi_hal_bt_set_profile_adv_name(FuriHalBtProfileHidKeyboard, app->config.bt_name);
|
||||
}
|
||||
if(app->bt_remember) {
|
||||
furi_hal_bt_set_profile_mac_addr(FuriHalBtProfileHidKeyboard, (uint8_t*)&BAD_KB_BOUND_MAC_ADDRESS);
|
||||
furi_hal_bt_set_profile_pairing_method(FuriHalBtProfileHidKeyboard, GapPairingPinCodeVerifyYesNo);
|
||||
furi_hal_bt_set_profile_mac_addr(
|
||||
FuriHalBtProfileHidKeyboard, (uint8_t*)&BAD_KB_BOUND_MAC_ADDRESS);
|
||||
furi_hal_bt_set_profile_pairing_method(
|
||||
FuriHalBtProfileHidKeyboard, GapPairingPinCodeVerifyYesNo);
|
||||
} else {
|
||||
furi_hal_bt_set_profile_mac_addr(FuriHalBtProfileHidKeyboard, app->config.bt_mac);
|
||||
furi_hal_bt_set_profile_pairing_method(FuriHalBtProfileHidKeyboard, GapPairingNone);
|
||||
|
||||
@@ -192,7 +192,8 @@ bool desktop_scene_main_on_event(void* context, SceneManagerEvent event) {
|
||||
break;
|
||||
}
|
||||
case DesktopMainEventOpenClock: {
|
||||
LoaderStatus status = loader_start(desktop->loader, FAP_LOADER_APP_NAME, EXT_PATH("apps/Misc/Nightstand.fap"));
|
||||
LoaderStatus status = loader_start(
|
||||
desktop->loader, FAP_LOADER_APP_NAME, EXT_PATH("apps/Misc/Nightstand.fap"));
|
||||
if(status != LoaderStatusOk) {
|
||||
FURI_LOG_E(TAG, "loader_start failed: %d", status);
|
||||
}
|
||||
|
||||
@@ -206,9 +206,7 @@ bool furi_hal_bt_start_app(FuriHalBtProfile profile, GapEventCallback event_cb,
|
||||
if(profile == FuriHalBtProfileSerial) {
|
||||
// Set mac address
|
||||
memcpy(
|
||||
config->mac_address,
|
||||
furi_hal_version_get_ble_mac(),
|
||||
sizeof(config->mac_address));
|
||||
config->mac_address, furi_hal_version_get_ble_mac(), sizeof(config->mac_address));
|
||||
// Set advertise name
|
||||
strlcpy(
|
||||
config->adv_name,
|
||||
@@ -488,10 +486,7 @@ void furi_hal_bt_set_profile_adv_name(
|
||||
strlen(&(profile_config[profile].config.adv_name[1])));
|
||||
} else {
|
||||
profile_config[profile].config.adv_name[0] = AD_TYPE_COMPLETE_LOCAL_NAME;
|
||||
memcpy(
|
||||
&(profile_config[profile].config.adv_name[1]),
|
||||
name,
|
||||
FURI_HAL_BT_ADV_NAME_LENGTH);
|
||||
memcpy(&(profile_config[profile].config.adv_name[1]), name, FURI_HAL_BT_ADV_NAME_LENGTH);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+11
-7
@@ -248,13 +248,17 @@ class Main(App):
|
||||
)
|
||||
)
|
||||
bundle_args.extend(self.other_args)
|
||||
|
||||
log_custom_fz_name = (
|
||||
environ.get("CUSTOM_FLIPPER_NAME", None)
|
||||
or ""
|
||||
)
|
||||
if (log_custom_fz_name != "") and (len(log_custom_fz_name) <= 8) and (log_custom_fz_name.isalnum()) and (log_custom_fz_name.isascii()):
|
||||
self.logger.info(f"Flipper Custom Name is set:\n\tName: {log_custom_fz_name} : length - {len(log_custom_fz_name)} chars")
|
||||
|
||||
log_custom_fz_name = environ.get("CUSTOM_FLIPPER_NAME", None) or ""
|
||||
if (
|
||||
(log_custom_fz_name != "")
|
||||
and (len(log_custom_fz_name) <= 8)
|
||||
and (log_custom_fz_name.isalnum())
|
||||
and (log_custom_fz_name.isascii())
|
||||
):
|
||||
self.logger.info(
|
||||
f"Flipper Custom Name is set:\n\tName: {log_custom_fz_name} : length - {len(log_custom_fz_name)} chars"
|
||||
)
|
||||
|
||||
if (bundle_result := UpdateMain(no_exit=True)(bundle_args)) == 0:
|
||||
self.note_dist_component("update", "dir", bundle_dir)
|
||||
|
||||
Reference in New Issue
Block a user