diff --git a/application.fam b/application.fam index 985ff3343f9..d7c6eda5bdf 100644 --- a/application.fam +++ b/application.fam @@ -14,6 +14,7 @@ App( sources=[ "*.c", "aeabi_uldivmod.sx", + "!plugin*.c", ], fap_icon="icons/logo.png", fap_category="NFC", @@ -39,3 +40,11 @@ App( fap_weburl="https://seader.ericbetts.dev", fap_icon_assets="icons", ) + +App( + appid="plugin_wiegand", + apptype=FlipperAppType.PLUGIN, + entry_point="plugin_wiegand_ep", + requires=["seader"], + sources=["plugin_wiegand.c"], +) diff --git a/plugin_interface.h b/plugin_interface.h new file mode 100644 index 00000000000..0e5ca518927 --- /dev/null +++ b/plugin_interface.h @@ -0,0 +1,19 @@ +/** + * @file plugin_interface.h + * @brief Example plugin interface. + * + * Common interface between a plugin and host application + */ +#pragma once + +#include +#include + +#define PLUGIN_APP_ID "plugin_wiegand" +#define PLUGIN_API_VERSION 1 + +typedef struct { + const char* name; + int (*count)(uint8_t, uint64_t); + int (*description)(uint8_t, uint64_t, size_t); +} PluginWiegand; diff --git a/plugin_wiegand.c b/plugin_wiegand.c new file mode 100644 index 00000000000..69e271fd508 --- /dev/null +++ b/plugin_wiegand.c @@ -0,0 +1,37 @@ + +#include "plugin_interface.h" + +#include + +static int wiegand_format_count(uint8_t bit_length, uint64_t bits) { + UNUSED(bit_length); + UNUSED(bits); + return 1337; +} + +static int wiegand_format_description(uint8_t bit_length, uint64_t bits, size_t index) { + UNUSED(bit_length); + UNUSED(bits); + UNUSED(index); + + return 0; +} + +/* Actual implementation of app<>plugin interface */ +static const PluginWiegand plugin_wiegand = { + .name = "Plugin Wiegand", + .count = &wiegand_format_count, + .description = &wiegand_format_description, +}; + +/* Plugin descriptor to comply with basic plugin specification */ +static const FlipperAppPluginDescriptor plugin_wiegand_descriptor = { + .appid = PLUGIN_APP_ID, + .ep_api_version = PLUGIN_API_VERSION, + .entry_point = &plugin_wiegand, +}; + +/* Plugin entry point - must return a pointer to const descriptor */ +const FlipperAppPluginDescriptor* plugin_wiegand_ep(void) { + return &plugin_wiegand_descriptor; +}