[FL-3106] SubGhz: better and more verbose error handling in protocols, stricter CAME validation (#2443)

* SubGhz: add error protocol
* WS: add error protocol
* SubGhz: error processing
* SubGhz: more stringent CAME protocol restrictions
* SubGhz: fix header duration CAME protocol
* SubGhz: delete comments
* SubGhz: sync SubGhzProtocolStatus with FuriStatus
* SubGhz: update documentation and bump api_version

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
Skorpionm
2023-03-03 19:09:13 +04:00
committed by GitHub
parent 6cc5119c64
commit 72ca6b25e9
130 changed files with 1455 additions and 1507 deletions
@@ -3,7 +3,7 @@
#include <furi.h>
#include <furi_hal.h>
#define WS_VERSION_APP "0.7"
#define WS_VERSION_APP "0.8"
#define WS_DEVELOPED "SkorP"
#define WS_GITHUB "https://github.com/flipperdevices/flipperzero-firmware"
@@ -258,7 +258,7 @@ uint8_t ws_protocol_decoder_acurite_592txr_get_hash_data(void* context) {
&instance->decoder, (instance->decoder.decode_count_bit / 8) + 1);
}
bool ws_protocol_decoder_acurite_592txr_serialize(
SubGhzProtocolStatus ws_protocol_decoder_acurite_592txr_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzRadioPreset* preset) {
@@ -267,22 +267,14 @@ bool ws_protocol_decoder_acurite_592txr_serialize(
return ws_block_generic_serialize(&instance->generic, flipper_format, preset);
}
bool ws_protocol_decoder_acurite_592txr_deserialize(void* context, FlipperFormat* flipper_format) {
SubGhzProtocolStatus
ws_protocol_decoder_acurite_592txr_deserialize(void* context, FlipperFormat* flipper_format) {
furi_assert(context);
WSProtocolDecoderAcurite_592TXR* instance = context;
bool ret = false;
do {
if(!ws_block_generic_deserialize(&instance->generic, flipper_format)) {
break;
}
if(instance->generic.data_count_bit !=
ws_protocol_acurite_592txr_const.min_count_bit_for_found) {
FURI_LOG_E(TAG, "Wrong number of bits in key");
break;
}
ret = true;
} while(false);
return ret;
return ws_block_generic_deserialize_check_count_bit(
&instance->generic,
flipper_format,
ws_protocol_acurite_592txr_const.min_count_bit_for_found);
}
void ws_protocol_decoder_acurite_592txr_get_string(void* context, FuriString* output) {
@@ -56,9 +56,9 @@ uint8_t ws_protocol_decoder_acurite_592txr_get_hash_data(void* context);
* @param context Pointer to a WSProtocolDecoderAcurite_592TXR instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
* @return status
*/
bool ws_protocol_decoder_acurite_592txr_serialize(
SubGhzProtocolStatus ws_protocol_decoder_acurite_592txr_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzRadioPreset* preset);
@@ -67,9 +67,10 @@ bool ws_protocol_decoder_acurite_592txr_serialize(
* Deserialize data WSProtocolDecoderAcurite_592TXR.
* @param context Pointer to a WSProtocolDecoderAcurite_592TXR instance
* @param flipper_format Pointer to a FlipperFormat instance
* @return true On success
* @return status
*/
bool ws_protocol_decoder_acurite_592txr_deserialize(void* context, FlipperFormat* flipper_format);
SubGhzProtocolStatus
ws_protocol_decoder_acurite_592txr_deserialize(void* context, FlipperFormat* flipper_format);
/**
* Getting a textual representation of the received data.
@@ -199,7 +199,7 @@ uint8_t ws_protocol_decoder_acurite_606tx_get_hash_data(void* context) {
&instance->decoder, (instance->decoder.decode_count_bit / 8) + 1);
}
bool ws_protocol_decoder_acurite_606tx_serialize(
SubGhzProtocolStatus ws_protocol_decoder_acurite_606tx_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzRadioPreset* preset) {
@@ -208,22 +208,14 @@ bool ws_protocol_decoder_acurite_606tx_serialize(
return ws_block_generic_serialize(&instance->generic, flipper_format, preset);
}
bool ws_protocol_decoder_acurite_606tx_deserialize(void* context, FlipperFormat* flipper_format) {
SubGhzProtocolStatus
ws_protocol_decoder_acurite_606tx_deserialize(void* context, FlipperFormat* flipper_format) {
furi_assert(context);
WSProtocolDecoderAcurite_606TX* instance = context;
bool ret = false;
do {
if(!ws_block_generic_deserialize(&instance->generic, flipper_format)) {
break;
}
if(instance->generic.data_count_bit !=
ws_protocol_acurite_606tx_const.min_count_bit_for_found) {
FURI_LOG_E(TAG, "Wrong number of bits in key");
break;
}
ret = true;
} while(false);
return ret;
return ws_block_generic_deserialize_check_count_bit(
&instance->generic,
flipper_format,
ws_protocol_acurite_606tx_const.min_count_bit_for_found);
}
void ws_protocol_decoder_acurite_606tx_get_string(void* context, FuriString* output) {
@@ -56,9 +56,9 @@ uint8_t ws_protocol_decoder_acurite_606tx_get_hash_data(void* context);
* @param context Pointer to a WSProtocolDecoderAcurite_606TX instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
* @return status
*/
bool ws_protocol_decoder_acurite_606tx_serialize(
SubGhzProtocolStatus ws_protocol_decoder_acurite_606tx_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzRadioPreset* preset);
@@ -67,9 +67,10 @@ bool ws_protocol_decoder_acurite_606tx_serialize(
* Deserialize data WSProtocolDecoderAcurite_606TX.
* @param context Pointer to a WSProtocolDecoderAcurite_606TX instance
* @param flipper_format Pointer to a FlipperFormat instance
* @return true On success
* @return status
*/
bool ws_protocol_decoder_acurite_606tx_deserialize(void* context, FlipperFormat* flipper_format);
SubGhzProtocolStatus
ws_protocol_decoder_acurite_606tx_deserialize(void* context, FlipperFormat* flipper_format);
/**
* Getting a textual representation of the received data.
@@ -199,7 +199,7 @@ uint8_t ws_protocol_decoder_acurite_609txc_get_hash_data(void* context) {
&instance->decoder, (instance->decoder.decode_count_bit / 8) + 1);
}
bool ws_protocol_decoder_acurite_609txc_serialize(
SubGhzProtocolStatus ws_protocol_decoder_acurite_609txc_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzRadioPreset* preset) {
@@ -208,22 +208,14 @@ bool ws_protocol_decoder_acurite_609txc_serialize(
return ws_block_generic_serialize(&instance->generic, flipper_format, preset);
}
bool ws_protocol_decoder_acurite_609txc_deserialize(void* context, FlipperFormat* flipper_format) {
SubGhzProtocolStatus
ws_protocol_decoder_acurite_609txc_deserialize(void* context, FlipperFormat* flipper_format) {
furi_assert(context);
WSProtocolDecoderAcurite_609TXC* instance = context;
bool ret = false;
do {
if(!ws_block_generic_deserialize(&instance->generic, flipper_format)) {
break;
}
if(instance->generic.data_count_bit !=
ws_protocol_acurite_609txc_const.min_count_bit_for_found) {
FURI_LOG_E(TAG, "Wrong number of bits in key");
break;
}
ret = true;
} while(false);
return ret;
return ws_block_generic_deserialize_check_count_bit(
&instance->generic,
flipper_format,
ws_protocol_acurite_609txc_const.min_count_bit_for_found);
}
void ws_protocol_decoder_acurite_609txc_get_string(void* context, FuriString* output) {
@@ -56,9 +56,9 @@ uint8_t ws_protocol_decoder_acurite_609txc_get_hash_data(void* context);
* @param context Pointer to a WSProtocolDecoderAcurite_609TXC instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
* @return status
*/
bool ws_protocol_decoder_acurite_609txc_serialize(
SubGhzProtocolStatus ws_protocol_decoder_acurite_609txc_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzRadioPreset* preset);
@@ -67,9 +67,10 @@ bool ws_protocol_decoder_acurite_609txc_serialize(
* Deserialize data WSProtocolDecoderAcurite_609TXC.
* @param context Pointer to a WSProtocolDecoderAcurite_609TXC instance
* @param flipper_format Pointer to a FlipperFormat instance
* @return true On success
* @return status
*/
bool ws_protocol_decoder_acurite_609txc_deserialize(void* context, FlipperFormat* flipper_format);
SubGhzProtocolStatus
ws_protocol_decoder_acurite_609txc_deserialize(void* context, FlipperFormat* flipper_format);
/**
* Getting a textual representation of the received data.
@@ -228,7 +228,7 @@ uint8_t ws_protocol_decoder_ambient_weather_get_hash_data(void* context) {
&instance->decoder, (instance->decoder.decode_count_bit / 8) + 1);
}
bool ws_protocol_decoder_ambient_weather_serialize(
SubGhzProtocolStatus ws_protocol_decoder_ambient_weather_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzRadioPreset* preset) {
@@ -237,22 +237,14 @@ bool ws_protocol_decoder_ambient_weather_serialize(
return ws_block_generic_serialize(&instance->generic, flipper_format, preset);
}
bool ws_protocol_decoder_ambient_weather_deserialize(void* context, FlipperFormat* flipper_format) {
SubGhzProtocolStatus
ws_protocol_decoder_ambient_weather_deserialize(void* context, FlipperFormat* flipper_format) {
furi_assert(context);
WSProtocolDecoderAmbient_Weather* instance = context;
bool ret = false;
do {
if(!ws_block_generic_deserialize(&instance->generic, flipper_format)) {
break;
}
if(instance->generic.data_count_bit !=
ws_protocol_ambient_weather_const.min_count_bit_for_found) {
FURI_LOG_E(TAG, "Wrong number of bits in key");
break;
}
ret = true;
} while(false);
return ret;
return ws_block_generic_deserialize_check_count_bit(
&instance->generic,
flipper_format,
ws_protocol_ambient_weather_const.min_count_bit_for_found);
}
void ws_protocol_decoder_ambient_weather_get_string(void* context, FuriString* output) {
@@ -56,9 +56,9 @@ uint8_t ws_protocol_decoder_ambient_weather_get_hash_data(void* context);
* @param context Pointer to a WSProtocolDecoderAmbient_Weather instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
* @return status
*/
bool ws_protocol_decoder_ambient_weather_serialize(
SubGhzProtocolStatus ws_protocol_decoder_ambient_weather_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzRadioPreset* preset);
@@ -67,9 +67,10 @@ bool ws_protocol_decoder_ambient_weather_serialize(
* Deserialize data WSProtocolDecoderAmbient_Weather.
* @param context Pointer to a WSProtocolDecoderAmbient_Weather instance
* @param flipper_format Pointer to a FlipperFormat instance
* @return true On success
* @return status
*/
bool ws_protocol_decoder_ambient_weather_deserialize(void* context, FlipperFormat* flipper_format);
SubGhzProtocolStatus
ws_protocol_decoder_ambient_weather_deserialize(void* context, FlipperFormat* flipper_format);
/**
* Getting a textual representation of the received data.
@@ -210,7 +210,7 @@ uint8_t ws_protocol_decoder_auriol_th_get_hash_data(void* context) {
&instance->decoder, (instance->decoder.decode_count_bit / 8) + 1);
}
bool ws_protocol_decoder_auriol_th_serialize(
SubGhzProtocolStatus ws_protocol_decoder_auriol_th_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzRadioPreset* preset) {
@@ -219,22 +219,12 @@ bool ws_protocol_decoder_auriol_th_serialize(
return ws_block_generic_serialize(&instance->generic, flipper_format, preset);
}
bool ws_protocol_decoder_auriol_th_deserialize(void* context, FlipperFormat* flipper_format) {
SubGhzProtocolStatus
ws_protocol_decoder_auriol_th_deserialize(void* context, FlipperFormat* flipper_format) {
furi_assert(context);
WSProtocolDecoderAuriol_TH* instance = context;
bool ret = false;
do {
if(!ws_block_generic_deserialize(&instance->generic, flipper_format)) {
break;
}
if(instance->generic.data_count_bit !=
ws_protocol_auriol_th_const.min_count_bit_for_found) {
FURI_LOG_E(TAG, "Wrong number of bits in key");
break;
}
ret = true;
} while(false);
return ret;
return ws_block_generic_deserialize_check_count_bit(
&instance->generic, flipper_format, ws_protocol_auriol_th_const.min_count_bit_for_found);
}
void ws_protocol_decoder_auriol_th_get_string(void* context, FuriString* output) {
@@ -56,9 +56,9 @@ uint8_t ws_protocol_decoder_auriol_th_get_hash_data(void* context);
* @param context Pointer to a WSProtocolDecoderAuriol_TH instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
* @return status
*/
bool ws_protocol_decoder_auriol_th_serialize(
SubGhzProtocolStatus ws_protocol_decoder_auriol_th_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzRadioPreset* preset);
@@ -67,9 +67,10 @@ bool ws_protocol_decoder_auriol_th_serialize(
* Deserialize data WSProtocolDecoderAuriol_TH.
* @param context Pointer to a WSProtocolDecoderAuriol_TH instance
* @param flipper_format Pointer to a FlipperFormat instance
* @return true On success
* @return status
*/
bool ws_protocol_decoder_auriol_th_deserialize(void* context, FlipperFormat* flipper_format);
SubGhzProtocolStatus
ws_protocol_decoder_auriol_th_deserialize(void* context, FlipperFormat* flipper_format);
/**
* Getting a textual representation of the received data.
@@ -217,7 +217,7 @@ uint8_t ws_protocol_decoder_gt_wt_02_get_hash_data(void* context) {
&instance->decoder, (instance->decoder.decode_count_bit / 8) + 1);
}
bool ws_protocol_decoder_gt_wt_02_serialize(
SubGhzProtocolStatus ws_protocol_decoder_gt_wt_02_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzRadioPreset* preset) {
@@ -226,22 +226,12 @@ bool ws_protocol_decoder_gt_wt_02_serialize(
return ws_block_generic_serialize(&instance->generic, flipper_format, preset);
}
bool ws_protocol_decoder_gt_wt_02_deserialize(void* context, FlipperFormat* flipper_format) {
SubGhzProtocolStatus
ws_protocol_decoder_gt_wt_02_deserialize(void* context, FlipperFormat* flipper_format) {
furi_assert(context);
WSProtocolDecoderGT_WT02* instance = context;
bool ret = false;
do {
if(!ws_block_generic_deserialize(&instance->generic, flipper_format)) {
break;
}
if(instance->generic.data_count_bit !=
ws_protocol_gt_wt_02_const.min_count_bit_for_found) {
FURI_LOG_E(TAG, "Wrong number of bits in key");
break;
}
ret = true;
} while(false);
return ret;
return ws_block_generic_deserialize_check_count_bit(
&instance->generic, flipper_format, ws_protocol_gt_wt_02_const.min_count_bit_for_found);
}
void ws_protocol_decoder_gt_wt_02_get_string(void* context, FuriString* output) {
@@ -56,9 +56,9 @@ uint8_t ws_protocol_decoder_gt_wt_02_get_hash_data(void* context);
* @param context Pointer to a WSProtocolDecoderGT_WT02 instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
* @return status
*/
bool ws_protocol_decoder_gt_wt_02_serialize(
SubGhzProtocolStatus ws_protocol_decoder_gt_wt_02_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzRadioPreset* preset);
@@ -67,9 +67,10 @@ bool ws_protocol_decoder_gt_wt_02_serialize(
* Deserialize data WSProtocolDecoderGT_WT02.
* @param context Pointer to a WSProtocolDecoderGT_WT02 instance
* @param flipper_format Pointer to a FlipperFormat instance
* @return true On success
* @return status
*/
bool ws_protocol_decoder_gt_wt_02_deserialize(void* context, FlipperFormat* flipper_format);
SubGhzProtocolStatus
ws_protocol_decoder_gt_wt_02_deserialize(void* context, FlipperFormat* flipper_format);
/**
* Getting a textual representation of the received data.
@@ -292,7 +292,7 @@ uint8_t ws_protocol_decoder_gt_wt_03_get_hash_data(void* context) {
&instance->decoder, (instance->decoder.decode_count_bit / 8) + 1);
}
bool ws_protocol_decoder_gt_wt_03_serialize(
SubGhzProtocolStatus ws_protocol_decoder_gt_wt_03_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzRadioPreset* preset) {
@@ -301,22 +301,12 @@ bool ws_protocol_decoder_gt_wt_03_serialize(
return ws_block_generic_serialize(&instance->generic, flipper_format, preset);
}
bool ws_protocol_decoder_gt_wt_03_deserialize(void* context, FlipperFormat* flipper_format) {
SubGhzProtocolStatus
ws_protocol_decoder_gt_wt_03_deserialize(void* context, FlipperFormat* flipper_format) {
furi_assert(context);
WSProtocolDecoderGT_WT03* instance = context;
bool ret = false;
do {
if(!ws_block_generic_deserialize(&instance->generic, flipper_format)) {
break;
}
if(instance->generic.data_count_bit !=
ws_protocol_gt_wt_03_const.min_count_bit_for_found) {
FURI_LOG_E(TAG, "Wrong number of bits in key");
break;
}
ret = true;
} while(false);
return ret;
return ws_block_generic_deserialize_check_count_bit(
&instance->generic, flipper_format, ws_protocol_gt_wt_03_const.min_count_bit_for_found);
}
void ws_protocol_decoder_gt_wt_03_get_string(void* context, FuriString* output) {
@@ -56,9 +56,9 @@ uint8_t ws_protocol_decoder_gt_wt_03_get_hash_data(void* context);
* @param context Pointer to a WSProtocolDecoderGT_WT03 instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
* @return status
*/
bool ws_protocol_decoder_gt_wt_03_serialize(
SubGhzProtocolStatus ws_protocol_decoder_gt_wt_03_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzRadioPreset* preset);
@@ -67,9 +67,10 @@ bool ws_protocol_decoder_gt_wt_03_serialize(
* Deserialize data WSProtocolDecoderGT_WT03.
* @param context Pointer to a WSProtocolDecoderGT_WT03 instance
* @param flipper_format Pointer to a FlipperFormat instance
* @return true On success
* @return status
*/
bool ws_protocol_decoder_gt_wt_03_deserialize(void* context, FlipperFormat* flipper_format);
SubGhzProtocolStatus
ws_protocol_decoder_gt_wt_03_deserialize(void* context, FlipperFormat* flipper_format);
/**
* Getting a textual representation of the received data.
@@ -248,7 +248,7 @@ uint8_t ws_protocol_decoder_infactory_get_hash_data(void* context) {
&instance->decoder, (instance->decoder.decode_count_bit / 8) + 1);
}
bool ws_protocol_decoder_infactory_serialize(
SubGhzProtocolStatus ws_protocol_decoder_infactory_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzRadioPreset* preset) {
@@ -257,22 +257,12 @@ bool ws_protocol_decoder_infactory_serialize(
return ws_block_generic_serialize(&instance->generic, flipper_format, preset);
}
bool ws_protocol_decoder_infactory_deserialize(void* context, FlipperFormat* flipper_format) {
SubGhzProtocolStatus
ws_protocol_decoder_infactory_deserialize(void* context, FlipperFormat* flipper_format) {
furi_assert(context);
WSProtocolDecoderInfactory* instance = context;
bool ret = false;
do {
if(!ws_block_generic_deserialize(&instance->generic, flipper_format)) {
break;
}
if(instance->generic.data_count_bit !=
ws_protocol_infactory_const.min_count_bit_for_found) {
FURI_LOG_E(TAG, "Wrong number of bits in key");
break;
}
ret = true;
} while(false);
return ret;
return ws_block_generic_deserialize_check_count_bit(
&instance->generic, flipper_format, ws_protocol_infactory_const.min_count_bit_for_found);
}
void ws_protocol_decoder_infactory_get_string(void* context, FuriString* output) {
@@ -56,9 +56,9 @@ uint8_t ws_protocol_decoder_infactory_get_hash_data(void* context);
* @param context Pointer to a WSProtocolDecoderInfactory instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
* @return status
*/
bool ws_protocol_decoder_infactory_serialize(
SubGhzProtocolStatus ws_protocol_decoder_infactory_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzRadioPreset* preset);
@@ -67,9 +67,10 @@ bool ws_protocol_decoder_infactory_serialize(
* Deserialize data WSProtocolDecoderInfactory.
* @param context Pointer to a WSProtocolDecoderInfactory instance
* @param flipper_format Pointer to a FlipperFormat instance
* @return true On success
* @return status
*/
bool ws_protocol_decoder_infactory_deserialize(void* context, FlipperFormat* flipper_format);
SubGhzProtocolStatus
ws_protocol_decoder_infactory_deserialize(void* context, FlipperFormat* flipper_format);
/**
* Getting a textual representation of the received data.
@@ -281,7 +281,7 @@ uint8_t ws_protocol_decoder_lacrosse_tx_get_hash_data(void* context) {
&instance->decoder, (instance->decoder.decode_count_bit / 8) + 1);
}
bool ws_protocol_decoder_lacrosse_tx_serialize(
SubGhzProtocolStatus ws_protocol_decoder_lacrosse_tx_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzRadioPreset* preset) {
@@ -290,22 +290,12 @@ bool ws_protocol_decoder_lacrosse_tx_serialize(
return ws_block_generic_serialize(&instance->generic, flipper_format, preset);
}
bool ws_protocol_decoder_lacrosse_tx_deserialize(void* context, FlipperFormat* flipper_format) {
SubGhzProtocolStatus
ws_protocol_decoder_lacrosse_tx_deserialize(void* context, FlipperFormat* flipper_format) {
furi_assert(context);
WSProtocolDecoderLaCrosse_TX* instance = context;
bool ret = false;
do {
if(!ws_block_generic_deserialize(&instance->generic, flipper_format)) {
break;
}
if(instance->generic.data_count_bit !=
ws_protocol_lacrosse_tx_const.min_count_bit_for_found) {
FURI_LOG_E(TAG, "Wrong number of bits in key");
break;
}
ret = true;
} while(false);
return ret;
return ws_block_generic_deserialize_check_count_bit(
&instance->generic, flipper_format, ws_protocol_lacrosse_tx_const.min_count_bit_for_found);
}
void ws_protocol_decoder_lacrosse_tx_get_string(void* context, FuriString* output) {
@@ -56,9 +56,9 @@ uint8_t ws_protocol_decoder_lacrosse_tx_get_hash_data(void* context);
* @param context Pointer to a WSProtocolDecoderLaCrosse_TX instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
* @return status
*/
bool ws_protocol_decoder_lacrosse_tx_serialize(
SubGhzProtocolStatus ws_protocol_decoder_lacrosse_tx_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzRadioPreset* preset);
@@ -67,9 +67,10 @@ bool ws_protocol_decoder_lacrosse_tx_serialize(
* Deserialize data WSProtocolDecoderLaCrosse_TX.
* @param context Pointer to a WSProtocolDecoderLaCrosse_TX instance
* @param flipper_format Pointer to a FlipperFormat instance
* @return true On success
* @return status
*/
bool ws_protocol_decoder_lacrosse_tx_deserialize(void* context, FlipperFormat* flipper_format);
SubGhzProtocolStatus
ws_protocol_decoder_lacrosse_tx_deserialize(void* context, FlipperFormat* flipper_format);
/**
* Getting a textual representation of the received data.
@@ -247,7 +247,7 @@ uint8_t ws_protocol_decoder_lacrosse_tx141thbv2_get_hash_data(void* context) {
&instance->decoder, (instance->decoder.decode_count_bit / 8) + 1);
}
bool ws_protocol_decoder_lacrosse_tx141thbv2_serialize(
SubGhzProtocolStatus ws_protocol_decoder_lacrosse_tx141thbv2_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzRadioPreset* preset) {
@@ -256,24 +256,15 @@ bool ws_protocol_decoder_lacrosse_tx141thbv2_serialize(
return ws_block_generic_serialize(&instance->generic, flipper_format, preset);
}
bool ws_protocol_decoder_lacrosse_tx141thbv2_deserialize(
SubGhzProtocolStatus ws_protocol_decoder_lacrosse_tx141thbv2_deserialize(
void* context,
FlipperFormat* flipper_format) {
furi_assert(context);
WSProtocolDecoderLaCrosse_TX141THBv2* instance = context;
bool ret = false;
do {
if(!ws_block_generic_deserialize(&instance->generic, flipper_format)) {
break;
}
if(instance->generic.data_count_bit !=
ws_protocol_lacrosse_tx141thbv2_const.min_count_bit_for_found) {
FURI_LOG_E(TAG, "Wrong number of bits in key");
break;
}
ret = true;
} while(false);
return ret;
return ws_block_generic_deserialize_check_count_bit(
&instance->generic,
flipper_format,
ws_protocol_lacrosse_tx141thbv2_const.min_count_bit_for_found);
}
void ws_protocol_decoder_lacrosse_tx141thbv2_get_string(void* context, FuriString* output) {
@@ -56,9 +56,9 @@ uint8_t ws_protocol_decoder_lacrosse_tx141thbv2_get_hash_data(void* context);
* @param context Pointer to a WSProtocolDecoderLaCrosse_TX141THBv2 instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
* @return status
*/
bool ws_protocol_decoder_lacrosse_tx141thbv2_serialize(
SubGhzProtocolStatus ws_protocol_decoder_lacrosse_tx141thbv2_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzRadioPreset* preset);
@@ -67,9 +67,9 @@ bool ws_protocol_decoder_lacrosse_tx141thbv2_serialize(
* Deserialize data WSProtocolDecoderLaCrosse_TX141THBv2.
* @param context Pointer to a WSProtocolDecoderLaCrosse_TX141THBv2 instance
* @param flipper_format Pointer to a FlipperFormat instance
* @return true On success
* @return status
*/
bool ws_protocol_decoder_lacrosse_tx141thbv2_deserialize(
SubGhzProtocolStatus ws_protocol_decoder_lacrosse_tx141thbv2_deserialize(
void* context,
FlipperFormat* flipper_format);
@@ -216,7 +216,7 @@ uint8_t ws_protocol_decoder_nexus_th_get_hash_data(void* context) {
&instance->decoder, (instance->decoder.decode_count_bit / 8) + 1);
}
bool ws_protocol_decoder_nexus_th_serialize(
SubGhzProtocolStatus ws_protocol_decoder_nexus_th_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzRadioPreset* preset) {
@@ -225,22 +225,12 @@ bool ws_protocol_decoder_nexus_th_serialize(
return ws_block_generic_serialize(&instance->generic, flipper_format, preset);
}
bool ws_protocol_decoder_nexus_th_deserialize(void* context, FlipperFormat* flipper_format) {
SubGhzProtocolStatus
ws_protocol_decoder_nexus_th_deserialize(void* context, FlipperFormat* flipper_format) {
furi_assert(context);
WSProtocolDecoderNexus_TH* instance = context;
bool ret = false;
do {
if(!ws_block_generic_deserialize(&instance->generic, flipper_format)) {
break;
}
if(instance->generic.data_count_bit !=
ws_protocol_nexus_th_const.min_count_bit_for_found) {
FURI_LOG_E(TAG, "Wrong number of bits in key");
break;
}
ret = true;
} while(false);
return ret;
return ws_block_generic_deserialize_check_count_bit(
&instance->generic, flipper_format, ws_protocol_nexus_th_const.min_count_bit_for_found);
}
void ws_protocol_decoder_nexus_th_get_string(void* context, FuriString* output) {
@@ -56,9 +56,9 @@ uint8_t ws_protocol_decoder_nexus_th_get_hash_data(void* context);
* @param context Pointer to a WSProtocolDecoderNexus_TH instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
* @return status
*/
bool ws_protocol_decoder_nexus_th_serialize(
SubGhzProtocolStatus ws_protocol_decoder_nexus_th_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzRadioPreset* preset);
@@ -67,9 +67,10 @@ bool ws_protocol_decoder_nexus_th_serialize(
* Deserialize data WSProtocolDecoderNexus_TH.
* @param context Pointer to a WSProtocolDecoderNexus_TH instance
* @param flipper_format Pointer to a FlipperFormat instance
* @return true On success
* @return status
*/
bool ws_protocol_decoder_nexus_th_deserialize(void* context, FlipperFormat* flipper_format);
SubGhzProtocolStatus
ws_protocol_decoder_nexus_th_deserialize(void* context, FlipperFormat* flipper_format);
/**
* Getting a textual representation of the received data.
@@ -302,17 +302,19 @@ uint8_t ws_protocol_decoder_oregon2_get_hash_data(void* context) {
&instance->decoder, (instance->decoder.decode_count_bit / 8) + 1);
}
bool ws_protocol_decoder_oregon2_serialize(
SubGhzProtocolStatus ws_protocol_decoder_oregon2_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzRadioPreset* preset) {
furi_assert(context);
WSProtocolDecoderOregon2* instance = context;
if(!ws_block_generic_serialize(&instance->generic, flipper_format, preset)) return false;
SubGhzProtocolStatus ret = SubGhzProtocolStatusError;
ret = ws_block_generic_serialize(&instance->generic, flipper_format, preset);
if(ret != SubGhzProtocolStatusOk) return ret;
uint32_t temp = instance->var_bits;
if(!flipper_format_write_uint32(flipper_format, "VarBits", &temp, 1)) {
FURI_LOG_E(TAG, "Error adding VarBits");
return false;
return SubGhzProtocolStatusErrorParserOthers;
}
if(!flipper_format_write_hex(
flipper_format,
@@ -320,22 +322,25 @@ bool ws_protocol_decoder_oregon2_serialize(
(const uint8_t*)&instance->var_data,
sizeof(instance->var_data))) {
FURI_LOG_E(TAG, "Error adding VarData");
return false;
return SubGhzProtocolStatusErrorParserOthers;
}
return true;
return ret;
}
bool ws_protocol_decoder_oregon2_deserialize(void* context, FlipperFormat* flipper_format) {
SubGhzProtocolStatus
ws_protocol_decoder_oregon2_deserialize(void* context, FlipperFormat* flipper_format) {
furi_assert(context);
WSProtocolDecoderOregon2* instance = context;
bool ret = false;
uint32_t temp_data;
SubGhzProtocolStatus ret = SubGhzProtocolStatusError;
do {
if(!ws_block_generic_deserialize(&instance->generic, flipper_format)) {
ret = ws_block_generic_deserialize(&instance->generic, flipper_format);
if(ret != SubGhzProtocolStatusOk) {
break;
}
if(!flipper_format_read_uint32(flipper_format, "VarBits", &temp_data, 1)) {
FURI_LOG_E(TAG, "Missing VarLen");
ret = SubGhzProtocolStatusErrorParserOthers;
break;
}
instance->var_bits = (uint8_t)temp_data;
@@ -345,13 +350,14 @@ bool ws_protocol_decoder_oregon2_deserialize(void* context, FlipperFormat* flipp
(uint8_t*)&instance->var_data,
sizeof(instance->var_data))) { //-V1051
FURI_LOG_E(TAG, "Missing VarData");
ret = SubGhzProtocolStatusErrorParserOthers;
break;
}
if(instance->generic.data_count_bit != ws_oregon2_const.min_count_bit_for_found) {
FURI_LOG_E(TAG, "Wrong number of bits in key: %d", instance->generic.data_count_bit);
ret = SubGhzProtocolStatusErrorValueBitCount;
break;
}
ret = true;
} while(false);
return ret;
}
@@ -283,7 +283,7 @@ uint8_t ws_protocol_decoder_oregon_v1_get_hash_data(void* context) {
&instance->decoder, (instance->decoder.decode_count_bit / 8) + 1);
}
bool ws_protocol_decoder_oregon_v1_serialize(
SubGhzProtocolStatus ws_protocol_decoder_oregon_v1_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzRadioPreset* preset) {
@@ -292,22 +292,12 @@ bool ws_protocol_decoder_oregon_v1_serialize(
return ws_block_generic_serialize(&instance->generic, flipper_format, preset);
}
bool ws_protocol_decoder_oregon_v1_deserialize(void* context, FlipperFormat* flipper_format) {
SubGhzProtocolStatus
ws_protocol_decoder_oregon_v1_deserialize(void* context, FlipperFormat* flipper_format) {
furi_assert(context);
WSProtocolDecoderOregon_V1* instance = context;
bool ret = false;
do {
if(!ws_block_generic_deserialize(&instance->generic, flipper_format)) {
break;
}
if(instance->generic.data_count_bit !=
ws_protocol_oregon_v1_const.min_count_bit_for_found) {
FURI_LOG_E(TAG, "Wrong number of bits in key");
break;
}
ret = true;
} while(false);
return ret;
return ws_block_generic_deserialize_check_count_bit(
&instance->generic, flipper_format, ws_protocol_oregon_v1_const.min_count_bit_for_found);
}
void ws_protocol_decoder_oregon_v1_get_string(void* context, FuriString* output) {
@@ -56,9 +56,9 @@ uint8_t ws_protocol_decoder_oregon_v1_get_hash_data(void* context);
* @param context Pointer to a WSProtocolDecoderOregon_V1 instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
* @return status
*/
bool ws_protocol_decoder_oregon_v1_serialize(
SubGhzProtocolStatus ws_protocol_decoder_oregon_v1_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzRadioPreset* preset);
@@ -67,9 +67,10 @@ bool ws_protocol_decoder_oregon_v1_serialize(
* Deserialize data WSProtocolDecoderOregon_V1.
* @param context Pointer to a WSProtocolDecoderOregon_V1 instance
* @param flipper_format Pointer to a FlipperFormat instance
* @return true On success
* @return status
*/
bool ws_protocol_decoder_oregon_v1_deserialize(void* context, FlipperFormat* flipper_format);
SubGhzProtocolStatus
ws_protocol_decoder_oregon_v1_deserialize(void* context, FlipperFormat* flipper_format);
/**
* Getting a textual representation of the received data.
@@ -211,7 +211,7 @@ uint8_t ws_protocol_decoder_thermopro_tx4_get_hash_data(void* context) {
&instance->decoder, (instance->decoder.decode_count_bit / 8) + 1);
}
bool ws_protocol_decoder_thermopro_tx4_serialize(
SubGhzProtocolStatus ws_protocol_decoder_thermopro_tx4_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzRadioPreset* preset) {
@@ -220,22 +220,14 @@ bool ws_protocol_decoder_thermopro_tx4_serialize(
return ws_block_generic_serialize(&instance->generic, flipper_format, preset);
}
bool ws_protocol_decoder_thermopro_tx4_deserialize(void* context, FlipperFormat* flipper_format) {
SubGhzProtocolStatus
ws_protocol_decoder_thermopro_tx4_deserialize(void* context, FlipperFormat* flipper_format) {
furi_assert(context);
WSProtocolDecoderThermoPRO_TX4* instance = context;
bool ret = false;
do {
if(!ws_block_generic_deserialize(&instance->generic, flipper_format)) {
break;
}
if(instance->generic.data_count_bit !=
ws_protocol_thermopro_tx4_const.min_count_bit_for_found) {
FURI_LOG_E(TAG, "Wrong number of bits in key");
break;
}
ret = true;
} while(false);
return ret;
return ws_block_generic_deserialize_check_count_bit(
&instance->generic,
flipper_format,
ws_protocol_thermopro_tx4_const.min_count_bit_for_found);
}
void ws_protocol_decoder_thermopro_tx4_get_string(void* context, FuriString* output) {
@@ -56,9 +56,9 @@ uint8_t ws_protocol_decoder_thermopro_tx4_get_hash_data(void* context);
* @param context Pointer to a WSProtocolDecoderThermoPRO_TX4 instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
* @return status
*/
bool ws_protocol_decoder_thermopro_tx4_serialize(
SubGhzProtocolStatus ws_protocol_decoder_thermopro_tx4_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzRadioPreset* preset);
@@ -67,9 +67,10 @@ bool ws_protocol_decoder_thermopro_tx4_serialize(
* Deserialize data WSProtocolDecoderThermoPRO_TX4.
* @param context Pointer to a WSProtocolDecoderThermoPRO_TX4 instance
* @param flipper_format Pointer to a FlipperFormat instance
* @return true On success
* @return status
*/
bool ws_protocol_decoder_thermopro_tx4_deserialize(void* context, FlipperFormat* flipper_format);
SubGhzProtocolStatus
ws_protocol_decoder_thermopro_tx4_deserialize(void* context, FlipperFormat* flipper_format);
/**
* Getting a textual representation of the received data.
@@ -246,7 +246,7 @@ uint8_t ws_protocol_decoder_tx_8300_get_hash_data(void* context) {
&instance->decoder, (instance->decoder.decode_count_bit / 8) + 1);
}
bool ws_protocol_decoder_tx_8300_serialize(
SubGhzProtocolStatus ws_protocol_decoder_tx_8300_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzRadioPreset* preset) {
@@ -255,21 +255,12 @@ bool ws_protocol_decoder_tx_8300_serialize(
return ws_block_generic_serialize(&instance->generic, flipper_format, preset);
}
bool ws_protocol_decoder_tx_8300_deserialize(void* context, FlipperFormat* flipper_format) {
SubGhzProtocolStatus
ws_protocol_decoder_tx_8300_deserialize(void* context, FlipperFormat* flipper_format) {
furi_assert(context);
WSProtocolDecoderTX_8300* instance = context;
bool ret = false;
do {
if(!ws_block_generic_deserialize(&instance->generic, flipper_format)) {
break;
}
if(instance->generic.data_count_bit != ws_protocol_tx_8300_const.min_count_bit_for_found) {
FURI_LOG_E(TAG, "Wrong number of bits in key");
break;
}
ret = true;
} while(false);
return ret;
return ws_block_generic_deserialize_check_count_bit(
&instance->generic, flipper_format, ws_protocol_tx_8300_const.min_count_bit_for_found);
}
void ws_protocol_decoder_tx_8300_get_string(void* context, FuriString* output) {
@@ -56,9 +56,9 @@ uint8_t ws_protocol_decoder_tx_8300_get_hash_data(void* context);
* @param context Pointer to a WSProtocolDecoderTX_8300 instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
* @return status
*/
bool ws_protocol_decoder_tx_8300_serialize(
SubGhzProtocolStatus ws_protocol_decoder_tx_8300_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzRadioPreset* preset);
@@ -67,9 +67,10 @@ bool ws_protocol_decoder_tx_8300_serialize(
* Deserialize data WSProtocolDecoderTX_8300.
* @param context Pointer to a WSProtocolDecoderTX_8300 instance
* @param flipper_format Pointer to a FlipperFormat instance
* @return true On success
* @return status
*/
bool ws_protocol_decoder_tx_8300_deserialize(void* context, FlipperFormat* flipper_format);
SubGhzProtocolStatus
ws_protocol_decoder_tx_8300_deserialize(void* context, FlipperFormat* flipper_format);
/**
* Getting a textual representation of the received data.
@@ -21,12 +21,12 @@ void ws_block_generic_get_preset_name(const char* preset_name, FuriString* prese
furi_string_set(preset_str, preset_name_temp);
}
bool ws_block_generic_serialize(
SubGhzProtocolStatus ws_block_generic_serialize(
WSBlockGeneric* instance,
FlipperFormat* flipper_format,
SubGhzRadioPreset* preset) {
furi_assert(instance);
bool res = false;
SubGhzProtocolStatus res = SubGhzProtocolStatusError;
FuriString* temp_str;
temp_str = furi_string_alloc();
do {
@@ -34,11 +34,13 @@ bool ws_block_generic_serialize(
if(!flipper_format_write_header_cstr(
flipper_format, WS_KEY_FILE_TYPE, WS_KEY_FILE_VERSION)) {
FURI_LOG_E(TAG, "Unable to add header");
res = SubGhzProtocolStatusErrorParserHeader;
break;
}
if(!flipper_format_write_uint32(flipper_format, "Frequency", &preset->frequency, 1)) {
FURI_LOG_E(TAG, "Unable to add Frequency");
res = SubGhzProtocolStatusErrorParserFrequency;
break;
}
@@ -46,34 +48,40 @@ bool ws_block_generic_serialize(
if(!flipper_format_write_string_cstr(
flipper_format, "Preset", furi_string_get_cstr(temp_str))) {
FURI_LOG_E(TAG, "Unable to add Preset");
res = SubGhzProtocolStatusErrorParserPreset;
break;
}
if(!strcmp(furi_string_get_cstr(temp_str), "FuriHalSubGhzPresetCustom")) {
if(!flipper_format_write_string_cstr(
flipper_format, "Custom_preset_module", "CC1101")) {
FURI_LOG_E(TAG, "Unable to add Custom_preset_module");
res = SubGhzProtocolStatusErrorParserCustomPreset;
break;
}
if(!flipper_format_write_hex(
flipper_format, "Custom_preset_data", preset->data, preset->data_size)) {
FURI_LOG_E(TAG, "Unable to add Custom_preset_data");
res = SubGhzProtocolStatusErrorParserCustomPreset;
break;
}
}
if(!flipper_format_write_string_cstr(flipper_format, "Protocol", instance->protocol_name)) {
FURI_LOG_E(TAG, "Unable to add Protocol");
res = SubGhzProtocolStatusErrorParserProtocolName;
break;
}
uint32_t temp_data = instance->id;
if(!flipper_format_write_uint32(flipper_format, "Id", &temp_data, 1)) {
FURI_LOG_E(TAG, "Unable to add Id");
res = SubGhzProtocolStatusErrorParserOthers;
break;
}
temp_data = instance->data_count_bit;
if(!flipper_format_write_uint32(flipper_format, "Bit", &temp_data, 1)) {
FURI_LOG_E(TAG, "Unable to add Bit");
res = SubGhzProtocolStatusErrorParserBitCount;
break;
}
@@ -84,18 +92,21 @@ bool ws_block_generic_serialize(
if(!flipper_format_write_hex(flipper_format, "Data", key_data, sizeof(uint64_t))) {
FURI_LOG_E(TAG, "Unable to add Data");
res = SubGhzProtocolStatusErrorParserOthers;
break;
}
temp_data = instance->battery_low;
if(!flipper_format_write_uint32(flipper_format, "Batt", &temp_data, 1)) {
FURI_LOG_E(TAG, "Unable to add Battery_low");
res = SubGhzProtocolStatusErrorParserOthers;
break;
}
temp_data = instance->humidity;
if(!flipper_format_write_uint32(flipper_format, "Hum", &temp_data, 1)) {
FURI_LOG_E(TAG, "Unable to add Humidity");
res = SubGhzProtocolStatusErrorParserOthers;
break;
}
@@ -107,52 +118,60 @@ bool ws_block_generic_serialize(
temp_data = curr_ts;
if(!flipper_format_write_uint32(flipper_format, "Ts", &temp_data, 1)) {
FURI_LOG_E(TAG, "Unable to add timestamp");
res = SubGhzProtocolStatusErrorParserOthers;
break;
}
temp_data = instance->channel;
if(!flipper_format_write_uint32(flipper_format, "Ch", &temp_data, 1)) {
FURI_LOG_E(TAG, "Unable to add Channel");
res = SubGhzProtocolStatusErrorParserOthers;
break;
}
temp_data = instance->btn;
if(!flipper_format_write_uint32(flipper_format, "Btn", &temp_data, 1)) {
FURI_LOG_E(TAG, "Unable to add Btn");
res = SubGhzProtocolStatusErrorParserOthers;
break;
}
float temp = instance->temp;
if(!flipper_format_write_float(flipper_format, "Temp", &temp, 1)) {
FURI_LOG_E(TAG, "Unable to add Temperature");
res = SubGhzProtocolStatusErrorParserOthers;
break;
}
res = true;
res = SubGhzProtocolStatusOk;
} while(false);
furi_string_free(temp_str);
return res;
}
bool ws_block_generic_deserialize(WSBlockGeneric* instance, FlipperFormat* flipper_format) {
SubGhzProtocolStatus
ws_block_generic_deserialize(WSBlockGeneric* instance, FlipperFormat* flipper_format) {
furi_assert(instance);
bool res = false;
SubGhzProtocolStatus res = SubGhzProtocolStatusError;
uint32_t temp_data = 0;
do {
if(!flipper_format_rewind(flipper_format)) {
FURI_LOG_E(TAG, "Rewind error");
res = SubGhzProtocolStatusErrorParserOthers;
break;
}
if(!flipper_format_read_uint32(flipper_format, "Id", (uint32_t*)&temp_data, 1)) {
FURI_LOG_E(TAG, "Missing Id");
res = SubGhzProtocolStatusErrorParserOthers;
break;
}
instance->id = (uint32_t)temp_data;
if(!flipper_format_read_uint32(flipper_format, "Bit", (uint32_t*)&temp_data, 1)) {
FURI_LOG_E(TAG, "Missing Bit");
res = SubGhzProtocolStatusErrorParserBitCount;
break;
}
instance->data_count_bit = (uint8_t)temp_data;
@@ -160,6 +179,7 @@ bool ws_block_generic_deserialize(WSBlockGeneric* instance, FlipperFormat* flipp
uint8_t key_data[sizeof(uint64_t)] = {0};
if(!flipper_format_read_hex(flipper_format, "Data", key_data, sizeof(uint64_t))) {
FURI_LOG_E(TAG, "Missing Data");
res = SubGhzProtocolStatusErrorParserOthers;
break;
}
@@ -169,30 +189,35 @@ bool ws_block_generic_deserialize(WSBlockGeneric* instance, FlipperFormat* flipp
if(!flipper_format_read_uint32(flipper_format, "Batt", (uint32_t*)&temp_data, 1)) {
FURI_LOG_E(TAG, "Missing Battery_low");
res = SubGhzProtocolStatusErrorParserOthers;
break;
}
instance->battery_low = (uint8_t)temp_data;
if(!flipper_format_read_uint32(flipper_format, "Hum", (uint32_t*)&temp_data, 1)) {
FURI_LOG_E(TAG, "Missing Humidity");
res = SubGhzProtocolStatusErrorParserOthers;
break;
}
instance->humidity = (uint8_t)temp_data;
if(!flipper_format_read_uint32(flipper_format, "Ts", (uint32_t*)&temp_data, 1)) {
FURI_LOG_E(TAG, "Missing timestamp");
res = SubGhzProtocolStatusErrorParserOthers;
break;
}
instance->timestamp = (uint32_t)temp_data;
if(!flipper_format_read_uint32(flipper_format, "Ch", (uint32_t*)&temp_data, 1)) {
FURI_LOG_E(TAG, "Missing Channel");
res = SubGhzProtocolStatusErrorParserOthers;
break;
}
instance->channel = (uint8_t)temp_data;
if(!flipper_format_read_uint32(flipper_format, "Btn", (uint32_t*)&temp_data, 1)) {
FURI_LOG_E(TAG, "Missing Btn");
res = SubGhzProtocolStatusErrorParserOthers;
break;
}
instance->btn = (uint8_t)temp_data;
@@ -200,12 +225,32 @@ bool ws_block_generic_deserialize(WSBlockGeneric* instance, FlipperFormat* flipp
float temp;
if(!flipper_format_read_float(flipper_format, "Temp", (float*)&temp, 1)) {
FURI_LOG_E(TAG, "Missing Temperature");
res = SubGhzProtocolStatusErrorParserOthers;
break;
}
instance->temp = temp;
res = true;
res = SubGhzProtocolStatusOk;
} while(0);
return res;
}
SubGhzProtocolStatus ws_block_generic_deserialize_check_count_bit(
WSBlockGeneric* instance,
FlipperFormat* flipper_format,
uint16_t count_bit) {
SubGhzProtocolStatus ret = SubGhzProtocolStatusError;
do {
ret = ws_block_generic_deserialize(instance, flipper_format);
if(ret != SubGhzProtocolStatusOk) {
break;
}
if(instance->data_count_bit != count_bit) {
FURI_LOG_E(TAG, "Wrong number of bits in key");
ret = SubGhzProtocolStatusErrorValueBitCount;
break;
}
} while(false);
return ret;
}
@@ -48,9 +48,9 @@ void ws_block_generic_get_preset_name(const char* preset_name, FuriString* prese
* @param instance Pointer to a WSBlockGeneric instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
* @return status
*/
bool ws_block_generic_serialize(
SubGhzProtocolStatus ws_block_generic_serialize(
WSBlockGeneric* instance,
FlipperFormat* flipper_format,
SubGhzRadioPreset* preset);
@@ -59,9 +59,22 @@ bool ws_block_generic_serialize(
* Deserialize data WSBlockGeneric.
* @param instance Pointer to a WSBlockGeneric instance
* @param flipper_format Pointer to a FlipperFormat instance
* @return true On success
* @return status
*/
bool ws_block_generic_deserialize(WSBlockGeneric* instance, FlipperFormat* flipper_format);
SubGhzProtocolStatus
ws_block_generic_deserialize(WSBlockGeneric* instance, FlipperFormat* flipper_format);
/**
* Deserialize data WSBlockGeneric.
* @param instance Pointer to a WSBlockGeneric instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param count_bit Count bit protocol
* @return status
*/
SubGhzProtocolStatus ws_block_generic_deserialize_check_count_bit(
WSBlockGeneric* instance,
FlipperFormat* flipper_format,
uint16_t count_bit);
#ifdef __cplusplus
}