[FL-2904, FL-2900, FL-2890] WS: add app WeatherStation (#1833)
* WeatherStation: start * SubGhz: rename protocol magellen -> magellan * WeatherStation: err Unresolved symbols: {'subghz_protocol_decoder_base_get_string'} * WeatherStation: fix Unresolved symbols: {'subghz_protocol_decoder_base_get_string'} * Subghz: add set protocol_items * WeatherStation: adding your protocols * WS: add Infactory protocol * WS: add history * WS: add setting * WS: add lock * WS: add hopper frequency * WS: fix history * WS fix string_t -> FuriString* * WS: add images * WS: history record update when receiving data from the sensor again * WS: add receiver info, delete extra code * WS: add protocol ThermoPRO_TX4 * [FL-2900] SubGhz: Move icons in Sub-GHz * WS: add Notification * [FL-2890] SubGhz: Rename *_user files in resources to _user.example * WS: add about scene * WS: removing redundant code * WS: add protocol Nexus-TH * WS: add protocol GT_WT03 * WS: fix notification and rename "Weather Station" -> "Read Weather Station" * SubGhz: partial unit tests fix * SubGhz: fix unit_test * SubGhz: remove dead code * SubGhz: rename SubGhzPresetDefinition into SubGhzRadioPreset, cleanup subghz types. Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
@@ -4,9 +4,17 @@
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
const uint16_t te_long;
|
||||
const uint16_t te_short;
|
||||
const uint16_t te_delta;
|
||||
const uint8_t min_count_bit_for_found;
|
||||
} SubGhzBlockConst;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@@ -4,6 +4,10 @@
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct SubGhzBlockDecoder SubGhzBlockDecoder;
|
||||
|
||||
struct SubGhzBlockDecoder {
|
||||
@@ -26,3 +30,7 @@ void subghz_protocol_blocks_add_bit(SubGhzBlockDecoder* decoder, uint8_t bit);
|
||||
* @return hash Hash sum
|
||||
*/
|
||||
uint8_t subghz_protocol_blocks_get_hash_data(SubGhzBlockDecoder* decoder, size_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@@ -6,6 +6,10 @@
|
||||
|
||||
#include <lib/toolbox/level_duration.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
bool is_running;
|
||||
size_t repeat;
|
||||
@@ -50,3 +54,7 @@ size_t subghz_protocol_blocks_get_upload(
|
||||
LevelDuration* upload,
|
||||
size_t max_size_upload,
|
||||
uint32_t duration_bit);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@@ -23,7 +23,7 @@ void subghz_block_generic_get_preset_name(const char* preset_name, FuriString* p
|
||||
bool subghz_block_generic_serialize(
|
||||
SubGhzBlockGeneric* instance,
|
||||
FlipperFormat* flipper_format,
|
||||
SubGhzPresetDefinition* preset) {
|
||||
SubGhzRadioPreset* preset) {
|
||||
furi_assert(instance);
|
||||
bool res = false;
|
||||
FuriString* temp_str;
|
||||
|
@@ -9,6 +9,10 @@
|
||||
#include "furi_hal.h"
|
||||
#include "../types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct SubGhzBlockGeneric SubGhzBlockGeneric;
|
||||
|
||||
struct SubGhzBlockGeneric {
|
||||
@@ -31,13 +35,13 @@ void subghz_block_generic_get_preset_name(const char* preset_name, FuriString* p
|
||||
* Serialize data SubGhzBlockGeneric.
|
||||
* @param instance Pointer to a SubGhzBlockGeneric instance
|
||||
* @param flipper_format Pointer to a FlipperFormat instance
|
||||
* @param preset The modulation on which the signal was received, SubGhzPresetDefinition
|
||||
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
|
||||
* @return true On success
|
||||
*/
|
||||
bool subghz_block_generic_serialize(
|
||||
SubGhzBlockGeneric* instance,
|
||||
FlipperFormat* flipper_format,
|
||||
SubGhzPresetDefinition* preset);
|
||||
SubGhzRadioPreset* preset);
|
||||
|
||||
/**
|
||||
* Deserialize data SubGhzBlockGeneric.
|
||||
@@ -46,3 +50,7 @@ bool subghz_block_generic_serialize(
|
||||
* @return true On success
|
||||
*/
|
||||
bool subghz_block_generic_deserialize(SubGhzBlockGeneric* instance, FlipperFormat* flipper_format);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@@ -14,4 +14,69 @@ uint8_t subghz_protocol_blocks_get_parity(uint64_t key, uint8_t count_bit) {
|
||||
parity += bit_read(key, i);
|
||||
}
|
||||
return parity & 0x01;
|
||||
}
|
||||
|
||||
uint8_t subghz_protocol_blocks_crc4(
|
||||
uint8_t const message[],
|
||||
unsigned nBytes,
|
||||
uint8_t polynomial,
|
||||
uint8_t init) {
|
||||
unsigned remainder = init << 4; // LSBs are unused
|
||||
unsigned poly = polynomial << 4;
|
||||
unsigned bit;
|
||||
|
||||
while(nBytes--) {
|
||||
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[],
|
||||
unsigned nBytes,
|
||||
uint8_t polynomial,
|
||||
uint8_t init) {
|
||||
unsigned remainder = init << 1; // LSB is unused
|
||||
unsigned poly = polynomial << 1;
|
||||
unsigned byte, bit;
|
||||
|
||||
for(byte = 0; byte < nBytes; ++byte) {
|
||||
remainder ^= message[byte];
|
||||
for(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[],
|
||||
unsigned nBytes,
|
||||
uint8_t polynomial,
|
||||
uint8_t init) {
|
||||
uint8_t remainder = init;
|
||||
unsigned byte, bit;
|
||||
|
||||
for(byte = 0; byte < nBytes; ++byte) {
|
||||
remainder ^= message[byte];
|
||||
for(bit = 0; bit < 8; ++bit) {
|
||||
if(remainder & 0x80) {
|
||||
remainder = (remainder << 1) ^ polynomial;
|
||||
} else {
|
||||
remainder = (remainder << 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return remainder;
|
||||
}
|
@@ -9,7 +9,11 @@
|
||||
#define bit_clear(value, bit) ((value) &= ~(1UL << (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))
|
||||
#define abs(x) ((x) > 0 ? (x) : -(x))
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/**
|
||||
* Flip the data bitwise.
|
||||
* @param key In data
|
||||
@@ -25,3 +29,51 @@ uint64_t subghz_protocol_blocks_reverse_key(uint64_t key, uint8_t count_bit);
|
||||
* @return parity
|
||||
*/
|
||||
uint8_t subghz_protocol_blocks_get_parity(uint64_t key, uint8_t count_bit);
|
||||
|
||||
/**
|
||||
* CRC-4.
|
||||
* @param message array of bytes to check
|
||||
* @param nBytes 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[],
|
||||
unsigned nBytes,
|
||||
uint8_t polynomial,
|
||||
uint8_t init);
|
||||
|
||||
/**
|
||||
* CRC-7.
|
||||
* @param message array of bytes to check
|
||||
* @param nBytes 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[],
|
||||
unsigned nBytes,
|
||||
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 nBytes 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[],
|
||||
unsigned nBytes,
|
||||
uint8_t polynomial,
|
||||
uint8_t init);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user