Merge remote-tracking branch 'origin/release-candidate' into release

This commit is contained in:
Aleksandr Kutuzov 2023-03-28 14:13:19 +09:00
commit c41fe8e4e4
606 changed files with 4551 additions and 4321 deletions

7
.github/CODEOWNERS vendored
View File

@ -22,8 +22,8 @@
/applications/main/subghz/ @skotopes @DrZlo13 @hedger @Skorpionm
/applications/main/u2f/ @skotopes @DrZlo13 @hedger @nminaylov
/applications/plugins/bt_hid_app/ @skotopes @DrZlo13 @hedger @gornekich
/applications/plugins/picopass/ @skotopes @DrZlo13 @hedger @gornekich
/applications/external/bt_hid_app/ @skotopes @DrZlo13 @hedger @gornekich
/applications/external/picopass/ @skotopes @DrZlo13 @hedger @gornekich
/applications/services/bt/ @skotopes @DrZlo13 @hedger @gornekich
/applications/services/cli/ @skotopes @DrZlo13 @hedger @nminaylov
@ -44,6 +44,9 @@
/applications/examples/example_thermo/ @skotopes @DrZlo13 @hedger @gsurkov
# Firmware targets
/firmware/ @skotopes @DrZlo13 @hedger @nminaylov
# Assets
/assets/resources/infrared/ @skotopes @DrZlo13 @hedger @gsurkov

View File

@ -18,16 +18,13 @@ jobs:
main:
runs-on: [self-hosted,FlipperZeroShell]
steps:
- name: 'Decontaminate previous build leftovers'
run: |
if [ -d .git ]; then
git submodule status || git checkout "$(git rev-list --max-parents=0 HEAD | tail -n 1)"
fi
- name: 'Wipe workspace'
run: find ./ -mount -maxdepth 1 -exec rm -rf {} \;
- name: 'Checkout code'
uses: actions/checkout@v3
with:
fetch-depth: 0
fetch-depth: 1
ref: ${{ github.event.pull_request.head.sha }}
- name: 'Get commit details'
@ -166,19 +163,14 @@ jobs:
if: ${{ !startsWith(github.ref, 'refs/tags') }}
runs-on: [self-hosted,FlipperZeroShell]
steps:
- name: 'Decontaminate previous build leftovers'
run: |
if [ -d .git ]
then
git submodule status \
|| git checkout "$(git rev-list --max-parents=0 HEAD | tail -n 1)"
fi
- name: 'Wipe workspace'
run: find ./ -mount -maxdepth 1 -exec rm -rf {} \;
- name: 'Checkout code'
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true
fetch-depth: 1
submodules: false
ref: ${{ github.event.pull_request.head.sha }}
- name: 'Get commit details'

View File

@ -1,4 +1,4 @@
name: 'Check submodules branch'
name: 'Lint sources & check submodule integrity'
on:
push:
@ -9,22 +9,25 @@ on:
- '*'
pull_request:
env:
TARGETS: f7
FBT_TOOLCHAIN_PATH: /runner/_work
SET_GH_OUTPUT: 1
jobs:
check_protobuf:
runs-on: [self-hosted, FlipperZeroShell]
lint_sources_check_submodules:
runs-on: [self-hosted,FlipperZeroShell]
steps:
- name: 'Decontaminate previous build leftovers'
run: |
if [ -d .git ]; then
git submodule status || git checkout "$(git rev-list --max-parents=0 HEAD | tail -n 1)"
fi
- name: 'Wipe workspace'
run: find ./ -mount -maxdepth 1 -exec rm -rf {} \;
- name: 'Checkout code'
uses: actions/checkout@v3
with:
fetch-depth: 0
fetch-depth: 1
ref: ${{ github.event.pull_request.head.sha }}
- name: 'Check protobuf branch'
run: |
git submodule update --init
@ -36,12 +39,28 @@ jobs:
BRANCHES=$(git branch -r --contains "$SUBMODULE_HASH");
COMMITS_IN_BRANCH="$(git rev-list --count dev)";
if [ $COMMITS_IN_BRANCH -lt $SUB_COMMITS_MIN ]; then
echo "name=fails::error" >> $GITHUB_OUTPUT
echo "name=fails::error" >> $GITHUB_OUTPUT;
echo "::error::Error: Too low commits in $SUB_BRANCH of submodule $SUB_PATH: $COMMITS_IN_BRANCH(expected $SUB_COMMITS_MIN+)";
exit 1;
fi
if ! grep -q "/$SUB_BRANCH" <<< "$BRANCHES"; then
echo "name=fails::error" >> $GITHUB_OUTPUT
echo "name=fails::error" >> $GITHUB_OUTPUT;
echo "::error::Error: Submodule $SUB_PATH is not on branch $SUB_BRANCH";
exit 1;
fi
- name: 'Check Python code formatting'
id: syntax_check_py
run: ./fbt lint_py 2>&1 >/dev/null || echo "errors=1" >> $GITHUB_OUTPUT
- name: 'Check C++ code formatting'
if: always()
id: syntax_check_cpp
run: ./fbt lint 2>&1 >/dev/null || echo "errors=1" >> $GITHUB_OUTPUT
- name: Report code formatting errors
if: ( steps.syntax_check_py.outputs.errors || steps.syntax_check_cpp.outputs.errors ) && github.event.pull_request
run: |
echo "Code formatting errors found";
echo "Please run './fbt format' or './fbt format_py' to fix them";
exit 1;

View File

@ -1,47 +0,0 @@
name: 'Lint C/C++ with clang-format'
on:
push:
branches:
- dev
- "release*"
tags:
- '*'
pull_request:
env:
TARGETS: f7
FBT_TOOLCHAIN_PATH: /runner/_work
SET_GH_OUTPUT: 1
jobs:
lint_c_cpp:
runs-on: [self-hosted,FlipperZeroShell]
steps:
- name: 'Decontaminate previous build leftovers'
run: |
if [ -d .git ]; then
git submodule status || git checkout "$(git rev-list --max-parents=0 HEAD | tail -n 1)"
fi
- name: 'Checkout code'
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: 'Check code formatting'
id: syntax_check
run: ./fbt lint
- name: Report code formatting errors
if: failure() && steps.syntax_check.outputs.errors && github.event.pull_request
uses: peter-evans/create-or-update-comment@v1
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
Please fix following code formatting errors:
```
${{ steps.syntax_check.outputs.errors }}
```
You might want to run `./fbt format` for an auto-fix.

View File

@ -1,33 +0,0 @@
name: 'Python Lint'
on:
push:
branches:
- dev
- "release*"
tags:
- '*'
pull_request:
env:
FBT_TOOLCHAIN_PATH: /runner/_work
SET_GH_OUTPUT: 1
jobs:
lint_python:
runs-on: [self-hosted,FlipperZeroShell]
steps:
- name: 'Decontaminate previous build leftovers'
run: |
if [ -d .git ]; then
git submodule status || git checkout "$(git rev-list --max-parents=0 HEAD | tail -n 1)"
fi
- name: 'Checkout code'
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: 'Check code formatting'
run: ./fbt lint_py

View File

@ -12,16 +12,13 @@ jobs:
merge_report:
runs-on: [self-hosted,FlipperZeroShell]
steps:
- name: 'Decontaminate previous build leftovers'
run: |
if [ -d .git ]; then
git submodule status || git checkout "$(git rev-list --max-parents=0 HEAD | tail -n 1)"
fi
- name: 'Wipe workspace'
run: find ./ -mount -maxdepth 1 -exec rm -rf {} \;
- name: 'Checkout code'
uses: actions/checkout@v3
with:
fetch-depth: 0
fetch-depth: 1
ref: ${{ github.event.pull_request.head.sha }}
- name: 'Get commit details'

View File

@ -19,16 +19,13 @@ jobs:
if: ${{ !github.event.pull_request.head.repo.fork }}
runs-on: [self-hosted, FlipperZeroShell]
steps:
- name: 'Decontaminate previous build leftovers'
run: |
if [ -d .git ]; then
git submodule status || git checkout "$(git rev-list --max-parents=0 HEAD | tail -n 1)"
fi
- name: 'Wipe workspace'
run: find ./ -mount -maxdepth 1 -exec rm -rf {} \;
- name: 'Checkout code'
uses: actions/checkout@v3
with:
fetch-depth: 0
fetch-depth: 1
ref: ${{ github.event.pull_request.head.sha }}
- name: 'Get commit details'

View File

@ -12,16 +12,13 @@ jobs:
run_units_on_bench:
runs-on: [self-hosted, FlipperZeroUnitTest]
steps:
- name: 'Decontaminate previous build leftovers'
run: |
if [ -d .git ]; then
git submodule status || git checkout "$(git rev-list --max-parents=0 HEAD | tail -n 1)"
fi
- name: 'Wipe workspace'
run: find ./ -mount -maxdepth 1 -exec rm -rf {} \;
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
fetch-depth: 1
ref: ${{ github.event.pull_request.head.sha }}
- name: 'Get flipper from device manager (mock)'

View File

@ -12,16 +12,14 @@ jobs:
test_updater_on_bench:
runs-on: [self-hosted, FlipperZeroUpdaterTest]
steps:
- name: 'Decontaminate previous build leftovers'
run: |
if [ -d .git ]; then
git submodule status || git checkout "$(git rev-list --max-parents=0 HEAD | tail -n 1)"
fi
- name: 'Wipe workspace'
run: find ./ -mount -maxdepth 1 -exec rm -rf {} \;
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
fetch-depth: 1
submodules: false
ref: ${{ github.event.pull_request.head.sha }}
- name: 'Get flipper from device manager (mock)'
@ -51,18 +49,14 @@ jobs:
run: |
echo "tag=$(git tag -l --sort=-version:refname | grep -v "rc\|RC" | head -1)" >> $GITHUB_OUTPUT
- name: 'Decontaminate previous build leftovers'
if: failure()
run: |
if [ -d .git ]; then
git submodule status || git checkout "$(git rev-list --max-parents=0 HEAD | tail -n 1)"
fi
- name: 'Wipe workspace'
run: find ./ -mount -maxdepth 1 -exec rm -rf {} \;
- name: 'Checkout latest release'
uses: actions/checkout@v3
if: failure()
with:
fetch-depth: 0
fetch-depth: 1
ref: ${{ steps.release_tag.outputs.tag }}
- name: 'Flash last release'

7
.gitmodules vendored
View File

@ -28,6 +28,9 @@
[submodule "lib/cxxheaderparser"]
path = lib/cxxheaderparser
url = https://github.com/robotpy/cxxheaderparser.git
[submodule "applications/plugins/dap_link/lib/free-dap"]
path = applications/plugins/dap_link/lib/free-dap
[submodule "applications/external/dap_link/lib/free-dap"]
path = applications/external/dap_link/lib/free-dap
url = https://github.com/ataradov/free-dap.git
[submodule "lib/heatshrink"]
path = lib/heatshrink
url = https://github.com/flipperdevices/heatshrink.git

View File

@ -1 +1 @@
--ignore-ccache -C gccarm --rules-config .pvsconfig -e lib/fatfs -e lib/fnv1a-hash -e lib/FreeRTOS-Kernel -e lib/heatshrink -e lib/libusb_stm32 -e lib/littlefs -e lib/mbedtls -e lib/micro-ecc -e lib/microtar -e lib/mlib -e lib/qrcode -e lib/ST25RFAL002 -e lib/STM32CubeWB -e lib/u8g2 -e lib/nanopb -e */arm-none-eabi/* -e applications/plugins/dap_link/lib/free-dap
--ignore-ccache -C gccarm --rules-config .pvsconfig -e lib/fatfs -e lib/fnv1a-hash -e lib/FreeRTOS-Kernel -e lib/heatshrink -e lib/libusb_stm32 -e lib/littlefs -e lib/mbedtls -e lib/micro-ecc -e lib/microtar -e lib/mlib -e lib/qrcode -e lib/ST25RFAL002 -e lib/STM32CubeWB -e lib/u8g2 -e lib/nanopb -e */arm-none-eabi/* -e applications/external/dap_link/lib/free-dap

View File

@ -139,34 +139,33 @@ if GetOption("fullenv") or any(
basic_dist = distenv.DistCommand("fw_dist", distenv["DIST_DEPENDS"])
distenv.Default(basic_dist)
dist_dir = distenv.GetProjetDirName()
dist_dir_name = distenv.GetProjetDirName()
dist_dir = distenv.Dir(f"#/dist/{dist_dir_name}")
external_apps_artifacts = firmware_env["FW_EXTAPPS"]
external_app_list = external_apps_artifacts.application_map.values()
fap_dist = [
distenv.Install(
distenv.Dir(f"#/dist/{dist_dir}/apps/debug_elf"),
list(
app_artifact.debug
for app_artifact in firmware_env["FW_EXTAPPS"].applications.values()
),
dist_dir.Dir("debug_elf"),
list(app_artifact.debug for app_artifact in external_app_list),
),
*(
distenv.Install(
f"#/dist/{dist_dir}/apps/{app_artifact.app.fap_category}",
app_artifact.compact[0],
dist_dir.File(dist_entry[1]).dir,
app_artifact.compact,
)
for app_artifact in firmware_env["FW_EXTAPPS"].applications.values()
for app_artifact in external_app_list
for dist_entry in app_artifact.dist_entries
),
]
Depends(
fap_dist,
list(
app_artifact.validator
for app_artifact in firmware_env["FW_EXTAPPS"].applications.values()
),
list(app_artifact.validator for app_artifact in external_app_list),
)
Alias("fap_dist", fap_dist)
# distenv.Default(fap_dist)
distenv.Depends(firmware_env["FW_RESOURCES"], firmware_env["FW_EXTAPPS"].resources_dist)
distenv.Depends(firmware_env["FW_RESOURCES"], external_apps_artifacts.resources_dist)
# Copy all faps to device

View File

@ -36,15 +36,20 @@ Applications for main Flipper menu.
- `u2f` - U2F Application
## plugins
## External
Extra apps for Plugins & App Loader menus.
External applications deployed to SD Card
- `bt_hid_app` - BT Remote controller
- `clock` - Clock application
- `dap_link` - DAP Link OnChip debugger
- `hid_app` - USB/BT Remote controller
- `music_player` - Music player app (demo)
- `picopass` - Picopass tool
- `nfc_magic` - NFC MFC Magic card application
- `picopass` - Picopass reader / writer
- `signal_generator` - Signal generator app: PWM and clock generator
- `snake_game` - Snake game application
- `spi_mem_manager` - SPI Memory reader / flasher
- `weather_station` - SubGHz weather station
## services

View File

@ -1,3 +1,4 @@
# Placeholder
App(
appid="example_apps",
name="Example apps bundle",

View File

@ -0,0 +1,31 @@
App(
appid="example_plugins",
name="Example: App w/plugin",
apptype=FlipperAppType.EXTERNAL,
entry_point="example_plugins_app",
stack_size=2 * 1024,
fap_category="Examples",
)
App(
appid="example_plugins_multi",
name="Example: App w/plugins",
apptype=FlipperAppType.EXTERNAL,
entry_point="example_plugins_multi_app",
stack_size=2 * 1024,
fap_category="Examples",
)
App(
appid="example_plugin1",
apptype=FlipperAppType.PLUGIN,
entry_point="example_plugin1_ep",
requires=["example_plugins", "example_plugins_multi"],
)
App(
appid="example_plugin2",
apptype=FlipperAppType.PLUGIN,
entry_point="example_plugin2_ep",
requires=["example_plugins_multi"],
)

View File

@ -0,0 +1,70 @@
/*
* 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;
}

View File

@ -0,0 +1,43 @@
/*
* An example of an advanced plugin host application.
* It uses PluginManager to load all plugins from a directory
*/
#include "plugin_interface.h"
#include <flipper_application/flipper_application.h>
#include <flipper_application/plugins/plugin_manager.h>
#include <loader/firmware_api/firmware_api.h>
#include <furi.h>
#define TAG "example_plugins"
int32_t example_plugins_multi_app(void* p) {
UNUSED(p);
FURI_LOG_I(TAG, "Starting");
PluginManager* manager =
plugin_manager_alloc(PLUGIN_APP_ID, PLUGIN_API_VERSION, firmware_api_interface);
if(plugin_manager_load_all(manager, APP_DATA_PATH("plugins")) != PluginManagerErrorNone) {
FURI_LOG_E(TAG, "Failed to load all libs");
return 0;
}
uint32_t plugin_count = plugin_manager_get_count(manager);
FURI_LOG_I(TAG, "Loaded %lu plugin(s)", plugin_count);
for(uint32_t i = 0; i < plugin_count; i++) {
const ExamplePlugin* plugin = plugin_manager_get_ep(manager, i);
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));
}
plugin_manager_free(manager);
FURI_LOG_I(TAG, "Goodbye!");
return 0;
}

View File

@ -0,0 +1,32 @@
/* A simple plugin implementing example_plugins application's plugin interface */
#include "plugin_interface.h"
#include <flipper_application/flipper_application.h>
static int example_plugin1_method1() {
return 42;
}
static int example_plugin1_method2(int arg1, int arg2) {
return arg1 + arg2;
}
/* Actual implementation of app<>plugin interface */
static const ExamplePlugin example_plugin1 = {
.name = "Demo App Plugin 1",
.method1 = &example_plugin1_method1,
.method2 = &example_plugin1_method2,
};
/* Plugin descriptor to comply with basic plugin specification */
static const FlipperAppPluginDescriptor example_plugin1_descriptor = {
.appid = PLUGIN_APP_ID,
.ep_api_version = PLUGIN_API_VERSION,
.entry_point = &example_plugin1,
};
/* Plugin entry point - must return a pointer to const descriptor */
const FlipperAppPluginDescriptor* example_plugin1_ep() {
return &example_plugin1_descriptor;
}

View File

@ -0,0 +1,32 @@
/* Second plugin implementing example_plugins application's plugin interface */
#include "plugin_interface.h"
#include <flipper_application/flipper_application.h>
static int example_plugin2_method1() {
return 1337;
}
static int example_plugin2_method2(int arg1, int arg2) {
return arg1 - arg2;
}
/* Actual implementation of app<>plugin interface */
static const ExamplePlugin example_plugin2 = {
.name = "Demo App Plugin 2",
.method1 = &example_plugin2_method1,
.method2 = &example_plugin2_method2,
};
/* Plugin descriptor to comply with basic plugin specification */
static const FlipperAppPluginDescriptor example_plugin2_descriptor = {
.appid = PLUGIN_APP_ID,
.ep_api_version = PLUGIN_API_VERSION,
.entry_point = &example_plugin2,
};
/* Plugin entry point - must return a pointer to const descriptor */
const FlipperAppPluginDescriptor* example_plugin2_ep() {
return &example_plugin2_descriptor;
}

View File

@ -0,0 +1,12 @@
#pragma once
/* Common interface between a plugin and host applicaion */
#define PLUGIN_APP_ID "example_plugins"
#define PLUGIN_API_VERSION 1
typedef struct {
const char* name;
int (*method1)();
int (*method2)(int, int);
} ExamplePlugin;

View File

@ -0,0 +1,25 @@
#include "app_api.h"
/* Actual implementation of app's API and its private state */
static uint32_t accumulator = 0;
void app_api_accumulator_set(uint32_t value) {
accumulator = value;
}
uint32_t app_api_accumulator_get() {
return accumulator;
}
void app_api_accumulator_add(uint32_t value) {
accumulator += value;
}
void app_api_accumulator_sub(uint32_t value) {
accumulator -= value;
}
void app_api_accumulator_mul(uint32_t value) {
accumulator *= value;
}

View File

@ -0,0 +1,25 @@
#pragma once
/*
* This file contains an API that is internally implemented by the application
* It is also exposed to plugins to allow them to use the application's API.
*/
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
void app_api_accumulator_set(uint32_t value);
uint32_t app_api_accumulator_get();
void app_api_accumulator_add(uint32_t value);
void app_api_accumulator_sub(uint32_t value);
void app_api_accumulator_mul(uint32_t value);
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,9 @@
#pragma once
#include <flipper_application/api_hashtable/api_hashtable.h>
/*
* Resolver interface with private application's symbols.
* Implementation is contained in app_api_table.c
*/
extern const ElfApiInterface* const application_api_interface;

View File

@ -0,0 +1,27 @@
#include <flipper_application/api_hashtable/api_hashtable.h>
#include <flipper_application/api_hashtable/compilesort.hpp>
/*
* This file contains an implementation of a symbol table
* with private app's symbols. It is used by composite API resolver
* to load plugins that use internal application's APIs.
*/
#include "app_api_table_i.h"
static_assert(!has_hash_collisions(app_api_table), "Detected API method hash collision!");
constexpr HashtableApiInterface applicaton_hashtable_api_interface{
{
.api_version_major = 0,
.api_version_minor = 0,
/* generic resolver using pre-sorted array */
.resolver_callback = &elf_resolve_from_hashtable,
},
/* pointers to application's API table boundaries */
.table_cbegin = app_api_table.cbegin(),
.table_cend = app_api_table.cend(),
};
/* Casting to generic resolver to use in Composite API resolver */
extern "C" const ElfApiInterface* const application_api_interface =
&applicaton_hashtable_api_interface;

View File

@ -0,0 +1,13 @@
#include "app_api.h"
/*
* A list of app's private functions and objects to expose for plugins.
* It is used to generate a table of symbols for import resolver to use.
* TBD: automatically generate this table from app's header files
*/
static constexpr auto app_api_table = sort(create_array_t<sym_entry>(
API_METHOD(app_api_accumulator_set, void, (uint32_t)),
API_METHOD(app_api_accumulator_get, uint32_t, ()),
API_METHOD(app_api_accumulator_add, void, (uint32_t)),
API_METHOD(app_api_accumulator_sub, void, (uint32_t)),
API_METHOD(app_api_accumulator_mul, void, (uint32_t))));

View File

@ -0,0 +1,24 @@
App(
appid="example_advanced_plugins",
name="Example: advanced plugins",
apptype=FlipperAppType.EXTERNAL,
entry_point="example_advanced_plugins_app",
stack_size=2 * 1024,
fap_category="Examples",
)
App(
appid="advanced_plugin1",
apptype=FlipperAppType.PLUGIN,
entry_point="advanced_plugin1_ep",
requires=["example_advanced_plugins"],
sources=["plugin1.c"],
)
App(
appid="advanced_plugin2",
apptype=FlipperAppType.PLUGIN,
entry_point="advanced_plugin2_ep",
requires=["example_advanced_plugins"],
sources=["plugin2.c"],
)

View File

@ -0,0 +1,48 @@
#include "app_api.h"
#include "plugin_interface.h"
#include "app_api_interface.h"
#include <flipper_application/flipper_application.h>
#include <flipper_application/plugins/plugin_manager.h>
#include <flipper_application/plugins/composite_resolver.h>
#include <loader/firmware_api/firmware_api.h>
#define TAG "example_advanced_plugins"
int32_t example_advanced_plugins_app(void* p) {
UNUSED(p);
FURI_LOG_I(TAG, "Starting");
CompositeApiResolver* resolver = composite_api_resolver_alloc();
composite_api_resolver_add(resolver, firmware_api_interface);
composite_api_resolver_add(resolver, application_api_interface);
PluginManager* manager = plugin_manager_alloc(
PLUGIN_APP_ID, PLUGIN_API_VERSION, composite_api_resolver_get(resolver));
do {
if(plugin_manager_load_all(manager, APP_DATA_PATH("plugins")) != PluginManagerErrorNone) {
FURI_LOG_E(TAG, "Failed to load all libs");
break;
}
uint32_t plugin_count = plugin_manager_get_count(manager);
FURI_LOG_I(TAG, "Loaded libs: %lu", plugin_count);
for(uint32_t i = 0; i < plugin_count; i++) {
const AdvancedPlugin* plugin = plugin_manager_get_ep(manager, i);
FURI_LOG_I(TAG, "plugin name: %s. Calling methods", plugin->name);
plugin->method1(228);
plugin->method2();
FURI_LOG_I(TAG, "Accumulator: %lu", app_api_accumulator_get());
}
} while(0);
plugin_manager_free(manager);
composite_api_resolver_free(resolver);
FURI_LOG_I(TAG, "Goodbye!");
return 0;
}

View File

@ -0,0 +1,40 @@
/*
* This plugin uses both firmware's API interface and private application headers.
* It can be loaded by a plugin manager that uses CompoundApiInterface,
* which combines both interfaces.
*/
#include "app_api.h"
#include "plugin_interface.h"
#include <flipper_application/flipper_application.h>
#include <furi.h>
static void advanced_plugin1_method1(int arg1) {
/* This function is implemented inside host application */
app_api_accumulator_add(arg1);
}
static void advanced_plugin1_method2() {
/* Accumulator value is stored inside host application */
FURI_LOG_I("TEST", "Plugin 1, accumulator: %lu", app_api_accumulator_get());
}
/* Actual implementation of app<>plugin interface */
static const AdvancedPlugin advanced_plugin1 = {
.name = "Advanced Plugin 1",
.method1 = &advanced_plugin1_method1,
.method2 = &advanced_plugin1_method2,
};
/* Plugin descriptor to comply with basic plugin specification */
static const FlipperAppPluginDescriptor advanced_plugin1_descriptor = {
.appid = PLUGIN_APP_ID,
.ep_api_version = PLUGIN_API_VERSION,
.entry_point = &advanced_plugin1,
};
/* Plugin entry point - must return a pointer to const descriptor */
const FlipperAppPluginDescriptor* advanced_plugin1_ep() {
return &advanced_plugin1_descriptor;
}

View File

@ -0,0 +1,40 @@
/*
* This plugin uses both firmware's API interface and private application headers.
* It can be loaded by a plugin manager that uses CompoundApiInterface,
* which combines both interfaces.
*/
#include "app_api.h"
#include "plugin_interface.h"
#include <flipper_application/flipper_application.h>
#include <furi.h>
static void advanced_plugin2_method1(int arg1) {
/* This function is implemented inside host application */
app_api_accumulator_mul(arg1);
}
static void advanced_plugin2_method2() {
/* Accumulator value is stored inside host application */
FURI_LOG_I("TEST", "Plugin 2, accumulator: %lu", app_api_accumulator_get());
}
/* Actual implementation of app<>plugin interface */
static const AdvancedPlugin advanced_plugin2 = {
.name = "Advanced Plugin 2",
.method1 = &advanced_plugin2_method1,
.method2 = &advanced_plugin2_method2,
};
/* Plugin descriptor to comply with basic plugin specification */
static const FlipperAppPluginDescriptor advanced_plugin2_descriptor = {
.appid = PLUGIN_APP_ID,
.ep_api_version = PLUGIN_API_VERSION,
.entry_point = &advanced_plugin2,
};
/* Plugin entry point - must return a pointer to const descriptor */
const FlipperAppPluginDescriptor* advanced_plugin2_ep() {
return &advanced_plugin2_descriptor;
}

View File

@ -0,0 +1,12 @@
#pragma once
/* Common interface between a plugin and host applicaion */
#define PLUGIN_APP_ID "example_plugins_advanced"
#define PLUGIN_API_VERSION 1
typedef struct {
const char* name;
void (*method1)(int);
void (*method2)();
} AdvancedPlugin;

View File

@ -19,9 +19,12 @@
#include <one_wire/maxim_crc.h>
#include <one_wire/one_wire_host.h>
#include <furi_hal_power.h>
#define UPDATE_PERIOD_MS 1000UL
#define TEXT_STORE_SIZE 64U
#define DS18B20_CMD_SKIP_ROM 0xccU
#define DS18B20_CMD_CONVERT 0x44U
#define DS18B20_CMD_READ_SCRATCHPAD 0xbeU
@ -92,7 +95,7 @@ static void example_thermo_request_temperature(ExampleThermoContext* context) {
/* After the reset, a ROM operation must follow.
If there is only one device connected, the "Skip ROM" command is most appropriate
(it can also be used to address all of the connected devices in some cases).*/
onewire_host_skip(onewire);
onewire_host_write(onewire, DS18B20_CMD_SKIP_ROM);
/* After the ROM operation, a device-specific command is issued.
In this case, it's a request to start measuring the temperature. */
onewire_host_write(onewire, DS18B20_CMD_CONVERT);
@ -133,7 +136,7 @@ static void example_thermo_read_temperature(ExampleThermoContext* context) {
/* After the reset, a ROM operation must follow.
If there is only one device connected, the "Skip ROM" command is most appropriate
(it can also be used to address all of the connected devices in some cases).*/
onewire_host_skip(onewire);
onewire_host_write(onewire, DS18B20_CMD_SKIP_ROM);
/* After the ROM operation, a device-specific command is issued.
This time, it will be the "Read Scratchpad" command which will
@ -267,6 +270,9 @@ static void example_thermo_input_callback(InputEvent* event, void* ctx) {
/* Starts the reader thread and handles the input */
static void example_thermo_run(ExampleThermoContext* context) {
/* Enable power on external pins */
furi_hal_power_enable_otg();
/* Configure the hardware in host mode */
onewire_host_start(context->onewire);
@ -299,6 +305,9 @@ static void example_thermo_run(ExampleThermoContext* context) {
/* Reset the hardware */
onewire_host_stop(context->onewire);
/* Disable power on external pins */
furi_hal_power_disable_otg();
}
/******************** Initialisation & startup *****************************/

6
applications/external/application.fam vendored Normal file
View File

@ -0,0 +1,6 @@
# Placeholder
App(
appid="external_apps",
name="External apps bundle",
apptype=FlipperAppType.METAPACKAGE,
)

View File

@ -1,7 +1,7 @@
App(
appid="clock",
name="Clock",
apptype=FlipperAppType.PLUGIN,
apptype=FlipperAppType.EXTERNAL,
entry_point="clock_app",
requires=["gui"],
stack_size=2 * 1024,

View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -1,7 +1,7 @@
App(
appid="dap_link",
name="DAP Link",
apptype=FlipperAppType.PLUGIN,
apptype=FlipperAppType.EXTERNAL,
entry_point="dap_link_app",
requires=[
"gui",

View File

Before

Width:  |  Height:  |  Size: 143 B

After

Width:  |  Height:  |  Size: 143 B

View File

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Before

Width:  |  Height:  |  Size: 160 B

After

Width:  |  Height:  |  Size: 160 B

View File

Before

Width:  |  Height:  |  Size: 168 B

After

Width:  |  Height:  |  Size: 168 B

View File

Before

Width:  |  Height:  |  Size: 159 B

After

Width:  |  Height:  |  Size: 159 B

View File

Before

Width:  |  Height:  |  Size: 173 B

After

Width:  |  Height:  |  Size: 173 B

View File

@ -1,7 +1,7 @@
App(
appid="hid_usb",
name="Remote",
apptype=FlipperAppType.PLUGIN,
apptype=FlipperAppType.EXTERNAL,
entry_point="hid_usb_app",
stack_size=1 * 1024,
fap_category="USB",
@ -14,7 +14,7 @@ App(
App(
appid="hid_ble",
name="Remote",
apptype=FlipperAppType.PLUGIN,
apptype=FlipperAppType.EXTERNAL,
entry_point="hid_ble_app",
stack_size=1 * 1024,
fap_category="Bluetooth",

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Before

Width:  |  Height:  |  Size: 657 B

After

Width:  |  Height:  |  Size: 657 B

View File

Before

Width:  |  Height:  |  Size: 102 B

After

Width:  |  Height:  |  Size: 102 B

View File

Before

Width:  |  Height:  |  Size: 172 B

After

Width:  |  Height:  |  Size: 172 B

View File

Before

Width:  |  Height:  |  Size: 173 B

After

Width:  |  Height:  |  Size: 173 B

View File

Before

Width:  |  Height:  |  Size: 180 B

After

Width:  |  Height:  |  Size: 180 B

View File

Before

Width:  |  Height:  |  Size: 177 B

After

Width:  |  Height:  |  Size: 177 B

View File

Before

Width:  |  Height:  |  Size: 179 B

After

Width:  |  Height:  |  Size: 179 B

View File

Before

Width:  |  Height:  |  Size: 178 B

After

Width:  |  Height:  |  Size: 178 B

View File

Before

Width:  |  Height:  |  Size: 177 B

After

Width:  |  Height:  |  Size: 177 B

View File

Before

Width:  |  Height:  |  Size: 178 B

After

Width:  |  Height:  |  Size: 178 B

View File

Before

Width:  |  Height:  |  Size: 177 B

After

Width:  |  Height:  |  Size: 177 B

View File

Before

Width:  |  Height:  |  Size: 176 B

After

Width:  |  Height:  |  Size: 176 B

View File

Before

Width:  |  Height:  |  Size: 176 B

After

Width:  |  Height:  |  Size: 176 B

View File

Before

Width:  |  Height:  |  Size: 179 B

After

Width:  |  Height:  |  Size: 179 B

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 102 B

After

Width:  |  Height:  |  Size: 102 B

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Some files were not shown because too many files have changed in this diff Show More