mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-07-13 23:58:11 -07:00
[FL-3331] SubGhz: add subghz_protocol_registry external API (#2712)
* [FL-3331] SubGhz: add subghz_protocol_registry external API * F18: fix API version --------- Co-authored-by: hedger <hedger@nanode.su>
This commit is contained in:
@@ -18,6 +18,7 @@ env.Append(
|
||||
File("blocks/generic.h"),
|
||||
File("blocks/math.h"),
|
||||
File("subghz_setting.h"),
|
||||
File("subghz_protocol_registry.h"),
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@@ -92,16 +92,17 @@ const char*
|
||||
|
||||
void subghz_environment_set_protocol_registry(
|
||||
SubGhzEnvironment* instance,
|
||||
void* protocol_registry_items) {
|
||||
const SubGhzProtocolRegistry* protocol_registry_items) {
|
||||
furi_assert(instance);
|
||||
const SubGhzProtocolRegistry* protocol_registry = protocol_registry_items;
|
||||
instance->protocol_registry = protocol_registry;
|
||||
}
|
||||
|
||||
void* subghz_environment_get_protocol_registry(SubGhzEnvironment* instance) {
|
||||
const SubGhzProtocolRegistry*
|
||||
subghz_environment_get_protocol_registry(SubGhzEnvironment* instance) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->protocol_registry);
|
||||
return (void*)instance->protocol_registry;
|
||||
return instance->protocol_registry;
|
||||
}
|
||||
|
||||
const char*
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <furi.h>
|
||||
#include "registry.h"
|
||||
|
||||
#include "subghz_keystore.h"
|
||||
|
||||
@@ -9,6 +10,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct SubGhzEnvironment SubGhzEnvironment;
|
||||
typedef struct SubGhzProtocolRegistry SubGhzProtocolRegistry;
|
||||
|
||||
/**
|
||||
* Allocate SubGhzEnvironment.
|
||||
@@ -93,14 +95,15 @@ const char*
|
||||
*/
|
||||
void subghz_environment_set_protocol_registry(
|
||||
SubGhzEnvironment* instance,
|
||||
void* protocol_registry_items);
|
||||
const SubGhzProtocolRegistry* protocol_registry_items);
|
||||
|
||||
/**
|
||||
* Get list of protocols to work.
|
||||
* @param instance Pointer to a SubGhzEnvironment instance
|
||||
* @return Pointer to a SubGhzProtocolRegistry
|
||||
*/
|
||||
void* subghz_environment_get_protocol_registry(SubGhzEnvironment* instance);
|
||||
const SubGhzProtocolRegistry*
|
||||
subghz_environment_get_protocol_registry(SubGhzEnvironment* instance);
|
||||
|
||||
/**
|
||||
* Get list of protocols names.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#include "../registry.h"
|
||||
#include "../subghz_protocol_registry.h"
|
||||
|
||||
#include "princeton.h"
|
||||
#include "keeloq.h"
|
||||
@@ -43,5 +44,3 @@
|
||||
#include "alutech_at_4n.h"
|
||||
#include "kinggates_stylo_4k.h"
|
||||
#include "bin_raw.h"
|
||||
|
||||
extern const SubGhzProtocolRegistry subghz_protocol_registry;
|
||||
|
||||
@@ -9,6 +9,7 @@ extern "C" {
|
||||
typedef struct SubGhzEnvironment SubGhzEnvironment;
|
||||
|
||||
typedef struct SubGhzProtocolRegistry SubGhzProtocolRegistry;
|
||||
typedef struct SubGhzProtocol SubGhzProtocol;
|
||||
|
||||
struct SubGhzProtocolRegistry {
|
||||
const SubGhzProtocol** items;
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "registry.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern const SubGhzProtocolRegistry subghz_protocol_registry;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
+5
-2
@@ -21,6 +21,9 @@
|
||||
#define SUBGHZ_RAW_FILE_VERSION 1
|
||||
#define SUBGHZ_RAW_FILE_TYPE "Flipper SubGhz RAW File"
|
||||
|
||||
typedef struct SubGhzProtocolRegistry SubGhzProtocolRegistry;
|
||||
typedef struct SubGhzEnvironment SubGhzEnvironment;
|
||||
|
||||
// Radio Preset
|
||||
typedef struct {
|
||||
FuriString* name;
|
||||
@@ -115,11 +118,11 @@ typedef enum {
|
||||
SubGhzProtocolFlag_BinRAW = (1 << 10),
|
||||
} SubGhzProtocolFlag;
|
||||
|
||||
typedef struct {
|
||||
struct SubGhzProtocol {
|
||||
const char* name;
|
||||
SubGhzProtocolType type;
|
||||
SubGhzProtocolFlag flag;
|
||||
|
||||
const SubGhzProtocolEncoder* encoder;
|
||||
const SubGhzProtocolDecoder* decoder;
|
||||
} SubGhzProtocol;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user