Skip to content

Commit

Permalink
add new app, apply fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
xMasterX committed Jan 5, 2024
1 parent 2ffce83 commit 7a3e7b8
Show file tree
Hide file tree
Showing 13 changed files with 1,453 additions and 0 deletions.
16 changes: 16 additions & 0 deletions non_catalog_apps/hid_file_transfer/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"C_Cpp.default.includePath": [
"${workspaceFolder}/../unleashed-firmware/**"
],
"files.associations": {
"docker-compose*.yml": "dockercompose",
"Dockerfile*": "dockerfile",
"docker-compose.*.yml": "dockercompose",
"Caddyfile*": "caddyfile",
"filelogger.h": "c",
"file_stream.h": "c",
"usbif.h": "c",
"elements.h": "c",
"menu.h": "c"
}
}
17 changes: 17 additions & 0 deletions non_catalog_apps/hid_file_transfer/application.fam
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
App(
appid="hidtransfer",
name="HID File Transfer",
apptype=FlipperAppType.EXTERNAL,
entry_point="hidtransfer_app",
cdefines=["APP_HID_TRANSFER"],
requires=[
"gui",
"dialogs",
],
stack_size=6 * 1024,
order=20,
fap_icon="icons/hid_10px.png",
fap_category="USB",
fap_icon_assets="assets",
fap_libs=["assets"],
)
1 change: 1 addition & 0 deletions non_catalog_apps/hid_file_transfer/assets/arrows.pixil
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"application":"pixil","type":".pixil","version":"2.7.0","website":"pixilart.com","author":"https://www.pixilart.com","contact":"support@pixilart.com","width":14,"height":14,"colors":{"default":["000000","ffffff","f44336","E91E63","9C27B0","673AB7","3F51B5","2196F3","03A9F4","00BCD4","009688","4CAF50","8BC34A","CDDC39","FFEB3B","FFC107","FF9800","FF5722","795548","9E9E9E","607D8B","ffebee","ffcdd2","ef9a9a","e57373","ef5350","e53935","d32f2f","c62828","b71c1c","ff8a80","ff5252","ff1744","d50000","fce4ec","f8bbd0","f48fb1","f06292","ec407a","e91e63","d81b60","c2185b","ad1457","880e4f","ff80ab","ff4081","f50057","c51162","f3e5f5","e1bee7","ce93d8","ba68c8","ab47bc","9c27b0","8e24aa","7b1fa2","6a1b9a","4a148c","ea80fc","e040fb","d500f9","aa00ff","ede7f6","d1c4e9","b39ddb","9575cd","7e57c2","673ab7","5e35b1","512da8","4527a0","311b92","b388ff","7c4dff","651fff","6200ea","e8eaf6","c5cae9","9fa8da","7986cb","5c6bc0","3f51b5","3949ab","303f9f","283593","1a237e","8c9eff","536dfe","3d5afe","304ffe","e3f2fd","bbdefb","90caf9","64b5f6","42a5f5","2196f3","1e88e5","1976d2","1565c0","0d47a1","82b1ff","448aff","2979ff","2962ff","e1f5fe","b3e5fc","81d4fa","4fc3f7","29b6f6","03a9f4","039be5","0288d1","0277bd","01579b","80d8ff","40c4ff","00b0ff","0091ea","e0f7fa","b2ebf2","80deea","4dd0e1","26c6da","00bcd4","00acc1","0097a7","00838f","006064","84ffff","18ffff","00e5ff","00b8d4","e0f2f1","b2dfdb","80cbc4","4db6ac","26a69a","009688","00897b","00796b","00695c","004d40","a7ffeb","64ffda","1de9b6","00bfa5","e8f5e9","c8e6c9","a5d6a7","81c784","66bb6a","4caf50","43a047","388e3c","2e7d32","1b5e20","b9f6ca","69f0ae","00e676","00c853","f1f8e9","dcedc8","c5e1a5","aed581","9ccc65","8bc34a","7cb342","689f38","558b2f","33691e","ccff90","b2ff59","76ff03","64dd17","f9fbe7","f0f4c3","e6ee9c","dce775","d4e157","cddc39","c0ca33","afb42b","9e9d24","827717","f4ff81","eeff41","c6ff00","aeea00","fffde7","fff9c4","fff59d","fff176","ffee58","ffeb3b","fdd835","fbc02d","f9a825","f57f17","ffff8d","ffff00","ffea00","ffd600","fff8e1","ffecb3","ffe082","ffd54f","ffca28","ffc107","ffb300","ffa000","ff8f00","ff6f00","ffe57f","ffd740","ffc400","ffab00","fff3e0","ffe0b2","ffcc80","ffb74d","ffa726","ff9800","fb8c00","f57c00","ef6c00","e65100","ffd180","ffab40","ff9100","ff6d00","fbe9e7","ffccbc","ffab91","ff8a65","ff7043","ff5722","f4511e","e64a19","d84315","bf360c","ff9e80","ff6e40","ff3d00","dd2c00","efebe9","d7ccc8","bcaaa4","a1887f","8d6e63","795548","6d4c41","5d4037","4e342e","3e2723","fafafa","f5f5f5","eeeeee","e0e0e0","bdbdbd","9e9e9e","757575","616161","424242","212121","eceff1","cfd8dc","b0bec5","90a4ae","78909c","607d8b","546e7a","455a64","37474f","263238"],"simple":["ffffff","d4d4d4","a1a1a1","787878","545454","303030","000000","edc5c5","e68383","ff0000","de2424","ad3636","823737","592b2b","f5d2ee","eb8dd7","f700b9","bf1f97","9c277f","732761","4f2445","e2bcf7","bf79e8","9d00ff","8330ba","6d3096","502c69","351b47","c5c3f0","736feb","0905f7","2e2eb0","2d2d80","252554","090936","c7e2ed","6ac3e6","00bbff","279ac4","347c96","2d5b6b","103947","bbf0d9","6febb3","00ff88","2eb878","349166","2b694c","0c3d25","c2edc0","76ed70","0dff00","36c72c","408c3b","315c2e","144511","d6edbb","b5eb73","8cff00","89c93a","6f8f44","4b632a","2a400c","f1f2bf","eef069","ffff00","baba30","91913f","5e5e2b","3b3b09","ffdeb8","f2ae61","ff8400","c48037","85623d","573e25","3d2309","fcbbae","ff8066","ff2b00","cc553d","9c5b4e","61372e","36130b"],"common":["000000","ffffff","464646","b4b4b4","990030","9c5a3c","ed1c24","ffa3b1","ff7e00","e5aa7a","ffc20e","f5e49c","fff200","fff9bd","a8e61d","d3f9bc","22b14c","00b7ef","99d9ea","4d6df3","709ad1","2f3699","546d8e","6f3198","b5a5d5"],"skin tones":["ffe0bd","ffdbac","ffcd94","eac086","e0ac69","f1c27d","ffad60","c68642","8d5524","896347","765339","613D24","4C2D17","391E0B","351606","2D1304","180A01","090300"],"NightClub":["000000","041020","061428","0A264D","0C3064","0E3A77","134FA3","134997","1C74EE","2BAFFF","38C5F8","12DCFE","31FFFF","F7FEFE"]},"colorSelected":"NightClub","frames":[{"name":"","speed":100,"layers":[{"id":0,"src":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAHElEQVQoU2P8DwQMZADGUY24Q200cPCkqCEUOAC66zfXeZ5jnwAAAABJRU5ErkJggg==","edit":false,"name":"Background","opacity":1,"active":true,"unqid":"lx72","options":{"blend":"source-over","locked":false,"filter":{"brightness":"100%","contrast":"100%","grayscale":"0%","blur":0,"dropshadow_x":0,"dropshadow_y":0,"dropshadow_blur":0,"dropshadow_alpha":1}}},{"id":1,"src":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAS0lEQVQoU2NkIBMwkqmPgRiN/4GGY6gjViPIYShqSdGIohlZI8hJxACwHnI0gvWRoxHDRlzORPYC3CJSAoesUCUrHrF6gRinUlcjACa0CQ8exkIDAAAAAElFTkSuQmCC","edit":false,"name":"Right","opacity":1,"active":true,"unqid":"knihbc","options":{"blend":"source-over","locked":false,"filter":{"brightness":"100%","contrast":"100%","grayscale":"0%","blur":0,"dropshadow_x":0,"dropshadow_y":0,"dropshadow_blur":0,"dropshadow_alpha":1}}},{"id":2,"src":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAATklEQVQoU2NkIBMwkqmPAZ/G/0BDccrjkgBpAgGSNMI0kaQRWRM+7zMiO4VYTWCXoPuBWM0YGkGmkeVHmL/IClVkzSRFB1GJiSZJDq/NAGa0CQ+hIbooAAAAAElFTkSuQmCC","edit":false,"name":"Left","opacity":1,"active":false,"unqid":"knihbc","options":{"blend":"source-over","locked":false,"filter":{"brightness":"100%","contrast":"100%","grayscale":"0%","blur":0,"dropshadow_x":0,"dropshadow_y":0,"dropshadow_blur":0,"dropshadow_alpha":1}}}],"active":true,"selectedLayer":"0","unqid":"96z1ir","preview":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAATklEQVQoU2P8DwQMZABGmmlkZGRkwOYogjaCNIIAumaiNaJrhmuEmUwonGA2k6wRZjPJGjFsxOVEZC8gBxDRgUNWqJIVjzi9QLMkh8tGABWDUte2etveAAAAAElFTkSuQmCC","width":14,"height":14}],"currentFrame":0,"speed":100,"name":"Untitled","preview":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAAA4A/sfR5H8Fkddasdmnacvx/AAAOCAYAAAAfSC3RAAAATklEQVQoU2P8DwQMZABGmmlkZGRkwOYogjaCNIIAumaiNaJrhmuEmUwonGA2k6wRZjPJGjFsxOVEZC8gBxDRgUNWqJIVjzi9QLMkh8tGABWDUte2etveAAAAAElFTkSuQmCC","previewApp":"","art_edit_id":0,"palette_id":"590","created_at":1688825172138,"updated_at":1688825172138,"persLayers":true,"id":1688824077663}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions non_catalog_apps/hid_file_transfer/constants.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@


#define TAG "HIDT_main"
#define TAG_IF "HIDT_IF"
108 changes: 108 additions & 0 deletions non_catalog_apps/hid_file_transfer/filelogger.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
#include "filelogger.h"
#include <core/check.h>
#include <core/mutex.h>
#include <furi_hal.h>
#include <storage/storage.h>

#define FURI_LOG_LEVEL_DEFAULT FuriLogLevelInfo

typedef struct {
FuriLogLevel log_level;
FuriLogPuts puts;
FuriLogTimestamp timestamp;
FuriMutex* mutex;
File *logFile;
Storage *storage;
} FuriLogParams;

static FuriLogParams furi_log;

void writeToLog(const char *msg) {
furi_hal_console_puts(msg);

// Storage *s = furi_record_open(RECORD_STORAGE);
// File *f = storage_file_alloc(s);
// storage_file_open(f, "/any/log.txt", FSAM_READ_WRITE, FSOM_OPEN_APPEND);
storage_file_write(furi_log.logFile, msg, strlen(msg));
// storage_file_close(f);
// storage_file_free(f);
// furi_record_close(RECORD_STORAGE);
}



void file_log_init() {
// Set default logging parameters
furi_log.log_level = FURI_LOG_LEVEL_DEFAULT;
furi_log.puts = writeToLog;
furi_log.timestamp = furi_get_tick;
furi_log.mutex = furi_mutex_alloc(FuriMutexTypeNormal);
furi_log.storage = furi_record_open(RECORD_STORAGE);
furi_log.logFile = storage_file_alloc(furi_log.storage);
storage_file_open(furi_log.logFile, "/any/log.txt", FSAM_READ_WRITE, FSOM_OPEN_APPEND);
}


void file_log_deinit() {
storage_file_close(furi_log.logFile);
storage_file_free(furi_log.logFile);
furi_record_close(RECORD_STORAGE);
furi_mutex_free(furi_log.mutex);
}

void file_log_print_format(FuriLogLevel level, const char* tag, const char* format, ...) {
if(level <= furi_log_get_level() &&
furi_mutex_acquire(furi_log.mutex, FuriWaitForever) == FuriStatusOk) {
FuriString* string;
string = furi_string_alloc();

const char* log_letter = " ";
switch(level) {
case FuriLogLevelError:
log_letter = "E";
break;
case FuriLogLevelWarn:
log_letter = "W";
break;
case FuriLogLevelInfo:
log_letter = "I";
break;
case FuriLogLevelDebug:
log_letter = "D";
break;
case FuriLogLevelTrace:
log_letter = "T";
break;
default:
break;
}

// Timestamp
furi_string_printf(
string,
"%lu [%s][%s] ",
furi_log.timestamp(),
log_letter,
tag);
furi_log.puts(furi_string_get_cstr(string));
furi_string_reset(string);

va_list args;
va_start(args, format);
furi_string_vprintf(string, format, args);
va_end(args);

furi_log.puts(furi_string_get_cstr(string));
furi_string_free(string);

furi_log.puts("\r\n");

furi_mutex_release(furi_log.mutex);
}
}


void file_log_set_timestamp(FuriLogTimestamp timestamp) {
furi_assert(timestamp);
furi_log.timestamp = timestamp;
}
70 changes: 70 additions & 0 deletions non_catalog_apps/hid_file_transfer/filelogger.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/**
* @file log.h
* Furi Logging system
*/
#pragma once

#include <core/log.h>

#ifdef __cplusplus
extern "C" {
#endif

/** Initialize logging */
void file_log_init();
void file_log_deinit();

/** Print log record
*
* @param level
* @param tag
* @param format
* @param ...
*/
void file_log_print_format(FuriLogLevel level, const char* tag, const char* format, ...)
_ATTRIBUTE((__format__(__printf__, 3, 4)));

// /** Set log level
// *
// * @param[in] level The level
// */
// void file_log_set_level(FuriLogLevel level);

// /** Get log level
// *
// * @return The furi log level.
// */
// FuriLogLevel file_log_get_level();

// /** Set log output callback
// *
// * @param[in] puts The puts callback
// */
// void file_log_set_puts(FuriLogPuts puts);

/** Set timestamp callback
*
* @param[in] timestamp The timestamp callback
*/
void file_log_set_timestamp(FuriLogTimestamp timestamp);

/** Log methods
*
* @param tag The application tag
* @param format The format
* @param ... VA Args
*/
#define FILE_LOG_E(tag, format, ...) \
file_log_print_format(FuriLogLevelError, tag, format, ##__VA_ARGS__)
#define FILE_LOG_W(tag, format, ...) \
file_log_print_format(FuriLogLevelWarn, tag, format, ##__VA_ARGS__)
#define FILE_LOG_I(tag, format, ...) \
file_log_print_format(FuriLogLevelInfo, tag, format, ##__VA_ARGS__)
#define FILE_LOG_D(tag, format, ...) \
file_log_print_format(FuriLogLevelDebug, tag, format, ##__VA_ARGS__)
#define FILE_LOG_T(tag, format, ...) \
file_log_print_format(FuriLogLevelTrace, tag, format, ##__VA_ARGS__)

#ifdef __cplusplus
}
#endif
6 changes: 6 additions & 0 deletions non_catalog_apps/hid_file_transfer/hidtransfer_icons.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once

#include <gui/icon.h>

extern const Icon I_left_14;
extern const Icon I_right_14;
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 7a3e7b8

Please sign in to comment.