mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-02-05 09:25:29 -05:00
princeton working
This commit is contained in:
parent
dd5b6d001a
commit
d2cb93d957
@ -34,8 +34,9 @@ namespace ui {
|
|||||||
void SubGhzDRecentEntryDetailView::update_data() {
|
void SubGhzDRecentEntryDetailView::update_data() {
|
||||||
// set text elements
|
// set text elements
|
||||||
text_type.set(SubGhzDView::getSensorTypeName((FPROTO_SUBGHZD_SENSOR)entry_.sensorType));
|
text_type.set(SubGhzDView::getSensorTypeName((FPROTO_SUBGHZD_SENSOR)entry_.sensorType));
|
||||||
text_id.set("0x" + to_string_hex(entry_.id));
|
text_id.set("0x" + to_string_hex(entry_.serial));
|
||||||
// text_temp.set(to_string_decimal(entry_.temp, 2));
|
if (entry_.bits > 0) console.writeln("Bits: " + to_string_dec_uint(entry_.bits));
|
||||||
|
if (entry_.btn != SD_NO_BTN) console.writeln("Btn: " + to_string_dec_uint(entry_.btn));
|
||||||
}
|
}
|
||||||
|
|
||||||
SubGhzDRecentEntryDetailView::SubGhzDRecentEntryDetailView(NavigationView& nav, const SubGhzDRecentEntry& entry)
|
SubGhzDRecentEntryDetailView::SubGhzDRecentEntryDetailView(NavigationView& nav, const SubGhzDRecentEntry& entry)
|
||||||
@ -44,7 +45,7 @@ SubGhzDRecentEntryDetailView::SubGhzDRecentEntryDetailView(NavigationView& nav,
|
|||||||
add_children({&button_done,
|
add_children({&button_done,
|
||||||
&text_type,
|
&text_type,
|
||||||
&text_id,
|
&text_id,
|
||||||
&text_temp,
|
&console,
|
||||||
&labels});
|
&labels});
|
||||||
|
|
||||||
button_done.on_select = [&nav](const ui::Button&) {
|
button_done.on_select = [&nav](const ui::Button&) {
|
||||||
@ -100,7 +101,7 @@ void SubGhzDView::on_tick_second() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SubGhzDView::on_data(const SubGhzDDataMessage* data) {
|
void SubGhzDView::on_data(const SubGhzDDataMessage* data) {
|
||||||
SubGhzDRecentEntry key{data->sensorType, data->id};
|
SubGhzDRecentEntry key{data->sensorType, data->serial, data->bits, data->btn};
|
||||||
auto matching_recent = find(recent, key.key());
|
auto matching_recent = find(recent, key.key());
|
||||||
if (matching_recent != std::end(recent)) {
|
if (matching_recent != std::end(recent)) {
|
||||||
// Found within. Move to front of list, increment counter.
|
// Found within. Move to front of list, increment counter.
|
||||||
@ -147,19 +148,15 @@ void RecentEntriesTable<ui::SubGhzDRecentEntries>::draw(
|
|||||||
line.reserve(30);
|
line.reserve(30);
|
||||||
|
|
||||||
line = SubGhzDView::getSensorTypeName((FPROTO_SUBGHZD_SENSOR)entry.sensorType);
|
line = SubGhzDView::getSensorTypeName((FPROTO_SUBGHZD_SENSOR)entry.sensorType);
|
||||||
if (line.length() < 14) {
|
line = line + " " + to_string_hex(entry.serial);
|
||||||
line += SubGhzDView::pad_string_with_spaces(14 - line.length());
|
if (line.length() < 19) {
|
||||||
|
line += SubGhzDView::pad_string_with_spaces(19 - line.length());
|
||||||
} else {
|
} else {
|
||||||
line = truncate(line, 14);
|
line = truncate(line, 19);
|
||||||
}
|
}
|
||||||
// TODO
|
|
||||||
|
|
||||||
// std::string idStr = to_string_hex(entry.id);
|
|
||||||
std::string ageStr = to_string_dec_uint(entry.age);
|
std::string ageStr = to_string_dec_uint(entry.age);
|
||||||
|
std::string bitsStr = to_string_dec_uint(entry.bits);
|
||||||
// line += SubGhzDView::pad_string_with_spaces(6 - id.length()) + temp;
|
line += SubGhzDView::pad_string_with_spaces(5 - bitsStr.length()) + bitsStr;
|
||||||
// line += SubGhzDView::pad_string_with_spaces(5 - humStr.length()) + humStr;
|
|
||||||
// line += SubGhzDView::pad_string_with_spaces(4 - chStr.length()) + chStr;
|
|
||||||
line += SubGhzDView::pad_string_with_spaces(4 - ageStr.length()) + ageStr;
|
line += SubGhzDView::pad_string_with_spaces(4 - ageStr.length()) + ageStr;
|
||||||
|
|
||||||
line.resize(target_rect.width() / 8, ' ');
|
line.resize(target_rect.width() / 8, ' ');
|
||||||
|
@ -42,19 +42,24 @@ struct SubGhzDRecentEntry {
|
|||||||
using Key = uint64_t;
|
using Key = uint64_t;
|
||||||
static constexpr Key invalid_key = 0x0fffffff; // todo calc the invalid all
|
static constexpr Key invalid_key = 0x0fffffff; // todo calc the invalid all
|
||||||
uint8_t sensorType = FPS_Invalid;
|
uint8_t sensorType = FPS_Invalid;
|
||||||
uint32_t id = 0xFFFFFFFF;
|
uint32_t serial = SD_NO_SERIAL;
|
||||||
|
uint16_t bits = 0;
|
||||||
|
uint8_t btn = SD_NO_BTN;
|
||||||
uint16_t age = 0; // updated on each seconds, show how long the signal was last seen
|
uint16_t age = 0; // updated on each seconds, show how long the signal was last seen
|
||||||
|
|
||||||
SubGhzDRecentEntry() {}
|
SubGhzDRecentEntry() {}
|
||||||
SubGhzDRecentEntry(
|
SubGhzDRecentEntry(
|
||||||
uint8_t sensorType,
|
uint8_t sensorType,
|
||||||
uint32_t id)
|
uint32_t serial,
|
||||||
|
uint16_t bits = 0,
|
||||||
|
uint8_t btn = SD_NO_BTN)
|
||||||
: sensorType{sensorType},
|
: sensorType{sensorType},
|
||||||
id{id} {
|
serial{serial},
|
||||||
|
bits{bits},
|
||||||
|
btn{btn} {
|
||||||
}
|
}
|
||||||
Key key() const {
|
Key key() const {
|
||||||
return (static_cast<uint64_t>(id) << 32) |
|
return (static_cast<uint64_t>(serial) << 32) |
|
||||||
(static_cast<uint64_t>(sensorType) & 0xFF) << 0;
|
(static_cast<uint64_t>(sensorType) & 0xFF) << 0;
|
||||||
}
|
}
|
||||||
void inc_age(int delta) {
|
void inc_age(int delta) {
|
||||||
@ -142,11 +147,13 @@ class SubGhzDRecentEntryDetailView : public View {
|
|||||||
SubGhzDRecentEntry entry_{};
|
SubGhzDRecentEntry entry_{};
|
||||||
Text text_type{{0 * 8, 1 * 16, 15 * 8, 16}, "?"};
|
Text text_type{{0 * 8, 1 * 16, 15 * 8, 16}, "?"};
|
||||||
Text text_id{{6 * 8, 2 * 16, 10 * 8, 16}, "?"};
|
Text text_id{{6 * 8, 2 * 16, 10 * 8, 16}, "?"};
|
||||||
Text text_temp{{6 * 8, 3 * 16, 8 * 8, 7 * 16}, "?"};
|
|
||||||
|
Console console{
|
||||||
|
{0, 4 * 16, 240, screen_height - (4 * 16) - 36}};
|
||||||
|
|
||||||
Labels labels{
|
Labels labels{
|
||||||
{{0 * 8, 0 * 16}, "Tpe:", Color::light_grey()},
|
{{0 * 8, 0 * 16}, "Type:", Color::light_grey()},
|
||||||
{{0 * 8, 2 * 16}, "Id: ", Color::light_grey()},
|
{{0 * 8, 2 * 16}, "Serial: ", Color::light_grey()},
|
||||||
{{0 * 8, 3 * 16}, "Data:", Color::light_grey()},
|
{{0 * 8, 3 * 16}, "Data:", Color::light_grey()},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -56,6 +56,7 @@ class FProtoSubGhzDAnsonic : public FProtoSubGhzDBase {
|
|||||||
btn = 0x0;
|
btn = 0x0;
|
||||||
data = decode_data;
|
data = decode_data;
|
||||||
data_count_bit = decode_count_bit;
|
data_count_bit = decode_count_bit;
|
||||||
|
subghz_protocol_ansonic_check_remote_controller();
|
||||||
if (callback) callback(this);
|
if (callback) callback(this);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -96,17 +97,11 @@ class FProtoSubGhzDAnsonic : public FProtoSubGhzDBase {
|
|||||||
*
|
*
|
||||||
* 1...10 - DIP
|
* 1...10 - DIP
|
||||||
* k- KEY
|
* k- KEY
|
||||||
|
* "DIP: " + ANSONICCNT_TO_DIP(cnt) + "\r\n";
|
||||||
*/
|
*/
|
||||||
cnt = data & 0xFFF;
|
cnt = data & 0xFFF;
|
||||||
btn = ((data >> 1) & 0x3);
|
btn = ((data >> 1) & 0x3);
|
||||||
}
|
serial = (uint32_t)(data & 0xFFFFFFFF);
|
||||||
void get_string(std::string& output) {
|
|
||||||
subghz_protocol_ansonic_check_remote_controller();
|
|
||||||
|
|
||||||
/* output = to_string_dec_uint(data_count_bit) + " bit\r\n";
|
|
||||||
output += "Key: " + to_string_hex((uint32_t)(data & 0xFFFFFFFF)) + "\r\n";
|
|
||||||
output += "BTN: " + to_string_dec_uint(btn) + "\r\n";
|
|
||||||
output += "DIP: " + ANSONICCNT_TO_DIP(cnt) + "\r\n";*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -47,6 +47,7 @@ class FProtoSubGhzDPrinceton : public FProtoSubGhzDBase {
|
|||||||
|
|
||||||
data = decode_data;
|
data = decode_data;
|
||||||
data_count_bit = decode_count_bit;
|
data_count_bit = decode_count_bit;
|
||||||
|
subghz_protocol_princeton_check_remote_controller();
|
||||||
if (callback) callback(this);
|
if (callback) callback(this);
|
||||||
}
|
}
|
||||||
last_data = decode_data;
|
last_data = decode_data;
|
||||||
@ -84,17 +85,8 @@ class FProtoSubGhzDPrinceton : public FProtoSubGhzDBase {
|
|||||||
void subghz_protocol_princeton_check_remote_controller() {
|
void subghz_protocol_princeton_check_remote_controller() {
|
||||||
serial = data >> 4;
|
serial = data >> 4;
|
||||||
btn = data & 0xF;
|
btn = data & 0xF;
|
||||||
}
|
// te = te
|
||||||
void get_string(std::string& output) {
|
// key = (uint32_t)(data & 0xFFFFFF) --the whole packet.
|
||||||
subghz_protocol_princeton_check_remote_controller();
|
|
||||||
uint32_t data_rev = FProtoGeneral::subghz_protocol_blocks_reverse_key(data, data_count_bit);
|
|
||||||
|
|
||||||
/* output = to_string_dec_uint(data_count_bit) + " bit\r\n";
|
|
||||||
output += "Key: " + to_string_hex((uint32_t)(data & 0xFFFFFF)) + "\r\n";
|
|
||||||
output += "Yek: " + to_string_hex(data_rev) + "\r\n";
|
|
||||||
output += "SN: " + to_string_dec_uint(serial) + "\r\n";
|
|
||||||
output += "BTN: " + to_string_dec_uint(btn) + "\r\n";
|
|
||||||
output += "TE: " + to_string_dec_uint(te) + "\r\n"; */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -12,7 +12,6 @@ For comments in a protocol implementation check w-nexus-th.hpp
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
// default values to indicate 'no value'
|
// default values to indicate 'no value'
|
||||||
#define SD_NO_ID 0xFFFFFFFF
|
|
||||||
|
|
||||||
class FProtoSubGhzDBase;
|
class FProtoSubGhzDBase;
|
||||||
typedef void (*SubGhzDProtocolDecoderBaseRxCallback)(FProtoSubGhzDBase* instance);
|
typedef void (*SubGhzDProtocolDecoderBaseRxCallback)(FProtoSubGhzDBase* instance);
|
||||||
@ -23,9 +22,10 @@ class FProtoSubGhzDBase {
|
|||||||
virtual ~FProtoSubGhzDBase() {}
|
virtual ~FProtoSubGhzDBase() {}
|
||||||
virtual void feed(bool level, uint32_t duration) = 0; // need to be implemented on each protocol handler.
|
virtual void feed(bool level, uint32_t duration) = 0; // need to be implemented on each protocol handler.
|
||||||
void setCallback(SubGhzDProtocolDecoderBaseRxCallback cb) { callback = cb; } // this is called when there is a hit.
|
void setCallback(SubGhzDProtocolDecoderBaseRxCallback cb) { callback = cb; } // this is called when there is a hit.
|
||||||
virtual void get_string(std::string& output) = 0;
|
|
||||||
uint8_t getSensorType() { return sensorType; }
|
uint8_t getSensorType() { return sensorType; }
|
||||||
uint32_t getSensorId() { return id; }
|
uint32_t getSensorSerial() { return serial; }
|
||||||
|
uint16_t getBits() { return data_count_bit; }
|
||||||
|
uint8_t getBtn() { return btn; }
|
||||||
uint8_t modulation = FPM_AM; // override this, if FM
|
uint8_t modulation = FPM_AM; // override this, if FM
|
||||||
protected:
|
protected:
|
||||||
// Helper functions to keep it as compatible with flipper as we can, so adding new protos will be easy.
|
// Helper functions to keep it as compatible with flipper as we can, so adding new protos will be easy.
|
||||||
@ -34,9 +34,15 @@ class FProtoSubGhzDBase {
|
|||||||
decode_count_bit++;
|
decode_count_bit++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// General weather data holder
|
// General data holder, these will be passed
|
||||||
uint8_t sensorType = FPS_Invalid;
|
uint8_t sensorType = FPS_Invalid;
|
||||||
uint32_t id = SD_NO_ID;
|
uint32_t key = SD_NO_KEY;
|
||||||
|
uint8_t btn = SD_NO_BTN;
|
||||||
|
uint32_t cnt = SD_NO_CNT;
|
||||||
|
uint32_t serial = SD_NO_SERIAL;
|
||||||
|
uint16_t data_count_bit = 0;
|
||||||
|
uint32_t seed = SD_NO_SEED;
|
||||||
|
// princeton TE
|
||||||
|
|
||||||
// inner logic stuff, also for flipper compatibility.
|
// inner logic stuff, also for flipper compatibility.
|
||||||
SubGhzDProtocolDecoderBaseRxCallback callback = NULL;
|
SubGhzDProtocolDecoderBaseRxCallback callback = NULL;
|
||||||
@ -45,14 +51,9 @@ class FProtoSubGhzDBase {
|
|||||||
uint32_t te_last = 0;
|
uint32_t te_last = 0;
|
||||||
uint64_t data = 0;
|
uint64_t data = 0;
|
||||||
uint64_t data_2 = 0;
|
uint64_t data_2 = 0;
|
||||||
uint32_t serial = 0;
|
|
||||||
uint16_t data_count_bit = 0;
|
|
||||||
uint64_t decode_data = 0;
|
uint64_t decode_data = 0;
|
||||||
uint32_t decode_count_bit = 0;
|
uint32_t decode_count_bit = 0;
|
||||||
uint8_t btn = 0;
|
|
||||||
uint32_t cnt = 0;
|
|
||||||
uint8_t cnt_2 = 0;
|
uint8_t cnt_2 = 0;
|
||||||
uint32_t seed = 0;
|
|
||||||
|
|
||||||
ManchesterState manchester_saved_state = ManchesterStateMid1;
|
ManchesterState manchester_saved_state = ManchesterStateMid1;
|
||||||
};
|
};
|
||||||
|
@ -30,7 +30,7 @@ class SubGhzDProtos : public FProtoListGeneral {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void callbackTarget(FProtoSubGhzDBase* instance) {
|
static void callbackTarget(FProtoSubGhzDBase* instance) {
|
||||||
SubGhzDDataMessage packet_message{instance->getSensorType(), instance->getSensorId()}; // TODO add get_string data too
|
SubGhzDDataMessage packet_message{instance->getSensorType(), instance->getSensorSerial(), instance->getBits(), instance->getBtn()};
|
||||||
shared_memory.application_queue.push(packet_message);
|
shared_memory.application_queue.push(packet_message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,12 @@ Also it must have a switch-case element in the getSubGhzDSensorTypeName() functi
|
|||||||
#define FPM_AM 0
|
#define FPM_AM 0
|
||||||
#define FPM_FM 1
|
#define FPM_FM 1
|
||||||
|
|
||||||
|
#define SD_NO_SERIAL 0xFFFFFFFF
|
||||||
|
#define SD_NO_BTN 0xFF
|
||||||
|
#define SD_NO_CNT 0xFF
|
||||||
|
#define SD_NO_KEY 0xFFFFFFFF
|
||||||
|
#define SD_NO_SEED 0xFFFFFFFF
|
||||||
|
|
||||||
enum FPROTO_SUBGHZD_SENSOR {
|
enum FPROTO_SUBGHZD_SENSOR {
|
||||||
FPS_Invalid = 0,
|
FPS_Invalid = 0,
|
||||||
FPS_ANSONIC = 1,
|
FPS_ANSONIC = 1,
|
||||||
|
@ -72,7 +72,7 @@ void WeatherProcessor::on_message(const Message* const message) {
|
|||||||
|
|
||||||
void WeatherProcessor::configure(const SubGhzFPRxConfigureMessage& message) {
|
void WeatherProcessor::configure(const SubGhzFPRxConfigureMessage& message) {
|
||||||
constexpr size_t decim_0_output_fs = baseband_fs / decim_0.decimation_factor;
|
constexpr size_t decim_0_output_fs = baseband_fs / decim_0.decimation_factor;
|
||||||
constexpr size_t decim_1_output_fs = decim_0_output_fs / decim_1.decimation_factor;
|
// constexpr size_t decim_1_output_fs = decim_0_output_fs / decim_1.decimation_factor; //unused
|
||||||
|
|
||||||
decim_0.configure(taps_200k_wfm_decim_0.taps);
|
decim_0.configure(taps_200k_wfm_decim_0.taps);
|
||||||
decim_1.configure(taps_200k_wfm_decim_1.taps);
|
decim_1.configure(taps_200k_wfm_decim_1.taps);
|
||||||
|
@ -42,8 +42,7 @@ class WeatherProcessor : public BasebandProcessor {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
static constexpr size_t baseband_fs = 4'000'000; // it works, I think we need to write that master clock in the baseband_threat , even later we decimate it.
|
static constexpr size_t baseband_fs = 4'000'000; // it works, I think we need to write that master clock in the baseband_threat , even later we decimate it.
|
||||||
static constexpr uint32_t nsPerDecSamp = 250 * 8; // In current sw , we do not scale it due to clock. We scaled it due to less array buffer sampes due to /8 decimation.
|
static constexpr uint32_t nsPerDecSamp = 250 * 8; // 10 exp9/baseband_fs * 8
|
||||||
// TODO , Pending to investigate , why ticks are not proportional to the SR clock, 500 nseg (2Mhz) , 250 nseg (4Mhz) ??? ;previous comment : "we nees ms to has to divide by 1000"
|
|
||||||
|
|
||||||
/* Array Buffer aux. used in decim0 and decim1 IQ c16 signed data ; (decim0 defines the max length of the array) */
|
/* Array Buffer aux. used in decim0 and decim1 IQ c16 signed data ; (decim0 defines the max length of the array) */
|
||||||
std::array<complex16_t, 512> dst{}; // decim0 /4 , 2048/4 = 512 complex I,Q
|
std::array<complex16_t, 512> dst{}; // decim0 /4 , 2048/4 = 512 complex I,Q
|
||||||
|
@ -1281,13 +1281,19 @@ class SubGhzDDataMessage : public Message {
|
|||||||
public:
|
public:
|
||||||
constexpr SubGhzDDataMessage(
|
constexpr SubGhzDDataMessage(
|
||||||
uint8_t sensorType = 0,
|
uint8_t sensorType = 0,
|
||||||
uint32_t id = 0xFFFFFFFF)
|
uint32_t serial = 0xFFFFFFFF,
|
||||||
|
uint16_t bits = 0,
|
||||||
|
uint8_t btn = 0xFF)
|
||||||
: Message{ID::SubGhzDData},
|
: Message{ID::SubGhzDData},
|
||||||
sensorType{sensorType},
|
sensorType{sensorType},
|
||||||
id{id} {
|
serial{serial},
|
||||||
|
bits{bits},
|
||||||
|
btn{btn} {
|
||||||
}
|
}
|
||||||
uint8_t sensorType = 0;
|
uint8_t sensorType = 0;
|
||||||
uint32_t id = 0xFFFFFFFF; // todo add results too!
|
uint32_t serial = 0xFFFFFFFF;
|
||||||
|
uint16_t bits;
|
||||||
|
uint8_t btn = 0xFF;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*__MESSAGE_H__*/
|
#endif /*__MESSAGE_H__*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user