mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-07-24 01:28:11 -07:00
Merge remote-tracking branch 'DarkFlippers/dev' into dev
This commit is contained in:
@@ -54,6 +54,10 @@ static bool bq27220_parameter_check(
|
||||
}
|
||||
|
||||
if(update) {
|
||||
// Datasheet contains incorrect procedure for memory update, more info:
|
||||
// https://e2e.ti.com/support/power-management-group/power-management/f/power-management-forum/719878/bq27220-technical-reference-manual-sluubd4-is-missing-extended-data-commands-chapter
|
||||
|
||||
// 2. Write the address AND the parameter data to 0x3E+ (auto increment)
|
||||
if(!furi_hal_i2c_write_mem(
|
||||
handle,
|
||||
BQ27220_ADDRESS,
|
||||
@@ -67,9 +71,12 @@ static bool bq27220_parameter_check(
|
||||
|
||||
furi_delay_us(10000);
|
||||
|
||||
// 3. Calculate the check sum: 0xFF - (sum of address and data) OR 0xFF
|
||||
uint8_t checksum = bq27220_get_checksum(buffer, size + 2);
|
||||
// 4. Write the check sum to 0x60 and the total length of (address + parameter data + check sum + length) to 0x61
|
||||
buffer[0] = checksum;
|
||||
buffer[1] = 4 + size; // TODO FL-3519: why 4?
|
||||
// 2 bytes address, `size` bytes data, 1 byte check sum, 1 byte length
|
||||
buffer[1] = 2 + size + 1 + 1;
|
||||
if(!furi_hal_i2c_write_mem(
|
||||
handle, BQ27220_ADDRESS, CommandMACDataSum, buffer, 2, BQ27220_I2C_TIMEOUT)) {
|
||||
FURI_LOG_I(TAG, "CRC write failed");
|
||||
|
||||
@@ -1366,7 +1366,7 @@ void nfc_device_set_name(NfcDevice* dev, const char* name) {
|
||||
static void nfc_device_get_path_without_ext(FuriString* orig_path, FuriString* shadow_path) {
|
||||
// TODO: this won't work if there is ".nfc" anywhere in the path other than
|
||||
// at the end
|
||||
size_t ext_start = furi_string_search(orig_path, NFC_APP_EXTENSION);
|
||||
size_t ext_start = furi_string_search(orig_path, NFC_APP_FILENAME_EXTENSION);
|
||||
furi_string_set_n(shadow_path, orig_path, 0, ext_start);
|
||||
}
|
||||
|
||||
@@ -1593,7 +1593,7 @@ bool nfc_file_select(NfcDevice* dev) {
|
||||
// Input events and views are managed by file_browser
|
||||
|
||||
const DialogsFileBrowserOptions browser_options = {
|
||||
.extension = NFC_APP_EXTENSION,
|
||||
.extension = NFC_APP_FILENAME_EXTENSION,
|
||||
.skip_assets = true,
|
||||
.hide_dot_files = true,
|
||||
.icon = &I_Nfc_10px,
|
||||
@@ -1665,7 +1665,7 @@ bool nfc_device_delete(NfcDevice* dev, bool use_load_path) {
|
||||
"%s/%s%s",
|
||||
furi_string_get_cstr(dev->folder),
|
||||
dev->dev_name,
|
||||
NFC_APP_EXTENSION);
|
||||
NFC_APP_FILENAME_EXTENSION);
|
||||
}
|
||||
if(!storage_simply_remove(dev->storage, furi_string_get_cstr(file_path))) break;
|
||||
// Delete shadow file if it exists
|
||||
@@ -1723,7 +1723,7 @@ bool nfc_device_restore(NfcDevice* dev, bool use_load_path) {
|
||||
"%s/%s%s",
|
||||
furi_string_get_cstr(dev->folder),
|
||||
dev->dev_name,
|
||||
NFC_APP_EXTENSION);
|
||||
NFC_APP_FILENAME_EXTENSION);
|
||||
}
|
||||
if(!nfc_device_load_data(dev, path, true)) break;
|
||||
restored = true;
|
||||
|
||||
@@ -21,7 +21,8 @@ extern "C" {
|
||||
#define NFC_READER_DATA_MAX_SIZE 64
|
||||
#define NFC_DICT_KEY_BATCH_SIZE 10
|
||||
|
||||
#define NFC_APP_EXTENSION ".nfc"
|
||||
#define NFC_APP_FILENAME_PREFIX "NFC"
|
||||
#define NFC_APP_FILENAME_EXTENSION ".nfc"
|
||||
#define NFC_APP_SHADOW_EXTENSION ".shd"
|
||||
|
||||
typedef void (*NfcLoadingCallback)(void* context, bool state);
|
||||
|
||||
@@ -382,7 +382,9 @@ bool mf_classic_check_card_type(uint8_t ATQA0, uint8_t ATQA1, uint8_t SAK) {
|
||||
} else if((ATQA0 == 0x01) && (ATQA1 == 0x0F) && (SAK == 0x01)) {
|
||||
//skylanders support
|
||||
return true;
|
||||
} else if((ATQA0 == 0x42 || ATQA0 == 0x02) && (SAK == 0x18)) {
|
||||
} else if(
|
||||
((ATQA0 == 0x42 || ATQA0 == 0x02) && (SAK == 0x18)) ||
|
||||
((ATQA0 == 0x02 || ATQA0 == 0x04 || ATQA0 == 0x08) && (SAK == 0x38))) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -394,13 +396,17 @@ MfClassicType mf_classic_get_classic_type(uint8_t ATQA0, uint8_t ATQA1, uint8_t
|
||||
if((ATQA0 == 0x44 || ATQA0 == 0x04)) {
|
||||
if((SAK == 0x08 || SAK == 0x88)) {
|
||||
return MfClassicType1k;
|
||||
} else if((SAK == 0x38)) {
|
||||
return MfClassicType4k;
|
||||
} else if((SAK == 0x09 || SAK == 0x89)) {
|
||||
return MfClassicTypeMini;
|
||||
}
|
||||
} else if((ATQA0 == 0x01) && (ATQA1 == 0x0F) && (SAK == 0x01)) {
|
||||
//skylanders support
|
||||
return MfClassicType1k;
|
||||
} else if((ATQA0 == 0x42 || ATQA0 == 0x02) && (SAK == 0x18)) {
|
||||
} else if(
|
||||
((ATQA0 == 0x42 || ATQA0 == 0x02) && (SAK == 0x18)) ||
|
||||
((ATQA0 == 0x02 || ATQA0 == 0x08) && (SAK == 0x38))) {
|
||||
return MfClassicType4k;
|
||||
}
|
||||
return MfClassicType1k;
|
||||
|
||||
@@ -108,7 +108,8 @@ bool subghz_protocol_raw_save_to_file_init(
|
||||
|
||||
furi_string_set(instance->file_name, dev_name);
|
||||
// First remove subghz device file if it was saved
|
||||
furi_string_printf(temp_str, "%s/%s%s", SUBGHZ_RAW_FOLDER, dev_name, SUBGHZ_APP_EXTENSION);
|
||||
furi_string_printf(
|
||||
temp_str, "%s/%s%s", SUBGHZ_RAW_FOLDER, dev_name, SUBGHZ_APP_FILENAME_EXTENSION);
|
||||
|
||||
if(!storage_simply_remove(instance->storage, furi_string_get_cstr(temp_str))) {
|
||||
break;
|
||||
|
||||
+2
-1
@@ -13,7 +13,8 @@
|
||||
|
||||
#define SUBGHZ_APP_FOLDER ANY_PATH("subghz")
|
||||
#define SUBGHZ_RAW_FOLDER EXT_PATH("subghz")
|
||||
#define SUBGHZ_APP_EXTENSION ".sub"
|
||||
#define SUBGHZ_APP_FILENAME_PREFIX "SubGHz"
|
||||
#define SUBGHZ_APP_FILENAME_EXTENSION ".sub"
|
||||
|
||||
#define SUBGHZ_KEY_FILE_VERSION 1
|
||||
#define SUBGHZ_KEY_FILE_TYPE "Flipper SubGhz Key File"
|
||||
|
||||
@@ -14,7 +14,7 @@ env.Append(
|
||||
File("manchester_decoder.h"),
|
||||
File("manchester_encoder.h"),
|
||||
File("path.h"),
|
||||
File("random_name.h"),
|
||||
File("name_generator.h"),
|
||||
File("sha256.h"),
|
||||
File("crc32_calc.h"),
|
||||
File("dir_walk.h"),
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
#include "name_generator.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <furi_hal_rtc.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <furi.h>
|
||||
|
||||
const char* const name_generator_left[] = {
|
||||
"super",
|
||||
"big",
|
||||
"little",
|
||||
"liquid",
|
||||
"unknown",
|
||||
"thin",
|
||||
"thick",
|
||||
"great",
|
||||
"my",
|
||||
"mini",
|
||||
"ultra",
|
||||
"haupt",
|
||||
"small",
|
||||
"random",
|
||||
"strange",
|
||||
};
|
||||
|
||||
const char* const name_generator_right[] = {
|
||||
"maslina",
|
||||
"sus",
|
||||
"anomalija",
|
||||
"artefact",
|
||||
"monolit",
|
||||
"burer",
|
||||
"sidorovich",
|
||||
"habar",
|
||||
"radar",
|
||||
"borov",
|
||||
"pda",
|
||||
"konserva",
|
||||
"aptechka",
|
||||
"door",
|
||||
"thing",
|
||||
"stuff",
|
||||
};
|
||||
|
||||
void name_generator_make_auto(char* name, size_t max_name_size, const char* prefix) {
|
||||
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDetailedFilename)) {
|
||||
name_generator_make_detailed(name, max_name_size, prefix);
|
||||
} else {
|
||||
name_generator_make_random(name, max_name_size);
|
||||
}
|
||||
}
|
||||
|
||||
void name_generator_make_random(char* name, size_t max_name_size) {
|
||||
furi_assert(name);
|
||||
furi_assert(max_name_size);
|
||||
|
||||
uint8_t name_generator_left_i = rand() % COUNT_OF(name_generator_left);
|
||||
uint8_t name_generator_right_i = rand() % COUNT_OF(name_generator_right);
|
||||
|
||||
snprintf(
|
||||
name,
|
||||
max_name_size,
|
||||
"%s_%s",
|
||||
name_generator_left[name_generator_left_i],
|
||||
name_generator_right[name_generator_right_i]);
|
||||
|
||||
// Set first symbol to upper case
|
||||
name[0] = name[0] - 0x20;
|
||||
}
|
||||
|
||||
void name_generator_make_detailed(char* name, size_t max_name_size, const char* prefix) {
|
||||
furi_assert(name);
|
||||
furi_assert(max_name_size);
|
||||
furi_assert(prefix);
|
||||
|
||||
FuriHalRtcDateTime dateTime;
|
||||
furi_hal_rtc_get_datetime(&dateTime);
|
||||
|
||||
snprintf(
|
||||
name,
|
||||
max_name_size,
|
||||
"%s-%.4d_%.2d_%.2d-%.2d_%.2d",
|
||||
prefix,
|
||||
dateTime.year,
|
||||
dateTime.month,
|
||||
dateTime.day,
|
||||
dateTime.hour,
|
||||
dateTime.minute);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Generates detailed/random name based on furi_hal flags
|
||||
*
|
||||
* @param name buffer to write random name
|
||||
* @param max_name_size length of given buffer
|
||||
* @param[in] prefix The prefix of the name
|
||||
*/
|
||||
void name_generator_make_auto(char* name, size_t max_name_size, const char* prefix);
|
||||
|
||||
/** Generates random name
|
||||
*
|
||||
* @param name buffer to write random name
|
||||
* @param max_name_size length of given buffer
|
||||
*/
|
||||
void name_generator_make_random(char* name, size_t max_name_size);
|
||||
|
||||
/** Generates detailed name
|
||||
*
|
||||
* @param name buffer to write random name
|
||||
* @param max_name_size length of given buffer
|
||||
* @param[in] prefix The prefix of the name
|
||||
*/
|
||||
void name_generator_make_detailed(char* name, size_t max_name_size, const char* prefix);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,51 +0,0 @@
|
||||
#include "random_name.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <furi.h>
|
||||
|
||||
void set_random_name(char* name, uint8_t max_name_size) {
|
||||
const char* prefix[] = {
|
||||
"super",
|
||||
"big",
|
||||
"little",
|
||||
"liquid",
|
||||
"unknown",
|
||||
"thin",
|
||||
"thick",
|
||||
"great",
|
||||
"my",
|
||||
"mini",
|
||||
"ultra",
|
||||
"haupt",
|
||||
"small",
|
||||
"random",
|
||||
"strange",
|
||||
};
|
||||
|
||||
const char* suffix[] = {
|
||||
"maslina",
|
||||
"sus",
|
||||
"anomalija",
|
||||
"artefact",
|
||||
"monolit",
|
||||
"burer",
|
||||
"sidorovich",
|
||||
"habar",
|
||||
"radar",
|
||||
"borov",
|
||||
"pda",
|
||||
"konserva",
|
||||
"aptechka",
|
||||
"door",
|
||||
"thing",
|
||||
"stuff",
|
||||
};
|
||||
// sus is not (sus)pect - this is about super sus
|
||||
uint8_t prefix_i = rand() % COUNT_OF(prefix);
|
||||
uint8_t suffix_i = rand() % COUNT_OF(suffix);
|
||||
|
||||
snprintf(name, max_name_size, "%s_%s", prefix[prefix_i], suffix[suffix_i]);
|
||||
// Set first symbol to upper case
|
||||
name[0] = name[0] - 0x20;
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Generates random name
|
||||
* @param name buffer to write random name
|
||||
* @param max_name_size length of given buffer
|
||||
*/
|
||||
void set_random_name(char* name, uint8_t max_name_size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -54,10 +54,10 @@ static bool
|
||||
|
||||
FuriString* filetype;
|
||||
|
||||
// TODO FL-3543: compare filetype?
|
||||
filetype = furi_string_alloc();
|
||||
update_manifest->valid =
|
||||
flipper_format_read_header(flipper_file, filetype, &update_manifest->manifest_version) &&
|
||||
furi_string_cmp_str(filetype, "Flipper firmware upgrade configuration") == 0 &&
|
||||
flipper_format_read_string(flipper_file, MANIFEST_KEY_INFO, update_manifest->version) &&
|
||||
flipper_format_read_uint32(
|
||||
flipper_file, MANIFEST_KEY_TARGET, &update_manifest->target, 1) &&
|
||||
|
||||
Reference in New Issue
Block a user