mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-06-20 21:04:24 -04:00
SubghzD & Weather improvments (#2237)
* Weather restructure * Added Solight TE44 protocol * Add disabled Marantec24, and GangQi * More opt in subghzd
This commit is contained in:
parent
76763b9bab
commit
e6afd7744d
75 changed files with 687 additions and 512 deletions
|
@ -212,7 +212,10 @@ const char* SubGhzDView::getSensorTypeName(FPROTO_SUBGHZD_SENSOR type) {
|
|||
return "Somify Keytis";
|
||||
case FPS_SOMIFY_TELIS:
|
||||
return "Somify Telis";
|
||||
|
||||
case FPS_GANGQI:
|
||||
return "GangQi";
|
||||
case FPS_MARANTEC24:
|
||||
return "Marantec24";
|
||||
case FPS_Invalid:
|
||||
default:
|
||||
return "Unknown";
|
||||
|
@ -717,5 +720,18 @@ void SubGhzDRecentEntryDetailView::parseProtocol() {
|
|||
serial = dataa & 0xFFFFFF; // address}
|
||||
return;
|
||||
}
|
||||
|
||||
if (entry_.sensorType == FPS_GANGQI) {
|
||||
btn = 0; // parser needs some time i think in flipper side.
|
||||
cnt = (uint8_t)(entry_.data >> 32);
|
||||
serial = (entry_.data & 0xFFFFFFFF);
|
||||
return;
|
||||
}
|
||||
|
||||
if (entry_.sensorType == FPS_MARANTEC24) {
|
||||
serial = (entry_.data >> 4);
|
||||
btn = entry_.data & 0xf;
|
||||
return;
|
||||
}
|
||||
}
|
||||
} // namespace ui
|
|
@ -26,6 +26,7 @@
|
|||
#include "baseband_api.hpp"
|
||||
#include "string_format.hpp"
|
||||
#include "portapack_persistent_memory.hpp"
|
||||
#include "../baseband/fprotos/fprotogeneral.hpp"
|
||||
|
||||
using namespace portapack;
|
||||
using namespace ui;
|
||||
|
@ -138,7 +139,8 @@ void WeatherView::on_tick_second() {
|
|||
}
|
||||
|
||||
void WeatherView::on_data(const WeatherDataMessage* data) {
|
||||
WeatherRecentEntry key{data->sensorType, data->id, data->temp, data->humidity, data->channel, data->battery_low};
|
||||
WeatherRecentEntry key = process_data(data);
|
||||
// WeatherRecentEntry key{data->sensorType, data->id, data->temp, data->humidity, data->channel, data->battery_low};
|
||||
auto matching_recent = find(recent, key.key());
|
||||
if (matching_recent != std::end(recent)) {
|
||||
// Found within. Move to front of list, increment counter.
|
||||
|
@ -209,6 +211,8 @@ const char* WeatherView::getWeatherSensorTypeName(FPROTO_WEATHER_SENSOR type) {
|
|||
return "Acurite5in1";
|
||||
case FPW_EmosE601x:
|
||||
return "EmosE601x";
|
||||
case FPW_SolightTE44:
|
||||
return "SolightTE44";
|
||||
case FPW_Invalid:
|
||||
default:
|
||||
return "Unknown";
|
||||
|
@ -254,4 +258,287 @@ void RecentEntriesTable<ui::WeatherRecentEntries>::draw(
|
|||
painter.draw_string(target_rect.location(), style, line);
|
||||
}
|
||||
|
||||
#define LACROSSE_TX_MSG_TYPE_TEMP 0x00
|
||||
#define LACROSSE_TX_MSG_TYPE_HUM 0x0E
|
||||
|
||||
WeatherRecentEntry WeatherView::process_data(const WeatherDataMessage* data) {
|
||||
WeatherRecentEntry ret = {};
|
||||
ret.sensorType = data->sensorType;
|
||||
int16_t i16 = 0;
|
||||
uint16_t u16 = 0;
|
||||
uint64_t u64 = 0;
|
||||
uint8_t u8 = 0;
|
||||
uint8_t channel_3021[] = {3, 0, 2, 1};
|
||||
float flo = 0.0;
|
||||
switch (data->sensorType) {
|
||||
case FPW_NexusTH:
|
||||
ret.id = (data->decode_data >> 28) & 0xFF;
|
||||
ret.battery_low = !((data->decode_data >> 27) & 1);
|
||||
ret.channel = ((data->decode_data >> 24) & 0x03) + 1;
|
||||
if (!((data->decode_data >> 23) & 1)) {
|
||||
ret.temp = (float)((data->decode_data >> 12) & 0x07FF) / 10.0f;
|
||||
} else {
|
||||
ret.temp = (float)((~(data->decode_data >> 12) & 0x07FF) + 1) / -10.0f;
|
||||
}
|
||||
ret.humidity = data->decode_data & 0xFF;
|
||||
if (ret.humidity > 95)
|
||||
ret.humidity = 95;
|
||||
else if (ret.humidity < 20)
|
||||
ret.humidity = 20;
|
||||
break;
|
||||
case FPW_Acurite592TXR:
|
||||
|
||||
u8 = ((data->decode_data >> 54) & 0x03);
|
||||
ret.channel = channel_3021[u8];
|
||||
ret.id = (data->decode_data >> 40) & 0x3FFF;
|
||||
ret.battery_low = !((data->decode_data >> 38) & 1);
|
||||
ret.humidity = (data->decode_data >> 24) & 0x7F;
|
||||
u16 = ((data->decode_data >> 9) & 0xF80) | ((data->decode_data >> 8) & 0x7F);
|
||||
ret.temp = ((float)(u16)-1000) / 10.0f;
|
||||
break;
|
||||
case FPW_Acurite606TX:
|
||||
ret.id = (data->decode_data >> 24) & 0xFF;
|
||||
ret.battery_low = (data->decode_data >> 23) & 1;
|
||||
if (!((data->decode_data >> 19) & 1)) {
|
||||
ret.temp = (float)((data->decode_data >> 8) & 0x07FF) / 10.0f;
|
||||
} else {
|
||||
ret.temp = (float)((~(data->decode_data >> 8) & 0x07FF) + 1) / -10.0f;
|
||||
}
|
||||
break;
|
||||
case FPW_Acurite609TX:
|
||||
ret.id = (data->decode_data >> 32) & 0xFF;
|
||||
ret.battery_low = (data->decode_data >> 31) & 1;
|
||||
ret.channel = WS_NO_CHANNEL;
|
||||
// Temperature in Celsius is encoded as a 12 bit integer value
|
||||
// multiplied by 10 using the 4th - 6th nybbles (bytes 1 & 2)
|
||||
// negative values are recovered by sign extend from int16_t.
|
||||
i16 = (int16_t)(((data->decode_data >> 12) & 0xf000) | ((data->decode_data >> 16) << 4));
|
||||
ret.temp = (i16 >> 4) * 0.1f;
|
||||
ret.humidity = (data->decode_data >> 8) & 0xff;
|
||||
break;
|
||||
case FPW_Ambient:
|
||||
id = (data->decode_data >> 32) & 0xFF;
|
||||
ret.battery_low = (data->decode_data >> 31) & 1;
|
||||
ret.channel = ((data->decode_data >> 28) & 0x07) + 1;
|
||||
ret.temp = FProtoGeneral::locale_fahrenheit_to_celsius(((float)((data->decode_data >> 16) & 0x0FFF) - 400.0f) / 10.0f);
|
||||
ret.humidity = (data->decode_data >> 8) & 0xFF;
|
||||
break;
|
||||
case FPW_AuriolAhfl:
|
||||
ret.id = data->decode_data >> 34;
|
||||
ret.battery_low = (data->decode_data >> 33) & 1;
|
||||
// btn = (data >> 32) & 1;
|
||||
ret.channel = ((data->decode_data >> 30) & 0x3) + 1;
|
||||
if (!((data->decode_data >> 29) & 1)) {
|
||||
ret.temp = (float)((data->decode_data >> 18) & 0x07FF) / 10.0f;
|
||||
} else {
|
||||
ret.temp = (float)((~(data->decode_data >> 18) & 0x07FF) + 1) / -10.0f;
|
||||
}
|
||||
ret.humidity = (data->decode_data >> 11) & 0x7F;
|
||||
break;
|
||||
case FPW_AuriolTH:
|
||||
ret.id = (data->decode_data >> 31) & 0xFF;
|
||||
ret.battery_low = ((data->decode_data >> 30) & 1);
|
||||
ret.channel = ((data->decode_data >> 25) & 0x03) + 1;
|
||||
if (!((data->decode_data >> 23) & 1)) {
|
||||
ret.temp = (float)((data->decode_data >> 13) & 0x07FF) / 10.0f;
|
||||
} else {
|
||||
ret.temp = (float)((~(data->decode_data >> 13) & 0x07FF) + 1) / -10.0f;
|
||||
}
|
||||
ret.humidity = (data->decode_data >> 1) & 0x7F;
|
||||
break;
|
||||
case FPW_GTWT02:
|
||||
ret.id = (data->decode_data >> 29) & 0xFF;
|
||||
ret.battery_low = (data->decode_data >> 28) & 1;
|
||||
// btn = (data->decode_data >> 27) & 1;
|
||||
ret.channel = ((data->decode_data >> 25) & 0x3) + 1;
|
||||
|
||||
if (!((data->decode_data >> 24) & 1)) {
|
||||
ret.temp = (float)((data->decode_data >> 13) & 0x07FF) / 10.0f;
|
||||
} else {
|
||||
ret.temp = (float)((~(data->decode_data >> 13) & 0x07FF) + 1) / -10.0f;
|
||||
}
|
||||
ret.humidity = (data->decode_data >> 6) & 0x7F;
|
||||
if (ret.humidity <= 10) // actually the sensors sends 10 below working range of 20%
|
||||
ret.humidity = 0;
|
||||
else if (ret.humidity > 90) // actually the sensors sends 110 above working range of 90%
|
||||
ret.humidity = 100;
|
||||
break;
|
||||
case FPW_GTWT03:
|
||||
ret.id = data->decode_data >> 33;
|
||||
ret.humidity = (data->decode_data >> 25) & 0xFF;
|
||||
if (ret.humidity <= 10) { // actually the sensors sends 10 below working range of 20%
|
||||
ret.humidity = 0;
|
||||
} else if (ret.humidity > 95) { // actually the sensors sends 110 above working range of 90%
|
||||
ret.humidity = 100;
|
||||
}
|
||||
ret.battery_low = (data->decode_data >> 24) & 1;
|
||||
// (data->decode_data >> 23) & 1;
|
||||
ret.channel = ((data->decode_data >> 21) & 0x03) + 1;
|
||||
if (!((data->decode_data >> 20) & 1)) {
|
||||
ret.temp = (float)((data->decode_data >> 9) & 0x07FF) / 10.0f;
|
||||
} else {
|
||||
ret.temp = (float)((~(data->decode_data >> 9) & 0x07FF) + 1) / -10.0f;
|
||||
}
|
||||
break;
|
||||
case FPW_INFACTORY:
|
||||
ret.id = data->decode_data >> 32;
|
||||
ret.battery_low = (data->decode_data >> 26) & 1;
|
||||
ret.temp = FProtoGeneral::locale_fahrenheit_to_celsius(((float)((data->decode_data >> 12) & 0x0FFF) - 900.0f) / 10.0f);
|
||||
ret.humidity = (((data->decode_data >> 8) & 0x0F) * 10) + ((data->decode_data >> 4) & 0x0F); // BCD, 'A0'=100%rH
|
||||
ret.channel = data->decode_data & 0x03;
|
||||
break;
|
||||
case FPW_LACROSSETX:
|
||||
u8 = (data->decode_data >> 32) & 0x0F;
|
||||
ret.id = (((data->decode_data >> 28) & 0x0F) << 3) | (((data->decode_data >> 24) & 0x0F) >> 1);
|
||||
flo = (float)((data->decode_data >> 20) & 0x0F) * 10.0f + (float)((data->decode_data >> 16) & 0x0F) + (float)((data->decode_data >> 12) & 0x0F) * 0.1f;
|
||||
if (u8 == LACROSSE_TX_MSG_TYPE_TEMP) { //-V1051
|
||||
ret.temp = flo - 50.0f;
|
||||
ret.humidity = WS_NO_HUMIDITY;
|
||||
} else if (u8 == LACROSSE_TX_MSG_TYPE_HUM) {
|
||||
// ToDo for verification, records are needed with sensors maintaining temperature and temperature for this standard
|
||||
ret.humidity = (uint8_t)flo;
|
||||
}
|
||||
break;
|
||||
case FPW_LACROSSETX141thbv2:
|
||||
ret.id = data->decode_data >> 32;
|
||||
ret.battery_low = (data->decode_data >> 31) & 1;
|
||||
// btn = (data->decode_data >> 30) & 1;
|
||||
ret.channel = ((data->decode_data >> 28) & 0x03) + 1;
|
||||
ret.temp = ((float)((data->decode_data >> 16) & 0x0FFF) - 500.0f) / 10.0f;
|
||||
ret.humidity = (data->decode_data >> 8) & 0xFF;
|
||||
break;
|
||||
case FPW_OREGON2:
|
||||
i16 = ((data->decode_data >> 4) & 0xF) * 10 + (((data->decode_data >> 4) >> 4) & 0xF);
|
||||
i16 *= 10;
|
||||
i16 += (data->decode_data >> 12) & 0xF;
|
||||
if (data->decode_data & 0xF) i16 = -i16;
|
||||
ret.temp = (float)i16 / 10.0;
|
||||
// todo fix missing parts.
|
||||
break;
|
||||
case FPW_OREGON3:
|
||||
// todo check
|
||||
ret.humidity = ((data->decode_data >> 4) & 0xF) * 10 + (((data->decode_data >> 4) >> 4) & 0xF);
|
||||
i16 = (((data->decode_data >> 12) >> 4) & 0xF) * 10 + ((((data->decode_data >> 12) >> 4) >> 4) & 0xF); // ws_oregon3_bcd_decode_short((data->decode_data >> 12) >> 4);
|
||||
i16 *= 10;
|
||||
i16 += ((data->decode_data >> 12) >> 12) & 0xF;
|
||||
if ((data->decode_data >> 12) & 0xF) i16 = -i16;
|
||||
ret.temp = (float)i16 / 10.0;
|
||||
break;
|
||||
case FPW_OREGONv1:
|
||||
u64 = FProtoGeneral::subghz_protocol_blocks_reverse_key(data->decode_data, 32);
|
||||
id = u64 & 0xFF;
|
||||
ret.channel = ((u64 >> 6) & 0x03) + 1;
|
||||
ret.temp = ((u64 >> 8) & 0x0F) * 0.1f + ((u64 >> 12) & 0x0F) + ((u64 >> 16) & 0x0F) * 10.0f;
|
||||
if (!((u64 >> 21) & 1)) {
|
||||
ret.temp = ret.temp;
|
||||
} else {
|
||||
ret.temp = -ret.temp;
|
||||
}
|
||||
ret.battery_low = !((u64 >> 23) & 1ULL);
|
||||
break;
|
||||
case FPW_THERMOPROTX4:
|
||||
ret.id = (data->decode_data >> 25) & 0xFF;
|
||||
ret.battery_low = (data->decode_data >> 24) & 1;
|
||||
// btn = (data->decode_data >> 23) & 1;
|
||||
ret.channel = ((data->decode_data >> 21) & 0x03) + 1;
|
||||
if (!((data->decode_data >> 20) & 1)) {
|
||||
ret.temp = (float)((data->decode_data >> 9) & 0x07FF) / 10.0f;
|
||||
} else {
|
||||
ret.temp = (float)((~(data->decode_data >> 9) & 0x07FF) + 1) / -10.0f;
|
||||
}
|
||||
ret.humidity = (data->decode_data >> 1) & 0xFF;
|
||||
break;
|
||||
case FPW_TX_8300:
|
||||
ret.humidity = (((data->decode_data >> 28) & 0x0F) * 10) + ((data->decode_data >> 24) & 0x0F);
|
||||
if (!((data->decode_data >> 22) & 0x03))
|
||||
ret.battery_low = 0;
|
||||
else
|
||||
ret.battery_low = 1;
|
||||
ret.channel = (data->decode_data >> 20) & 0x03;
|
||||
ret.id = (data->decode_data >> 12) & 0x7F;
|
||||
ret.temp = ((data->decode_data >> 8) & 0x0F) * 10.0f + ((data->decode_data >> 4) & 0x0F) +
|
||||
(data->decode_data & 0x0F) * 0.1f;
|
||||
if (!((data->decode_data >> 19) & 1)) {
|
||||
ret.temp = ret.temp;
|
||||
} else {
|
||||
ret.temp = -ret.temp;
|
||||
}
|
||||
break;
|
||||
case FPW_WENDOX_W6726:
|
||||
ret.id = (data->decode_data >> 24) & 0xFF;
|
||||
ret.battery_low = (data->decode_data >> 6) & 1;
|
||||
if (((data->decode_data >> 23) & 1)) {
|
||||
ret.temp = (float)(((data->decode_data >> 14) & 0x1FF) + 12) / 10.0f;
|
||||
} else {
|
||||
ret.temp = (float)((~(data->decode_data >> 14) & 0x1FF) + 1 - 12) / -10.0f;
|
||||
}
|
||||
if (ret.temp < -50.0f) {
|
||||
ret.temp = -50.0f;
|
||||
} else if (ret.temp > 70.0f) {
|
||||
ret.temp = 70.0f;
|
||||
}
|
||||
break;
|
||||
case FPW_Acurite986:
|
||||
ret.id = FProtoGeneral::subghz_protocol_blocks_reverse_key(data->decode_data >> 24, 8);
|
||||
ret.id = (id << 8) | FProtoGeneral::subghz_protocol_blocks_reverse_key(data->decode_data >> 16, 8);
|
||||
ret.battery_low = (data->decode_data >> 14) & 1;
|
||||
ret.channel = ((data->decode_data >> 15) & 1) + 1;
|
||||
i16 = FProtoGeneral::subghz_protocol_blocks_reverse_key(data->decode_data >> 32, 8);
|
||||
if (i16 & 0x80) {
|
||||
i16 = -(i16 & 0x7F);
|
||||
}
|
||||
ret.temp = FProtoGeneral::locale_fahrenheit_to_celsius((float)i16);
|
||||
break;
|
||||
case FPW_KEDSUM:
|
||||
ret.id = data->decode_data >> 32;
|
||||
if ((data->decode_data >> 30) & 0x3) {
|
||||
ret.battery_low = 0;
|
||||
} else {
|
||||
ret.battery_low = 1;
|
||||
}
|
||||
ret.channel = ((data->decode_data >> 28) & 0x3) + 1;
|
||||
u16 = ((data->decode_data >> 16) & 0x0f) << 8 | ((data->decode_data >> 20) & 0x0f) << 4 | ((data->decode_data >> 24) & 0x0f);
|
||||
ret.temp = FProtoGeneral::locale_fahrenheit_to_celsius(((float)u16 - 900.0f) / 10.0f);
|
||||
ret.humidity = ((data->decode_data >> 8) & 0x0f) << 4 | ((data->decode_data >> 12) & 0x0f);
|
||||
break;
|
||||
case FPW_Acurite5in1:
|
||||
u8 = ((data->decode_data >> 62) & 0x03);
|
||||
ret.channel = channel_3021[u8];
|
||||
ret.id = (data->decode_data >> 48) & 0x3FFF;
|
||||
ret.battery_low = !((data->decode_data >> 46) & 1);
|
||||
ret.humidity = (data->decode_data >> 8) & 0x7F;
|
||||
u16 = ((data->decode_data >> (24 - 7)) & 0x780) | ((data->decode_data >> 16) & 0x7F);
|
||||
ret.temp = FProtoGeneral::locale_fahrenheit_to_celsius(((float)(u16)-400) / 10.0f);
|
||||
break;
|
||||
case FPW_EmosE601x:
|
||||
ret.id = 0xffff; //(upper_decode_data >> 24) & 0xff; //todo maybe with oregon, and +64bit usage/message
|
||||
ret.battery_low = (data->decode_data >> 10) & 1;
|
||||
i16 = (data->decode_data >> 40) & 0xfff;
|
||||
/* Handle signed data */
|
||||
if (i16 & 0x800) {
|
||||
i16 |= 0xf000;
|
||||
}
|
||||
ret.temp = (float)i16 / 10.0;
|
||||
ret.humidity = (data->decode_data >> 32) & 0xff;
|
||||
ret.channel = (data->decode_data >> 52) & 0x03;
|
||||
break;
|
||||
case FPW_SolightTE44:
|
||||
ret.id = (data->decode_data >> 28) & 0xff;
|
||||
ret.battery_low = !(data->decode_data >> 27) & 0x01;
|
||||
ret.channel = ((data->decode_data >> 24) & 0x03) + 1;
|
||||
i16 = (data->decode_data >> 12) & 0x0fff;
|
||||
/* Handle signed data */
|
||||
if (i16 & 0x0800) {
|
||||
i16 |= 0xf000;
|
||||
}
|
||||
ret.temp = (float)i16 / 10.0;
|
||||
break;
|
||||
case FPW_Invalid:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace ui
|
||||
|
|
|
@ -96,7 +96,7 @@ class WeatherView : public View {
|
|||
private:
|
||||
void on_tick_second();
|
||||
void on_data(const WeatherDataMessage* data);
|
||||
|
||||
WeatherRecentEntry process_data(const WeatherDataMessage* data);
|
||||
NavigationView& nav_;
|
||||
RxRadioState radio_state_{
|
||||
433'920'000 /* frequency */,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue