Eric Betts 1 год назад
Родитель
Сommit
6bbd7d560c
3 измененных файлов с 65 добавлено и 0 удалено
  1. 9 0
      application.fam
  2. 19 0
      plugin_interface.h
  3. 37 0
      plugin_wiegand.c

+ 9 - 0
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"],
+)

+ 19 - 0
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 <stdint.h>
+#include <stddef.h>
+
+#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;

+ 37 - 0
plugin_wiegand.c

@@ -0,0 +1,37 @@
+
+#include "plugin_interface.h"
+
+#include <flipper_application/flipper_application.h>
+
+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;
+}