mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-10 15:04:19 +00:00
[FL-3401, FL-3402] SubGhz: add "SubGhz test" external application and the ability to work "SubGhz" as an external application (#2851)
* [FL-3401] SubGhz: add "SubGhz test" external application * SubGhz: delete test test functionality from SubGhz app * [FL-3402] SubGhz: move func protocol creation API Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
parent
d8500510be
commit
cef59887ed
40 changed files with 1070 additions and 222 deletions
14
applications/debug/subghz_test/application.fam
Normal file
14
applications/debug/subghz_test/application.fam
Normal file
|
@ -0,0 +1,14 @@
|
|||
App(
|
||||
appid="subghz_test",
|
||||
name="Sub-Ghz test",
|
||||
apptype=FlipperAppType.DEBUG,
|
||||
targets=["f7"],
|
||||
entry_point="subghz_test_app",
|
||||
requires=["gui"],
|
||||
stack_size=4 * 1024,
|
||||
order=50,
|
||||
fap_icon="subghz_test_10px.png",
|
||||
fap_category="Debug",
|
||||
fap_icon_assets="images",
|
||||
fap_version="0.1",
|
||||
)
|
|
@ -0,0 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
typedef enum {
|
||||
//SubGhzTestCustomEvent
|
||||
SubGhzTestCustomEventStartId = 100,
|
||||
SubGhzTestCustomEventSceneShowOnlyRX,
|
||||
} SubGhzTestCustomEvent;
|
|
@ -1,4 +1,4 @@
|
|||
#include "subghz_testing.h"
|
||||
#include "subghz_test_frequency.h"
|
||||
|
||||
const uint32_t subghz_frequencies_testing[] = {
|
||||
/* 300 - 348 */
|
|
@ -1,5 +1,5 @@
|
|||
#pragma once
|
||||
#include "../subghz_i.h"
|
||||
#include "../subghz_test_app_i.h"
|
||||
|
||||
extern const uint32_t subghz_frequencies_testing[];
|
||||
extern const uint32_t subghz_frequencies_count_testing;
|
18
applications/debug/subghz_test/helpers/subghz_test_types.h
Normal file
18
applications/debug/subghz_test/helpers/subghz_test_types.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
#pragma once
|
||||
|
||||
#include <furi.h>
|
||||
#include <furi_hal.h>
|
||||
|
||||
#define SUBGHZ_TEST_VERSION_APP "0.1"
|
||||
#define SUBGHZ_TEST_DEVELOPED "SkorP"
|
||||
#define SUBGHZ_TEST_GITHUB "https://github.com/flipperdevices/flipperzero-firmware"
|
||||
|
||||
typedef enum {
|
||||
SubGhzTestViewVariableItemList,
|
||||
SubGhzTestViewSubmenu,
|
||||
SubGhzTestViewStatic,
|
||||
SubGhzTestViewCarrier,
|
||||
SubGhzTestViewPacket,
|
||||
SubGhzTestViewWidget,
|
||||
SubGhzTestViewPopup,
|
||||
} SubGhzTestView;
|
BIN
applications/debug/subghz_test/images/DolphinCommon_56x48.png
Normal file
BIN
applications/debug/subghz_test/images/DolphinCommon_56x48.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
244
applications/debug/subghz_test/protocol/math.c
Normal file
244
applications/debug/subghz_test/protocol/math.c
Normal file
|
@ -0,0 +1,244 @@
|
|||
#include "math.h"
|
||||
|
||||
uint64_t subghz_protocol_blocks_reverse_key(uint64_t key, uint8_t bit_count) {
|
||||
uint64_t reverse_key = 0;
|
||||
for(uint8_t i = 0; i < bit_count; i++) {
|
||||
reverse_key = reverse_key << 1 | bit_read(key, i);
|
||||
}
|
||||
return reverse_key;
|
||||
}
|
||||
|
||||
uint8_t subghz_protocol_blocks_get_parity(uint64_t key, uint8_t bit_count) {
|
||||
uint8_t parity = 0;
|
||||
for(uint8_t i = 0; i < bit_count; i++) {
|
||||
parity += bit_read(key, i);
|
||||
}
|
||||
return parity & 0x01;
|
||||
}
|
||||
|
||||
uint8_t subghz_protocol_blocks_crc4(
|
||||
uint8_t const message[],
|
||||
size_t size,
|
||||
uint8_t polynomial,
|
||||
uint8_t init) {
|
||||
uint8_t remainder = init << 4; // LSBs are unused
|
||||
uint8_t poly = polynomial << 4;
|
||||
uint8_t bit;
|
||||
|
||||
while(size--) {
|
||||
remainder ^= *message++;
|
||||
for(bit = 0; bit < 8; bit++) {
|
||||
if(remainder & 0x80) {
|
||||
remainder = (remainder << 1) ^ poly;
|
||||
} else {
|
||||
remainder = (remainder << 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return remainder >> 4 & 0x0f; // discard the LSBs
|
||||
}
|
||||
|
||||
uint8_t subghz_protocol_blocks_crc7(
|
||||
uint8_t const message[],
|
||||
size_t size,
|
||||
uint8_t polynomial,
|
||||
uint8_t init) {
|
||||
uint8_t remainder = init << 1; // LSB is unused
|
||||
uint8_t poly = polynomial << 1;
|
||||
|
||||
for(size_t byte = 0; byte < size; ++byte) {
|
||||
remainder ^= message[byte];
|
||||
for(uint8_t bit = 0; bit < 8; ++bit) {
|
||||
if(remainder & 0x80) {
|
||||
remainder = (remainder << 1) ^ poly;
|
||||
} else {
|
||||
remainder = (remainder << 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return remainder >> 1 & 0x7f; // discard the LSB
|
||||
}
|
||||
|
||||
uint8_t subghz_protocol_blocks_crc8(
|
||||
uint8_t const message[],
|
||||
size_t size,
|
||||
uint8_t polynomial,
|
||||
uint8_t init) {
|
||||
uint8_t remainder = init;
|
||||
|
||||
for(size_t byte = 0; byte < size; ++byte) {
|
||||
remainder ^= message[byte];
|
||||
for(uint8_t bit = 0; bit < 8; ++bit) {
|
||||
if(remainder & 0x80) {
|
||||
remainder = (remainder << 1) ^ polynomial;
|
||||
} else {
|
||||
remainder = (remainder << 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return remainder;
|
||||
}
|
||||
|
||||
uint8_t subghz_protocol_blocks_crc8le(
|
||||
uint8_t const message[],
|
||||
size_t size,
|
||||
uint8_t polynomial,
|
||||
uint8_t init) {
|
||||
uint8_t remainder = subghz_protocol_blocks_reverse_key(init, 8);
|
||||
polynomial = subghz_protocol_blocks_reverse_key(polynomial, 8);
|
||||
|
||||
for(size_t byte = 0; byte < size; ++byte) {
|
||||
remainder ^= message[byte];
|
||||
for(uint8_t bit = 0; bit < 8; ++bit) {
|
||||
if(remainder & 1) {
|
||||
remainder = (remainder >> 1) ^ polynomial;
|
||||
} else {
|
||||
remainder = (remainder >> 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return remainder;
|
||||
}
|
||||
|
||||
uint16_t subghz_protocol_blocks_crc16lsb(
|
||||
uint8_t const message[],
|
||||
size_t size,
|
||||
uint16_t polynomial,
|
||||
uint16_t init) {
|
||||
uint16_t remainder = init;
|
||||
|
||||
for(size_t byte = 0; byte < size; ++byte) {
|
||||
remainder ^= message[byte];
|
||||
for(uint8_t bit = 0; bit < 8; ++bit) {
|
||||
if(remainder & 1) {
|
||||
remainder = (remainder >> 1) ^ polynomial;
|
||||
} else {
|
||||
remainder = (remainder >> 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return remainder;
|
||||
}
|
||||
|
||||
uint16_t subghz_protocol_blocks_crc16(
|
||||
uint8_t const message[],
|
||||
size_t size,
|
||||
uint16_t polynomial,
|
||||
uint16_t init) {
|
||||
uint16_t remainder = init;
|
||||
|
||||
for(size_t byte = 0; byte < size; ++byte) {
|
||||
remainder ^= message[byte] << 8;
|
||||
for(uint8_t bit = 0; bit < 8; ++bit) {
|
||||
if(remainder & 0x8000) {
|
||||
remainder = (remainder << 1) ^ polynomial;
|
||||
} else {
|
||||
remainder = (remainder << 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return remainder;
|
||||
}
|
||||
|
||||
uint8_t subghz_protocol_blocks_lfsr_digest8(
|
||||
uint8_t const message[],
|
||||
size_t size,
|
||||
uint8_t gen,
|
||||
uint8_t key) {
|
||||
uint8_t sum = 0;
|
||||
for(size_t byte = 0; byte < size; ++byte) {
|
||||
uint8_t data = message[byte];
|
||||
for(int i = 7; i >= 0; --i) {
|
||||
// XOR key into sum if data bit is set
|
||||
if((data >> i) & 1) sum ^= key;
|
||||
|
||||
// roll the key right (actually the LSB is dropped here)
|
||||
// and apply the gen (needs to include the dropped LSB as MSB)
|
||||
if(key & 1)
|
||||
key = (key >> 1) ^ gen;
|
||||
else
|
||||
key = (key >> 1);
|
||||
}
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
uint8_t subghz_protocol_blocks_lfsr_digest8_reflect(
|
||||
uint8_t const message[],
|
||||
size_t size,
|
||||
uint8_t gen,
|
||||
uint8_t key) {
|
||||
uint8_t sum = 0;
|
||||
// Process message from last byte to first byte (reflected)
|
||||
for(int byte = size - 1; byte >= 0; --byte) {
|
||||
uint8_t data = message[byte];
|
||||
// Process individual bits of each byte (reflected)
|
||||
for(uint8_t i = 0; i < 8; ++i) {
|
||||
// XOR key into sum if data bit is set
|
||||
if((data >> i) & 1) {
|
||||
sum ^= key;
|
||||
}
|
||||
|
||||
// roll the key left (actually the LSB is dropped here)
|
||||
// and apply the gen (needs to include the dropped lsb as MSB)
|
||||
if(key & 0x80)
|
||||
key = (key << 1) ^ gen;
|
||||
else
|
||||
key = (key << 1);
|
||||
}
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
uint16_t subghz_protocol_blocks_lfsr_digest16(
|
||||
uint8_t const message[],
|
||||
size_t size,
|
||||
uint16_t gen,
|
||||
uint16_t key) {
|
||||
uint16_t sum = 0;
|
||||
for(size_t byte = 0; byte < size; ++byte) {
|
||||
uint8_t data = message[byte];
|
||||
for(int8_t i = 7; i >= 0; --i) {
|
||||
// if data bit is set then xor with key
|
||||
if((data >> i) & 1) sum ^= key;
|
||||
|
||||
// roll the key right (actually the LSB is dropped here)
|
||||
// and apply the gen (needs to include the dropped LSB as MSB)
|
||||
if(key & 1)
|
||||
key = (key >> 1) ^ gen;
|
||||
else
|
||||
key = (key >> 1);
|
||||
}
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
uint8_t subghz_protocol_blocks_add_bytes(uint8_t const message[], size_t size) {
|
||||
uint32_t result = 0;
|
||||
for(size_t i = 0; i < size; ++i) {
|
||||
result += message[i];
|
||||
}
|
||||
return (uint8_t)result;
|
||||
}
|
||||
|
||||
uint8_t subghz_protocol_blocks_parity8(uint8_t byte) {
|
||||
byte ^= byte >> 4;
|
||||
byte &= 0xf;
|
||||
return (0x6996 >> byte) & 1;
|
||||
}
|
||||
|
||||
uint8_t subghz_protocol_blocks_parity_bytes(uint8_t const message[], size_t size) {
|
||||
uint8_t result = 0;
|
||||
for(size_t i = 0; i < size; ++i) {
|
||||
result ^= subghz_protocol_blocks_parity8(message[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
uint8_t subghz_protocol_blocks_xor_bytes(uint8_t const message[], size_t size) {
|
||||
uint8_t result = 0;
|
||||
for(size_t i = 0; i < size; ++i) {
|
||||
result ^= message[i];
|
||||
}
|
||||
return result;
|
||||
}
|
222
applications/debug/subghz_test/protocol/math.h
Normal file
222
applications/debug/subghz_test/protocol/math.h
Normal file
|
@ -0,0 +1,222 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#define bit_read(value, bit) (((value) >> (bit)) & 0x01)
|
||||
#define bit_set(value, bit) \
|
||||
({ \
|
||||
__typeof__(value) _one = (1); \
|
||||
(value) |= (_one << (bit)); \
|
||||
})
|
||||
#define bit_clear(value, bit) \
|
||||
({ \
|
||||
__typeof__(value) _one = (1); \
|
||||
(value) &= ~(_one << (bit)); \
|
||||
})
|
||||
#define bit_write(value, bit, bitvalue) (bitvalue ? bit_set(value, bit) : bit_clear(value, bit))
|
||||
#define DURATION_DIFF(x, y) (((x) < (y)) ? ((y) - (x)) : ((x) - (y)))
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Flip the data bitwise
|
||||
*
|
||||
* @param key In data
|
||||
* @param bit_count number of data bits
|
||||
*
|
||||
* @return Reverse data
|
||||
*/
|
||||
uint64_t subghz_protocol_blocks_reverse_key(uint64_t key, uint8_t bit_count);
|
||||
|
||||
/** Get parity the data bitwise
|
||||
*
|
||||
* @param key In data
|
||||
* @param bit_count number of data bits
|
||||
*
|
||||
* @return parity
|
||||
*/
|
||||
uint8_t subghz_protocol_blocks_get_parity(uint64_t key, uint8_t bit_count);
|
||||
|
||||
/** CRC-4
|
||||
*
|
||||
* @param message array of bytes to check
|
||||
* @param size number of bytes in message
|
||||
* @param polynomial CRC polynomial
|
||||
* @param init starting crc value
|
||||
*
|
||||
* @return CRC value
|
||||
*/
|
||||
uint8_t subghz_protocol_blocks_crc4(
|
||||
uint8_t const message[],
|
||||
size_t size,
|
||||
uint8_t polynomial,
|
||||
uint8_t init);
|
||||
|
||||
/** CRC-7
|
||||
*
|
||||
* @param message array of bytes to check
|
||||
* @param size number of bytes in message
|
||||
* @param polynomial CRC polynomial
|
||||
* @param init starting crc value
|
||||
*
|
||||
* @return CRC value
|
||||
*/
|
||||
uint8_t subghz_protocol_blocks_crc7(
|
||||
uint8_t const message[],
|
||||
size_t size,
|
||||
uint8_t polynomial,
|
||||
uint8_t init);
|
||||
|
||||
/** Generic Cyclic Redundancy Check CRC-8. Example polynomial: 0x31 = x8 + x5 +
|
||||
* x4 + 1 (x8 is implicit) Example polynomial: 0x80 = x8 + x7 (a normal
|
||||
* bit-by-bit parity XOR)
|
||||
*
|
||||
* @param message array of bytes to check
|
||||
* @param size number of bytes in message
|
||||
* @param polynomial byte is from x^7 to x^0 (x^8 is implicitly one)
|
||||
* @param init starting crc value
|
||||
*
|
||||
* @return CRC value
|
||||
*/
|
||||
uint8_t subghz_protocol_blocks_crc8(
|
||||
uint8_t const message[],
|
||||
size_t size,
|
||||
uint8_t polynomial,
|
||||
uint8_t init);
|
||||
|
||||
/** "Little-endian" Cyclic Redundancy Check CRC-8 LE Input and output are
|
||||
* reflected, i.e. least significant bit is shifted in first
|
||||
*
|
||||
* @param message array of bytes to check
|
||||
* @param size number of bytes in message
|
||||
* @param polynomial CRC polynomial
|
||||
* @param init starting crc value
|
||||
*
|
||||
* @return CRC value
|
||||
*/
|
||||
uint8_t subghz_protocol_blocks_crc8le(
|
||||
uint8_t const message[],
|
||||
size_t size,
|
||||
uint8_t polynomial,
|
||||
uint8_t init);
|
||||
|
||||
/** CRC-16 LSB. Input and output are reflected, i.e. least significant bit is
|
||||
* shifted in first. Note that poly and init already need to be reflected
|
||||
*
|
||||
* @param message array of bytes to check
|
||||
* @param size number of bytes in message
|
||||
* @param polynomial CRC polynomial
|
||||
* @param init starting crc value
|
||||
*
|
||||
* @return CRC value
|
||||
*/
|
||||
uint16_t subghz_protocol_blocks_crc16lsb(
|
||||
uint8_t const message[],
|
||||
size_t size,
|
||||
uint16_t polynomial,
|
||||
uint16_t init);
|
||||
|
||||
/** CRC-16
|
||||
*
|
||||
* @param message array of bytes to check
|
||||
* @param size number of bytes in message
|
||||
* @param polynomial CRC polynomial
|
||||
* @param init starting crc value
|
||||
*
|
||||
* @return CRC value
|
||||
*/
|
||||
uint16_t subghz_protocol_blocks_crc16(
|
||||
uint8_t const message[],
|
||||
size_t size,
|
||||
uint16_t polynomial,
|
||||
uint16_t init);
|
||||
|
||||
/** Digest-8 by "LFSR-based Toeplitz hash"
|
||||
*
|
||||
* @param message bytes of message data
|
||||
* @param size number of bytes to digest
|
||||
* @param gen key stream generator, needs to includes the MSB if the
|
||||
* LFSR is rolling
|
||||
* @param key initial key
|
||||
*
|
||||
* @return digest value
|
||||
*/
|
||||
uint8_t subghz_protocol_blocks_lfsr_digest8(
|
||||
uint8_t const message[],
|
||||
size_t size,
|
||||
uint8_t gen,
|
||||
uint8_t key);
|
||||
|
||||
/** Digest-8 by "LFSR-based Toeplitz hash", byte reflect, bit reflect
|
||||
*
|
||||
* @param message bytes of message data
|
||||
* @param size number of bytes to digest
|
||||
* @param gen key stream generator, needs to includes the MSB if the
|
||||
* LFSR is rolling
|
||||
* @param key initial key
|
||||
*
|
||||
* @return digest value
|
||||
*/
|
||||
uint8_t subghz_protocol_blocks_lfsr_digest8_reflect(
|
||||
uint8_t const message[],
|
||||
size_t size,
|
||||
uint8_t gen,
|
||||
uint8_t key);
|
||||
|
||||
/** Digest-16 by "LFSR-based Toeplitz hash"
|
||||
*
|
||||
* @param message bytes of message data
|
||||
* @param size number of bytes to digest
|
||||
* @param gen key stream generator, needs to includes the MSB if the
|
||||
* LFSR is rolling
|
||||
* @param key initial key
|
||||
*
|
||||
* @return digest value
|
||||
*/
|
||||
uint16_t subghz_protocol_blocks_lfsr_digest16(
|
||||
uint8_t const message[],
|
||||
size_t size,
|
||||
uint16_t gen,
|
||||
uint16_t key);
|
||||
|
||||
/** Compute Addition of a number of bytes
|
||||
*
|
||||
* @param message bytes of message data
|
||||
* @param size number of bytes to sum
|
||||
*
|
||||
* @return summation value
|
||||
*/
|
||||
uint8_t subghz_protocol_blocks_add_bytes(uint8_t const message[], size_t size);
|
||||
|
||||
/** Compute bit parity of a single byte (8 bits)
|
||||
*
|
||||
* @param byte single byte to check
|
||||
*
|
||||
* @return 1 odd parity, 0 even parity
|
||||
*/
|
||||
uint8_t subghz_protocol_blocks_parity8(uint8_t byte);
|
||||
|
||||
/** Compute bit parity of a number of bytes
|
||||
*
|
||||
* @param message bytes of message data
|
||||
* @param size number of bytes to sum
|
||||
*
|
||||
* @return 1 odd parity, 0 even parity
|
||||
*/
|
||||
uint8_t subghz_protocol_blocks_parity_bytes(uint8_t const message[], size_t size);
|
||||
|
||||
/** Compute XOR (byte-wide parity) of a number of bytes
|
||||
*
|
||||
* @param message bytes of message data
|
||||
* @param size number of bytes to sum
|
||||
*
|
||||
* @return summation value, per bit-position 1 odd parity, 0 even parity
|
||||
*/
|
||||
uint8_t subghz_protocol_blocks_xor_bytes(uint8_t const message[], size_t size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -1,7 +1,7 @@
|
|||
#include "princeton_for_testing.h"
|
||||
|
||||
#include <furi_hal.h>
|
||||
#include "../blocks/math.h"
|
||||
#include "math.h"
|
||||
|
||||
/*
|
||||
* Help
|
|
@ -1,6 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
#include "base.h"
|
||||
//#include "base.h"
|
||||
#include <furi.h>
|
||||
#include <lib/toolbox/level_duration.h>
|
||||
|
||||
/** SubGhzDecoderPrinceton anonymous type */
|
||||
typedef struct SubGhzDecoderPrinceton SubGhzDecoderPrinceton;
|
30
applications/debug/subghz_test/scenes/subghz_test_scene.c
Normal file
30
applications/debug/subghz_test/scenes/subghz_test_scene.c
Normal file
|
@ -0,0 +1,30 @@
|
|||
#include "../subghz_test_app_i.h"
|
||||
|
||||
// Generate scene on_enter handlers array
|
||||
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_enter,
|
||||
void (*const subghz_test_scene_on_enter_handlers[])(void*) = {
|
||||
#include "subghz_test_scene_config.h"
|
||||
};
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Generate scene on_event handlers array
|
||||
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_event,
|
||||
bool (*const subghz_test_scene_on_event_handlers[])(void* context, SceneManagerEvent event) = {
|
||||
#include "subghz_test_scene_config.h"
|
||||
};
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Generate scene on_exit handlers array
|
||||
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_exit,
|
||||
void (*const subghz_test_scene_on_exit_handlers[])(void* context) = {
|
||||
#include "subghz_test_scene_config.h"
|
||||
};
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Initialize scene handlers configuration structure
|
||||
const SceneManagerHandlers subghz_test_scene_handlers = {
|
||||
.on_enter_handlers = subghz_test_scene_on_enter_handlers,
|
||||
.on_event_handlers = subghz_test_scene_on_event_handlers,
|
||||
.on_exit_handlers = subghz_test_scene_on_exit_handlers,
|
||||
.scene_num = SubGhzTestSceneNum,
|
||||
};
|
29
applications/debug/subghz_test/scenes/subghz_test_scene.h
Normal file
29
applications/debug/subghz_test/scenes/subghz_test_scene.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
#pragma once
|
||||
|
||||
#include <gui/scene_manager.h>
|
||||
|
||||
// Generate scene id and total number
|
||||
#define ADD_SCENE(prefix, name, id) SubGhzTestScene##id,
|
||||
typedef enum {
|
||||
#include "subghz_test_scene_config.h"
|
||||
SubGhzTestSceneNum,
|
||||
} SubGhzTestScene;
|
||||
#undef ADD_SCENE
|
||||
|
||||
extern const SceneManagerHandlers subghz_test_scene_handlers;
|
||||
|
||||
// Generate scene on_enter handlers declaration
|
||||
#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_enter(void*);
|
||||
#include "subghz_test_scene_config.h"
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Generate scene on_event handlers declaration
|
||||
#define ADD_SCENE(prefix, name, id) \
|
||||
bool prefix##_scene_##name##_on_event(void* context, SceneManagerEvent event);
|
||||
#include "subghz_test_scene_config.h"
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Generate scene on_exit handlers declaration
|
||||
#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_exit(void* context);
|
||||
#include "subghz_test_scene_config.h"
|
||||
#undef ADD_SCENE
|
|
@ -0,0 +1,66 @@
|
|||
#include "../subghz_test_app_i.h"
|
||||
|
||||
void subghz_test_scene_about_widget_callback(GuiButtonType result, InputType type, void* context) {
|
||||
SubGhzTestApp* app = context;
|
||||
if(type == InputTypeShort) {
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, result);
|
||||
}
|
||||
}
|
||||
|
||||
void subghz_test_scene_about_on_enter(void* context) {
|
||||
SubGhzTestApp* app = context;
|
||||
|
||||
FuriString* temp_str;
|
||||
temp_str = furi_string_alloc();
|
||||
furi_string_printf(temp_str, "\e#%s\n", "Information");
|
||||
|
||||
furi_string_cat_printf(temp_str, "Version: %s\n", SUBGHZ_TEST_VERSION_APP);
|
||||
furi_string_cat_printf(temp_str, "Developed by: %s\n", SUBGHZ_TEST_DEVELOPED);
|
||||
furi_string_cat_printf(temp_str, "Github: %s\n\n", SUBGHZ_TEST_GITHUB);
|
||||
|
||||
furi_string_cat_printf(temp_str, "\e#%s\n", "Description");
|
||||
furi_string_cat_printf(
|
||||
temp_str,
|
||||
"This application is designed\nto test the functionality of the\nbuilt-in CC1101 module.\n\n");
|
||||
|
||||
widget_add_text_box_element(
|
||||
app->widget,
|
||||
0,
|
||||
0,
|
||||
128,
|
||||
14,
|
||||
AlignCenter,
|
||||
AlignBottom,
|
||||
"\e#\e! \e!\n",
|
||||
false);
|
||||
widget_add_text_box_element(
|
||||
app->widget,
|
||||
0,
|
||||
2,
|
||||
128,
|
||||
14,
|
||||
AlignCenter,
|
||||
AlignBottom,
|
||||
"\e#\e! Sub-Ghz Test \e!\n",
|
||||
false);
|
||||
widget_add_text_scroll_element(app->widget, 0, 16, 128, 50, furi_string_get_cstr(temp_str));
|
||||
furi_string_free(temp_str);
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SubGhzTestViewWidget);
|
||||
}
|
||||
|
||||
bool subghz_test_scene_about_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhzTestApp* app = context;
|
||||
bool consumed = false;
|
||||
UNUSED(app);
|
||||
UNUSED(event);
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void subghz_test_scene_about_on_exit(void* context) {
|
||||
SubGhzTestApp* app = context;
|
||||
|
||||
// Clear views
|
||||
widget_reset(app->widget);
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
#include "../subghz_test_app_i.h"
|
||||
|
||||
void subghz_test_scene_carrier_callback(SubGhzTestCarrierEvent event, void* context) {
|
||||
furi_assert(context);
|
||||
SubGhzTestApp* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, event);
|
||||
}
|
||||
|
||||
void subghz_test_scene_carrier_on_enter(void* context) {
|
||||
SubGhzTestApp* app = context;
|
||||
subghz_test_carrier_set_callback(
|
||||
app->subghz_test_carrier, subghz_test_scene_carrier_callback, app);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SubGhzTestViewCarrier);
|
||||
}
|
||||
|
||||
bool subghz_test_scene_carrier_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhzTestApp* app = context;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubGhzTestCarrierEventOnlyRx) {
|
||||
scene_manager_next_scene(app->scene_manager, SubGhzTestSceneShowOnlyRx);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void subghz_test_scene_carrier_on_exit(void* context) {
|
||||
UNUSED(context);
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
ADD_SCENE(subghz_test, start, Start)
|
||||
ADD_SCENE(subghz_test, about, About)
|
||||
ADD_SCENE(subghz_test, carrier, Carrier)
|
||||
ADD_SCENE(subghz_test, packet, Packet)
|
||||
ADD_SCENE(subghz_test, static, Static)
|
||||
ADD_SCENE(subghz_test, show_only_rx, ShowOnlyRx)
|
|
@ -0,0 +1,29 @@
|
|||
#include "../subghz_test_app_i.h"
|
||||
|
||||
void subghz_test_scene_packet_callback(SubGhzTestPacketEvent event, void* context) {
|
||||
furi_assert(context);
|
||||
SubGhzTestApp* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, event);
|
||||
}
|
||||
|
||||
void subghz_test_scene_packet_on_enter(void* context) {
|
||||
SubGhzTestApp* app = context;
|
||||
subghz_test_packet_set_callback(
|
||||
app->subghz_test_packet, subghz_test_scene_packet_callback, app);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SubGhzTestViewPacket);
|
||||
}
|
||||
|
||||
bool subghz_test_scene_packet_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhzTestApp* app = context;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubGhzTestPacketEventOnlyRx) {
|
||||
scene_manager_next_scene(app->scene_manager, SubGhzTestSceneShowOnlyRx);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void subghz_test_scene_packet_on_exit(void* context) {
|
||||
UNUSED(context);
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
#include "../subghz_test_app_i.h"
|
||||
#include <subghz_test_icons.h>
|
||||
|
||||
void subghz_test_scene_show_only_rx_popup_callback(void* context) {
|
||||
SubGhzTestApp* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, SubGhzTestCustomEventSceneShowOnlyRX);
|
||||
}
|
||||
|
||||
void subghz_test_scene_show_only_rx_on_enter(void* context) {
|
||||
SubGhzTestApp* app = context;
|
||||
|
||||
// Setup view
|
||||
Popup* popup = app->popup;
|
||||
|
||||
const char* header_text = "Transmission is blocked";
|
||||
const char* message_text = "Transmission on\nthis frequency is\nrestricted in\nyour region";
|
||||
if(!furi_hal_region_is_provisioned()) {
|
||||
header_text = "Firmware update needed";
|
||||
message_text = "Please update\nfirmware before\nusing this feature\nflipp.dev/upd";
|
||||
}
|
||||
|
||||
popup_set_header(popup, header_text, 63, 3, AlignCenter, AlignTop);
|
||||
popup_set_text(popup, message_text, 0, 17, AlignLeft, AlignTop);
|
||||
popup_set_icon(popup, 72, 17, &I_DolphinCommon_56x48);
|
||||
|
||||
popup_set_timeout(popup, 1500);
|
||||
popup_set_context(popup, app);
|
||||
popup_set_callback(popup, subghz_test_scene_show_only_rx_popup_callback);
|
||||
popup_enable_timeout(popup);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SubGhzTestViewPopup);
|
||||
}
|
||||
|
||||
bool subghz_test_scene_show_only_rx_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhzTestApp* app = context;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubGhzTestCustomEventSceneShowOnlyRX) {
|
||||
scene_manager_previous_scene(app->scene_manager);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void subghz_test_scene_show_only_rx_on_exit(void* context) {
|
||||
SubGhzTestApp* app = context;
|
||||
Popup* popup = app->popup;
|
||||
|
||||
popup_reset(popup);
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
#include "../subghz_test_app_i.h"
|
||||
|
||||
typedef enum {
|
||||
SubmenuIndexSubGhzTestCarrier,
|
||||
SubmenuIndexSubGhzTestPacket,
|
||||
SubmenuIndexSubGhzTestStatic,
|
||||
SubmenuIndexSubGhzTestAbout,
|
||||
} SubmenuIndex;
|
||||
|
||||
void subghz_test_scene_start_submenu_callback(void* context, uint32_t index) {
|
||||
SubGhzTestApp* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, index);
|
||||
}
|
||||
|
||||
void subghz_test_scene_start_on_enter(void* context) {
|
||||
SubGhzTestApp* app = context;
|
||||
Submenu* submenu = app->submenu;
|
||||
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"Carrier",
|
||||
SubmenuIndexSubGhzTestCarrier,
|
||||
subghz_test_scene_start_submenu_callback,
|
||||
app);
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"Packet",
|
||||
SubmenuIndexSubGhzTestPacket,
|
||||
subghz_test_scene_start_submenu_callback,
|
||||
app);
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"Static",
|
||||
SubmenuIndexSubGhzTestStatic,
|
||||
subghz_test_scene_start_submenu_callback,
|
||||
app);
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"About",
|
||||
SubmenuIndexSubGhzTestAbout,
|
||||
subghz_test_scene_start_submenu_callback,
|
||||
app);
|
||||
|
||||
submenu_set_selected_item(
|
||||
submenu, scene_manager_get_scene_state(app->scene_manager, SubGhzTestSceneStart));
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SubGhzTestViewSubmenu);
|
||||
}
|
||||
|
||||
bool subghz_test_scene_start_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhzTestApp* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubmenuIndexSubGhzTestAbout) {
|
||||
scene_manager_next_scene(app->scene_manager, SubGhzTestSceneAbout);
|
||||
consumed = true;
|
||||
} else if(event.event == SubmenuIndexSubGhzTestCarrier) {
|
||||
scene_manager_next_scene(app->scene_manager, SubGhzTestSceneCarrier);
|
||||
consumed = true;
|
||||
} else if(event.event == SubmenuIndexSubGhzTestPacket) {
|
||||
scene_manager_next_scene(app->scene_manager, SubGhzTestScenePacket);
|
||||
consumed = true;
|
||||
} else if(event.event == SubmenuIndexSubGhzTestStatic) {
|
||||
scene_manager_next_scene(app->scene_manager, SubGhzTestSceneStatic);
|
||||
consumed = true;
|
||||
}
|
||||
scene_manager_set_scene_state(app->scene_manager, SubGhzTestSceneStart, event.event);
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void subghz_test_scene_start_on_exit(void* context) {
|
||||
SubGhzTestApp* app = context;
|
||||
submenu_reset(app->submenu);
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
#include "../subghz_test_app_i.h"
|
||||
|
||||
void subghz_test_scene_static_callback(SubGhzTestStaticEvent event, void* context) {
|
||||
furi_assert(context);
|
||||
SubGhzTestApp* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, event);
|
||||
}
|
||||
|
||||
void subghz_test_scene_static_on_enter(void* context) {
|
||||
SubGhzTestApp* app = context;
|
||||
subghz_test_static_set_callback(
|
||||
app->subghz_test_static, subghz_test_scene_static_callback, app);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SubGhzTestViewStatic);
|
||||
}
|
||||
|
||||
bool subghz_test_scene_static_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhzTestApp* app = context;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubGhzTestStaticEventOnlyRx) {
|
||||
scene_manager_next_scene(app->scene_manager, SubGhzTestSceneShowOnlyRx);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void subghz_test_scene_static_on_exit(void* context) {
|
||||
UNUSED(context);
|
||||
}
|
BIN
applications/debug/subghz_test/subghz_test_10px.png
Normal file
BIN
applications/debug/subghz_test/subghz_test_10px.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 181 B |
139
applications/debug/subghz_test/subghz_test_app.c
Normal file
139
applications/debug/subghz_test/subghz_test_app.c
Normal file
|
@ -0,0 +1,139 @@
|
|||
#include "subghz_test_app_i.h"
|
||||
|
||||
#include <furi.h>
|
||||
#include <furi_hal.h>
|
||||
|
||||
static bool subghz_test_app_custom_event_callback(void* context, uint32_t event) {
|
||||
furi_assert(context);
|
||||
SubGhzTestApp* app = context;
|
||||
return scene_manager_handle_custom_event(app->scene_manager, event);
|
||||
}
|
||||
|
||||
static bool subghz_test_app_back_event_callback(void* context) {
|
||||
furi_assert(context);
|
||||
SubGhzTestApp* app = context;
|
||||
return scene_manager_handle_back_event(app->scene_manager);
|
||||
}
|
||||
|
||||
static void subghz_test_app_tick_event_callback(void* context) {
|
||||
furi_assert(context);
|
||||
SubGhzTestApp* app = context;
|
||||
scene_manager_handle_tick_event(app->scene_manager);
|
||||
}
|
||||
|
||||
SubGhzTestApp* subghz_test_app_alloc() {
|
||||
SubGhzTestApp* app = malloc(sizeof(SubGhzTestApp));
|
||||
|
||||
// GUI
|
||||
app->gui = furi_record_open(RECORD_GUI);
|
||||
|
||||
// View Dispatcher
|
||||
app->view_dispatcher = view_dispatcher_alloc();
|
||||
app->scene_manager = scene_manager_alloc(&subghz_test_scene_handlers, app);
|
||||
view_dispatcher_enable_queue(app->view_dispatcher);
|
||||
|
||||
view_dispatcher_set_event_callback_context(app->view_dispatcher, app);
|
||||
view_dispatcher_set_custom_event_callback(
|
||||
app->view_dispatcher, subghz_test_app_custom_event_callback);
|
||||
view_dispatcher_set_navigation_event_callback(
|
||||
app->view_dispatcher, subghz_test_app_back_event_callback);
|
||||
view_dispatcher_set_tick_event_callback(
|
||||
app->view_dispatcher, subghz_test_app_tick_event_callback, 100);
|
||||
|
||||
view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);
|
||||
|
||||
// Open Notification record
|
||||
app->notifications = furi_record_open(RECORD_NOTIFICATION);
|
||||
|
||||
// SubMenu
|
||||
app->submenu = submenu_alloc();
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher, SubGhzTestViewSubmenu, submenu_get_view(app->submenu));
|
||||
|
||||
// Widget
|
||||
app->widget = widget_alloc();
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher, SubGhzTestViewWidget, widget_get_view(app->widget));
|
||||
|
||||
// Popup
|
||||
app->popup = popup_alloc();
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher, SubGhzTestViewPopup, popup_get_view(app->popup));
|
||||
|
||||
// Carrier Test Module
|
||||
app->subghz_test_carrier = subghz_test_carrier_alloc();
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher,
|
||||
SubGhzTestViewCarrier,
|
||||
subghz_test_carrier_get_view(app->subghz_test_carrier));
|
||||
|
||||
// Packet Test
|
||||
app->subghz_test_packet = subghz_test_packet_alloc();
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher,
|
||||
SubGhzTestViewPacket,
|
||||
subghz_test_packet_get_view(app->subghz_test_packet));
|
||||
|
||||
// Static send
|
||||
app->subghz_test_static = subghz_test_static_alloc();
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher,
|
||||
SubGhzTestViewStatic,
|
||||
subghz_test_static_get_view(app->subghz_test_static));
|
||||
|
||||
scene_manager_next_scene(app->scene_manager, SubGhzTestSceneStart);
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
void subghz_test_app_free(SubGhzTestApp* app) {
|
||||
furi_assert(app);
|
||||
|
||||
// Submenu
|
||||
view_dispatcher_remove_view(app->view_dispatcher, SubGhzTestViewSubmenu);
|
||||
submenu_free(app->submenu);
|
||||
|
||||
// Widget
|
||||
view_dispatcher_remove_view(app->view_dispatcher, SubGhzTestViewWidget);
|
||||
widget_free(app->widget);
|
||||
|
||||
// Popup
|
||||
view_dispatcher_remove_view(app->view_dispatcher, SubGhzTestViewPopup);
|
||||
popup_free(app->popup);
|
||||
|
||||
// Carrier Test
|
||||
view_dispatcher_remove_view(app->view_dispatcher, SubGhzTestViewCarrier);
|
||||
subghz_test_carrier_free(app->subghz_test_carrier);
|
||||
|
||||
// Packet Test
|
||||
view_dispatcher_remove_view(app->view_dispatcher, SubGhzTestViewPacket);
|
||||
subghz_test_packet_free(app->subghz_test_packet);
|
||||
|
||||
// Static
|
||||
view_dispatcher_remove_view(app->view_dispatcher, SubGhzTestViewStatic);
|
||||
subghz_test_static_free(app->subghz_test_static);
|
||||
|
||||
// View dispatcher
|
||||
view_dispatcher_free(app->view_dispatcher);
|
||||
scene_manager_free(app->scene_manager);
|
||||
|
||||
// Notifications
|
||||
furi_record_close(RECORD_NOTIFICATION);
|
||||
app->notifications = NULL;
|
||||
|
||||
// Close records
|
||||
furi_record_close(RECORD_GUI);
|
||||
|
||||
free(app);
|
||||
}
|
||||
|
||||
int32_t subghz_test_app(void* p) {
|
||||
UNUSED(p);
|
||||
SubGhzTestApp* subghz_test_app = subghz_test_app_alloc();
|
||||
|
||||
view_dispatcher_run(subghz_test_app->view_dispatcher);
|
||||
|
||||
subghz_test_app_free(subghz_test_app);
|
||||
|
||||
return 0;
|
||||
}
|
5
applications/debug/subghz_test/subghz_test_app_i.c
Normal file
5
applications/debug/subghz_test/subghz_test_app_i.c
Normal file
|
@ -0,0 +1,5 @@
|
|||
#include "subghz_test_app_i.h"
|
||||
|
||||
#include <furi.h>
|
||||
|
||||
#define TAG "SubGhzTest"
|
32
applications/debug/subghz_test/subghz_test_app_i.h
Normal file
32
applications/debug/subghz_test/subghz_test_app_i.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
#pragma once
|
||||
|
||||
#include "helpers/subghz_test_types.h"
|
||||
#include "helpers/subghz_test_event.h"
|
||||
|
||||
#include "scenes/subghz_test_scene.h"
|
||||
#include <gui/gui.h>
|
||||
#include <gui/view_dispatcher.h>
|
||||
#include <gui/scene_manager.h>
|
||||
#include <gui/modules/submenu.h>
|
||||
#include <gui/modules/widget.h>
|
||||
#include <gui/modules/popup.h>
|
||||
#include <notification/notification_messages.h>
|
||||
|
||||
#include "views/subghz_test_static.h"
|
||||
#include "views/subghz_test_carrier.h"
|
||||
#include "views/subghz_test_packet.h"
|
||||
|
||||
typedef struct SubGhzTestApp SubGhzTestApp;
|
||||
|
||||
struct SubGhzTestApp {
|
||||
Gui* gui;
|
||||
ViewDispatcher* view_dispatcher;
|
||||
SceneManager* scene_manager;
|
||||
NotificationApp* notifications;
|
||||
Submenu* submenu;
|
||||
Widget* widget;
|
||||
Popup* popup;
|
||||
SubGhzTestStatic* subghz_test_static;
|
||||
SubGhzTestCarrier* subghz_test_carrier;
|
||||
SubGhzTestPacket* subghz_test_packet;
|
||||
};
|
|
@ -1,6 +1,6 @@
|
|||
#include "subghz_test_carrier.h"
|
||||
#include "../subghz_i.h"
|
||||
#include "../helpers/subghz_testing.h"
|
||||
#include "../subghz_test_app_i.h"
|
||||
#include "../helpers/subghz_test_frequency.h"
|
||||
#include <lib/subghz/devices/cc1101_configs.h>
|
||||
|
||||
#include <math.h>
|
|
@ -1,6 +1,6 @@
|
|||
#include "subghz_test_packet.h"
|
||||
#include "../subghz_i.h"
|
||||
#include "../helpers/subghz_testing.h"
|
||||
#include "../subghz_test_app_i.h"
|
||||
#include "../helpers/subghz_test_frequency.h"
|
||||
#include <lib/subghz/devices/cc1101_configs.h>
|
||||
|
||||
#include <math.h>
|
||||
|
@ -8,7 +8,7 @@
|
|||
#include <furi_hal.h>
|
||||
#include <input/input.h>
|
||||
#include <toolbox/level_duration.h>
|
||||
#include <lib/subghz/protocols/princeton_for_testing.h>
|
||||
#include "../protocol/princeton_for_testing.h"
|
||||
|
||||
#define SUBGHZ_TEST_PACKET_COUNT 500
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
#include "subghz_test_static.h"
|
||||
#include "../subghz_i.h"
|
||||
#include "../helpers/subghz_testing.h"
|
||||
#include "../subghz_test_app_i.h"
|
||||
#include "../helpers/subghz_test_frequency.h"
|
||||
#include <lib/subghz/devices/cc1101_configs.h>
|
||||
|
||||
#include <math.h>
|
||||
|
@ -8,7 +8,7 @@
|
|||
#include <furi_hal.h>
|
||||
#include <input/input.h>
|
||||
#include <notification/notification_messages.h>
|
||||
#include <lib/subghz/protocols/princeton_for_testing.h>
|
||||
#include "../protocol/princeton_for_testing.h"
|
||||
|
||||
#define TAG "SubGhzTestStatic"
|
||||
|
|
@ -80,9 +80,6 @@ typedef enum {
|
|||
SubGhzViewIdFrequencyAnalyzer,
|
||||
SubGhzViewIdReadRAW,
|
||||
|
||||
SubGhzViewIdStatic,
|
||||
SubGhzViewIdTestCarrier,
|
||||
SubGhzViewIdTestPacket,
|
||||
} SubGhzViewId;
|
||||
|
||||
/** SubGhz load type file */
|
||||
|
|
|
@ -12,10 +12,6 @@ ADD_SCENE(subghz, show_only_rx, ShowOnlyRx)
|
|||
ADD_SCENE(subghz, saved_menu, SavedMenu)
|
||||
ADD_SCENE(subghz, delete, Delete)
|
||||
ADD_SCENE(subghz, delete_success, DeleteSuccess)
|
||||
ADD_SCENE(subghz, test, Test)
|
||||
ADD_SCENE(subghz, test_static, TestStatic)
|
||||
ADD_SCENE(subghz, test_carrier, TestCarrier)
|
||||
ADD_SCENE(subghz, test_packet, TestPacket)
|
||||
ADD_SCENE(subghz, set_type, SetType)
|
||||
ADD_SCENE(subghz, frequency_analyzer, FrequencyAnalyzer)
|
||||
ADD_SCENE(subghz, read_raw, ReadRAW)
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
enum SubmenuIndex {
|
||||
SubmenuIndexRead = 10,
|
||||
SubmenuIndexSaved,
|
||||
SubmenuIndexTest,
|
||||
SubmenuIndexAddManually,
|
||||
SubmenuIndexFrequencyAnalyzer,
|
||||
SubmenuIndexReadRAW,
|
||||
|
@ -56,10 +55,6 @@ void subghz_scene_start_on_enter(void* context) {
|
|||
SubmenuIndexRadioSetting,
|
||||
subghz_scene_start_submenu_callback,
|
||||
subghz);
|
||||
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
|
||||
submenu_add_item(
|
||||
subghz->submenu, "Test", SubmenuIndexTest, subghz_scene_start_submenu_callback, subghz);
|
||||
}
|
||||
submenu_set_selected_item(
|
||||
subghz->submenu, scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneStart));
|
||||
|
||||
|
@ -101,11 +96,6 @@ bool subghz_scene_start_on_event(void* context, SceneManagerEvent event) {
|
|||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneFrequencyAnalyzer);
|
||||
dolphin_deed(DolphinDeedSubGhzFrequencyAnalyzer);
|
||||
return true;
|
||||
} else if(event.event == SubmenuIndexTest) {
|
||||
scene_manager_set_scene_state(
|
||||
subghz->scene_manager, SubGhzSceneStart, SubmenuIndexTest);
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneTest);
|
||||
return true;
|
||||
} else if(event.event == SubmenuIndexShowRegionInfo) {
|
||||
scene_manager_set_scene_state(
|
||||
subghz->scene_manager, SubGhzSceneStart, SubmenuIndexShowRegionInfo);
|
||||
|
|
|
@ -1,61 +0,0 @@
|
|||
#include "../subghz_i.h"
|
||||
|
||||
enum SubmenuIndex {
|
||||
SubmenuIndexCarrier,
|
||||
SubmenuIndexPacket,
|
||||
SubmenuIndexStatic,
|
||||
};
|
||||
|
||||
void subghz_scene_test_submenu_callback(void* context, uint32_t index) {
|
||||
SubGhz* subghz = context;
|
||||
view_dispatcher_send_custom_event(subghz->view_dispatcher, index);
|
||||
}
|
||||
|
||||
void subghz_scene_test_on_enter(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
|
||||
submenu_add_item(
|
||||
subghz->submenu,
|
||||
"Carrier",
|
||||
SubmenuIndexCarrier,
|
||||
subghz_scene_test_submenu_callback,
|
||||
subghz);
|
||||
submenu_add_item(
|
||||
subghz->submenu, "Packet", SubmenuIndexPacket, subghz_scene_test_submenu_callback, subghz);
|
||||
submenu_add_item(
|
||||
subghz->submenu, "Static", SubmenuIndexStatic, subghz_scene_test_submenu_callback, subghz);
|
||||
|
||||
submenu_set_selected_item(
|
||||
subghz->submenu, scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneTest));
|
||||
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdMenu);
|
||||
}
|
||||
|
||||
bool subghz_scene_test_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhz* subghz = context;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubmenuIndexCarrier) {
|
||||
scene_manager_set_scene_state(
|
||||
subghz->scene_manager, SubGhzSceneTest, SubmenuIndexCarrier);
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneTestCarrier);
|
||||
return true;
|
||||
} else if(event.event == SubmenuIndexPacket) {
|
||||
scene_manager_set_scene_state(
|
||||
subghz->scene_manager, SubGhzSceneTest, SubmenuIndexPacket);
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneTestPacket);
|
||||
return true;
|
||||
} else if(event.event == SubmenuIndexStatic) {
|
||||
scene_manager_set_scene_state(
|
||||
subghz->scene_manager, SubGhzSceneTest, SubmenuIndexStatic);
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneTestStatic);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void subghz_scene_test_on_exit(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
submenu_reset(subghz->submenu);
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
#include "../subghz_i.h"
|
||||
#include "../views/subghz_test_carrier.h"
|
||||
|
||||
void subghz_scene_test_carrier_callback(SubGhzTestCarrierEvent event, void* context) {
|
||||
furi_assert(context);
|
||||
SubGhz* subghz = context;
|
||||
view_dispatcher_send_custom_event(subghz->view_dispatcher, event);
|
||||
}
|
||||
|
||||
void subghz_scene_test_carrier_on_enter(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
subghz_test_carrier_set_callback(
|
||||
subghz->subghz_test_carrier, subghz_scene_test_carrier_callback, subghz);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdTestCarrier);
|
||||
}
|
||||
|
||||
bool subghz_scene_test_carrier_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhz* subghz = context;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubGhzTestCarrierEventOnlyRx) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowOnlyRx);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void subghz_scene_test_carrier_on_exit(void* context) {
|
||||
UNUSED(context);
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
#include "../subghz_i.h"
|
||||
#include "../views/subghz_test_packet.h"
|
||||
|
||||
void subghz_scene_test_packet_callback(SubGhzTestPacketEvent event, void* context) {
|
||||
furi_assert(context);
|
||||
SubGhz* subghz = context;
|
||||
view_dispatcher_send_custom_event(subghz->view_dispatcher, event);
|
||||
}
|
||||
|
||||
void subghz_scene_test_packet_on_enter(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
subghz_test_packet_set_callback(
|
||||
subghz->subghz_test_packet, subghz_scene_test_packet_callback, subghz);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdTestPacket);
|
||||
}
|
||||
|
||||
bool subghz_scene_test_packet_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhz* subghz = context;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubGhzTestPacketEventOnlyRx) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowOnlyRx);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void subghz_scene_test_packet_on_exit(void* context) {
|
||||
UNUSED(context);
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
#include "../subghz_i.h"
|
||||
#include "../views/subghz_test_static.h"
|
||||
|
||||
void subghz_scene_test_static_callback(SubGhzTestStaticEvent event, void* context) {
|
||||
furi_assert(context);
|
||||
SubGhz* subghz = context;
|
||||
view_dispatcher_send_custom_event(subghz->view_dispatcher, event);
|
||||
}
|
||||
|
||||
void subghz_scene_test_static_on_enter(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
subghz_test_static_set_callback(
|
||||
subghz->subghz_test_static, subghz_scene_test_static_callback, subghz);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdStatic);
|
||||
}
|
||||
|
||||
bool subghz_scene_test_static_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhz* subghz = context;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubGhzTestStaticEventOnlyRx) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowOnlyRx);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void subghz_scene_test_static_on_exit(void* context) {
|
||||
UNUSED(context);
|
||||
}
|
|
@ -129,27 +129,6 @@ SubGhz* subghz_alloc() {
|
|||
SubGhzViewIdReadRAW,
|
||||
subghz_read_raw_get_view(subghz->subghz_read_raw));
|
||||
|
||||
// Carrier Test Module
|
||||
subghz->subghz_test_carrier = subghz_test_carrier_alloc();
|
||||
view_dispatcher_add_view(
|
||||
subghz->view_dispatcher,
|
||||
SubGhzViewIdTestCarrier,
|
||||
subghz_test_carrier_get_view(subghz->subghz_test_carrier));
|
||||
|
||||
// Packet Test
|
||||
subghz->subghz_test_packet = subghz_test_packet_alloc();
|
||||
view_dispatcher_add_view(
|
||||
subghz->view_dispatcher,
|
||||
SubGhzViewIdTestPacket,
|
||||
subghz_test_packet_get_view(subghz->subghz_test_packet));
|
||||
|
||||
// Static send
|
||||
subghz->subghz_test_static = subghz_test_static_alloc();
|
||||
view_dispatcher_add_view(
|
||||
subghz->view_dispatcher,
|
||||
SubGhzViewIdStatic,
|
||||
subghz_test_static_get_view(subghz->subghz_test_static));
|
||||
|
||||
//init threshold rssi
|
||||
subghz->threshold_rssi = subghz_threshold_rssi_alloc();
|
||||
|
||||
|
@ -183,18 +162,6 @@ void subghz_free(SubGhz* subghz) {
|
|||
subghz_txrx_stop(subghz->txrx);
|
||||
subghz_txrx_sleep(subghz->txrx);
|
||||
|
||||
// Packet Test
|
||||
view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdTestPacket);
|
||||
subghz_test_packet_free(subghz->subghz_test_packet);
|
||||
|
||||
// Carrier Test
|
||||
view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdTestCarrier);
|
||||
subghz_test_carrier_free(subghz->subghz_test_carrier);
|
||||
|
||||
// Static
|
||||
view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdStatic);
|
||||
subghz_test_static_free(subghz->subghz_test_static);
|
||||
|
||||
// Receiver
|
||||
view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdReceiver);
|
||||
subghz_view_receiver_free(subghz->subghz_receiver);
|
||||
|
|
|
@ -9,10 +9,6 @@
|
|||
#include "views/subghz_frequency_analyzer.h"
|
||||
#include "views/subghz_read_raw.h"
|
||||
|
||||
#include "views/subghz_test_static.h"
|
||||
#include "views/subghz_test_carrier.h"
|
||||
#include "views/subghz_test_packet.h"
|
||||
|
||||
#include <gui/gui.h>
|
||||
#include <assets_icons.h>
|
||||
#include <dialogs/dialogs.h>
|
||||
|
@ -64,9 +60,6 @@ struct SubGhz {
|
|||
|
||||
SubGhzFrequencyAnalyzer* subghz_frequency_analyzer;
|
||||
SubGhzReadRAW* subghz_read_raw;
|
||||
SubGhzTestStatic* subghz_test_static;
|
||||
SubGhzTestCarrier* subghz_test_carrier;
|
||||
SubGhzTestPacket* subghz_test_packet;
|
||||
|
||||
SubGhzProtocolFlag filter;
|
||||
FuriString* error_str;
|
||||
|
|
|
@ -1384,8 +1384,8 @@ Function,+,furi_hal_subghz_rx_pipe_not_empty,_Bool,
|
|||
Function,+,furi_hal_subghz_set_async_mirror_pin,void,const GpioPin*
|
||||
Function,+,furi_hal_subghz_set_frequency,uint32_t,uint32_t
|
||||
Function,+,furi_hal_subghz_set_frequency_and_path,uint32_t,uint32_t
|
||||
Function,-,furi_hal_subghz_set_path,void,FuriHalSubGhzPath
|
||||
Function,-,furi_hal_subghz_shutdown,void,
|
||||
Function,+,furi_hal_subghz_set_path,void,FuriHalSubGhzPath
|
||||
Function,+,furi_hal_subghz_shutdown,void,
|
||||
Function,+,furi_hal_subghz_sleep,void,
|
||||
Function,+,furi_hal_subghz_start_async_rx,void,"FuriHalSubGhzCaptureCallback, void*"
|
||||
Function,+,furi_hal_subghz_start_async_tx,_Bool,"FuriHalSubGhzAsyncTxCallback, void*"
|
||||
|
@ -2745,6 +2745,7 @@ Function,+,subghz_protocol_decoder_base_get_hash_data,uint8_t,SubGhzProtocolDeco
|
|||
Function,+,subghz_protocol_decoder_base_get_string,_Bool,"SubGhzProtocolDecoderBase*, FuriString*"
|
||||
Function,+,subghz_protocol_decoder_base_serialize,SubGhzProtocolStatus,"SubGhzProtocolDecoderBase*, FlipperFormat*, SubGhzRadioPreset*"
|
||||
Function,-,subghz_protocol_decoder_base_set_decoder_callback,void,"SubGhzProtocolDecoderBase*, SubGhzProtocolDecoderBaseRxCallback, void*"
|
||||
Function,+,subghz_protocol_decoder_bin_raw_data_input_rssi,void,"SubGhzProtocolDecoderBinRAW*, float"
|
||||
Function,+,subghz_protocol_decoder_raw_alloc,void*,SubGhzEnvironment*
|
||||
Function,+,subghz_protocol_decoder_raw_deserialize,SubGhzProtocolStatus,"void*, FlipperFormat*"
|
||||
Function,+,subghz_protocol_decoder_raw_feed,void,"void*, _Bool, uint32_t"
|
||||
|
@ -2756,6 +2757,7 @@ Function,+,subghz_protocol_encoder_raw_deserialize,SubGhzProtocolStatus,"void*,
|
|||
Function,+,subghz_protocol_encoder_raw_free,void,void*
|
||||
Function,+,subghz_protocol_encoder_raw_stop,void,void*
|
||||
Function,+,subghz_protocol_encoder_raw_yield,LevelDuration,void*
|
||||
Function,+,subghz_protocol_keeloq_create_data,_Bool,"void*, FlipperFormat*, uint32_t, uint8_t, uint16_t, const char*, SubGhzRadioPreset*"
|
||||
Function,+,subghz_protocol_raw_file_encoder_worker_set_callback_end,void,"SubGhzProtocolEncoderRAW*, SubGhzProtocolEncoderRAWCallbackEnd, void*"
|
||||
Function,+,subghz_protocol_raw_gen_fff_data,void,"FlipperFormat*, const char*, const char*"
|
||||
Function,+,subghz_protocol_raw_get_sample_write,size_t,SubGhzProtocolDecoderRAW*
|
||||
|
@ -2765,6 +2767,8 @@ Function,+,subghz_protocol_raw_save_to_file_stop,void,SubGhzProtocolDecoderRAW*
|
|||
Function,+,subghz_protocol_registry_count,size_t,const SubGhzProtocolRegistry*
|
||||
Function,+,subghz_protocol_registry_get_by_index,const SubGhzProtocol*,"const SubGhzProtocolRegistry*, size_t"
|
||||
Function,+,subghz_protocol_registry_get_by_name,const SubGhzProtocol*,"const SubGhzProtocolRegistry*, const char*"
|
||||
Function,+,subghz_protocol_secplus_v1_check_fixed,_Bool,uint32_t
|
||||
Function,+,subghz_protocol_secplus_v2_create_data,_Bool,"void*, FlipperFormat*, uint32_t, uint8_t, uint32_t, SubGhzRadioPreset*"
|
||||
Function,+,subghz_receiver_alloc_init,SubGhzReceiver*,SubGhzEnvironment*
|
||||
Function,+,subghz_receiver_decode,void,"SubGhzReceiver*, _Bool, uint32_t"
|
||||
Function,+,subghz_receiver_free,void,SubGhzReceiver*
|
||||
|
|
|
|
@ -8,6 +8,31 @@ extern "C" {
|
|||
|
||||
extern const SubGhzProtocolRegistry subghz_protocol_registry;
|
||||
|
||||
typedef struct SubGhzProtocolDecoderBinRAW SubGhzProtocolDecoderBinRAW;
|
||||
|
||||
bool subghz_protocol_secplus_v2_create_data(
|
||||
void* context,
|
||||
FlipperFormat* flipper_format,
|
||||
uint32_t serial,
|
||||
uint8_t btn,
|
||||
uint32_t cnt,
|
||||
SubGhzRadioPreset* preset);
|
||||
|
||||
bool subghz_protocol_keeloq_create_data(
|
||||
void* context,
|
||||
FlipperFormat* flipper_format,
|
||||
uint32_t serial,
|
||||
uint8_t btn,
|
||||
uint16_t cnt,
|
||||
const char* manufacture_name,
|
||||
SubGhzRadioPreset* preset);
|
||||
|
||||
void subghz_protocol_decoder_bin_raw_data_input_rssi(
|
||||
SubGhzProtocolDecoderBinRAW* instance,
|
||||
float rssi);
|
||||
|
||||
bool subghz_protocol_secplus_v1_check_fixed(uint32_t fixed);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue