Skip to content

Commit

Permalink
Replace decoded signal with one decoded by the "unknown" decoder.
Browse files Browse the repository at this point in the history
  • Loading branch information
antirez committed Jan 27, 2023
1 parent 911cb67 commit 79ef4f5
Showing 1 changed file with 45 additions and 37 deletions.
82 changes: 45 additions & 37 deletions signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,44 @@

bool decode_signal(RawSamplesBuffer *s, uint64_t len, ProtoViewMsgInfo *info);

/* =============================================================================
* Protocols table.
*
* Supported protocols go here, with the relevant implementation inside
* protocols/<name>.c
* ===========================================================================*/

extern ProtoViewDecoder Oregon2Decoder;
extern ProtoViewDecoder B4B1Decoder;
extern ProtoViewDecoder RenaultTPMSDecoder;
extern ProtoViewDecoder ToyotaTPMSDecoder;
extern ProtoViewDecoder SchraderTPMSDecoder;
extern ProtoViewDecoder SchraderEG53MA4TPMSDecoder;
extern ProtoViewDecoder CitroenTPMSDecoder;
extern ProtoViewDecoder FordTPMSDecoder;
extern ProtoViewDecoder KeeloqDecoder;
extern ProtoViewDecoder ProtoViewChatDecoder;
extern ProtoViewDecoder UnknownDecoder;

ProtoViewDecoder *Decoders[] = {
&Oregon2Decoder, /* Oregon sensors v2.1 protocol. */
&B4B1Decoder, /* PT, SC, ... 24 bits remotes. */
&RenaultTPMSDecoder, /* Renault TPMS. */
&ToyotaTPMSDecoder, /* Toyota TPMS. */
&SchraderTPMSDecoder, /* Schrader TPMS. */
&SchraderEG53MA4TPMSDecoder, /* Schrader EG53MA4 TPMS. */
&CitroenTPMSDecoder, /* Citroen TPMS. */
&FordTPMSDecoder, /* Ford TPMS. */
&KeeloqDecoder, /* Keeloq remote. */
&ProtoViewChatDecoder, /* Protoview simple text messages. */

/* Warning: the following decoder must stay at the end of the
* list. Otherwise would detect most signals and prevent the actaul
* decoders from handling them. */
&UnknownDecoder, /* General protocol detector. */
NULL
};

/* =============================================================================
* Raw signal detection
* ===========================================================================*/
Expand Down Expand Up @@ -191,8 +229,11 @@ void scan_for_signal(ProtoViewApp *app, RawSamplesBuffer *source, uint32_t min_d
/* Accept this signal as the new signal if either it's longer
* than the previous undecoded one, or the previous one was
* unknown and this is decoded. */
if ((thislen > app->signal_bestlen && app->signal_decoded == false)
|| (app->signal_decoded == false && decoded))
bool current_not_decoded = app->signal_decoded == false ||
app->msg_info->decoder == &UnknownDecoder;

if (current_not_decoded &&
(thislen > app->signal_bestlen || decoded))
{
free_msg_info(app->msg_info);
app->msg_info = info;
Expand All @@ -204,7 +245,8 @@ void scan_for_signal(ProtoViewApp *app, RawSamplesBuffer *source, uint32_t min_d
(int)thislen, DetectedSamples->short_pulse_dur);

adjust_raw_view_scale(app,DetectedSamples->short_pulse_dur);
notify_signal_detected(app,decoded);
if (app->msg_info->decoder != &UnknownDecoder)
notify_signal_detected(app,decoded);
} else {
/* If the structure was not filled, discard it. Otherwise
* now the owner is app->msg_info. */
Expand Down Expand Up @@ -540,40 +582,6 @@ uint32_t convert_from_diff_manchester(uint8_t *buf, uint64_t buflen, uint8_t *bi
return decoded;
}

/* Supported protocols go here, with the relevant implementation inside
* protocols/<name>.c */

extern ProtoViewDecoder Oregon2Decoder;
extern ProtoViewDecoder B4B1Decoder;
extern ProtoViewDecoder RenaultTPMSDecoder;
extern ProtoViewDecoder ToyotaTPMSDecoder;
extern ProtoViewDecoder SchraderTPMSDecoder;
extern ProtoViewDecoder SchraderEG53MA4TPMSDecoder;
extern ProtoViewDecoder CitroenTPMSDecoder;
extern ProtoViewDecoder FordTPMSDecoder;
extern ProtoViewDecoder KeeloqDecoder;
extern ProtoViewDecoder ProtoViewChatDecoder;
extern ProtoViewDecoder UnknownDecoder;

ProtoViewDecoder *Decoders[] = {
&Oregon2Decoder, /* Oregon sensors v2.1 protocol. */
&B4B1Decoder, /* PT, SC, ... 24 bits remotes. */
&RenaultTPMSDecoder, /* Renault TPMS. */
&ToyotaTPMSDecoder, /* Toyota TPMS. */
&SchraderTPMSDecoder, /* Schrader TPMS. */
&SchraderEG53MA4TPMSDecoder, /* Schrader EG53MA4 TPMS. */
&CitroenTPMSDecoder, /* Citroen TPMS. */
&FordTPMSDecoder, /* Ford TPMS. */
&KeeloqDecoder, /* Keeloq remote. */
&ProtoViewChatDecoder, /* Protoview simple text messages. */

/* Warning: the following decoder must stay at the end of the
* list. Otherwise would detect most signals and prevent the actaul
* decoders from handling them. */
&UnknownDecoder, /* General protocol detector. */
NULL
};

/* Free the message info and allocated data. */
void free_msg_info(ProtoViewMsgInfo *i) {
if (i == NULL) return;
Expand Down

0 comments on commit 79ef4f5

Please sign in to comment.