princeton working

This commit is contained in:
HTotoo
2023-12-09 15:48:50 +01:00
parent dd5b6d001a
commit d2cb93d957
10 changed files with 61 additions and 58 deletions
+3 -8
View File
@@ -56,6 +56,7 @@ class FProtoSubGhzDAnsonic : public FProtoSubGhzDBase {
btn = 0x0;
data = decode_data;
data_count_bit = decode_count_bit;
subghz_protocol_ansonic_check_remote_controller();
if (callback) callback(this);
}
break;
@@ -96,17 +97,11 @@ class FProtoSubGhzDAnsonic : public FProtoSubGhzDBase {
*
* 1...10 - DIP
* k- KEY
* "DIP: " + ANSONICCNT_TO_DIP(cnt) + "\r\n";
*/
cnt = data & 0xFFF;
btn = ((data >> 1) & 0x3);
}
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";*/
serial = (uint32_t)(data & 0xFFFFFFFF);
}
protected:
+3 -11
View File
@@ -47,6 +47,7 @@ class FProtoSubGhzDPrinceton : public FProtoSubGhzDBase {
data = decode_data;
data_count_bit = decode_count_bit;
subghz_protocol_princeton_check_remote_controller();
if (callback) callback(this);
}
last_data = decode_data;
@@ -84,17 +85,8 @@ class FProtoSubGhzDPrinceton : public FProtoSubGhzDBase {
void subghz_protocol_princeton_check_remote_controller() {
serial = data >> 4;
btn = data & 0xF;
}
void get_string(std::string& output) {
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"; */
// te = te
// key = (uint32_t)(data & 0xFFFFFF) --the whole packet.
}
protected:
+11 -10
View File
@@ -12,7 +12,6 @@ For comments in a protocol implementation check w-nexus-th.hpp
#include <string>
// default values to indicate 'no value'
#define SD_NO_ID 0xFFFFFFFF
class FProtoSubGhzDBase;
typedef void (*SubGhzDProtocolDecoderBaseRxCallback)(FProtoSubGhzDBase* instance);
@@ -23,9 +22,10 @@ class FProtoSubGhzDBase {
virtual ~FProtoSubGhzDBase() {}
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.
virtual void get_string(std::string& output) = 0;
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
protected:
// 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++;
}
// General weather data holder
// General data holder, these will be passed
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.
SubGhzDProtocolDecoderBaseRxCallback callback = NULL;
@@ -45,14 +51,9 @@ class FProtoSubGhzDBase {
uint32_t te_last = 0;
uint64_t data = 0;
uint64_t data_2 = 0;
uint32_t serial = 0;
uint16_t data_count_bit = 0;
uint64_t decode_data = 0;
uint32_t decode_count_bit = 0;
uint8_t btn = 0;
uint32_t cnt = 0;
uint8_t cnt_2 = 0;
uint32_t seed = 0;
ManchesterState manchester_saved_state = ManchesterStateMid1;
};
+1 -1
View File
@@ -30,7 +30,7 @@ class SubGhzDProtos : public FProtoListGeneral {
}
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);
}
@@ -11,6 +11,12 @@ Also it must have a switch-case element in the getSubGhzDSensorTypeName() functi
#define FPM_AM 0
#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 {
FPS_Invalid = 0,
FPS_ANSONIC = 1,
+1 -1
View File
@@ -72,7 +72,7 @@ void WeatherProcessor::on_message(const Message* const message) {
void WeatherProcessor::configure(const SubGhzFPRxConfigureMessage& message) {
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_1.configure(taps_200k_wfm_decim_1.taps);
+1 -2
View File
@@ -42,8 +42,7 @@ class WeatherProcessor : public BasebandProcessor {
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 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.
// 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"
static constexpr uint32_t nsPerDecSamp = 250 * 8; // 10 exp9/baseband_fs * 8
/* 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