De-libify name changer

This commit is contained in:
MX 2023-05-19 06:33:15 +03:00
parent de5afa1304
commit e7965c6d95
No known key found for this signature in database
GPG Key ID: 7CCC66B7DBDD1C83
7 changed files with 54 additions and 69 deletions

View File

@ -9,6 +9,6 @@ App(
"desktop",
"loader",
"power",
"namechange_srv",
"namechanger_srv",
],
)

View File

@ -1,7 +1,7 @@
App(
appid="namechange_srv",
appid="namechanger_srv",
apptype=FlipperAppType.STARTUP,
entry_point="namechange_on_system_start",
entry_point="namechanger_on_system_start",
requires=["storage", "cli", "bt"],
conflicts=["updater"],
order=600,

View File

@ -1,46 +0,0 @@
#include <furi_hal.h>
#include <cli/cli.h>
#include <cli/cli_vcp.h>
#include <storage/storage.h>
#include <toolbox/namechanger.h>
#include <bt/bt_service/bt.h>
int32_t namechange_on_system_start(void* p) {
UNUSED(p);
if(furi_hal_rtc_get_boot_mode() != FuriHalRtcBootModeNormal) {
return 0;
}
// Wait for all required services to start and create their records
uint8_t timeout = 0;
while(!furi_record_exists(RECORD_CLI) || !furi_record_exists(RECORD_BT) ||
!furi_record_exists(RECORD_STORAGE)) {
timeout++;
if(timeout > 250) {
return 0;
}
furi_delay_ms(5);
}
// Hehe bad code now here, bad bad bad, very bad, bad example, dont take it, make it better
if(NameChanger_Init()) {
Cli* cli = furi_record_open(RECORD_CLI);
cli_session_close(cli);
furi_delay_ms(2); // why i added delays here
cli_session_open(cli, &cli_vcp);
furi_record_close(RECORD_CLI);
furi_delay_ms(3);
Bt* bt = furi_record_open(RECORD_BT);
if(!bt_set_profile(bt, BtProfileSerial)) {
//FURI_LOG_D(TAG, "Failed to touch bluetooth to name change");
}
furi_record_close(RECORD_BT);
bt = NULL;
furi_delay_ms(3);
}
return 0;
}

View File

@ -1,10 +1,15 @@
#include "namechanger.h"
#include <furi_hal.h>
#include <furi_hal_version.h>
#include <cli/cli.h>
#include <cli/cli_vcp.h>
#include <bt/bt_service/bt.h>
#include <storage/storage.h>
#include <flipper_format/flipper_format.h>
#define TAG "NameChanger"
bool NameChanger_Init() {
static bool namechanger_init() {
Storage* storage = furi_record_open(RECORD_STORAGE);
// Kostil + velosiped = top ficha
@ -64,4 +69,43 @@ bool NameChanger_Init() {
furi_string_free(str);
return res;
}
int32_t namechanger_on_system_start(void* p) {
UNUSED(p);
if(furi_hal_rtc_get_boot_mode() != FuriHalRtcBootModeNormal) {
return 0;
}
// Wait for all required services to start and create their records
uint8_t timeout = 0;
while(!furi_record_exists(RECORD_CLI) || !furi_record_exists(RECORD_BT) ||
!furi_record_exists(RECORD_STORAGE)) {
timeout++;
if(timeout > 250) {
return 0;
}
furi_delay_ms(5);
}
// Hehe bad code now here, bad bad bad, very bad, bad example, dont take it, make it better
if(namechanger_init()) {
Cli* cli = furi_record_open(RECORD_CLI);
cli_session_close(cli);
furi_delay_ms(2); // why i added delays here
cli_session_open(cli, &cli_vcp);
furi_record_close(RECORD_CLI);
furi_delay_ms(3);
Bt* bt = furi_record_open(RECORD_BT);
if(!bt_set_profile(bt, BtProfileSerial)) {
//FURI_LOG_D(TAG, "Failed to touch bluetooth to name change");
}
furi_record_close(RECORD_BT);
bt = NULL;
furi_delay_ms(3);
}
return 0;
}

View File

@ -0,0 +1,5 @@
#pragma once
#define NAMECHANGER_HEADER "Flipper Name File"
#define NAMECHANGER_VERSION 1
#define NAMECHANGER_PATH EXT_PATH("dolphin/name.settings")

View File

@ -1,7 +1,7 @@
#include <furi.h>
#include <gui/modules/popup.h>
#include <gui/scene_manager.h>
#include <toolbox/namechanger.h>
#include <namechanger/namechanger.h>
#include <flipper_format/flipper_format.h>
#include <power/power_service/power.h>

View File

@ -1,18 +0,0 @@
#pragma once
#define NAMECHANGER_HEADER "Flipper Name File"
#define NAMECHANGER_VERSION 1
#define NAMECHANGER_PATH EXT_PATH("dolphin/name.settings")
#include "stdbool.h"
#ifdef __cplusplus
extern "C" {
#endif
// Initializes the name changer. (Load name file, apply changes)
bool NameChanger_Init();
#ifdef __cplusplus
}
#endif