feat(subghz): added Solight TE44 recognition (#183)

* feat(subghz): added Solight TE44 recognition

Added the Solight TE44 weather station, with a protocol similar to Auriol HG06061A but with a checksum and different sync values.
Updated the tests as well, including a raw and a decoded capture.

* Lint fixes

* Update changelog

---------

Co-authored-by: Willy-JL <49810075+Willy-JL@users.noreply.github.com>
This commit is contained in:
m7i-org
2024-08-21 20:46:08 -04:00
committed by GitHub
parent 788c517f7d
commit ff0e885fba
8 changed files with 374 additions and 0 deletions

View File

@@ -7,6 +7,7 @@
- Apps:
- Tools: Key Copier (by @zinongli)
- Sub-GHz: Music to Sub-GHz Radio (by @jamisonderek)
- Sub-GHz: Added Solight TE44 weather station recognition (by @m7i-org)
- Settings: Show free flash amount in internal storage info (by @Willy-JL)
- Services:
- OFW: On SD insert load BT, Desktop, Dolphin, Expansion, Notification, Region files (by @gsurkov)

View File

@@ -0,0 +1,16 @@
Filetype: Flipper SubGhz Key File
Version: 1
Frequency: 433920000
Preset: FuriHalSubGhzPresetOok650Async
Latitute: nan
Longitude: nan
Protocol: Solight TE44
Id: 148
Bit: 36
Data: 00 00 00 09 49 11 5F E9
Batt: 0
Hum: 255
Ts: 1723592365
Ch: 2
Btn: 255
Temp: 27.700001

View File

@@ -0,0 +1,8 @@
Filetype: Flipper SubGhz RAW File
Version: 1
Frequency: 433920000
Preset: FuriHalSubGhzPresetOok650Async
Protocol: RAW
RAW_Data: 512 -1940 504 -960 508 -960 500 -1940 504 -956 512 -1932 508 -960 508 -956 504 -1940 500 -960 508 -960 508 -1932 508 -960 500 -960 508 -960 508 -1932 508 -960 500 -968 500 -960 508 -1932 508 -960 504 -1940 500 -964 504 -1932 508 -1936 508 -1932 508 -1936 508 -1936 504 -1936 508 -1936 500 -1940 504 -956 508 -1932 512 -956 508 -960 508 -1932 500 -476 508 -3888 508 -1932 512 -956 508 -960 500 -1940 500 -960 508 -1936 504 -960 508 -956 512 -1932 504 -964 500 -960 504 -1936 508 -960 508 -956 508 -960 504 -1940 500 -964 500 -960 508 -960 508 -1932 508 -956 504 -1940 504 -960 504 -1940 504 -1940 500 -1940 500 -1940 504 -1932 508 -1936 508 -1932 508 -1936 508 -956 508 -1936 508 -956 508 -960 500 -1940 500 -476 508 -3884 508 -1936 504 -960 508 -960 508 -1932 508 -960 500 -1940 500 -964 504 -964 500 -1940 500 -960 508 -960 508 -1932 508 -960 504 -960 508 -960 500 -1940 500 -968 500 -956 508 -960 508 -1932 508 -960 508 -1932 508 -960 508 -1932 508 -1932 508 -1932 512 -1932 508 -1932 508 -1936 504 -1936 508 -1932 512 -956 508 -1932 508 -956 508 -960 508 -1936 504 -468 508 -3892 500 -1940 500 -968 500 -956 508 -1940 504 -956 508 -1932 508 -960 508 -956 508 -1932 512 -956 508 -960 508 -1932 508 -956 512 -956 508 -956 500 -1944 496 -968 500 -964 500 -960 508 -1940 500 -960 508 -1940 500 -956 508 -1940 500 -1944 500 -1940 500 -1940 500 -1944 504 -1932 508 -1936 508 -1932 508 -960 504 -1932 512 -956 508 -956 508 -1936 508 -464 512 -3888 508 -1932 508 -956 508 -960 508 -1928 512 -960 504 -1936 504 -960 508 -956 508 -1932 512 -956 508 -956 508 -1936 504 -960 508 -956 508 -960 508 -1932 504 -960 508 -960 500 -964 500 -1940 508 -956 500 -1944 504 -960 508 -1932 508 -1932 508 -1932 508 -1940 504 -1936 500 -1944 504 -1932 508 -1936 504 -960 508 -1932 508 -956 508 -960 508 -1932 504 -476 500 -3892 508 -1936 504 -964 500 -964 500 -1940 500 -968 500 -1940 504 -960 508 -956 500 -1940 508 -956 508 -960 508 -1932 508 -960 504 -960 504 -960 508 -1932 508 -956 508 -960 504 -960 508 -1932 508 -956 508 -1936 504 -960 508 -1940 500 -1940 504 -1932 508 -1932 512 -1936 500 -1940 508 -1932 508 -1932 508 -956 508 -1940 500 -964 500 -968 500 -1936 500 -476 508 -3888 508 -1932 508 -956 512 -952 512 -1932 504 -960 508 -1940 500 -964 500 -964 500 -1940 508 -960 504 -960 504 -1932 508 -960 508 -956 508 -956 508 -1932 508 -956 512 -956 504 -960 508 -1940 500 -964 500 -1940
RAW_Data: 504 -960 508 -1932 508 -1936 500 -1940 508 -1932 508 -1932 508 -1936 504 -1940 504 -1932 508 -956 512 -1936 500 -964 500 -968 500 -1940 504 -716 500 -3896 500 -1940 504 -960 508 -960 504 -1932 508 -960 504 -1940 500 -964 500 -968 504 -1932 508 -956 508 -960 504 -1940 504 -964 500 -964 500 -964 500 -1940 504 -960 508 -956 508 -956 508 -1932 508 -956 508 -1940 504 -960 504 -1936 504 -1940 500 -1940 508 -1932 504 -1940 500 -1940 504 -1936 504 -1940 508 -956 508 -1932 508 -956 508 -956 508 -1940 500 -472 508 -3888 508 -1936 504 -964 500 -964 500 -1940 504 -960 504 -1940 500 -964 500 -968 496 -1940 508 -956 508 -956 508 -1940 500 -964 500 -964 500 -964 508 -1932 504 -960 504 -960 508 -956 508 -1936 512 -952 508 -1936 504 -956 508 -1936 508 -1936 504 -1940 500 -1940 504 -1940 500 -1936 508 -1932 508 -1940 504 -960 508 -1932 504 -964 500 -964 504 -1936 508 -464 508 -3892 504 -1936 508 -956 508 -956 508 -1940 500 -964 504 -1932 508 -956 508 -964 500 -1940 504 -960 508 -956 508 -1936 504 -960 500 -968 504 -956 508 -1932 504 -968 496 -968 500 -964 504 -1932 508 -956 508 -1940 508 -956 504 -1932 508 -1940 504 -1932 508 -1936 508 -1932 508 -1936 508 -1932 504 -1940 508 -956 508 -1940 496 -968 496 -964 508 -1932 504 -476 508 -3884 508 -1936 500 -968 500 -964 504 -1932 508 -964 500 -1940 504 -956 508 -956 508 -1936 508 -960 504 -960 504 -1940 500 -960 508 -960 504 -960 504 -1940 500 -964 504 -960 508 -956 508 -1936 504 -960 504 -1932 508 -964 500 -1940 504 -1940 500 -1936 508 -1936 500 -1940 508 -1936 508 -1928 508 -1940 504 -960 504 -1940 500 -964 504 -956 508 -1940 500 -472 508 -3884 504 -1940 508 -956 508 -956 508 -1940 504 -956 508 -1936 508 -956 508 -956 508 -1936 500 -964 508 -956 508 -1936 504 -960 508 -956 508 -956 508 -1936 508 -956 508 -956 508 -956 508 -1936 508 -956 504 -1940 508 -956 504 -1940 500 -1936 508 -1940 504 -1932 504 -1940 504 -1940 500 -1936 508 -1936 508 -956 508 -1936 508 -956 508 -956 508 -1936 504 -10004

View File

@@ -670,6 +670,13 @@ MU_TEST(subghz_decoder_dickert_test) {
"Test decoder " SUBGHZ_PROTOCOL_DICKERT_MAHS_NAME " error\r\n");
}
MU_TEST(subghz_decoder_solight_te44_test) {
mu_assert(
subghz_decoder_test(
EXT_PATH("unit_tests/subghz/solight_te44_raw.sub"), WS_PROTOCOL_SOLIGHT_TE44_NAME),
"Test decoder " WS_PROTOCOL_SOLIGHT_TE44_NAME " error\r\n");
}
//test encoders
MU_TEST(subghz_encoder_princeton_test) {
mu_assert(
@@ -892,6 +899,7 @@ MU_TEST_SUITE(subghz) {
MU_RUN_TEST(subghz_decoder_kinggates_stylo4k_test);
MU_RUN_TEST(subghz_decoder_mastercode_test);
MU_RUN_TEST(subghz_decoder_dickert_test);
MU_RUN_TEST(subghz_decoder_solight_te44_test);
MU_RUN_TEST(subghz_encoder_princeton_test);
MU_RUN_TEST(subghz_encoder_came_test);

View File

@@ -57,6 +57,7 @@ const SubGhzProtocol* subghz_protocol_registry_items[] = {
&ws_protocol_oregon3,
&ws_protocol_acurite_592txr,
&ws_protocol_ambient_weather,
&ws_protocol_solight_te44, // Should be before auriol
&ws_protocol_auriol_th,
&ws_protocol_oregon_v1,
&ws_protocol_tx_8300,

View File

@@ -66,6 +66,7 @@
#include "kedsum_th.h"
#include "emos_e601x.h"
#include "acurite_5n1.h"
#include "solight_te44.h"
#include "pocsag.h"
#include "schrader_gg4.h"
#include "bin_raw.h"

View File

@@ -0,0 +1,259 @@
#include "solight_te44.h"
#include "furi/core/log.h"
#define TAG "WSProtocolSolightTE44"
/*
* Help
* https://github.com/merbanan/rtl_433/blob/master/src/devices/solight_te44.c
*
* Solight TE44 -- Generic wireless thermometer, which might be sold as part of different kits.
*
* So far these were identified (mostly sold in central/eastern europe)
* - Solight TE44
* - Solight TE66
* - EMOS E0107T
* - NX-6876-917 from Pearl (for FWS-70 station).
* - newer TFA 30.3197
*
* Rated -50 C to 70 C, frequency 433,92 MHz, three selectable channels.
*
* Encoding (see in applications/debug/unit_tests/resources/unit_tests/subghz/solight_te44_raw.sub for example)
* - Data begins with 500 -3890
* - A zero is encoded 500 -960
* - A one is encoded 500 -1940
* - Repetition ends with 500 -470 500 -3890
*
* Data structure:
*
* - 12 repetitions of the same 36 bit payload, a sync between each repetition
* - 36 bit payload format: IIII IIII B0cc TTTT TTTT TTTT 1111 cccc cccc
* ^ ^ ^ ^ ^
* | | | | |
* 8 bit ID (resets) at 28--/ | | | |
* 1 bit battery flag at 27--/ / | |
* 2 bit channel (0-2) at 24 ---/ / |
* 12 bit signed int temp(C) scale 10 at 12----/ /
* 8 bit checksum --------------------------------------------/
*
* If you're looking at this and thinking: this looks a lot like the Auriol HG06061A data structure. You're not alone,
* this is almost identical except for the last checksum, which is not only absent in the Auriol structure, but
* the same bits encode the humidity value. So maybe this explains older results of some random weather stations with
* implausible humidity values. By adding this before Auriol and expecting the weird data sync we avoid conflicts
* with its decoder.
*
* @m7i-org - because I want less BinRAW in my life
*
*/
static const SubGhzBlockConst ws_protocol_solight_te44_const = {
.te_short = 490,
.te_long = 3000,
.te_delta = 150,
.min_count_bit_for_found = 36,
};
struct WSProtocolDecoderSolightTE44 {
SubGhzProtocolDecoderBase base;
SubGhzBlockDecoder decoder;
WSBlockGeneric generic;
};
struct WSProtocolEncoderSolightTE44 {
SubGhzProtocolEncoderBase base;
SubGhzProtocolBlockEncoder encoder;
WSBlockGeneric generic;
};
const SubGhzProtocolDecoder ws_protocol_solight_te44_decoder = {
.alloc = ws_protocol_decoder_solight_te44_alloc,
.free = ws_protocol_decoder_solight_te44_free,
.feed = ws_protocol_decoder_solight_te44_feed,
.reset = ws_protocol_decoder_solight_te44_reset,
.get_hash_data = NULL,
.get_hash_data_long = ws_protocol_decoder_solight_te44_get_hash_data,
.serialize = ws_protocol_decoder_solight_te44_serialize,
.deserialize = ws_protocol_decoder_solight_te44_deserialize,
.get_string = ws_protocol_decoder_solight_te44_get_string,
.get_string_brief = NULL,
};
const SubGhzProtocolEncoder ws_protocol_solight_te44_encoder = {
.alloc = NULL,
.free = NULL,
.deserialize = NULL,
.stop = NULL,
.yield = NULL,
};
const SubGhzProtocol ws_protocol_solight_te44 = {
.name = WS_PROTOCOL_SOLIGHT_TE44_NAME,
.type = SubGhzProtocolTypeStatic,
.flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_315 | SubGhzProtocolFlag_868 |
SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_Load |
SubGhzProtocolFlag_Save,
.filter = SubGhzProtocolFilter_Weather,
.decoder = &ws_protocol_solight_te44_decoder,
.encoder = &ws_protocol_solight_te44_encoder,
};
typedef enum {
SolightTE44DecoderStepReset = 0,
SolightTE44DecoderStepSaveDuration,
SolightTE44DecoderStepCheckDuration,
} SolightTE44DecoderStep;
void* ws_protocol_decoder_solight_te44_alloc(SubGhzEnvironment* environment) {
UNUSED(environment);
WSProtocolDecoderSolightTE44* instance = malloc(sizeof(WSProtocolDecoderSolightTE44));
instance->base.protocol = &ws_protocol_solight_te44;
instance->generic.protocol_name = instance->base.protocol->name;
return instance;
}
void ws_protocol_decoder_solight_te44_free(void* context) {
furi_assert(context);
WSProtocolDecoderSolightTE44* instance = context;
free(instance);
}
void ws_protocol_decoder_solight_te44_reset(void* context) {
furi_assert(context);
WSProtocolDecoderSolightTE44* instance = context;
instance->decoder.parser_step = SolightTE44DecoderStepReset;
}
static bool ws_protocol_solight_te44_check(WSProtocolDecoderSolightTE44* instance) {
if(!instance->decoder.decode_data) return false;
if(((instance->decoder.decode_data >> 8) & 0x0f) != 0x0f) return false; // const not 1111
// Rubicson CRC check
uint8_t msg_rubicson_crc[] = {
instance->decoder.decode_data >> 28,
instance->decoder.decode_data >> 20,
instance->decoder.decode_data >> 12,
0xf0,
(instance->decoder.decode_data & 0xf0) | (instance->decoder.decode_data & 0x0f)};
uint8_t rubicson_crc = subghz_protocol_blocks_crc8(msg_rubicson_crc, 5, 0x31, 0x6c);
return rubicson_crc == 0;
}
/**
* Analysis of received data
* @param instance Pointer to a WSBlockGeneric* instance
*/
static void ws_protocol_solight_te44_extract_data(WSBlockGeneric* instance) {
instance->id = (instance->data >> 28) & 0xff;
instance->battery_low = !(instance->data >> 27) & 0x01;
instance->channel = ((instance->data >> 24) & 0x03) + 1;
int16_t temp = (instance->data >> 12) & 0x0fff;
/* Handle signed data */
if(temp & 0x0800) {
temp |= 0xf000;
}
instance->temp = (float)temp / 10.0;
instance->btn = WS_NO_BTN;
instance->humidity = WS_NO_HUMIDITY;
}
void ws_protocol_decoder_solight_te44_feed(void* context, bool level, uint32_t duration) {
furi_assert(context);
WSProtocolDecoderSolightTE44* instance = context;
switch(instance->decoder.parser_step) {
case SolightTE44DecoderStepReset:
if((!level) && duration >= ws_protocol_solight_te44_const.te_long) {
instance->decoder.parser_step = SolightTE44DecoderStepSaveDuration;
instance->decoder.decode_data = 0;
instance->decoder.decode_count_bit = 0;
}
break;
case SolightTE44DecoderStepSaveDuration:
if(level) {
instance->decoder.te_last = duration;
instance->decoder.parser_step = SolightTE44DecoderStepCheckDuration;
} else {
instance->decoder.parser_step = SolightTE44DecoderStepReset;
}
break;
case SolightTE44DecoderStepCheckDuration:
if(!level) {
if(DURATION_DIFF(duration, ws_protocol_solight_te44_const.te_short) <
ws_protocol_solight_te44_const.te_delta) {
if(instance->decoder.decode_count_bit ==
ws_protocol_solight_te44_const.min_count_bit_for_found &&
ws_protocol_solight_te44_check(instance)) {
instance->generic.data = instance->decoder.decode_data;
instance->generic.data_count_bit = instance->decoder.decode_count_bit;
ws_protocol_solight_te44_extract_data(&instance->generic);
if(instance->base.callback) {
instance->base.callback(&instance->base, instance->base.context);
}
}
instance->decoder.decode_data = 0;
instance->decoder.decode_count_bit = 0;
instance->decoder.parser_step = SolightTE44DecoderStepReset;
} else if(
DURATION_DIFF(instance->decoder.te_last, ws_protocol_solight_te44_const.te_short) <
ws_protocol_solight_te44_const.te_delta) {
if(DURATION_DIFF(duration, ws_protocol_solight_te44_const.te_short * 2) <
ws_protocol_solight_te44_const.te_delta) {
subghz_protocol_blocks_add_bit(&instance->decoder, 0);
instance->decoder.parser_step = SolightTE44DecoderStepSaveDuration;
} else if(
DURATION_DIFF(duration, ws_protocol_solight_te44_const.te_short * 4) <
ws_protocol_solight_te44_const.te_delta) {
subghz_protocol_blocks_add_bit(&instance->decoder, 1);
instance->decoder.parser_step = SolightTE44DecoderStepSaveDuration;
} else
instance->decoder.parser_step = SolightTE44DecoderStepReset;
} else
instance->decoder.parser_step = SolightTE44DecoderStepReset;
} else
instance->decoder.parser_step = SolightTE44DecoderStepReset;
break;
}
}
uint32_t ws_protocol_decoder_solight_te44_get_hash_data(void* context) {
furi_assert(context);
WSProtocolDecoderSolightTE44* instance = context;
return subghz_protocol_blocks_get_hash_data_long(
&instance->decoder, (instance->decoder.decode_count_bit / 8) + 1);
}
SubGhzProtocolStatus ws_protocol_decoder_solight_te44_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzRadioPreset* preset) {
furi_assert(context);
WSProtocolDecoderSolightTE44* instance = context;
return ws_block_generic_serialize(&instance->generic, flipper_format, preset);
}
SubGhzProtocolStatus
ws_protocol_decoder_solight_te44_deserialize(void* context, FlipperFormat* flipper_format) {
furi_assert(context);
WSProtocolDecoderSolightTE44* instance = context;
return ws_block_generic_deserialize_check_count_bit(
&instance->generic,
flipper_format,
ws_protocol_solight_te44_const.min_count_bit_for_found);
}
void ws_protocol_decoder_solight_te44_get_string(void* context, FuriString* output) {
furi_assert(context);
WSProtocolDecoderSolightTE44* instance = context;
ws_block_generic_get_string(&instance->generic, output);
}

View File

@@ -0,0 +1,80 @@
#pragma once
#include <lib/subghz/protocols/base.h>
#include <lib/subghz/blocks/const.h>
#include <lib/subghz/blocks/decoder.h>
#include <lib/subghz/blocks/encoder.h>
#include "ws_generic.h"
#include <lib/subghz/blocks/math.h>
#define WS_PROTOCOL_SOLIGHT_TE44_NAME "Solight TE44"
typedef struct WSProtocolDecoderSolightTE44 WSProtocolDecoderSolightTE44;
typedef struct WSProtocolEncoderSolightTE44 WSProtocolEncoderSolightTE44;
extern const SubGhzProtocolDecoder ws_protocol_solight_te44_decoder;
extern const SubGhzProtocolEncoder ws_protocol_solight_te44_encoder;
extern const SubGhzProtocol ws_protocol_solight_te44;
/**
* Allocate WSProtocolDecoderSolightTE44.
* @param environment Pointer to a SubGhzEnvironment instance
* @return WSProtocolDecoderSolightTE44* pointer to a WSProtocolDecoderSolightTE44 instance
*/
void* ws_protocol_decoder_solight_te44_alloc(SubGhzEnvironment* environment);
/**
* Free WSProtocolDecoderSolightTE44.
* @param context Pointer to a WSProtocolDecoderSolightTE44 instance
*/
void ws_protocol_decoder_solight_te44_free(void* context);
/**
* Reset decoder WSProtocolDecoderSolightTE44.
* @param context Pointer to a WSProtocolDecoderSolightTE44 instance
*/
void ws_protocol_decoder_solight_te44_reset(void* context);
/**
* Parse a raw sequence of levels and durations received from the air.
* @param context Pointer to a WSProtocolDecoderSolightTE44 instance
* @param level Signal level true-high false-low
* @param duration Duration of this level in, us
*/
void ws_protocol_decoder_solight_te44_feed(void* context, bool level, uint32_t duration);
/**
* Getting the hash sum of the last randomly received parcel.
* @param context Pointer to a WSProtocolDecoderSolightTE44 instance
* @return hash Hash sum
*/
uint32_t ws_protocol_decoder_solight_te44_get_hash_data(void* context);
/**
* Serialize data WSProtocolDecoderSolightTE44.
* @param context Pointer to a WSProtocolDecoderSolightTE44 instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return status
*/
SubGhzProtocolStatus ws_protocol_decoder_solight_te44_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzRadioPreset* preset);
/**
* Deserialize data WSProtocolDecoderSolightTE44.
* @param context Pointer to a WSProtocolDecoderSolightTE44 instance
* @param flipper_format Pointer to a FlipperFormat instance
* @return status
*/
SubGhzProtocolStatus
ws_protocol_decoder_solight_te44_deserialize(void* context, FlipperFormat* flipper_format);
/**
* Getting a textual representation of the received data.
* @param context Pointer to a WSProtocolDecoderSolightTE44 instance
* @param output Resulting text
*/
void ws_protocol_decoder_solight_te44_get_string(void* context, FuriString* output);