mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-12-30 14:43:08 +00:00
53435579b3
* fbt, faploader: minimal app module implementation * faploader, libs: moved API hashtable core to flipper_application * example: compound api * lib: flipper_application: naming fixes, doxygen comments * fbt: changed `requires` manifest field behavior for app extensions * examples: refactored plugin apps; faploader: changed new API naming; fbt: changed PLUGIN app type meaning * loader: dropped support for debug apps & plugin menus * moved applications/plugins -> applications/external * Restored x bit on chiplist_convert.py * git: fixed free-dap submodule path * pvs: updated submodule paths * examples: example_advanced_plugins.c: removed potential memory leak on errors * examples: example_plugins: refined requires * fbt: not deploying app modules for debug/sample apps; extra validation for .PLUGIN-type apps * apps: removed cdefines for external apps * fbt: moved ext app path definition * fbt: reworked fap_dist handling; f18: synced api_symbols.csv * fbt: removed resources_paths for extapps * scripts: reworked storage * scripts: reworked runfap.py & selfupdate.py to use new api * wip: fal runner * fbt: moved file packaging into separate module * scripts: storage: fixes * scripts: storage: minor fixes for new api * fbt: changed internal artifact storage details for external apps * scripts: storage: additional fixes and better error reporting; examples: using APP_DATA_PATH() * fbt, scripts: reworked launch_app to deploy plugins; moved old runfap.py to distfap.py * fbt: extra check for plugins descriptors * fbt: additional checks in emitter * fbt: better info message on SDK rebuild * scripts: removed requirements.txt * loader: removed remnants of plugins & debug menus * post-review fixes
70 lines
2.1 KiB
C
70 lines
2.1 KiB
C
/*
|
|
* An example of a plugin host application.
|
|
* Loads a single plugin and calls its methods.
|
|
*/
|
|
|
|
#include "plugin_interface.h"
|
|
|
|
#include <furi.h>
|
|
|
|
#include <flipper_application/flipper_application.h>
|
|
#include <loader/firmware_api/firmware_api.h>
|
|
#include <storage/storage.h>
|
|
|
|
#define TAG "example_plugins"
|
|
|
|
int32_t example_plugins_app(void* p) {
|
|
UNUSED(p);
|
|
|
|
FURI_LOG_I(TAG, "Starting");
|
|
|
|
Storage* storage = furi_record_open(RECORD_STORAGE);
|
|
|
|
FlipperApplication* app = flipper_application_alloc(storage, firmware_api_interface);
|
|
|
|
do {
|
|
FlipperApplicationPreloadStatus preload_res =
|
|
flipper_application_preload(app, APP_DATA_PATH("plugins/example_plugin1.fal"));
|
|
|
|
if(preload_res != FlipperApplicationPreloadStatusSuccess) {
|
|
FURI_LOG_E(TAG, "Failed to preload plugin");
|
|
break;
|
|
}
|
|
|
|
if(!flipper_application_is_plugin(app)) {
|
|
FURI_LOG_E(TAG, "Plugin file is not a library");
|
|
break;
|
|
}
|
|
|
|
FlipperApplicationLoadStatus load_status = flipper_application_map_to_memory(app);
|
|
if(load_status != FlipperApplicationLoadStatusSuccess) {
|
|
FURI_LOG_E(TAG, "Failed to load plugin file");
|
|
break;
|
|
}
|
|
|
|
const FlipperAppPluginDescriptor* app_descriptor =
|
|
flipper_application_plugin_get_descriptor(app);
|
|
|
|
FURI_LOG_I(
|
|
TAG,
|
|
"Loaded plugin for appid '%s', API %lu",
|
|
app_descriptor->appid,
|
|
app_descriptor->ep_api_version);
|
|
|
|
furi_check(app_descriptor->ep_api_version == PLUGIN_API_VERSION);
|
|
furi_check(strcmp(app_descriptor->appid, PLUGIN_APP_ID) == 0);
|
|
|
|
const ExamplePlugin* plugin = app_descriptor->entry_point;
|
|
|
|
FURI_LOG_I(TAG, "Plugin name: %s", plugin->name);
|
|
FURI_LOG_I(TAG, "Plugin method1: %d", plugin->method1());
|
|
FURI_LOG_I(TAG, "Plugin method2(7,8): %d", plugin->method2(7, 8));
|
|
FURI_LOG_I(TAG, "Plugin method2(1337,228): %d", plugin->method2(1337, 228));
|
|
} while(false);
|
|
flipper_application_free(app);
|
|
|
|
furi_record_close(RECORD_STORAGE);
|
|
FURI_LOG_I(TAG, "Goodbye!");
|
|
|
|
return 0;
|
|
}
|