diff --git a/applications/system/FZ-ChiefCooker/app/AppConfig.hpp b/applications/system/FZ-ChiefCooker/app/AppConfig.hpp index f0851414..5bb560c8 100644 --- a/applications/system/FZ-ChiefCooker/app/AppConfig.hpp +++ b/applications/system/FZ-ChiefCooker/app/AppConfig.hpp @@ -12,6 +12,10 @@ #define KEY_CONFIG_SAVED_STRATEGY "SavedStationStrategy" #define KEY_CONFIG_AUTOSAVE "AutosaveFoundSignals" #define KEY_CONFIG_USER_CATGEGORY "UserCategory" +#define KEY_CONFIG_AUTO_HOP "AutoHop" +#define KEY_CONFIG_HOP_DWELL_MS "HopDwellMs" +#define KEY_CONFIG_HOP_BAND "HopBand" +#define KEY_CONFIG_MODULATION "ModulationIndex" class AppConfig { public: @@ -22,6 +26,17 @@ public: bool AutosaveFoundSignals = true; String* CurrentUserCategory = NULL; + // --- Scanning mode --- + // false = manual (single fixed Frequency), true = automatic frequency + // hopping across the selected HopBand. + bool AutoHop = false; + // Dwell time per frequency while hopping, in milliseconds. + uint32_t HopDwellMs = 300; + // Which frequency set to hop across: 0 = curated pagers, 1 = all freqs. + uint32_t HopBandMode = 0; + // Modulation preset index (see ModulationManager): 0 = AM650 (pager default). + uint32_t ModulationIndex = 0; + private: void readFromFile(FlipperFile* file) { String* userCat = new String(); @@ -36,6 +51,10 @@ private: file->ReadUInt32(KEY_CONFIG_SAVED_STRATEGY, &savedStrategyValue); file->ReadBool(KEY_CONFIG_AUTOSAVE, &AutosaveFoundSignals); file->ReadString(KEY_CONFIG_USER_CATGEGORY, userCat); + file->ReadBool(KEY_CONFIG_AUTO_HOP, &AutoHop); + file->ReadUInt32(KEY_CONFIG_HOP_DWELL_MS, &HopDwellMs); + file->ReadUInt32(KEY_CONFIG_HOP_BAND, &HopBandMode); + file->ReadUInt32(KEY_CONFIG_MODULATION, &ModulationIndex); SavedStrategy = static_cast(savedStrategyValue); if(!userCat->isEmpty()) { @@ -53,6 +72,10 @@ private: file->WriteUInt32(KEY_CONFIG_SAVED_STRATEGY, SavedStrategy); file->WriteBool(KEY_CONFIG_AUTOSAVE, AutosaveFoundSignals); file->WriteString(KEY_CONFIG_USER_CATGEGORY, CurrentUserCategory != NULL ? CurrentUserCategory->cstr() : ""); + file->WriteBool(KEY_CONFIG_AUTO_HOP, AutoHop); + file->WriteUInt32(KEY_CONFIG_HOP_DWELL_MS, HopDwellMs); + file->WriteUInt32(KEY_CONFIG_HOP_BAND, HopBandMode); + file->WriteUInt32(KEY_CONFIG_MODULATION, ModulationIndex); } public: diff --git a/applications/system/FZ-ChiefCooker/app/screen/ScanStationsScreen.hpp b/applications/system/FZ-ChiefCooker/app/screen/ScanStationsScreen.hpp index 7a866a20..f4215f35 100644 --- a/applications/system/FZ-ChiefCooker/app/screen/ScanStationsScreen.hpp +++ b/applications/system/FZ-ChiefCooker/app/screen/ScanStationsScreen.hpp @@ -8,6 +8,8 @@ #include "PagerActionsScreen.hpp" #include "lib/hardware/subghz/SubGhzModule.hpp" +#include "lib/hardware/subghz/ModulationManager.hpp" +#include "lib/hardware/subghz/HopBandManager.hpp" #include "app/AppConfig.hpp" #include "app/AppNotifications.hpp" @@ -49,6 +51,7 @@ private: bool updateUserCategory = true; int scanForMoreButtonIndex = -1; uint32_t fromFilePagersCount = 0; + String hopCaption; // live caption buffer for the hopping frequency public: ScanStationsScreen(AppConfig* config) : ScanStationsScreen(config, true, NotSelected, NULL) { @@ -67,7 +70,7 @@ public: HANDLER_3ARG(&ScanStationsScreen::getElementColumnName) ); menuView->SetOnDestroyHandler(HANDLER(&ScanStationsScreen::destroy)); - menuView->SetOnReturnToViewHandler([this]() { this->menuView->Refresh(); }); + menuView->SetOnReturnToViewHandler(HANDLER(&ScanStationsScreen::onReturnToView)); menuView->SetGoBackHandler(HANDLER(&ScanStationsScreen::goBack)); menuView->SetColumnFonts(stationScreenColumnFonts); @@ -75,11 +78,13 @@ public: menuView->SetLeftButton("Conf", HANDLER_1ARG(&ScanStationsScreen::showConfig)); - subghz = new SubGhzModule(config->Frequency); + subghz = new SubGhzModule( + config->Frequency, ModulationManager::GetPreset(config->ModulationIndex)); subghz->SetReceiveHandler(HANDLER_1ARG(&ScanStationsScreen::receive)); + subghz->SetHopFrequencyChangedHandler(HANDLER_1ARG(&ScanStationsScreen::onHopFrequencyChanged)); if(receiveNew) { subghz->SetReceiveAfterTransmission(true); - subghz->ReceiveAsync(); + startScanning(); } pagerReceiver = new PagerReceiver(config); @@ -95,11 +100,7 @@ public: } if(receiveNew) { - if(subghz->IsExternal()) { - menuView->SetNoElementCaption("Receiving via EXT..."); - } else { - menuView->SetNoElementCaption("Receiving..."); - } + updateReceivingCaption(); } else { menuView->SetNoElementCaption("No stations found!"); } @@ -122,11 +123,74 @@ public: } private: + // Start receiving in the mode selected in config: automatic hopping across + // the chosen band, or manual single-frequency listening. + void startScanning() { + if(config->AutoHop) { + uint32_t* freqs = new uint32_t[HopBandManager::GetMaxCount()]; + size_t count = HopBandManager::FillFrequencies( + (HopBand)config->HopBandMode, freqs, HopBandManager::GetMaxCount()); + if(count > 0) { + subghz->StartHopping(freqs, count, config->HopDwellMs); + } else { + subghz->ReceiveAsync(); // fallback to manual if list empty + } + delete[] freqs; + } else { + subghz->StopHopping(); + subghz->SetReceiveFrequency(config->Frequency); + subghz->ReceiveAsync(); + } + updateReceivingCaption(); + } + + // Caption shown while listening: reflects hopping vs manual and, when + // hopping, the live frequency the receiver is currently parked on. + void updateReceivingCaption() { + const char* via = subghz->IsExternal() ? " EXT" : ""; + uint32_t freq = subghz->GetReceiveFrequency(); + if(config->AutoHop && subghz->IsHopping()) { + hopCaption.format( + "Hopping%s %lu.%02lu", via, freq / 1000000, (freq % 1000000) / 10000); + } else { + hopCaption.format( + "Recv%s %lu.%02lu", via, freq / 1000000, (freq % 1000000) / 10000); + } + menuView->SetNoElementCaption(hopCaption.cstr()); + } + + // Called by SubGhzModule each time the hopper retunes: refresh the live + // frequency caption if the list is still empty (nothing captured yet). + void onHopFrequencyChanged(uint32_t) { + if(menuView->GetElementsCount() == 0) { + updateReceivingCaption(); + if(menuView->IsOnTop()) { + menuView->Refresh(); + } + } + } + void receive(SubGhzReceivedData* data) { + // When hopping, stop on the first hit so the signal is not missed while + // the radio keeps sweeping. The user can resume via "Scan here for more". + if(subghz->IsHopping()) { + subghz->StopHopping(); + } pagerAdded(pagerReceiver->Receive(data)); delete data; } + // Returning from Settings: the user may have flipped Manual/Auto-hop, the + // band, dwell, or modulation. Re-apply the scan mode if we are still in an + // active receive session with nothing captured yet, so config changes take + // effect immediately without leaving the screen. + void onReturnToView() { + if(receiveMode && menuView->GetElementsCount() == 0) { + startScanning(); + } + menuView->Refresh(); + } + void pagerAdded(ReceivedPagerData* pagerData) { if(pagerData != NULL) { if(pagerData->IsNew()) { @@ -235,7 +299,7 @@ private: if((int)index == scanForMoreButtonIndex) { if(!receiveMode) { subghz->SetReceiveAfterTransmission(true); - subghz->ReceiveAsync(); + startScanning(); receiveMode = true; } diff --git a/applications/system/FZ-ChiefCooker/app/screen/SettingsScreen.hpp b/applications/system/FZ-ChiefCooker/app/screen/SettingsScreen.hpp index 815e3ebb..49e2378e 100644 --- a/applications/system/FZ-ChiefCooker/app/screen/SettingsScreen.hpp +++ b/applications/system/FZ-ChiefCooker/app/screen/SettingsScreen.hpp @@ -5,6 +5,8 @@ #include "app/pager/PagerReceiver.hpp" #include "lib/String.hpp" #include "lib/hardware/subghz/SubGhzModule.hpp" +#include "lib/hardware/subghz/ModulationManager.hpp" +#include "lib/hardware/subghz/HopBandManager.hpp" #include "lib/ui/UiManager.hpp" #include "lib/ui/view/VariableItemListUiView.hpp" @@ -16,19 +18,31 @@ private: VariableItemListUiView* varItemList; UiVariableItem* currentCategoryItem; + UiVariableItem* scanModeItem; UiVariableItem* frequencyItem; + UiVariableItem* hopBandItem; + UiVariableItem* hopDwellItem; + UiVariableItem* modulationItem; UiVariableItem* maxPagerItem; UiVariableItem* signalRepeatItem; UiVariableItem* ignoreSavedItem; UiVariableItem* autosaveFoundItem; - UiVariableItem* debugModeItem; + UiVariableItem* debugModeItem = NULL; String frequencyStr; + String hopDwellStr; String maxPagerStr; String signalRepeatStr; bool updateUserCategory; uint32_t categoryItemIndex; + // Dwell time options (ms) offered for hopping. + static const uint32_t* GetDwellOptions(uint8_t* countOut) { + static const uint32_t dwellOptions[] = {100, 200, 300, 500, 750, 1000}; + *countOut = 6; + return dwellOptions; + } + public: SettingsScreen(AppConfig* config, PagerReceiver* receiver, SubGhzModule* subghz, bool updateUserCategory) { this->config = config; @@ -44,6 +58,18 @@ public: currentCategoryItem = new UiVariableItem("Category", HANDLER_1ARG(&SettingsScreen::categoryChangedHandler)) ); + varItemList->AddItem( + scanModeItem = new UiVariableItem( + "Scan mode", + config->AutoHop ? 1 : 0, + 2, + [this](uint8_t val) { + this->config->AutoHop = (val != 0); + return this->config->AutoHop ? "Auto hop" : "Manual"; + } + ) + ); + varItemList->AddItem( frequencyItem = new UiVariableItem( "Scan frequency", @@ -57,6 +83,46 @@ public: ) ); + varItemList->AddItem( + hopBandItem = new UiVariableItem( + "Hop band", + config->HopBandMode, + HopBandManager::GetBandCount(), + [this](uint8_t val) { + this->config->HopBandMode = val; + return HopBandManager::GetBandName((HopBand)val); + } + ) + ); + + varItemList->AddItem( + hopDwellItem = new UiVariableItem( + "Hop dwell (ms)", + dwellIndexForValue(config->HopDwellMs), + dwellOptionCount(), + [this](uint8_t val) { + uint8_t count = 0; + const uint32_t* opts = GetDwellOptions(&count); + if(val >= count) val = count - 1; + this->config->HopDwellMs = opts[val]; + return hopDwellStr.fromInt(this->config->HopDwellMs); + } + ) + ); + + varItemList->AddItem( + modulationItem = new UiVariableItem( + "Modulation", + config->ModulationIndex, + ModulationManager::GetCount(), + [this](uint8_t val) { + this->config->ModulationIndex = val; + this->subghz->SetPreset(ModulationManager::GetPreset(val)); + return ModulationManager::GetName(val); + } + ) + ); + varItemList->AddItem( maxPagerItem = new UiVariableItem( "Max pager value", @@ -141,6 +207,23 @@ private: return value ? "ON" : "OFF"; } + uint8_t dwellOptionCount() { + uint8_t count = 0; + GetDwellOptions(&count); + return count; + } + + uint8_t dwellIndexForValue(uint32_t value) { + uint8_t count = 0; + const uint32_t* opts = GetDwellOptions(&count); + for(uint8_t i = 0; i < count; i++) { + if(opts[i] == value) { + return i; + } + } + return 2; // default to 300ms + } + const char* savedStationsStrategy(SavedStationStrategy value) { switch(value) { case IGNORE: @@ -165,7 +248,11 @@ private: } delete currentCategoryItem; + delete scanModeItem; delete frequencyItem; + delete hopBandItem; + delete hopDwellItem; + delete modulationItem; delete maxPagerItem; delete signalRepeatItem; delete ignoreSavedItem; diff --git a/applications/system/FZ-ChiefCooker/lib/hardware/subghz/HopBandManager.hpp b/applications/system/FZ-ChiefCooker/lib/hardware/subghz/HopBandManager.hpp new file mode 100644 index 00000000..6c878cc5 --- /dev/null +++ b/applications/system/FZ-ChiefCooker/lib/hardware/subghz/HopBandManager.hpp @@ -0,0 +1,81 @@ +#pragma once + +#include +#include + +#include "lib/hardware/subghz/FrequencyManager.hpp" + +// Provides the frequency list used by the automatic hopping scanner. +// +// Two modes: +// HOP_BAND_PAGERS -> a small curated list of the frequencies restaurant +// pagers actually use (fast to sweep, high hit rate). +// HOP_BAND_ALL -> every frequency from the firmware setting_user list +// (full coverage, slower sweep). +enum HopBand { + HOP_BAND_PAGERS = 0, + HOP_BAND_ALL = 1, +}; + +class HopBandManager { +public: + // Curated pager frequencies (Hz). These are the common OOK pager bands. + static const uint32_t* GetPagerFrequencies(size_t* countOut) { + static const uint32_t pagerFreqs[] = { + 315000000, // 315.00 MHz + 433920000, // 433.92 MHz + 434075000, // 434.07 MHz + 467750000, // 467.75 MHz + }; + *countOut = sizeof(pagerFreqs) / sizeof(pagerFreqs[0]); + return pagerFreqs; + } + + // Fills `out` with the frequency list for the given band and returns the + // count. `out` must have room for at least GetMaxCount() entries. For + // HOP_BAND_ALL the list is copied from FrequencyManager (firmware list). + static size_t FillFrequencies(HopBand band, uint32_t* out, size_t maxCount) { + if(band == HOP_BAND_PAGERS) { + size_t count = 0; + const uint32_t* pagers = GetPagerFrequencies(&count); + if(count > maxCount) { + count = maxCount; + } + for(size_t i = 0; i < count; i++) { + out[i] = pagers[i]; + } + return count; + } + + // HOP_BAND_ALL: pull the whole firmware frequency list. + FrequencyManager* fm = FrequencyManager::GetInstance(); + size_t count = fm->GetFrequencyCount(); + if(count > maxCount) { + count = maxCount; + } + for(size_t i = 0; i < count; i++) { + out[i] = fm->GetFrequency(i); + } + return count; + } + + // Upper bound on the number of hop frequencies (firmware lists are small). + static size_t GetMaxCount() { + return 64; + } + + static const char* GetBandName(HopBand band) { + switch(band) { + case HOP_BAND_PAGERS: + return "Pagers"; + case HOP_BAND_ALL: + return "All freqs"; + default: + return "?"; + } + } + + static uint8_t GetBandCount() { + return 2; + } +}; diff --git a/applications/system/FZ-ChiefCooker/lib/hardware/subghz/ModulationManager.hpp b/applications/system/FZ-ChiefCooker/lib/hardware/subghz/ModulationManager.hpp new file mode 100644 index 00000000..bdbb107c --- /dev/null +++ b/applications/system/FZ-ChiefCooker/lib/hardware/subghz/ModulationManager.hpp @@ -0,0 +1,55 @@ +#pragma once + +#include +#include + +// Small helper mapping the modulation presets Chief Cooker exposes in Settings +// to their FuriHalSubGhzPreset value and a short display name. +// +// NOTE: the restaurant pager protocols (Princeton / SMC5326) are OOK/AM, so +// "AM650" is the only preset that decodes pagers. The other presets are useful +// only if the receiver is used as a generic signal scanner. +class ModulationManager { +public: + struct Entry { + FuriHalSubGhzPreset preset; + const char* name; + }; + + static const Entry* GetEntries() { + static const Entry entries[] = { + {FuriHalSubGhzPresetOok650Async, "AM650"}, + {FuriHalSubGhzPresetOok270Async, "AM270"}, + {FuriHalSubGhzPreset2FSKDev238Async, "FM238"}, + {FuriHalSubGhzPreset2FSKDev476Async, "FM476"}, + }; + return entries; + } + + static uint8_t GetCount() { + return 4; + } + + static FuriHalSubGhzPreset GetPreset(uint8_t index) { + if(index >= GetCount()) { + index = 0; + } + return GetEntries()[index].preset; + } + + static const char* GetName(uint8_t index) { + if(index >= GetCount()) { + index = 0; + } + return GetEntries()[index].name; + } + + static uint8_t GetIndex(FuriHalSubGhzPreset preset) { + for(uint8_t i = 0; i < GetCount(); i++) { + if(GetEntries()[i].preset == preset) { + return i; + } + } + return 0; + } +}; diff --git a/applications/system/FZ-ChiefCooker/lib/hardware/subghz/SubGhzModule.hpp b/applications/system/FZ-ChiefCooker/lib/hardware/subghz/SubGhzModule.hpp index 5cba16c3..c615a1d0 100644 --- a/applications/system/FZ-ChiefCooker/lib/hardware/subghz/SubGhzModule.hpp +++ b/applications/system/FZ-ChiefCooker/lib/hardware/subghz/SubGhzModule.hpp @@ -44,6 +44,22 @@ private: SubGhzState state = IDLE; bool receiveAfterTransmission = false; + // Currently loaded modulation preset (default OOK 650kHz AM for pagers). + FuriHalSubGhzPreset currentPreset = FuriHalSubGhzPresetOok650Async; + + // --- Frequency hopping state --- + // rxHopTimer periodically retunes the receiver across hopFrequencies while + // RX is active, so the user does not have to hunt frequencies by hand. + FuriTimer* rxHopTimer = NULL; + uint32_t* hopFrequencies = NULL; // owned copy of the hop list + size_t hopCount = 0; + size_t hopIndex = 0; + bool hopping = false; + uint32_t hopDwellTicks = 0; // dwell time per frequency, in kernel ticks + // Optional callback fired every time the hopper retunes, so the UI can show + // the live frequency. Receives the new active frequency in Hz. + function hopFrequencyChangedHandler; + static void captureCallback(SubGhzReceiver* receiver, SubGhzProtocolDecoderBase* decoderBase, void* context) { UNUSED(receiver); @@ -75,6 +91,33 @@ private: } } + // Periodic hop callback: advance to the next frequency in the list and + // retune the live receiver without tearing the whole RX pipeline down. + static void rxHopCallback(void* context) { + SubGhzModule* subghz = (SubGhzModule*)context; + if(!subghz->hopping || subghz->hopCount == 0 || subghz->state != RECEIVING) { + return; + } + + subghz->hopIndex = (subghz->hopIndex + 1) % subghz->hopCount; + uint32_t freq = subghz->hopFrequencies[subghz->hopIndex]; + + // Light retune: keep the worker/receiver alive, just idle the radio, + // move frequency, flush and restart async RX. This is much cheaper than + // the full SetReceiveFrequency() stop/alloc/restart cycle. + subghz->receiveFrequency = freq; + subghz_devices_stop_async_rx(subghz->device); + subghz_devices_idle(subghz->device); + subghz->setFrequencyIgnoringStateChecks(freq); + subghz_devices_flush_rx(subghz->device); + subghz_devices_start_async_rx( + subghz->device, (void*)subghz_worker_rx_callback, subghz->worker); + + if(subghz->hopFrequencyChangedHandler != NULL) { + subghz->hopFrequencyChangedHandler(freq); + } + } + void prepareReceiver() { receiver = subghz_receiver_alloc_init(environment); subghz_receiver_set_filter(receiver, SubGhzProtocolFlag_Decodable); @@ -93,7 +136,7 @@ private: } public: - SubGhzModule(uint32_t frequency) { + SubGhzModule(uint32_t frequency, FuriHalSubGhzPreset preset = FuriHalSubGhzPresetOok650Async) { environment = subghz_environment_alloc(); subghz_environment_set_protocol_registry(environment, &subghz_protocol_registry); @@ -109,11 +152,40 @@ public: } subghz_devices_begin(device); - subghz_devices_load_preset(device, FuriHalSubGhzPresetOok650Async, NULL); + currentPreset = preset; + subghz_devices_load_preset(device, currentPreset, NULL); SetReceiveFrequency(frequency); txCompleteCheckTimer = furi_timer_alloc(txCompleteCheckCallback, FuriTimerTypePeriodic, this); + rxHopTimer = furi_timer_alloc(rxHopCallback, FuriTimerTypePeriodic, this); + } + + // Change the modulation preset live. Reloads the preset on the radio and, + // if we were receiving, restarts RX so the new modulation takes effect. + void SetPreset(FuriHalSubGhzPreset preset) { + if(currentPreset == preset) { + return; + } + currentPreset = preset; + + bool restoreReceive = state == RECEIVING; + bool wasHopping = hopping; + PutToIdle(); + + subghz_devices_load_preset(device, currentPreset, NULL); + + if(restoreReceive) { + ReceiveAsync(); + if(wasHopping) { + furi_timer_start(rxHopTimer, hopDwellTicks); + hopping = true; + } + } + } + + FuriHalSubGhzPreset GetPreset() { + return currentPreset; } void SetReceiveFrequency(uint32_t frequency) { @@ -169,6 +241,69 @@ public: this->txCompleteHandler = txCompleteHandler; } + // --- Frequency hopping API --- + + // Fired every time the hopper retunes; use it to display the live frequency. + void SetHopFrequencyChangedHandler(function handler) { + hopFrequencyChangedHandler = handler; + } + + // Begin hopping across the given frequency list, dwelling dwellMs on each. + // Copies the list so the caller may free/reuse its array. RX is (re)started + // on the first frequency. Call StopHopping() to return to a single fixed + // frequency (manual mode). + void StartHopping(const uint32_t* freqs, size_t count, uint32_t dwellMs) { + if(freqs == NULL || count == 0) { + return; + } + + StopHopping(); + + hopFrequencies = new uint32_t[count]; + for(size_t i = 0; i < count; i++) { + hopFrequencies[i] = freqs[i]; + } + hopCount = count; + hopIndex = 0; + + // Start listening on the first hop frequency. + receiveFrequency = hopFrequencies[0]; + ReceiveAsync(); + if(hopFrequencyChangedHandler != NULL) { + hopFrequencyChangedHandler(receiveFrequency); + } + + if(dwellMs < 10) { + dwellMs = 10; // floor to keep the radio stable + } + hopDwellTicks = furi_kernel_get_tick_frequency() * dwellMs / 1000; + hopping = true; + furi_timer_start(rxHopTimer, hopDwellTicks); + } + + // Stop hopping and stay on the current frequency (manual mode). + void StopHopping() { + if(rxHopTimer != NULL) { + furi_timer_stop(rxHopTimer); + } + hopping = false; + + if(hopFrequencies != NULL) { + delete[] hopFrequencies; + hopFrequencies = NULL; + } + hopCount = 0; + hopIndex = 0; + } + + bool IsHopping() { + return hopping; + } + + uint32_t GetReceiveFrequency() { + return receiveFrequency; + } + void Transmit(SubGhzPayload* payload, uint32_t frequency) { if(state != TRANSMITTING) { PutToIdle(); @@ -213,6 +348,12 @@ private: public: void StopReceive() { + // Pause the hop timer while the radio is idle so it does not retune a + // stopped receiver. hopping stays true so callers can resume, but the + // timer is only re-armed by StartHopping()/SetPreset(). + if(rxHopTimer != NULL) { + furi_timer_stop(rxHopTimer); + } subghz_worker_stop(worker); subghz_devices_stop_async_rx(device); subghz_devices_idle(device); @@ -255,6 +396,12 @@ public: ~SubGhzModule() { PutToIdle(); + StopHopping(); + if(rxHopTimer != NULL) { + furi_timer_free(rxHopTimer); + rxHopTimer = NULL; + } + if(txCompleteCheckTimer != NULL) { furi_timer_free(txCompleteCheckTimer); } diff --git a/applications/system/FZ-ChiefCooker/lib/hardware/subghz/data/SubGhzReceivedDataImpl.hpp b/applications/system/FZ-ChiefCooker/lib/hardware/subghz/data/SubGhzReceivedDataImpl.hpp index 9a9e7077..059e5f57 100644 --- a/applications/system/FZ-ChiefCooker/lib/hardware/subghz/data/SubGhzReceivedDataImpl.hpp +++ b/applications/system/FZ-ChiefCooker/lib/hardware/subghz/data/SubGhzReceivedDataImpl.hpp @@ -20,7 +20,6 @@ public: } uint32_t GetHash() { - //return decoder->protocol->decoder->get_hash_data_long(decoder); return decoder->protocol->decoder->get_hash_data(decoder); } diff --git a/applications/system/chief_cooker/.clang-format b/applications/system/chief_cooker/.clang-format deleted file mode 100644 index f125b3b7..00000000 --- a/applications/system/chief_cooker/.clang-format +++ /dev/null @@ -1,246 +0,0 @@ ---- -Language: Cpp -AccessModifierOffset: -4 -AlignAfterOpenBracket: BlockIndent -AlignArrayOfStructures: None -AlignConsecutiveAssignments: - Enabled: false - AcrossEmptyLines: false - AcrossComments: false - AlignCompound: false - AlignFunctionPointers: false - PadOperators: true -AlignConsecutiveBitFields: - Enabled: true - AcrossEmptyLines: true - AcrossComments: true - AlignCompound: false - AlignFunctionPointers: false - PadOperators: true -AlignConsecutiveDeclarations: - Enabled: false - AcrossEmptyLines: false - AcrossComments: false - AlignCompound: false - AlignFunctionPointers: false - PadOperators: true -AlignConsecutiveMacros: - Enabled: true - AcrossEmptyLines: false - AcrossComments: true - AlignCompound: true - AlignFunctionPointers: false - PadOperators: true -AlignConsecutiveShortCaseStatements: - Enabled: false - AcrossEmptyLines: false - AcrossComments: false - AlignCaseColons: false -AlignEscapedNewlines: Left -AlignOperands: Align -AlignTrailingComments: - Kind: Never - OverEmptyLines: 0 -AllowAllArgumentsOnNextLine: true -AllowAllParametersOfDeclarationOnNextLine: false -AllowBreakBeforeNoexceptSpecifier: Never -AllowShortBlocksOnASingleLine: Never -AllowShortCaseLabelsOnASingleLine: false -AllowShortCompoundRequirementOnASingleLine: true -AllowShortEnumsOnASingleLine: false -AllowShortFunctionsOnASingleLine: None -AllowShortIfStatementsOnASingleLine: WithoutElse -AllowShortLambdasOnASingleLine: All -AllowShortLoopsOnASingleLine: false -AlwaysBreakAfterDefinitionReturnType: None -AlwaysBreakAfterReturnType: None -AlwaysBreakBeforeMultilineStrings: false -AlwaysBreakTemplateDeclarations: Yes -AttributeMacros: - - __capability -BinPackArguments: false -BinPackParameters: false -BitFieldColonSpacing: Both -BraceWrapping: - AfterCaseLabel: false - AfterClass: false - AfterControlStatement: Never - AfterEnum: false - AfterExternBlock: false - AfterFunction: false - AfterNamespace: false - AfterObjCDeclaration: false - AfterStruct: false - AfterUnion: false - BeforeCatch: false - BeforeElse: false - BeforeLambdaBody: false - BeforeWhile: false - IndentBraces: false - SplitEmptyFunction: true - SplitEmptyRecord: true - SplitEmptyNamespace: true -BreakAdjacentStringLiterals: true -BreakAfterAttributes: Leave -BreakAfterJavaFieldAnnotations: false -BreakArrays: true -BreakBeforeBinaryOperators: None -BreakBeforeConceptDeclarations: Always -BreakBeforeBraces: Attach -BreakBeforeInlineASMColon: OnlyMultiline -BreakBeforeTernaryOperators: false -BreakConstructorInitializers: AfterColon -BreakInheritanceList: AfterComma -BreakStringLiterals: false -ColumnLimit: 130 -CommentPragmas: '^ IWYU pragma:' -CompactNamespaces: false -ConstructorInitializerIndentWidth: 8 -ContinuationIndentWidth: 4 -Cpp11BracedListStyle: true -DerivePointerAlignment: false -DisableFormat: false -EmptyLineAfterAccessModifier: Never -EmptyLineBeforeAccessModifier: LogicalBlock -ExperimentalAutoDetectBinPacking: false -FixNamespaceComments: false -ForEachMacros: - - foreach - - Q_FOREACH - - BOOST_FOREACH - - M_EACH -IfMacros: - - KJ_IF_MAYBE -IncludeBlocks: Preserve -IncludeCategories: - - Regex: '.*' - Priority: 1 - SortPriority: 0 - CaseSensitive: false - - Regex: '^(<|"(gtest|gmock|isl|json)/)' - Priority: 3 - SortPriority: 0 - CaseSensitive: false - - Regex: '.*' - Priority: 1 - SortPriority: 0 - CaseSensitive: false -IncludeIsMainRegex: '(Test)?$' -IncludeIsMainSourceRegex: '' -IndentAccessModifiers: false -IndentCaseBlocks: false -IndentCaseLabels: false -IndentExternBlock: AfterExternBlock -IndentGotoLabels: true -IndentPPDirectives: None -IndentRequiresClause: false -IndentWidth: 4 -IndentWrappedFunctionNames: true -InsertBraces: false -InsertNewlineAtEOF: true -InsertTrailingCommas: None -IntegerLiteralSeparator: - Binary: 0 - BinaryMinDigits: 0 - Decimal: 0 - DecimalMinDigits: 0 - Hex: 0 - HexMinDigits: 0 -JavaScriptQuotes: Leave -JavaScriptWrapImports: true -KeepEmptyLinesAtTheStartOfBlocks: false -KeepEmptyLinesAtEOF: false -LambdaBodyIndentation: Signature -LineEnding: DeriveLF -MacroBlockBegin: '' -MacroBlockEnd: '' -MaxEmptyLinesToKeep: 1 -NamespaceIndentation: None -ObjCBinPackProtocolList: Auto -ObjCBlockIndentWidth: 4 -ObjCBreakBeforeNestedBlockParam: true -ObjCSpaceAfterProperty: true -ObjCSpaceBeforeProtocolList: true -PackConstructorInitializers: BinPack -PenaltyBreakAssignment: 10 -PenaltyBreakBeforeFirstCallParameter: 30 -PenaltyBreakComment: 10 -PenaltyBreakFirstLessLess: 0 -PenaltyBreakOpenParenthesis: 0 -PenaltyBreakScopeResolution: 500 -PenaltyBreakString: 10 -PenaltyBreakTemplateDeclaration: 10 -PenaltyExcessCharacter: 100 -PenaltyIndentedWhitespace: 0 -PenaltyReturnTypeOnItsOwnLine: 60 -PointerAlignment: Left -PPIndentWidth: -1 -QualifierAlignment: Leave -ReferenceAlignment: Pointer -ReflowComments: false -RemoveBracesLLVM: false -RemoveParentheses: Leave -RemoveSemicolon: true -RequiresClausePosition: OwnLine -RequiresExpressionIndentation: OuterScope -SeparateDefinitionBlocks: Leave -ShortNamespaceLines: 1 -SkipMacroDefinitionBody: false -SortIncludes: Never -SortJavaStaticImport: Before -SortUsingDeclarations: Never -SpaceAfterCStyleCast: false -SpaceAfterLogicalNot: false -SpaceAfterTemplateKeyword: true -SpaceAroundPointerQualifiers: Default -SpaceBeforeAssignmentOperators: true -SpaceBeforeCaseColon: false -SpaceBeforeCpp11BracedList: false -SpaceBeforeCtorInitializerColon: true -SpaceBeforeInheritanceColon: true -SpaceBeforeJsonColon: false -SpaceBeforeParens: Never -SpaceBeforeParensOptions: - AfterControlStatements: false - AfterForeachMacros: false - AfterFunctionDefinitionName: false - AfterFunctionDeclarationName: false - AfterIfMacros: false - AfterOverloadedOperator: false - AfterPlacementOperator: true - AfterRequiresInClause: false - AfterRequiresInExpression: false - BeforeNonEmptyParentheses: false -SpaceBeforeRangeBasedForLoopColon: true -SpaceBeforeSquareBrackets: false -SpaceInEmptyBlock: false -SpacesBeforeTrailingComments: 1 -SpacesInAngles: Never -SpacesInContainerLiterals: false -SpacesInLineCommentPrefix: - Minimum: 1 - Maximum: -1 -SpacesInParens: Never -SpacesInParensOptions: - InCStyleCasts: false - InConditionalStatements: false - InEmptyParentheses: false - Other: false -SpacesInSquareBrackets: false -Standard: c++20 -StatementAttributeLikeMacros: - - Q_EMIT -StatementMacros: - - Q_UNUSED - - QT_REQUIRE_VERSION -TabWidth: 4 -UseTab: Never -VerilogBreakBetweenInstancePorts: true -WhitespaceSensitiveMacros: - - STRINGIZE - - PP_STRINGIZE - - BOOST_PP_STRINGIZE - - NS_SWIFT_NAME - - CF_SWIFT_NAME -... - diff --git a/applications/system/chief_cooker/.github/workflows/build.yml b/applications/system/chief_cooker/.github/workflows/build.yml deleted file mode 100644 index 7fbaeaed..00000000 --- a/applications/system/chief_cooker/.github/workflows/build.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: "FAP: Build for multiple SDK sources" -# This will build your app for dev and release channels on GitHub. -# It will also build your app every day to make sure it's up to date with the latest SDK changes. -# See https://github.com/marketplace/actions/build-flipper-application-package-fap for more information - -on: - push: - ## put your main branch name under "branches" - #branches: - # - master - pull_request: - schedule: - # do a build every day - - cron: "1 1 * * *" - -jobs: - ufbt-build: - runs-on: ubuntu-latest - strategy: - matrix: - include: - - name: Momentum firmware - sdk-index-url: https://up.momentum-fw.dev/firmware/directory.json - sdk-channel: release - name: 'ufbt: Build for ${{ matrix.name }}' - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Build with ufbt - uses: flipperdevices/flipperzero-ufbt-action@v0.1 - id: build-app - with: - sdk-channel: ${{ matrix.sdk-channel }} - sdk-index-url: ${{ matrix.sdk-index-url }} - - name: Upload app artifacts - uses: actions/upload-artifact@v4.6.1 - with: - # See ufbt action docs for other output variables - name: ${{ github.event.repository.name }}-${{ steps.build-app.outputs.suffix }} - path: ${{ steps.build-app.outputs.fap-artifacts }} diff --git a/applications/system/chief_cooker/.gitignore b/applications/system/chief_cooker/.gitignore deleted file mode 100644 index 98f31b07..00000000 --- a/applications/system/chief_cooker/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -dist/* -.vscode -.clangd -.editorconfig -.env -.ufbt diff --git a/applications/system/chief_cooker/LICENSE b/applications/system/chief_cooker/LICENSE deleted file mode 100644 index 0db4b5b1..00000000 --- a/applications/system/chief_cooker/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2025 Denr01 - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/applications/system/chief_cooker/README.md b/applications/system/chief_cooker/README.md deleted file mode 100644 index 233341ac..00000000 --- a/applications/system/chief_cooker/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# Chief Cooker -Your ultimate Flipper Zero restaurant pager tool. Be a _real chief_ of all the restaurants on the food court! - -This app supports receiving, decoding, editing and sending restaurant pager signals. - -**Developed & compatible with [Momentum firmware](https://github.com/Next-Flip/Momentum-Firmware).** Other firmwares are most likely not supported (but I've not tried). - -## Video demo -[![Video 1](https://img.youtube.com/vi/iuQSyesS9-o/0.jpg)](https://youtube.com/shorts/iuQSyesS9-o) - -More demos: -- [Video 2](https://youtube.com/shorts/KGDAGblbtFo) -- [Video 3](https://youtube.com/shorts/QqbfHF-yDiE) - -## Disclaimer -I've built this app for research and learning purposes. But please, don't use it in a way that could hurt anyone or anything. - -Use it responsibly, okay? - -## [Usage instructions](instructions/instructions.md) -Please, read the [instructions](instructions/instructions.md) before using the app. It will definitely make your life easier! - -## Features -- **Receive** signals from pager stations -- Automatically **decode** them and dsiplay station number, pager number and action (Ring/Mute/etc) -- Manually **change encoding in real-time** to look for the best one if automatically detected encoding is not working -- **Resend** captured message to specific pager to all at once to **make them all ring**! -- **Modify** captured signal, e.g. change pager number or action -- **Save** captured signals (and give each station a name) -- Create separate **categories** for each food court you are chief on -- Display signals from saved stations **by ther names** (instead of HEX code) or hide them from list -- **Send** signals from saved stations at any time, no need to capture it again -- Of course, suports working with **external CC1101 module** to cover the area of all the pagers on your food court! - -## Supported protocols -- Princeton -- SMC5326 - -## Supported pager encodings -- Retekess TD157 -- Retekess TD165/T119 -- Retekess TD174 -- L8R / Retekess T111 (not tested) -- L8S / iBells ZJ-68 (check [source code](app/pager/decoder/L8SDecoder.hpp#L8) for description) - -## Contributing -If you want to add any new pager encoding, please feel free to create PR with it! - -Also you can open issue and share with me any captured data (and at least pager number) if you have any and maybe I'll try create a decoder for it - -## Building -If you build the source code just with regular `ufbt` command, the app will probably crash due to out of memory error because your device will have less that 10 kb of free RAM on the "Scan" screen. - -This is because after you compile the app with ufbt, the result executable will contain hundreds of sections with very long names like `.fast.rel.text._ZNSt17_Function_handlerIFvmEZN18PagerActionsScreenC4EP9AppConfigSt8functionIFP15StoredPagerDatavEEP12PagerDecoderP13PagerProtocolP12SubGhzModuleEUlmE_E9_M_invokeERKSt9_Any_dataOm`. -**These names stay in RAM during the execution and consume about 20kb of heap!** - -The reason for it is [name mangling](https://en.wikipedia.org/wiki/Name_mangling). Perhaps, the gcc parameter `-fno-mangle` could disable it, but unfortunately, it is not possible to pass any arguments to gcc when you compile app with `ufbt`. -Luckily the sections inside the compiled file can be renamed using gcc's `objcopy` tool with `--rename-section` parameter. To automate it, I built a small python script which renames them all and gives them short names like `_s1`, `_s2`, `_s228` etc... - -**Therfore you must use [scripts/build-and-clear.py](scripts/build-and-clear.py) script instead!** It will build, rename sections and upload the fap to flipper. - -After building and cleaning your `.fap` with it, you'll get extra +20kb of free RAM which will make compiled app work stably. - -The `.fap` files under the release tab are already cleared with this script, so if you just want to use this app without modifications, just forget about it and download the latest one from releases. - -## Support & Donate - -> [PayPal](https://paypal.me/denr01) - -## Special Thanks -- [meoker/pagger](https://github.com/meoker/pagger) for Retekess pager encodings -- This [awesome repository](https://dev.xcjs.com/r0073dl053r/flipper-playground/-/tree/main/Sub-GHz/Restaurant_Pagers?ref_type=heads) for Retekess T111 and iBells ZJ-68 files diff --git a/applications/system/chief_cooker/app/App.hpp b/applications/system/chief_cooker/app/App.hpp deleted file mode 100644 index 1152129e..00000000 --- a/applications/system/chief_cooker/app/App.hpp +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#include "lib/ui/UiManager.hpp" -#include "lib/hardware/notification/Notification.hpp" -#include "lib/hardware/subghz/FrequencyManager.hpp" - -#include "AppConfig.hpp" -#include "app/screen/MainMenuScreen.hpp" - -using namespace std; - -class App { -public: - void Run() { - UiManager* ui = UiManager::GetInstance(); - ui->InitGui(); - - FrequencyManager* frequencyManager = FrequencyManager::GetInstance(); - AppConfig* config = new AppConfig(); - config->Load(); - - MainMenuScreen* mainMenuScreen = new MainMenuScreen(config); - ui->PushView(mainMenuScreen->GetView()); - ui->RunEventLoop(); - - delete frequencyManager; - delete mainMenuScreen; - delete config; - delete ui; - - Notification::Dispose(); - } -}; diff --git a/applications/system/chief_cooker/app/AppConfig.hpp b/applications/system/chief_cooker/app/AppConfig.hpp deleted file mode 100644 index f0851414..00000000 --- a/applications/system/chief_cooker/app/AppConfig.hpp +++ /dev/null @@ -1,78 +0,0 @@ -#pragma once - -#include - -#include "app/AppFileSystem.hpp" -#include "lib/file/FileManager.hpp" -#include "app/pager/SavedStationStrategy.hpp" - -#define KEY_CONFIG_FREQUENCY "Frequency" -#define KEY_CONFIG_MAX_PAGERS "MaxPagerForBatchOrDetection" -#define KEY_CONFIG_REPEATS "SignalRepeats" -#define KEY_CONFIG_SAVED_STRATEGY "SavedStationStrategy" -#define KEY_CONFIG_AUTOSAVE "AutosaveFoundSignals" -#define KEY_CONFIG_USER_CATGEGORY "UserCategory" - -class AppConfig { -public: - uint32_t Frequency = 433920000; - uint32_t MaxPagerForBatchOrDetection = 30; - uint32_t SignalRepeats = 10; - SavedStationStrategy SavedStrategy = SHOW_NAME; - bool AutosaveFoundSignals = true; - String* CurrentUserCategory = NULL; - -private: - void readFromFile(FlipperFile* file) { - String* userCat = new String(); - uint32_t savedStrategyValue = SavedStrategy; - if(CurrentUserCategory != NULL) { - delete CurrentUserCategory; - } - - file->ReadUInt32(KEY_CONFIG_FREQUENCY, &Frequency); - file->ReadUInt32(KEY_CONFIG_MAX_PAGERS, &MaxPagerForBatchOrDetection); - file->ReadUInt32(KEY_CONFIG_REPEATS, &SignalRepeats); - file->ReadUInt32(KEY_CONFIG_SAVED_STRATEGY, &savedStrategyValue); - file->ReadBool(KEY_CONFIG_AUTOSAVE, &AutosaveFoundSignals); - file->ReadString(KEY_CONFIG_USER_CATGEGORY, userCat); - - SavedStrategy = static_cast(savedStrategyValue); - if(!userCat->isEmpty()) { - CurrentUserCategory = userCat; - } else { - CurrentUserCategory = NULL; - delete userCat; - } - } - - void writeToFile(FlipperFile* file) { - file->WriteUInt32(KEY_CONFIG_FREQUENCY, Frequency); - file->WriteUInt32(KEY_CONFIG_MAX_PAGERS, MaxPagerForBatchOrDetection); - file->WriteUInt32(KEY_CONFIG_REPEATS, SignalRepeats); - file->WriteUInt32(KEY_CONFIG_SAVED_STRATEGY, SavedStrategy); - file->WriteBool(KEY_CONFIG_AUTOSAVE, AutosaveFoundSignals); - file->WriteString(KEY_CONFIG_USER_CATGEGORY, CurrentUserCategory != NULL ? CurrentUserCategory->cstr() : ""); - } - -public: - void Load() { - FlipperFile* configFile = FileManager().OpenRead(CONFIG_FILE_PATH); - if(configFile != NULL) { - readFromFile(configFile); - delete configFile; - } - } - - void Save() { - FlipperFile* configFile = FileManager().OpenWrite(CONFIG_FILE_PATH); - if(configFile != NULL) { - writeToFile(configFile); - delete configFile; - } - } - - const char* GetCurrentUserCategoryCstr() { - return CurrentUserCategory == NULL ? NULL : CurrentUserCategory->cstr(); - } -}; diff --git a/applications/system/chief_cooker/app/AppFileSystem.hpp b/applications/system/chief_cooker/app/AppFileSystem.hpp deleted file mode 100644 index a9cbedf1..00000000 --- a/applications/system/chief_cooker/app/AppFileSystem.hpp +++ /dev/null @@ -1,188 +0,0 @@ -#pragma once - -#include -#include - -#include "app/pager/PagerSerializer.hpp" -#include "lib/file/FileManager.hpp" -#include "pager/data/NamedPagerData.hpp" - -// .fff stands for (f)lipper (f)ile (f)ormat -#define CONFIG_FILE_PATH APP_DATA_PATH("config.fff") - -#define STATIONS_PATH APP_DATA_PATH("stations") -#define STATIONS_PATH_OF(path) STATIONS_PATH "/" path - -#define SAVED_STATIONS_PATH STATIONS_PATH_OF("saved") -#define AUTOSAVED_STATIONS_PATH STATIONS_PATH_OF("autosaved") - -#define MAX_FILENAME_LENGTH 16 - -using namespace std; - -enum CategoryType { - User, - Autosaved, - - NotSelected, -}; - -class AppFileSysytem { -private: - String* getCategoryPath(CategoryType categoryType, const char* category) { - switch(categoryType) { - case User: - if(category != NULL) { - return new String("%s/%s", SAVED_STATIONS_PATH, category); - } else { - return new String(SAVED_STATIONS_PATH); - } - - case Autosaved: - return new String("%s/%s", AUTOSAVED_STATIONS_PATH, category); - - default: - case NotSelected: - return NULL; - } - } - - String* getFilePath(CategoryType categoryType, const char* category, StoredPagerData* pager) { - String* categoryPath = getCategoryPath(categoryType, category); - String* pagerFilename = PagerSerializer().GetFilename(pager); - String* filePath = new String("%s/%s", categoryPath->cstr(), pagerFilename->cstr()); - delete categoryPath; - delete pagerFilename; - return filePath; - } - -public: - int GetCategories(forward_list* categoryList, CategoryType categoryType) { - const char* dirPath; - switch(categoryType) { - case User: - dirPath = SAVED_STATIONS_PATH; - break; - - case Autosaved: - dirPath = AUTOSAVED_STATIONS_PATH; - break; - - default: - return 0; - } - - FileManager fileManager = FileManager(); - Directory* dir = fileManager.OpenDirectory(dirPath); - uint16_t categoriesLoaded = 0; - - if(dir != NULL) { - char fileName[MAX_FILENAME_LENGTH]; - while(dir->GetNextDir(fileName, MAX_FILENAME_LENGTH)) { - char* category = new char[strlen(fileName)]; - strcpy(category, fileName); - categoryList->push_front(category); - categoriesLoaded++; - } - } - - delete dir; - return categoriesLoaded; - } - - size_t GetStationsFromDirectory( - forward_list* stationList, - ProtocolAndDecoderProvider* pdProvider, - CategoryType categoryType, - const char* category, - bool loadNames - ) { - FileManager fileManager = FileManager(); - String* stationDirPath = getCategoryPath(categoryType, category); - Directory* dir = fileManager.OpenDirectory(stationDirPath->cstr()); - PagerSerializer serializer = PagerSerializer(); - size_t stationsLoaded = 0; - - if(dir != NULL) { - char fileName[MAX_FILENAME_LENGTH]; - while(dir->GetNextFile(fileName, MAX_FILENAME_LENGTH)) { - String* stationName = new String(); - StoredPagerData pager = - serializer.LoadPagerData(&fileManager, stationName, stationDirPath->cstr(), fileName, pdProvider); - - if(!loadNames) { - delete stationName; - stationName = NULL; - } - - NamedPagerData returnData = NamedPagerData(); - returnData.storedData = pager; - returnData.name = stationName; - stationList->push_front(returnData); - stationsLoaded++; - } - } - - delete dir; - delete stationDirPath; - - return stationsLoaded; - } - - String* GetOnlyStationName(CategoryType categoryType, const char* category, StoredPagerData* pager) { - FileManager fileManager = FileManager(); - String* categoryPath = getCategoryPath(categoryType, category); - String* name = PagerSerializer().LoadOnlyStationName(&fileManager, categoryPath->cstr(), pager); - delete categoryPath; - return name; - } - - void AutoSave(StoredPagerData* storedData, PagerDecoder* decoder, PagerProtocol* protocol, uint32_t frequency) { - DateTime datetime; - furi_hal_rtc_get_datetime(&datetime); - String* todayDate = new String("%d-%02d-%02d", datetime.year, datetime.month, datetime.day); - String* todaysDir = getCategoryPath(Autosaved, todayDate->cstr()); - - FileManager fileManager = FileManager(); - fileManager.CreateDirIfNotExists(STATIONS_PATH); - fileManager.CreateDirIfNotExists(AUTOSAVED_STATIONS_PATH); - fileManager.CreateDirIfNotExists(todaysDir->cstr()); - - PagerSerializer().SavePagerData(&fileManager, todaysDir->cstr(), "", storedData, decoder, protocol, frequency); - - delete todaysDir; - delete todayDate; - } - - void SaveToUserCategory( - const char* userCategory, - const char* stationName, - StoredPagerData* storedData, - PagerDecoder* decoder, - PagerProtocol* protocol, - uint32_t frequency - ) { - String* catDir = getCategoryPath(User, userCategory); - - FileManager fileManager = FileManager(); - fileManager.CreateDirIfNotExists(STATIONS_PATH); - fileManager.CreateDirIfNotExists(AUTOSAVED_STATIONS_PATH); - fileManager.CreateDirIfNotExists(catDir->cstr()); - - PagerSerializer().SavePagerData(&fileManager, catDir->cstr(), stationName, storedData, decoder, protocol, frequency); - - delete catDir; - } - - void DeletePager(const char* userCategory, StoredPagerData* storedData) { - String* filePath = getFilePath(User, userCategory, storedData); - FileManager().DeleteFile(filePath->cstr()); - delete filePath; - } - - void DeleteCategory(const char* userCategory) { - String* catPath = getCategoryPath(User, userCategory); - FileManager().DeleteFile(catPath->cstr()); - delete catPath; - } -}; diff --git a/applications/system/chief_cooker/app/AppNotifications.hpp b/applications/system/chief_cooker/app/AppNotifications.hpp deleted file mode 100644 index 4dd1d4ec..00000000 --- a/applications/system/chief_cooker/app/AppNotifications.hpp +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#include "lib/hardware/notification/Notification.hpp" - -const NotificationSequence NOTIFICATION_PAGER_RECEIVE = { - &message_vibro_on, - &message_note_e6, - - &message_blue_255, - &message_delay_50, - - &message_sound_off, - &message_vibro_off, - - NULL, -}; diff --git a/applications/system/chief_cooker/app/pager/PagerAction.hpp b/applications/system/chief_cooker/app/pager/PagerAction.hpp deleted file mode 100644 index ab34f3e9..00000000 --- a/applications/system/chief_cooker/app/pager/PagerAction.hpp +++ /dev/null @@ -1,42 +0,0 @@ -#pragma once - -enum PagerAction { - UNKNOWN, - RING, - MUTE, - DESYNC, - TURN_OFF_ALL, - - PagerActionCount, -}; - -class PagerActions { -public: - static const char* GetDescription(PagerAction action) { - switch(action) { - case UNKNOWN: - return "?"; - case RING: - return "RING"; - case MUTE: - return "MUTE"; - case DESYNC: - return "DESYNC_ALL"; - case TURN_OFF_ALL: - return "ALL_OFF"; - default: - return ""; - } - } - - static bool IsPagerActionSpecial(PagerAction action) { - switch(action) { - case DESYNC: - case TURN_OFF_ALL: - return true; - - default: - return false; - } - } -}; diff --git a/applications/system/chief_cooker/app/pager/PagerReceiver.hpp b/applications/system/chief_cooker/app/pager/PagerReceiver.hpp deleted file mode 100644 index 050d1ffe..00000000 --- a/applications/system/chief_cooker/app/pager/PagerReceiver.hpp +++ /dev/null @@ -1,319 +0,0 @@ -#pragma once - -#include "ProtocolAndDecoderProvider.hpp" -#include -#include - -#include "lib/hardware/subghz/FrequencyManager.hpp" -#include "lib/hardware/subghz/data/SubGhzReceivedData.hpp" - -#include "app/AppConfig.hpp" - -#include "data/ReceivedPagerData.hpp" -#include "data/KnownStationData.hpp" - -#include "protocol/PrincetonProtocol.hpp" -#include "protocol/Smc5326Protocol.hpp" - -#include "decoder/Td157Decoder.hpp" -#include "decoder/Td165Decoder.hpp" -#include "decoder/Td174Decoder.hpp" -#include "decoder/L8RDecoder.hpp" -#include "decoder/L8SDecoder.hpp" - -#undef LOG_TAG -#define LOG_TAG "PGR_RCV" - -#define MAX_REPEATS 99 -#define PAGERS_ARRAY_SIZE_MULTIPLIER 8 - -using namespace std; - -class PagerReceiver : public ProtocolAndDecoderProvider { -public: - static const uint8_t protocolsCount = 2; - PagerProtocol* protocols[protocolsCount]{ - new PrincetonProtocol(), - new Smc5326Protocol(), - }; - - static const uint8_t decodersCount = 5; - PagerDecoder* decoders[decodersCount]{ - new Td157Decoder(), - new Td165Decoder(), - new Td174Decoder(), - new L8RDecoder(), - new L8SDecoder(), - }; - -private: - AppConfig* config; - uint16_t nextPagerIndex = 0; - uint16_t pagersArraySize = PAGERS_ARRAY_SIZE_MULTIPLIER; - StoredPagerData* pagers = new StoredPagerData[pagersArraySize]; - size_t knownStationsSize = 0; - KnownStationData* knownStations; - uint32_t lastFrequency = 0; - uint8_t lastFrequencyIndex = 0; - bool knownStationsLoaded = false; - const char* userCategory; - - void loadKnownStations() { - AppFileSysytem appFilesystem; - forward_list stations; - bool withNames = config->SavedStrategy == SHOW_NAME; - - size_t count = appFilesystem.GetStationsFromDirectory(&stations, this, User, userCategory, withNames); - - knownStations = new KnownStationData[count]; - for(size_t i = 0; i < count; i++) { - knownStations[i] = buildKnownStationWithName(stations.front()); - stations.pop_front(); - } - - knownStationsSize = count; - knownStationsLoaded = true; - } - - void unloadKnownStations() { - for(size_t i = 0; i < knownStationsSize; i++) { - if(knownStations[i].name != NULL) { - delete knownStations[i].name; - } - } - - delete[] knownStations; - - knownStationsLoaded = false; - knownStationsSize = 0; - } - - KnownStationData buildKnownStationWithName(NamedPagerData pager) { - KnownStationData data = KnownStationData(); - data.frequency = pager.storedData.frequency; - data.protocol = pager.storedData.protocol; - data.decoder = pager.storedData.decoder; - data.station = decoders[pager.storedData.decoder]->GetStation(pager.storedData.data); - data.name = pager.name; - return data; - } - - KnownStationData buildKnownStationWithoutName(StoredPagerData* pager) { - KnownStationData data = KnownStationData(); - data.frequency = pager->frequency; - data.protocol = pager->protocol; - data.decoder = pager->decoder; - data.station = decoders[pager->decoder]->GetStation(pager->data); - data.name = NULL; - return data; - } - - PagerDecoder* getDecoder(StoredPagerData* pagerData) { - for(size_t i = 0; i < decodersCount; i++) { - pagerData->decoder = i; - if(IsKnown(pagerData)) { - return decoders[i]; - } - } - - for(size_t i = 0; i < decodersCount; i++) { - if(decoders[i]->GetPager(pagerData->data) <= config->MaxPagerForBatchOrDetection) { - return decoders[i]; - } - } - - return decoders[0]; - } - - void addPager(StoredPagerData data) { - if(nextPagerIndex == pagersArraySize) { - pagersArraySize += PAGERS_ARRAY_SIZE_MULTIPLIER; - StoredPagerData* newPagers = new StoredPagerData[pagersArraySize]; - for(int i = 0; i < nextPagerIndex; i++) { - newPagers[i] = pagers[i]; - } - delete[] pagers; - pagers = newPagers; - } - pagers[nextPagerIndex++] = data; - } - -public: - PagerReceiver(AppConfig* config) { - this->config = config; - - for(size_t i = 0; i < protocolsCount; i++) { - protocols[i]->id = i; - } - - for(size_t i = 0; i < decodersCount; i++) { - decoders[i]->id = i; - } - - SetUserCategory(config->CurrentUserCategory); - } - - void SetUserCategory(String* category) { - SetUserCategory(category != NULL ? category->cstr() : NULL); - } - - const char* GetCurrentUserCategory() { - return userCategory; - } - - void SetUserCategory(const char* category) { - userCategory = category; - } - - PagerProtocol* GetProtocolByName(const char* systemProtocolName) { - for(size_t i = 0; i < protocolsCount; i++) { - if(strcmp(systemProtocolName, protocols[i]->GetSystemName()) == 0) { - return protocols[i]; - } - } - - return NULL; - } - - PagerDecoder* GetDecoderByName(const char* shortName) { - for(size_t i = 0; i < decodersCount; i++) { - if(strcmp(shortName, decoders[i]->GetShortName()) == 0) { - return decoders[i]; - } - } - - return NULL; - } - - void ReloadKnownStations() { - unloadKnownStations(); - loadKnownStations(); - } - - void LoadStationsFromDirectory( - CategoryType categoryType, - const char* category, - function pagerHandler - ) { - AppFileSysytem appFilesystem; - forward_list stations; - bool withNames = !knownStationsLoaded && config->SavedStrategy == SHOW_NAME; - - int count = appFilesystem.GetStationsFromDirectory(&stations, this, categoryType, category, withNames); - - delete[] pagers; - pagers = new StoredPagerData[count]; - - if(!knownStationsLoaded) { - knownStations = new KnownStationData[count]; - } - - for(int i = 0; i < count; i++) { - NamedPagerData pagerData = stations.front(); - pagers[i] = pagerData.storedData; - if(!knownStationsLoaded) { - knownStations[i] = buildKnownStationWithName(pagerData); - } - stations.pop_front(); - - pagerHandler(new ReceivedPagerData(PagerGetter(i), i, true)); - } - - if(!knownStationsLoaded) { - knownStationsSize = count; - } - - nextPagerIndex = count; - pagersArraySize = count; - knownStationsLoaded = true; - } - - PagerDataGetter PagerGetter(size_t index) { - return [this, index]() { return &pagers[index]; }; - } - - String* GetName(StoredPagerData* pager) { - uint32_t stationId = buildKnownStationWithoutName(pager).toInt(); - for(size_t i = 0; i < knownStationsSize; i++) { - if(knownStations[i].toInt() == stationId) { - return knownStations[i].name; - } - } - return NULL; - } - - bool IsKnown(StoredPagerData* pager) { - uint32_t stationId = buildKnownStationWithoutName(pager).toInt(); - for(size_t i = 0; i < knownStationsSize; i++) { - if(knownStations[i].toInt() == stationId) { - return true; - } - } - return false; - } - - ReceivedPagerData* Receive(SubGhzReceivedData* data) { - PagerProtocol* protocol = GetProtocolByName(data->GetProtocolName()); - if(protocol == NULL) { - return NULL; - } - - int index = -1; - uint32_t dataHash = data->GetHash(); - - for(size_t i = 0; i < nextPagerIndex; i++) { - if(pagers[i].data == dataHash && pagers[i].protocol == protocol->id) { - if(pagers[i].repeats < MAX_REPEATS) { - pagers[i].repeats++; - } else { - return NULL; // no need to modify element any more - } - index = i; - break; - } - } - - bool isNew = index < 0; - if(isNew) { - if(data->GetFrequency() != lastFrequency) { - lastFrequencyIndex = FrequencyManager::GetInstance()->GetFrequencyIndex(data->GetFrequency()); - lastFrequency = data->GetFrequency(); - } - - StoredPagerData storedData = StoredPagerData(); - storedData.data = dataHash; - storedData.protocol = protocol->id; - storedData.repeats = 1; - storedData.te = data->GetTE(); - storedData.frequency = lastFrequencyIndex; - storedData.decoder = getDecoder(&storedData)->id; - storedData.edited = false; - - if(config->SavedStrategy == HIDE && IsKnown(&storedData)) { - return NULL; - } - - if(config->AutosaveFoundSignals) { - AppFileSysytem().AutoSave(&storedData, decoders[storedData.decoder], protocol, lastFrequency); - } - - index = nextPagerIndex; - addPager(storedData); - } - - return new ReceivedPagerData(PagerGetter(index), index, isNew); - } - - ~PagerReceiver() { - for(PagerProtocol* protocol : protocols) { - delete protocol; - } - - for(PagerDecoder* decoder : decoders) { - delete decoder; - } - - delete[] pagers; - unloadKnownStations(); - } -}; diff --git a/applications/system/chief_cooker/app/pager/PagerSerializer.hpp b/applications/system/chief_cooker/app/pager/PagerSerializer.hpp deleted file mode 100644 index 42879011..00000000 --- a/applications/system/chief_cooker/app/pager/PagerSerializer.hpp +++ /dev/null @@ -1,100 +0,0 @@ -#pragma once - -#include "ProtocolAndDecoderProvider.hpp" -#include "lib/String.hpp" -#include "lib/file/FileManager.hpp" -#include "lib/file/FlipperFile.hpp" - -#include "data/StoredPagerData.hpp" -#include "lib/hardware/subghz/FrequencyManager.hpp" -#include "protocol/PagerProtocol.hpp" -#include "decoder/PagerDecoder.hpp" - -#define KEY_PAGER_STATION_NAME "StationName" -#define KEY_PAGER_FREQUENCY "Frequency" -#define KEY_PAGER_PROTOCOL "Protocol" -#define KEY_PAGER_DECODER "Decoder" -#define KEY_PAGER_DATA "Data" -#define KEY_PAGER_TE "TE" - -#define NAME_MIN_LENGTH 2 -#define NAME_MAX_LENGTH 20 - -class PagerSerializer { -private: -public: - String* GetFilename(StoredPagerData* pager) { - return new String("%06X.fff", pager->data); - } - - void SavePagerData( - FileManager* fileManager, - const char* dir, - const char* stationName, - StoredPagerData* pager, - PagerDecoder* decoder, - PagerProtocol* protocol, - uint32_t frequency - ) { - String* fileName = GetFilename(pager); - FlipperFile* stationFile = fileManager->OpenWrite(dir, fileName->cstr()); - - stationFile->WriteString(KEY_PAGER_STATION_NAME, stationName); - stationFile->WriteUInt32(KEY_PAGER_FREQUENCY, frequency); - stationFile->WriteString(KEY_PAGER_PROTOCOL, protocol->GetSystemName()); - stationFile->WriteString(KEY_PAGER_DECODER, decoder->GetShortName()); - stationFile->WriteUInt32(KEY_PAGER_TE, pager->te); - stationFile->WriteHex(KEY_PAGER_DATA, pager->data); - - delete stationFile; - delete fileName; - } - - String* LoadOnlyStationName(FileManager* fileManager, const char* dir, StoredPagerData* pager) { - String* filename = GetFilename(pager); - FlipperFile* stationFile = fileManager->OpenRead(dir, filename->cstr()); - delete filename; - - String* stationName = NULL; - if(stationFile != NULL) { - stationName = new String(); - stationFile->ReadString(KEY_PAGER_STATION_NAME, stationName); - delete stationFile; - } - return stationName; - } - - StoredPagerData LoadPagerData( - FileManager* fileManager, - String* stationName, - const char* dir, - const char* fileName, - ProtocolAndDecoderProvider* pdProvider - ) { - FlipperFile* stationFile = fileManager->OpenRead(dir, fileName); - - uint32_t te = 0; - uint64_t hex = 0; - uint32_t frequency = 0; - String protocolName; - String decoderName; - - stationFile->ReadString(KEY_PAGER_STATION_NAME, stationName); - stationFile->ReadUInt32(KEY_PAGER_FREQUENCY, &frequency); - stationFile->ReadString(KEY_PAGER_PROTOCOL, &protocolName); - stationFile->ReadString(KEY_PAGER_DECODER, &decoderName); - stationFile->ReadUInt32(KEY_PAGER_TE, &te); - stationFile->ReadHex(KEY_PAGER_DATA, &hex); - - delete stationFile; - - StoredPagerData pager; - pager.data = hex; - pager.te = te; - pager.edited = false; - pager.frequency = FrequencyManager::GetInstance()->GetFrequencyIndex(frequency); - pager.protocol = pdProvider->GetProtocolByName(protocolName.cstr())->id; - pager.decoder = pdProvider->GetDecoderByName(decoderName.cstr())->id; - return pager; - } -}; diff --git a/applications/system/chief_cooker/app/pager/ProtocolAndDecoderProvider.hpp b/applications/system/chief_cooker/app/pager/ProtocolAndDecoderProvider.hpp deleted file mode 100644 index 7fb445f7..00000000 --- a/applications/system/chief_cooker/app/pager/ProtocolAndDecoderProvider.hpp +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -#include "protocol/PagerProtocol.hpp" -#include "decoder/PagerDecoder.hpp" - -class ProtocolAndDecoderProvider { -public: - virtual PagerProtocol* GetProtocolByName(const char* name) = 0; - virtual PagerDecoder* GetDecoderByName(const char* name) = 0; - virtual ~ProtocolAndDecoderProvider() { - } -}; diff --git a/applications/system/chief_cooker/app/pager/SavedStationStrategy.hpp b/applications/system/chief_cooker/app/pager/SavedStationStrategy.hpp deleted file mode 100644 index dcea2596..00000000 --- a/applications/system/chief_cooker/app/pager/SavedStationStrategy.hpp +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -enum SavedStationStrategy { - IGNORE, // don't check if station is saved, show as unknown - SHOW_NAME, // show station name instead of hex and station number - HIDE, // hide all station signals from the search - - SavedStationStrategyValuesCount, -}; diff --git a/applications/system/chief_cooker/app/pager/data/KnownStationData.hpp b/applications/system/chief_cooker/app/pager/data/KnownStationData.hpp deleted file mode 100644 index 085f04b8..00000000 --- a/applications/system/chief_cooker/app/pager/data/KnownStationData.hpp +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once - -#include "lib/String.hpp" -#include - -struct KnownStationData { - uint8_t frequency : 8; - uint8_t protocol : 2; - uint8_t decoder : 4; - uint8_t unused : 2; // align - uint16_t station : 16; - String* name; - -public: - uint32_t toInt(); -}; - -union KnownStationDataUnion { - KnownStationData stationData; - uint32_t intValue; -}; - -uint32_t KnownStationData::toInt() { - KnownStationDataUnion u; - u.stationData = *this; - u.stationData.unused = 0; - return u.intValue; -} diff --git a/applications/system/chief_cooker/app/pager/data/NamedPagerData.hpp b/applications/system/chief_cooker/app/pager/data/NamedPagerData.hpp deleted file mode 100644 index 5cc9db0c..00000000 --- a/applications/system/chief_cooker/app/pager/data/NamedPagerData.hpp +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -#include "StoredPagerData.hpp" -#include "lib/String.hpp" - -struct NamedPagerData { - StoredPagerData storedData; - String* name; -}; diff --git a/applications/system/chief_cooker/app/pager/data/ReceivedPagerData.hpp b/applications/system/chief_cooker/app/pager/data/ReceivedPagerData.hpp deleted file mode 100644 index 552f4d63..00000000 --- a/applications/system/chief_cooker/app/pager/data/ReceivedPagerData.hpp +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once - -#include -#include "StoredPagerData.hpp" - -class ReceivedPagerData { -private: - PagerDataGetter getStoredData; - uint32_t index; - bool isNew; - -public: - ReceivedPagerData(PagerDataGetter storedDataGetter, uint32_t index, bool isNew) { - this->getStoredData = storedDataGetter; - this->index = index; - this->isNew = isNew; - } - - bool IsNew() { - return isNew; - } - - uint32_t GetIndex() { - return index; - } - - StoredPagerData* GetData() { - return getStoredData(); - } -}; diff --git a/applications/system/chief_cooker/app/pager/data/StoredPagerData.hpp b/applications/system/chief_cooker/app/pager/data/StoredPagerData.hpp deleted file mode 100644 index f531f7b4..00000000 --- a/applications/system/chief_cooker/app/pager/data/StoredPagerData.hpp +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#include -#include - -using namespace std; - -struct StoredPagerData { - // first 4-byte - uint32_t data : 25; - uint8_t repeats : 7; - - // second 4-byte - // byte 1 - uint8_t frequency : 8; - - // byte 2 - uint8_t decoder : 4; // max 16 decoders, enough for now - uint8_t protocol : 2; // max 4 protocols (only ) - bool edited : 1; - uint8_t : 0; - - // byte 3-4 - uint16_t te : 11; // 2048 values should be enough - - // 5 bits still unused -}; - -// StoredPagerData is short-living because it's stored as array of stack allocated objects in PagerReceiver class. -// If array size changes, it reallocates all the objects on the new addresses in memory. We could store pointers in array instead of stack objects, -// but it would take more memory which is not acceptable (sizeof(StoredPagerData) + sizeof(StoredPagerData*)) vs sizeof(StoredPagerData). -// That's why we pass the getter instead of object itself, to make sure we always have the right pointer to the StoredPagerData structure. -typedef function PagerDataGetter; diff --git a/applications/system/chief_cooker/app/pager/decoder/L8RDecoder.hpp b/applications/system/chief_cooker/app/pager/decoder/L8RDecoder.hpp deleted file mode 100644 index 8318cbf6..00000000 --- a/applications/system/chief_cooker/app/pager/decoder/L8RDecoder.hpp +++ /dev/null @@ -1,81 +0,0 @@ -#pragma once - -#include "PagerDecoder.hpp" - -#define T111_ACTION_RING 0 - -// Retekess T111 / L8R -// L8R — (L)ast (8) bits (R)eversed order (for pager number) -// seems to be Retekess T111 encoding, but cannot check it due to lack of information -// So I decided to keep it's name as L8R -class L8RDecoder : public PagerDecoder { -private: - const uint32_t stationMask = 0b111111111111100000000000; // leading 13 bits (of 24) are station (any maybe more) - const uint32_t actionMask = 0b11100000000; // next 3 bits are action (possibly, just my guess, may be they are also station) - const uint32_t pagerMask = 0b11111111; // and the last 8 bits seem to be pager number - - const uint8_t stationBitCount = 13; - const uint8_t stationOffset = 11; - - const uint8_t actionBitCount = 3; - const uint8_t actionOffset = 8; - - const uint8_t pagerBitCount = 8; - -public: - const char* GetShortName() { - return "L8R"; - } - - uint16_t GetStation(uint32_t data) { - uint32_t stationReversed = (data & stationMask) >> stationOffset; - return reverseBits(stationReversed, stationBitCount); - } - - uint16_t GetPager(uint32_t data) { - uint32_t pagerReversed = data & pagerMask; - return reverseBits(pagerReversed, pagerBitCount); - } - - uint8_t GetActionValue(uint32_t data) { - uint32_t actionReversed = (data & actionMask) >> actionOffset; - return reverseBits(actionReversed, actionBitCount); - } - - PagerAction GetAction(uint32_t data) { - switch(GetActionValue(data)) { - case T111_ACTION_RING: - return RING; - - default: - return UNKNOWN; - } - } - - uint32_t SetPager(uint32_t data, uint16_t pagerNum) { - return (data & ~pagerMask) | reverseBits(pagerNum, pagerBitCount); - } - - uint32_t SetActionValue(uint32_t data, uint8_t actionValue) { - uint32_t actionCleared = data & ~actionMask; - return actionCleared | (reverseBits(actionValue, actionBitCount) << actionOffset); - } - - uint32_t SetAction(uint32_t data, PagerAction action) { - switch(action) { - case RING: - return SetActionValue(data, T111_ACTION_RING); - - default: - return data; - } - } - - bool IsSupported(PagerAction) { - return false; - } - - uint8_t GetActionsCount() { - return 8; - } -}; diff --git a/applications/system/chief_cooker/app/pager/decoder/L8SDecoder.hpp b/applications/system/chief_cooker/app/pager/decoder/L8SDecoder.hpp deleted file mode 100644 index 9713ed26..00000000 --- a/applications/system/chief_cooker/app/pager/decoder/L8SDecoder.hpp +++ /dev/null @@ -1,61 +0,0 @@ -#pragma once - -#include "core/core_defines.h" - -#include "PagerDecoder.hpp" - -// iBells ZJ-68 / L8S -// L8S — (L)ast (8) bits (S)traight order (non-reversed) (for pager number) -class L8SDecoder : public PagerDecoder { -private: - const uint32_t stationMask = 0b111111111111100000000000; // leading 13 bits (of 24) are station (let it be) - const uint32_t actionMask = 0b11100000000; // next 3 bits are action (possibly, just my guess, may be they are also station) - const uint32_t pagerMask = 0b11111111; // and the last 8 bits should be enough for pager number - - const uint8_t stationOffset = 11; - const uint8_t actionOffset = 8; - -public: - const char* GetShortName() { - return "L8S"; - } - - uint16_t GetStation(uint32_t data) { - return (data & stationMask) >> stationOffset; - } - - uint16_t GetPager(uint32_t data) { - return data & pagerMask; - } - - uint8_t GetActionValue(uint32_t data) { - return (data & actionMask) >> actionOffset; - } - - PagerAction GetAction(uint32_t data) { - UNUSED(data); - return UNKNOWN; - } - - uint32_t SetPager(uint32_t data, uint16_t pagerNum) { - return (data & ~pagerMask) | pagerNum; - } - - uint32_t SetActionValue(uint32_t data, uint8_t actionValue) { - uint32_t actionCleared = data & ~actionMask; - return actionCleared | (actionValue << actionOffset); - } - - uint32_t SetAction(uint32_t data, PagerAction action) { - UNUSED(action); - return data; - } - - bool IsSupported(PagerAction) { - return false; - } - - uint8_t GetActionsCount() { - return 8; - } -}; diff --git a/applications/system/chief_cooker/app/pager/decoder/PagerDecoder.hpp b/applications/system/chief_cooker/app/pager/decoder/PagerDecoder.hpp deleted file mode 100644 index 918ebf3b..00000000 --- a/applications/system/chief_cooker/app/pager/decoder/PagerDecoder.hpp +++ /dev/null @@ -1,52 +0,0 @@ -#pragma once - -#include -#include "../PagerAction.hpp" - -using namespace std; - -class PagerDecoder { -public: - uint8_t id; - virtual const char* GetShortName() = 0; - - virtual uint16_t GetStation(uint32_t data) = 0; - - virtual uint16_t GetPager(uint32_t data) = 0; - virtual uint32_t SetPager(uint32_t data, uint16_t pagerNum) = 0; - - virtual uint8_t GetActionValue(uint32_t data) = 0; - virtual PagerAction GetAction(uint32_t data) = 0; - virtual uint32_t SetAction(uint32_t data, PagerAction action) = 0; - virtual uint32_t SetActionValue(uint32_t data, uint8_t action) = 0; - virtual bool IsSupported(PagerAction action) = 0; - virtual uint8_t GetActionsCount() = 0; - - uint8_t GetSupportedActionsCount() { - uint8_t count = 0; - for(uint8_t i = 0; i < PagerActionCount; i++) { - if(IsSupported(static_cast(i))) { - count++; - } - } - return count; - } - - virtual ~PagerDecoder() { - } - -protected: - uint32_t reverseBits(uint32_t number, int count) { - uint32_t rev = 0; - - while(count-- > 0) { - rev <<= 1; - if((number & 1) == 1) { - rev ^= 1; - } - number >>= 1; - } - - return rev; - } -}; diff --git a/applications/system/chief_cooker/app/pager/decoder/Td157Decoder.hpp b/applications/system/chief_cooker/app/pager/decoder/Td157Decoder.hpp deleted file mode 100644 index 3a2968db..00000000 --- a/applications/system/chief_cooker/app/pager/decoder/Td157Decoder.hpp +++ /dev/null @@ -1,87 +0,0 @@ -#pragma once - -#include "PagerDecoder.hpp" - -#define TD157_ACTION_RING 0b0010 -#define TD157_ACTION_TURN_OFF_ALL 0b1111 -#define TD157_PAGER_TURN_OFF_ALL 999 - -// Retekess TD157 -class Td157Decoder : public PagerDecoder { -private: - const uint32_t stationMask = 0b111111111100000000000000; // leading 10 bits (of 24) are station - const uint32_t pagerMask = 0b11111111110000; // next 10 bits are pager - const uint32_t actionMask = 0b1111; // and the last 4 bits is action - - const uint8_t stationOffset = 14; - const uint8_t pagerOffset = 4; - -public: - const char* GetShortName() { - return "TD157"; - } - - uint16_t GetStation(uint32_t data) { - uint32_t station = (data & stationMask) >> stationOffset; - return (uint16_t)station; - } - - uint16_t GetPager(uint32_t data) { - uint32_t pager = (data & pagerMask) >> pagerOffset; - return (uint16_t)pager; - } - - uint32_t SetPager(uint32_t data, uint16_t pagerNum) { - uint32_t pagerClearedData = data & ~pagerMask; - return pagerClearedData | (pagerNum << pagerOffset); - } - - uint8_t GetActionValue(uint32_t data) { - return data & actionMask; - } - - PagerAction GetAction(uint32_t data) { - switch(GetActionValue(data)) { - case TD157_ACTION_RING: - return RING; - case TD157_ACTION_TURN_OFF_ALL: - if(GetPager(data) == TD157_PAGER_TURN_OFF_ALL) { - return TURN_OFF_ALL; - } - return UNKNOWN; - default: - return UNKNOWN; - } - } - - uint32_t SetAction(uint32_t data, PagerAction action) { - switch(action) { - case RING: - return SetActionValue(data, TD157_ACTION_RING); - case TURN_OFF_ALL: - return SetActionValue(SetPager(data, TD157_PAGER_TURN_OFF_ALL), TD157_ACTION_TURN_OFF_ALL); - default: - return data; - } - } - - virtual uint32_t SetActionValue(uint32_t data, uint8_t action) { - return (data & ~actionMask) | action; - } - - bool IsSupported(PagerAction action) { - switch(action) { - case RING: - case TURN_OFF_ALL: - return true; - - default: - return false; - } - return false; - } - - uint8_t GetActionsCount() { - return actionMask + 1; - } -}; diff --git a/applications/system/chief_cooker/app/pager/decoder/Td165Decoder.hpp b/applications/system/chief_cooker/app/pager/decoder/Td165Decoder.hpp deleted file mode 100644 index c3caacd7..00000000 --- a/applications/system/chief_cooker/app/pager/decoder/Td165Decoder.hpp +++ /dev/null @@ -1,98 +0,0 @@ -#pragma once - -#include "PagerDecoder.hpp" - -#define TD165_ACTION_RING 0 -#define TD165_ACTION_MUTE 1 -#define TD165_PAGER_TURN_OFF_ALL 1005 - -// Retekess TD165/T119 -class Td165Decoder : public PagerDecoder { -private: - const uint32_t stationMask = 0b111111111111100000000000; // leading 13 bits (of 24) are station - const uint32_t pagerMask = 0b11111111110; // next 10 bits are pager - const uint32_t actionMask = 0b1; // and the last 1 bit is action - - const uint8_t stationBitCount = 13; - const uint8_t stationOffset = 11; - - const uint8_t pagerBitCount = 10; - const uint8_t pagerOffset = 1; - -public: - const char* GetShortName() { - return "TD165"; - } - - uint16_t GetStation(uint32_t data) { - uint32_t stationReversed = (data & stationMask) >> stationOffset; - return reverseBits(stationReversed, stationBitCount); - } - - uint16_t GetPager(uint32_t data) { - uint32_t pagerReversed = (data & pagerMask) >> pagerOffset; - return reverseBits(pagerReversed, pagerBitCount); - } - - uint8_t GetActionValue(uint32_t data) { - return data & actionMask; - } - - PagerAction GetAction(uint32_t data) { - switch(GetActionValue(data)) { - case TD165_ACTION_RING: - if(GetPager(data) == TD165_PAGER_TURN_OFF_ALL) { - return TURN_OFF_ALL; - } - return RING; - - case TD165_ACTION_MUTE: - return MUTE; - - default: - return UNKNOWN; - } - } - - uint32_t SetPager(uint32_t data, uint16_t pagerNum) { - uint32_t pagerCleared = data & ~pagerMask; - return pagerCleared | (reverseBits(pagerNum, pagerBitCount) << pagerOffset); - } - - uint32_t SetActionValue(uint32_t data, uint8_t actionValue) { - return (data & ~actionMask) | actionValue; - } - - uint32_t SetAction(uint32_t data, PagerAction action) { - switch(action) { - case RING: - return SetActionValue(data, TD165_ACTION_RING); - - case MUTE: - return SetActionValue(data, TD165_ACTION_MUTE); - - case TURN_OFF_ALL: - return SetActionValue(SetPager(data, TD165_PAGER_TURN_OFF_ALL), TD165_ACTION_RING); - - default: - return data; - } - } - - bool IsSupported(PagerAction action) { - switch(action) { - case RING: - case MUTE: - case TURN_OFF_ALL: - return true; - - default: - return false; - } - return false; - } - - uint8_t GetActionsCount() { - return actionMask + 1; - } -}; diff --git a/applications/system/chief_cooker/app/pager/decoder/Td174Decoder.hpp b/applications/system/chief_cooker/app/pager/decoder/Td174Decoder.hpp deleted file mode 100644 index 5dd35fb4..00000000 --- a/applications/system/chief_cooker/app/pager/decoder/Td174Decoder.hpp +++ /dev/null @@ -1,97 +0,0 @@ -#pragma once - -#include "PagerDecoder.hpp" - -#define TD174_ACTION_RING 0 -#define TD174_ACTION_DESYNC 3 -#define TD174_PAGER_DESYNC 237 - -// Retekess TD174 -class Td174Decoder : public PagerDecoder { -private: - const uint32_t stationMask = 0b111111111111100000000000; // leading 13 bits (of 24) are station - const uint32_t actionMask = 0b11000000000; // next 2 bits are action - const uint32_t pagerMask = 0b111111111; // and the last 9 bits is pager - - const uint8_t stationBitCount = 13; - const uint8_t stationOffset = 11; - - const uint8_t actionBitCount = 2; - const uint8_t actionOffset = 9; - - const uint8_t pagerBitCount = 9; - -public: - const char* GetShortName() { - return "TD174"; - } - - uint16_t GetStation(uint32_t data) { - uint32_t stationReversed = (data & stationMask) >> stationOffset; - return reverseBits(stationReversed, stationBitCount); - } - - uint16_t GetPager(uint32_t data) { - uint32_t pagerReversed = data & pagerMask; - return reverseBits(pagerReversed, pagerBitCount); - } - - uint8_t GetActionValue(uint32_t data) { - uint32_t actionReversed = (data & actionMask) >> actionOffset; - return reverseBits(actionReversed, actionBitCount); - } - - PagerAction GetAction(uint32_t data) { - switch(GetActionValue(data)) { - case TD174_ACTION_RING: - return RING; - - case TD174_ACTION_DESYNC: - if(GetPager(data) == TD174_PAGER_DESYNC) { - return DESYNC; - } - return UNKNOWN; - - default: - return UNKNOWN; - } - } - - uint32_t SetPager(uint32_t data, uint16_t pagerNum) { - return (data & ~pagerMask) | reverseBits(pagerNum, pagerBitCount); - } - - uint32_t SetActionValue(uint32_t data, uint8_t actionValue) { - uint32_t actionCleared = data & ~actionMask; - return actionCleared | (reverseBits(actionValue, actionBitCount) << actionOffset); - } - - uint32_t SetAction(uint32_t data, PagerAction action) { - switch(action) { - case RING: - return SetActionValue(data, TD174_ACTION_RING); - - case DESYNC: - return SetActionValue(SetPager(data, TD174_PAGER_DESYNC), TD174_ACTION_DESYNC); - - default: - return data; - } - } - - bool IsSupported(PagerAction action) { - switch(action) { - case RING: - case DESYNC: - return true; - - default: - return false; - } - return false; - } - - uint8_t GetActionsCount() { - return 4; - } -}; diff --git a/applications/system/chief_cooker/app/pager/protocol/PagerProtocol.hpp b/applications/system/chief_cooker/app/pager/protocol/PagerProtocol.hpp deleted file mode 100644 index 1d4f3af9..00000000 --- a/applications/system/chief_cooker/app/pager/protocol/PagerProtocol.hpp +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#include - -#include "lib/hardware/subghz/SubGhzPayload.hpp" - -class PagerProtocol { -public: - uint8_t id; - virtual const char* GetSystemName() = 0; - virtual int GetFallbackTE() = 0; - virtual int GetMaxTE() = 0; - virtual SubGhzPayload* CreatePayload(uint64_t data, uint32_t te, uint32_t repeats) = 0; - virtual ~PagerProtocol() { - } -}; diff --git a/applications/system/chief_cooker/app/pager/protocol/PrincetonProtocol.hpp b/applications/system/chief_cooker/app/pager/protocol/PrincetonProtocol.hpp deleted file mode 100644 index c4952c59..00000000 --- a/applications/system/chief_cooker/app/pager/protocol/PrincetonProtocol.hpp +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once - -#include - -#include "PagerProtocol.hpp" - -class PrincetonProtocol : public PagerProtocol { -public: - const char* GetSystemName() { - return "Princeton"; - } - - int GetFallbackTE() { - return 212; - } - - int GetMaxTE() { - return 1200; - } - - SubGhzPayload* CreatePayload(uint64_t data, uint32_t te, uint32_t repeats) { - SubGhzPayload* payload = new SubGhzPayload(GetSystemName()); - payload->SetBits(24); - payload->SetKey(data); - payload->SetTE(te); - // somewhy repeats are always 10 even if we set it, so use here "software repeats" instead - payload->SetSoftwareRepeats(ceil(repeats / 10.0)); - payload->SetRepeat(10); // just in case they'll fix it - - return payload; - } -}; diff --git a/applications/system/chief_cooker/app/pager/protocol/Smc5326Protocol.hpp b/applications/system/chief_cooker/app/pager/protocol/Smc5326Protocol.hpp deleted file mode 100644 index a907e274..00000000 --- a/applications/system/chief_cooker/app/pager/protocol/Smc5326Protocol.hpp +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once - -#include "PagerProtocol.hpp" - -class Smc5326Protocol : public PagerProtocol { - const char* GetSystemName() { - return "SMC5326"; - } - - int GetFallbackTE() { - return 326; - } - - int GetMaxTE() { - return 900; - } - - SubGhzPayload* CreatePayload(uint64_t data, uint32_t te, uint32_t repeats) { - SubGhzPayload* payload = new SubGhzPayload(GetSystemName()); - payload->SetBits(25); - payload->SetKey(data); - payload->SetTE(te); - payload->SetRepeat(repeats); - return payload; - } -}; diff --git a/applications/system/chief_cooker/app/screen/BatchTransmissionScreen.hpp b/applications/system/chief_cooker/app/screen/BatchTransmissionScreen.hpp deleted file mode 100644 index 6dc565a8..00000000 --- a/applications/system/chief_cooker/app/screen/BatchTransmissionScreen.hpp +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#include "lib/String.hpp" -#include "lib/ui/view/UiView.hpp" -#include "lib/ui/view/ProgressbarPopupUiView.hpp" - -class BatchTransmissionScreen { -private: - ProgressbarPopupUiView* popup; - String statusStr; - -public: - BatchTransmissionScreen(int pagersTotal) { - popup = new ProgressbarPopupUiView("Transmitting..."); - SetProgress(0, pagersTotal); - popup->SetOnDestroyHandler(HANDLER(&BatchTransmissionScreen::destroy)); - } - - void SetProgress(int pagerNum, int pagersTotal) { - float progressValue = (float)pagerNum / pagersTotal; - popup->SetProgress(statusStr.format("Pager %d / %d", pagerNum, pagersTotal), progressValue); - } - -private: - void destroy() { - delete this; - } - -public: - UiView* GetView() { - return popup; - } -}; diff --git a/applications/system/chief_cooker/app/screen/EditPagerScreen.hpp b/applications/system/chief_cooker/app/screen/EditPagerScreen.hpp deleted file mode 100644 index 79be4c17..00000000 --- a/applications/system/chief_cooker/app/screen/EditPagerScreen.hpp +++ /dev/null @@ -1,313 +0,0 @@ -#pragma once - -#include "SelectCategoryScreen.hpp" -#include "lib/HandlerContext.hpp" -#include "lib/String.hpp" -#include "app/pager/PagerReceiver.hpp" -#include "lib/hardware/subghz/SubGhzModule.hpp" -#include "lib/ui/view/UiView.hpp" -#include "lib/ui/view/VariableItemListUiView.hpp" -#include "lib/ui/view/TextInputUiView.hpp" -#include "lib/ui/view/DialogUiView.hpp" -#include "lib/FlipperDolphin.hpp" -#include "lib/ui/UiManager.hpp" -#include "app/AppFileSystem.hpp" -#include "app/pager/PagerSerializer.hpp" - -#define TE_DIV 10 - -class EditPagerScreen { -private: - AppConfig* config; - SubGhzModule* subghz; - PagerReceiver* receiver; - PagerDataGetter getPager; - VariableItemListUiView* varItemList; - - UiVariableItem* encodingItem = NULL; - UiVariableItem* stationItem = NULL; - UiVariableItem* pagerItem = NULL; - UiVariableItem* actionItem = NULL; - UiVariableItem* hexItem = NULL; - UiVariableItem* protocolItem = NULL; - UiVariableItem* frequencyItem = NULL; - UiVariableItem* teItem = NULL; - UiVariableItem* repeatsItem = NULL; - - UiVariableItem* saveAsItem = NULL; - UiVariableItem* deleteItem = NULL; - - String stationStr; - String pagerStr; - String actionStr; - String hexStr; - String repeatsStr; - String frequencyStr; - String teStr; - int32_t saveAsItemIndex = -1; - int32_t deleteItemIndex = -1; - - bool isFromFile; - const char* saveAsName = NULL; - -public: - EditPagerScreen( - AppConfig* config, - SubGhzModule* subghz, - PagerReceiver* receiver, - PagerDataGetter pagerGetter, - bool isFromFile - ) { - this->config = config; - this->subghz = subghz; - this->receiver = receiver; - this->getPager = pagerGetter; - this->isFromFile = isFromFile; - - StoredPagerData* pager = getPager(); - PagerDecoder* decoder = receiver->decoders[pager->decoder]; - PagerProtocol* protocol = receiver->protocols[pager->protocol]; - uint32_t frequency = FrequencyManager::GetInstance()->GetFrequency(pager->frequency); - - varItemList = new VariableItemListUiView(); - varItemList->SetOnDestroyHandler(HANDLER(&EditPagerScreen::destroy)); - varItemList->SetEnterPressHandler(HANDLER_1ARG(&EditPagerScreen::enterPressed)); - - varItemList->AddItem( - encodingItem = new UiVariableItem( - "Encoding", pager->decoder, receiver->decodersCount, HANDLER_1ARG(&EditPagerScreen::encodingValueChanged) - ) - ); - - varItemList->AddItem(stationItem = new UiVariableItem("Station", HANDLER_1ARG(&EditPagerScreen::stationValueChanged))); - varItemList->AddItem(pagerItem = new UiVariableItem("Pager", HANDLER_1ARG(&EditPagerScreen::pagerValueChanged))); - updatePagerIsEditable(); - - varItemList->AddItem( - actionItem = new UiVariableItem( - "Action", - decoder->GetActionValue(pager->data), - decoder->GetActionsCount(), - HANDLER_1ARG(&EditPagerScreen::actionValueChanged) - ) - ); - - varItemList->AddItem(hexItem = new UiVariableItem("HEX value", HANDLER_1ARG(&EditPagerScreen::hexValueChanged))); - varItemList->AddItem(protocolItem = new UiVariableItem("Protocol", protocol->GetSystemName())); - varItemList->AddItem( - frequencyItem = new UiVariableItem( - "Frequency", frequencyStr.format("%lu.%02lu", frequency / 1000000, (frequency % 1000000) / 10000) - ) - ); - varItemList->AddItem( - teItem = new UiVariableItem( - "TE", pager->te / TE_DIV, protocol->GetMaxTE() / TE_DIV, HANDLER_1ARG(&EditPagerScreen::teValueChanged) - ) - ); - varItemList->AddItem( - repeatsItem = new UiVariableItem( - "Signal Repeats", repeatsStr.format(pager->repeats == MAX_REPEATS ? "%d+" : "%d", pager->repeats) - ) - ); - - if(canSave()) { - const char* saveAsItemName = isFromFile ? "Save / Rename" : "Save signal as..."; - saveAsItemIndex = varItemList->AddItem(saveAsItem = new UiVariableItem(saveAsItemName, "")); - } - - if(canDelete()) { - deleteItemIndex = varItemList->AddItem(deleteItem = new UiVariableItem("Delete station", "")); - } - } - -private: - bool canSave() { - return !receiver->IsKnown(getPager()) || this->isFromFile; - } - - bool canDelete() { - return isFromFile; - } - - String* currentStationName() { - return receiver->GetName(getPager()); - } - - void updatePagerIsEditable() { - StoredPagerData* pager = getPager(); - int pagerNum = receiver->decoders[pager->decoder]->GetPager(pager->data); - if(pagerNum < UINT8_MAX) { - pagerItem->SetSelectedItem(pagerNum, UINT8_MAX); - } else { - pagerItem->SetSelectedItem(0, 1); - } - } - - void enterPressed(int32_t index) { - if(index == saveAsItemIndex) { - saveAs(); - } else if(index == deleteItemIndex) { - DialogUiView* removeConfirmation = new DialogUiView("Really delete?", currentStationName()->cstr()); - removeConfirmation->AddLeftButton("Nope"); - removeConfirmation->AddRightButton("Yup"); - removeConfirmation->SetResultHandler(HANDLER_1ARG(&EditPagerScreen::confirmDelete)); - - UiManager::GetInstance()->PushView(removeConfirmation); - } else { - transmitMessage(); - } - } - - void confirmDelete(DialogExResult result) { - if(result == DialogExResultRight) { - AppFileSysytem().DeletePager(receiver->GetCurrentUserCategory(), getPager()); - receiver->ReloadKnownStations(); - UiManager::GetInstance()->PopView(false); - } - } - - void transmitMessage() { - StoredPagerData* pager = getPager(); - PagerProtocol* protocol = receiver->protocols[pager->protocol]; - uint32_t frequency = FrequencyManager::GetInstance()->GetFrequency(pager->frequency); - subghz->Transmit(protocol->CreatePayload(pager->data, pager->te, config->SignalRepeats), frequency); - - FlipperDolphin::Deed(DolphinDeedSubGhzSend); - } - - void saveAs() { - TextInputUiView* nameInputView = new TextInputUiView("Enter station name", NAME_MIN_LENGTH, NAME_MAX_LENGTH); - String* name = currentStationName(); - if(name != NULL) { - nameInputView->SetDefaultText(name); - } - nameInputView->SetResultHandler(HANDLER_1ARG(&EditPagerScreen::saveAsHandler)); - UiManager::GetInstance()->PushView(nameInputView); - } - - void saveAsHandler(const char* name) { - saveAsName = name; - - UiManager::GetInstance()->ShowLoading(); - UiManager::GetInstance()->PushView( - (new SelectCategoryScreen(true, User, HANDLER_2ARG(&EditPagerScreen::categorySelected)))->GetView() - ); - } - - void categorySelected(CategoryType, const char* category) { - StoredPagerData* pager = getPager(); - PagerDecoder* decoder = receiver->decoders[pager->decoder]; - PagerProtocol* protocol = receiver->protocols[pager->protocol]; - uint32_t frequency = FrequencyManager::GetInstance()->GetFrequency(pager->frequency); - - AppFileSysytem().SaveToUserCategory(category, saveAsName, pager, decoder, protocol, frequency); - FlipperDolphin::Deed(DolphinDeedSubGhzSave); - - receiver->ReloadKnownStations(); - - for(int i = 0; i < 3; i++) { - UiManager::GetInstance()->PopView(false); - } - } - - const char* encodingValueChanged(uint8_t index) { - StoredPagerData* pager = getPager(); - PagerDecoder* decoder = receiver->decoders[index]; - pager->decoder = index; - - if(stationItem != NULL) { - stationItem->Refresh(); - } - if(pagerItem != NULL) { - updatePagerIsEditable(); - pagerItem->Refresh(); - } - if(actionItem != NULL) { - actionItem->SetSelectedItem(decoder->GetActionValue(pager->data), decoder->GetActionsCount()); - } - return receiver->decoders[pager->decoder]->GetShortName(); - } - - const char* stationValueChanged(uint8_t) { - StoredPagerData* pager = getPager(); - return stationStr.fromInt(receiver->decoders[pager->decoder]->GetStation(pager->data)); - } - - const char* pagerValueChanged(uint8_t newPager) { - StoredPagerData* pager = getPager(); - PagerDecoder* decoder = receiver->decoders[pager->decoder]; - if(pagerItem->Editable() && newPager != decoder->GetPager(pager->data)) { - pager->data = decoder->SetPager(pager->data, newPager); - pager->edited = true; - - if(hexItem != NULL) { - hexItem->Refresh(); - } - } - return pagerStr.fromInt(decoder->GetPager(pager->data)); - } - - const char* actionValueChanged(uint8_t value) { - StoredPagerData* pager = getPager(); - PagerDecoder* decoder = receiver->decoders[pager->decoder]; - if(decoder->GetActionValue(pager->data) != value) { - pager->data = decoder->SetActionValue(pager->data, value); - pager->edited = true; - } - - if(hexItem != NULL) { - hexItem->Refresh(); - } - - uint8_t actionValue = decoder->GetActionValue(pager->data); - PagerAction action = decoder->GetAction(pager->data); - const char* actionDesc = PagerActions::GetDescription(action); - - return actionStr.format("%d (%s)", actionValue, actionDesc); - } - - const char* hexValueChanged(uint8_t) { - StoredPagerData* pager = getPager(); - return hexStr.format("%06X", (unsigned int)pager->data); - } - - const char* teValueChanged(uint8_t newTeIndex) { - StoredPagerData* pager = getPager(); - if(newTeIndex != pager->te / TE_DIV) { - int teDiff = pager->te % TE_DIV; - int newTe = newTeIndex * TE_DIV + teDiff; - - pager->te = newTe; - pager->edited = true; - } - - return teStr.format("%d", pager->te); - } - - void destroy() { - delete encodingItem; - delete stationItem; - delete pagerItem; - delete actionItem; - delete hexItem; - delete frequencyItem; - delete teItem; - delete protocolItem; - delete repeatsItem; - - if(saveAsItem != NULL) { - delete saveAsItem; - } - - if(deleteItem != NULL) { - delete deleteItem; - } - - delete this; - } - -public: - UiView* GetView() { - return varItemList; - } -}; diff --git a/applications/system/chief_cooker/app/screen/MainMenuScreen.hpp b/applications/system/chief_cooker/app/screen/MainMenuScreen.hpp deleted file mode 100644 index 05d10cd4..00000000 --- a/applications/system/chief_cooker/app/screen/MainMenuScreen.hpp +++ /dev/null @@ -1,76 +0,0 @@ -#pragma once - -#include "app/AppConfig.hpp" - -#include "lib/ui/view/UiView.hpp" -#include "lib/ui/view/SubMenuUiView.hpp" -#include "lib/ui/UiManager.hpp" - -#include "app/AppNotifications.hpp" - -#include "SelectCategoryScreen.hpp" -#include "ScanStationsScreen.hpp" - -class MainMenuScreen { -private: - AppConfig* config; - SubMenuUiView* menuView; - -public: - MainMenuScreen(AppConfig* config) { - this->config = config; - - menuView = new SubMenuUiView("Chief Cooker"); - menuView->AddItem("Scan for station signals", HANDLER_1ARG(&MainMenuScreen::scanStationsMenuPressed)); - menuView->AddItem("Saved stations database", HANDLER_1ARG(&MainMenuScreen::stationDatabasePressed)); - menuView->AddItem("About / Manual", HANDLER_1ARG(&MainMenuScreen::aboutPressed)); - menuView->SetOnDestroyHandler(HANDLER(&MainMenuScreen::destroy)); - } - - UiView* GetView() { - return menuView; - } - -private: - void scanStationsMenuPressed(uint32_t) { - UiManager::GetInstance()->ShowLoading(); - UiManager::GetInstance()->PushView((new ScanStationsScreen(config))->GetView()); - } - - void stationDatabasePressed(uint32_t) { - SubMenuUiView* savedMenuView = new SubMenuUiView("Select database"); - savedMenuView->AddItem("Saved by you", HANDLER_1ARG(&MainMenuScreen::savedStationsPressed)); - savedMenuView->AddItem("Autosaved", HANDLER_1ARG(&MainMenuScreen::autosavedStationsPressed)); - UiManager::GetInstance()->PushView(savedMenuView); - } - - void savedStationsPressed(uint32_t) { - UiManager::GetInstance()->ShowLoading(); - UiManager::GetInstance()->PushView( - (new SelectCategoryScreen(false, User, HANDLER_2ARG(&MainMenuScreen::categorySelected)))->GetView() - ); - } - - void autosavedStationsPressed(uint32_t) { - UiManager::GetInstance()->ShowLoading(); - UiManager::GetInstance()->PushView( - (new SelectCategoryScreen(false, Autosaved, HANDLER_2ARG(&MainMenuScreen::categorySelected)))->GetView() - ); - } - - void categorySelected(CategoryType categoryType, const char* category) { - UiManager::GetInstance()->ShowLoading(); - UiManager::GetInstance()->PushView((new ScanStationsScreen(config, categoryType, category))->GetView()); - } - - void aboutPressed(uint32_t index) { - UNUSED(index); - - Notification::Play(&NOTIFICATION_PAGER_RECEIVE); - menuView->SetItemLabel(index, "Developed by Denr01!"); - } - - void destroy() { - delete this; - } -}; diff --git a/applications/system/chief_cooker/app/screen/PagerActionsScreen.hpp b/applications/system/chief_cooker/app/screen/PagerActionsScreen.hpp deleted file mode 100644 index 4be0e77a..00000000 --- a/applications/system/chief_cooker/app/screen/PagerActionsScreen.hpp +++ /dev/null @@ -1,160 +0,0 @@ -#pragma once - -#include "lib/String.hpp" -#include "app/AppConfig.hpp" -#include "app/pager/data/StoredPagerData.hpp" -#include "app/pager/decoder/PagerDecoder.hpp" -#include "app/pager/protocol/PagerProtocol.hpp" -#include "lib/hardware/subghz/SubGhzModule.hpp" -#include "lib/ui/view/UiView.hpp" -#include "lib/ui/view/SubMenuUiView.hpp" -#include "app/screen/BatchTransmissionScreen.hpp" -#include "lib/FlipperDolphin.hpp" -#include "lib/ui/UiManager.hpp" - -class PagerActionsScreen { -private: - AppConfig* config; - SubMenuUiView* submenu; - PagerDecoder* decoder; - PagerProtocol* protocol; - SubGhzModule* subghz; - PagerDataGetter getPager; - BatchTransmissionScreen* batchTransmissionScreen; - - String headerStr; - String resendToAllStr; - String resendToCurrentStr; - String** actionsStrings; - - uint32_t currentBatchFrequency; - uint32_t currentPager = 0; - bool transmittingBatch = false; - -public: - PagerActionsScreen( - AppConfig* config, - PagerDataGetter pagerGetter, - PagerDecoder* decoder, - PagerProtocol* protocol, - SubGhzModule* subghz - ) { - this->config = config; - this->getPager = pagerGetter; - this->decoder = decoder; - this->protocol = protocol; - this->subghz = subghz; - - StoredPagerData* pager = getPager(); - PagerAction currentAction = decoder->GetAction(pager->data); - uint8_t actionValue = decoder->GetActionValue(pager->data); - uint16_t stationNum = decoder->GetStation(pager->data); - uint16_t pagerNum = decoder->GetPager(pager->data); - - submenu = new SubMenuUiView(headerStr.format("Station %d actions", stationNum)); - submenu->SetOnDestroyHandler(HANDLER(&PagerActionsScreen::destroy)); - submenu->SetOnReturnToViewHandler(HANDLER(&PagerActionsScreen::onReturn)); - - submenu->AddItem( - resendToAllStr.format("Resend %d (%s) to ALL", actionValue, PagerActions::GetDescription(currentAction)), - HANDLER_1ARG(&PagerActionsScreen::resendToAll) - ); - - if(currentAction == UNKNOWN) { - submenu->AddItem( - resendToCurrentStr.format("Resend only to pager %d", pagerNum), HANDLER_1ARG(&PagerActionsScreen::resendSingle) - ); - } - - actionsStrings = new String*[decoder->GetSupportedActionsCount()]; - for(size_t actionIndex = 0, i = 0; actionIndex < PagerActionCount; actionIndex++) { - PagerAction action = static_cast(actionIndex); - if(!decoder->IsSupported(action)) { - continue; - } - - if(PagerActions::IsPagerActionSpecial(action)) { - actionsStrings[i] = new String("Trigger action %s", PagerActions::GetDescription(action)); - } else { - actionsStrings[i] = new String("%s only pager %d", PagerActions::GetDescription(action), pagerNum); - } - - submenu->AddItem(actionsStrings[i]->cstr(), [this, action](uint32_t) { sendAction(action); }); - i++; - } - - subghz->SetTransmitCompleteHandler(HANDLER(&PagerActionsScreen::txComplete)); - } - -private: - void resendToAll(uint32_t) { - currentPager = 0; - transmittingBatch = true; - currentBatchFrequency = FrequencyManager::GetInstance()->GetFrequency(getPager()->frequency); - - batchTransmissionScreen = new BatchTransmissionScreen(config->MaxPagerForBatchOrDetection); - UiManager::GetInstance()->PushView(batchTransmissionScreen->GetView()); - sendCurrentPager(); - - FlipperDolphin::Deed(DolphinDeedSubGhzSend); - } - - void resendSingle(uint32_t) { - StoredPagerData* pager = getPager(); - uint32_t frequency = FrequencyManager::GetInstance()->GetFrequency(pager->frequency); - subghz->Transmit(protocol->CreatePayload(pager->data, pager->te, config->SignalRepeats), frequency); - - FlipperDolphin::Deed(DolphinDeedSubGhzSend); - } - - void sendAction(PagerAction action) { - StoredPagerData* pager = getPager(); - uint32_t frequency = FrequencyManager::GetInstance()->GetFrequency(pager->frequency); - subghz->Transmit( - protocol->CreatePayload(decoder->SetAction(pager->data, action), pager->te, config->SignalRepeats), frequency - ); - - FlipperDolphin::Deed(DolphinDeedSubGhzSend); - } - - void sendCurrentPager() { - StoredPagerData* pager = getPager(); - batchTransmissionScreen->SetProgress(currentPager, config->MaxPagerForBatchOrDetection); - subghz->Transmit( - protocol->CreatePayload(decoder->SetPager(pager->data, currentPager), pager->te, config->SignalRepeats), - currentBatchFrequency - ); - } - - void txComplete() { - if(transmittingBatch) { - if(++currentPager <= config->MaxPagerForBatchOrDetection) { - sendCurrentPager(); - return; - } else { - transmittingBatch = false; - UiManager::GetInstance()->PopView(false); - } - } - - subghz->DefaultAfterTransmissionHandler(); - } - - void onReturn() { - transmittingBatch = false; - } - - void destroy() { - subghz->SetTransmitCompleteHandler(NULL); - for(size_t i = 0; i < decoder->GetSupportedActionsCount(); i++) { - delete actionsStrings[i]; - } - delete[] actionsStrings; - delete this; - } - -public: - UiView* GetView() { - return submenu; - } -}; diff --git a/applications/system/chief_cooker/app/screen/ScanStationsScreen.hpp b/applications/system/chief_cooker/app/screen/ScanStationsScreen.hpp deleted file mode 100644 index 7a866a20..00000000 --- a/applications/system/chief_cooker/app/screen/ScanStationsScreen.hpp +++ /dev/null @@ -1,282 +0,0 @@ -#pragma once - -#include "SettingsScreen.hpp" -#include "lib/hardware/subghz/data/SubGhzReceivedDataStub.hpp" -#include "lib/ui/view/ColumnOrientedListUiView.hpp" - -#include "EditPagerScreen.hpp" -#include "PagerActionsScreen.hpp" - -#include "lib/hardware/subghz/SubGhzModule.hpp" - -#include "app/AppConfig.hpp" -#include "app/AppNotifications.hpp" -#include "app/pager/PagerReceiver.hpp" - -static int8_t stationScreenColumnOffsets[]{ - 3, // station name (if known) - 3, // hex - 49, // station - 72, // pager - 94, // action - 128 - 8 // repeats / edit flag -}; -static Font stationScreenColumnFonts[]{ - FontSecondary, // station name (if known) - FontBatteryPercent, // hex - FontSecondary, // station - FontSecondary, // pager - FontBatteryPercent, // action - FontBatteryPercent, // repeats -}; - -static Align stationScreenColumnAlignments[]{ - AlignLeft, // station name (if known) - AlignLeft, // hex - AlignCenter, // station - AlignCenter, // pager - AlignCenter, // action - AlignRight, // repeats -}; - -class ScanStationsScreen { -private: - AppConfig* config; - ColumnOrientedListUiView* menuView; - PagerReceiver* pagerReceiver; - SubGhzModule* subghz; - bool receiveMode = false; - bool updateUserCategory = true; - int scanForMoreButtonIndex = -1; - uint32_t fromFilePagersCount = 0; - -public: - ScanStationsScreen(AppConfig* config) : ScanStationsScreen(config, true, NotSelected, NULL) { - } - - ScanStationsScreen(AppConfig* config, CategoryType categoryType, const char* category) : - ScanStationsScreen(config, false, categoryType, category) { - } - - ScanStationsScreen(AppConfig* config, bool receiveNew, CategoryType categoryType, const char* category) { - this->config = config; - - menuView = new ColumnOrientedListUiView( - stationScreenColumnOffsets, - sizeof(stationScreenColumnOffsets), - HANDLER_3ARG(&ScanStationsScreen::getElementColumnName) - ); - menuView->SetOnDestroyHandler(HANDLER(&ScanStationsScreen::destroy)); - menuView->SetOnReturnToViewHandler([this]() { this->menuView->Refresh(); }); - menuView->SetGoBackHandler(HANDLER(&ScanStationsScreen::goBack)); - - menuView->SetColumnFonts(stationScreenColumnFonts); - menuView->SetColumnAlignments(stationScreenColumnAlignments); - - menuView->SetLeftButton("Conf", HANDLER_1ARG(&ScanStationsScreen::showConfig)); - - subghz = new SubGhzModule(config->Frequency); - subghz->SetReceiveHandler(HANDLER_1ARG(&ScanStationsScreen::receive)); - if(receiveNew) { - subghz->SetReceiveAfterTransmission(true); - subghz->ReceiveAsync(); - } - - pagerReceiver = new PagerReceiver(config); - if(categoryType == User) { - pagerReceiver->SetUserCategory(category); - updateUserCategory = false; - - if(category != NULL) { - menuView->SetRightButton("Delete category", HANDLER_1ARG(&ScanStationsScreen::deleteCategory)); - } - } else { - pagerReceiver->ReloadKnownStations(); - } - - if(receiveNew) { - if(subghz->IsExternal()) { - menuView->SetNoElementCaption("Receiving via EXT..."); - } else { - menuView->SetNoElementCaption("Receiving..."); - } - } else { - menuView->SetNoElementCaption("No stations found!"); - } - - if(!receiveNew) { - pagerReceiver->LoadStationsFromDirectory(categoryType, category, HANDLER_1ARG(&ScanStationsScreen::pagerAdded)); - - if(categoryType == User && menuView->GetElementsCount() > 0) { - scanForMoreButtonIndex = menuView->GetElementsCount(); - fromFilePagersCount = menuView->GetElementsCount(); - menuView->AddElement(); - } - } - - receiveMode = receiveNew; - } - - UiView* GetView() { - return menuView; - } - -private: - void receive(SubGhzReceivedData* data) { - pagerAdded(pagerReceiver->Receive(data)); - delete data; - } - - void pagerAdded(ReceivedPagerData* pagerData) { - if(pagerData != NULL) { - if(pagerData->IsNew()) { - if(receiveMode) { - Notification::Play(&NOTIFICATION_PAGER_RECEIVE); - } - - if(pagerData->GetIndex() == 0) { // add buttons after capturing the first transmission - menuView->SetCenterButton("Actions", HANDLER_1ARG(&ScanStationsScreen::showActions)); - menuView->SetRightButton("Edit", HANDLER_1ARG(&ScanStationsScreen::editPagerMessage)); - } - - if(!receiveMode || scanForMoreButtonIndex == -1) { - menuView->AddElement(); - } else { - scanForMoreButtonIndex = -1; - } - } - - if(menuView->IsOnTop()) { - menuView->Refresh(); - } - - delete pagerData; - } - } - - void getElementColumnName(int index, int column, String* str) { - StoredPagerData* pagerData = pagerReceiver->PagerGetter(index)(); - PagerDecoder* decoder = pagerReceiver->decoders[pagerData->decoder]; - String* name = pagerReceiver->GetName(pagerData); - - if(index == scanForMoreButtonIndex) { - if(column == 0) { - if(!receiveMode) { - str->format("> Scan here for more"); - } else { - str->format("Scanning..."); - } - } - return; - } - - switch(column) { - case 0: // station name - if(name != NULL) { - str->format("%s", name->cstr()); - } - break; - - case 1: // hex - if(name == NULL) { - str->format("%06X", pagerData->data); - } - break; - - case 2: // station - if(name == NULL) { - str->format("%d", decoder->GetStation(pagerData->data)); - } - break; - - case 3: // pager - str->format("%d", decoder->GetPager(pagerData->data)); - break; - - case 4: // action - { - PagerAction action = decoder->GetAction(pagerData->data); - if(action == UNKNOWN) { - str->format("%d", decoder->GetActionValue(pagerData->data)); - } else { - str->format("%.4s", PagerActions::GetDescription(action)); - } - }; break; - - case 5: // repeats or edit flag - if(pagerData->edited) { - str->format("**"); - } else if(receiveMode) { - str->format("x%d", pagerData->repeats); - } - break; - - default: - break; - } - } - - void showConfig(uint32_t) { - SettingsScreen* screen = new SettingsScreen(config, pagerReceiver, subghz, updateUserCategory); - UiManager::GetInstance()->PushView(screen->GetView()); - } - - void editPagerMessage(uint32_t index) { - if((int)index == scanForMoreButtonIndex) { - return; - } - - PagerDataGetter getPager = pagerReceiver->PagerGetter(index); - EditPagerScreen* screen = new EditPagerScreen(config, subghz, pagerReceiver, getPager, index < fromFilePagersCount); - UiManager::GetInstance()->PushView(screen->GetView()); - } - - void showActions(uint32_t index) { - if((int)index == scanForMoreButtonIndex) { - if(!receiveMode) { - subghz->SetReceiveAfterTransmission(true); - subghz->ReceiveAsync(); - - receiveMode = true; - } - return; - } - - PagerDataGetter getPager = pagerReceiver->PagerGetter(index); - StoredPagerData* pagerData = getPager(); - PagerDecoder* decoder = pagerReceiver->decoders[pagerData->decoder]; - PagerProtocol* protocol = pagerReceiver->protocols[pagerData->protocol]; - - PagerActionsScreen* screen = new PagerActionsScreen(config, getPager, decoder, protocol, subghz); - UiManager::GetInstance()->PushView(screen->GetView()); - } - - bool goBack() { - if(receiveMode && menuView->GetElementsCount() > 0) { - DialogUiView* confirmGoBack = new DialogUiView("Really stop scan?", "You may loose captured signals"); - confirmGoBack->AddLeftButton("No"); - confirmGoBack->AddRightButton("Yes"); - confirmGoBack->SetResultHandler(HANDLER_1ARG(&ScanStationsScreen::goBackConfirmationHandler)); - UiManager::GetInstance()->PushView(confirmGoBack); - return false; - } - return true; - } - - void deleteCategory(int) { - AppFileSysytem().DeleteCategory(pagerReceiver->GetCurrentUserCategory()); - menuView->SetRightButton("Deleted", NULL); - } - - void goBackConfirmationHandler(DialogExResult dialogResult) { - if(dialogResult == DialogExResultRight) { - UiManager::GetInstance()->PopView(false); - } - } - - void destroy() { - delete subghz; - delete pagerReceiver; - delete this; - } -}; diff --git a/applications/system/chief_cooker/app/screen/SelectCategoryScreen.hpp b/applications/system/chief_cooker/app/screen/SelectCategoryScreen.hpp deleted file mode 100644 index f8a93544..00000000 --- a/applications/system/chief_cooker/app/screen/SelectCategoryScreen.hpp +++ /dev/null @@ -1,88 +0,0 @@ -#pragma once - -#include "app/AppFileSystem.hpp" -#include "lib/ui/UiManager.hpp" -#include "lib/ui/view/SubMenuUiView.hpp" -#include "lib/ui/view/TextInputUiView.hpp" - -#define MIN_CAT_NAME_LENGTH 2 -#define MAX_CAT_NAME_LENGTH MAX_FILENAME_LENGTH - -class SelectCategoryScreen { -private: - SubMenuUiView* menu; - CategoryType categoryType; - forward_list categories; - function categorySelectedHandler; - TextInputUiView* nameInput; - char* categoryAddedName; - -public: - SelectCategoryScreen( - bool canCreateNew, - CategoryType categoryType, - function categorySelectedHandler - ) { - this->categoryType = categoryType; - this->categorySelectedHandler = categorySelectedHandler; - - menu = new SubMenuUiView("Select category"); - menu->SetOnDestroyHandler(HANDLER(&SelectCategoryScreen::destory)); - - if(canCreateNew) { - menu->AddItem("+ Create NEW", HANDLER_1ARG(&SelectCategoryScreen::createNew)); - } - - if(categoryType == User) { - menu->AddItem("", [categoryType, categorySelectedHandler](uint32_t) { - return categorySelectedHandler(categoryType, NULL); - }); - } - - AppFileSysytem().GetCategories(&categories, categoryType); - for(char* category : categories) { - addCategory(category); - } - } - - UiView* GetView() { - return menu; - } - -private: - void createNew(uint32_t) { - if(categoryAddedName != NULL) { - categorySelectedHandler(categoryType, categoryAddedName); - return; - } - if(nameInput == NULL) { - nameInput = new TextInputUiView("Enter category name", MIN_CAT_NAME_LENGTH, MAX_CAT_NAME_LENGTH); - nameInput->SetOnDestroyHandler([this]() { this->nameInput = NULL; }); - nameInput->SetResultHandler(HANDLER_1ARG(&SelectCategoryScreen::addAndSelectCategory)); - } - UiManager::GetInstance()->PushView(nameInput); - } - - void addCategory(char* name) { - menu->AddItem(name, [this, name](uint32_t) { return this->categorySelectedHandler(this->categoryType, name); }); - } - - void addAndSelectCategory(char* name) { - categoryAddedName = name; - menu->SetItemLabel(0, name); - UiManager::GetInstance()->PopView(true); - } - - void destory() { - while(!categories.empty()) { - delete[] categories.front(); - categories.pop_front(); - } - - if(nameInput != NULL) { - delete nameInput; - } - - delete this; - } -}; diff --git a/applications/system/chief_cooker/app/screen/SettingsScreen.hpp b/applications/system/chief_cooker/app/screen/SettingsScreen.hpp deleted file mode 100644 index 815e3ebb..00000000 --- a/applications/system/chief_cooker/app/screen/SettingsScreen.hpp +++ /dev/null @@ -1,177 +0,0 @@ -#pragma once - -#include "SelectCategoryScreen.hpp" -#include "app/AppConfig.hpp" -#include "app/pager/PagerReceiver.hpp" -#include "lib/String.hpp" -#include "lib/hardware/subghz/SubGhzModule.hpp" -#include "lib/ui/UiManager.hpp" -#include "lib/ui/view/VariableItemListUiView.hpp" - -class SettingsScreen { -private: - AppConfig* config; - SubGhzModule* subghz; - PagerReceiver* receiver; - VariableItemListUiView* varItemList; - - UiVariableItem* currentCategoryItem; - UiVariableItem* frequencyItem; - UiVariableItem* maxPagerItem; - UiVariableItem* signalRepeatItem; - UiVariableItem* ignoreSavedItem; - UiVariableItem* autosaveFoundItem; - UiVariableItem* debugModeItem; - - String frequencyStr; - String maxPagerStr; - String signalRepeatStr; - bool updateUserCategory; - uint32_t categoryItemIndex; - -public: - SettingsScreen(AppConfig* config, PagerReceiver* receiver, SubGhzModule* subghz, bool updateUserCategory) { - this->config = config; - this->receiver = receiver; - this->subghz = subghz; - this->updateUserCategory = updateUserCategory; - - varItemList = new VariableItemListUiView(); - varItemList->SetOnDestroyHandler(HANDLER(&SettingsScreen::destroy)); - varItemList->SetEnterPressHandler(HANDLER_1ARG(&SettingsScreen::enterPressHandler)); - - categoryItemIndex = varItemList->AddItem( - currentCategoryItem = new UiVariableItem("Category", HANDLER_1ARG(&SettingsScreen::categoryChangedHandler)) - ); - - varItemList->AddItem( - frequencyItem = new UiVariableItem( - "Scan frequency", - FrequencyManager::GetInstance()->GetFrequencyIndex(config->Frequency), - FrequencyManager::GetInstance()->GetFrequencyCount(), - [this](uint8_t val) { - uint32_t freq = this->config->Frequency = FrequencyManager::GetInstance()->GetFrequency(val); - this->subghz->SetReceiveFrequency(this->config->Frequency); - return frequencyStr.format("%lu.%02lu", freq / 1000000, (freq % 1000000) / 10000); - } - ) - ); - - varItemList->AddItem( - maxPagerItem = new UiVariableItem( - "Max pager value", - config->MaxPagerForBatchOrDetection - 1, - UINT8_MAX, - [this](uint8_t val) { - this->config->MaxPagerForBatchOrDetection = val + 1; - return maxPagerStr.fromInt(this->config->MaxPagerForBatchOrDetection); - } - ) - ); - - varItemList->AddItem( - signalRepeatItem = new UiVariableItem( - "Times to repeat signal", - config->SignalRepeats - 1, - UINT8_MAX, - [this](uint8_t val) { - this->config->SignalRepeats = val + 1; - return signalRepeatStr.fromInt(this->config->SignalRepeats); - } - ) - ); - - varItemList->AddItem( - ignoreSavedItem = new UiVariableItem( - "Saved stations", - config->SavedStrategy, - SavedStationStrategyValuesCount, - [this](uint8_t val) { - this->config->SavedStrategy = static_cast(val); - return savedStationsStrategy(this->config->SavedStrategy); - } - ) - ); - - varItemList->AddItem( - autosaveFoundItem = new UiVariableItem( - "Autosave found signals", - config->AutosaveFoundSignals, - 2, - [this](uint8_t val) { - this->config->AutosaveFoundSignals = val; - return boolOption(val); - } - ) - ); - } - - UiView* GetView() { - return varItemList; - } - -private: - void enterPressHandler(uint32_t index) { - if(index != categoryItemIndex) { - return; - } - UiManager::GetInstance()->PushView( - (new SelectCategoryScreen(false, User, HANDLER_2ARG(&SettingsScreen::categorySelected)))->GetView() - ); - } - - void categorySelected(CategoryType, const char* category) { - if(config->CurrentUserCategory != NULL) { - delete config->CurrentUserCategory; - } - config->CurrentUserCategory = category != NULL ? new String("%s", category) : NULL; - UiManager::GetInstance()->PopView(false); - currentCategoryItem->Refresh(); - } - - const char* categoryChangedHandler(uint8_t) { - const char* category = config->GetCurrentUserCategoryCstr(); - if(category == NULL) { - category = "Default"; - } - return category; - } - - const char* boolOption(uint8_t value) { - return value ? "ON" : "OFF"; - } - - const char* savedStationsStrategy(SavedStationStrategy value) { - switch(value) { - case IGNORE: - return "Ignore"; - - case SHOW_NAME: - return "Show name"; - - case HIDE: - return "Hide"; - - default: - return NULL; - } - } - - void destroy() { - config->Save(); - if(updateUserCategory) { - receiver->SetUserCategory(config->CurrentUserCategory); - receiver->ReloadKnownStations(); - } - - delete currentCategoryItem; - delete frequencyItem; - delete maxPagerItem; - delete signalRepeatItem; - delete ignoreSavedItem; - delete autosaveFoundItem; - delete debugModeItem; - - delete this; - } -}; diff --git a/applications/system/chief_cooker/application.fam b/applications/system/chief_cooker/application.fam deleted file mode 100644 index 5df136b5..00000000 --- a/applications/system/chief_cooker/application.fam +++ /dev/null @@ -1,17 +0,0 @@ -# For details & more options, see documentation/AppManifests.md in firmware repo - -App( - appid="chief_cooker", # Must be unique - name="Chief Cooker", # Displayed in menus - apptype=FlipperAppType.EXTERNAL, - entry_point="chief_cooker_app", - stack_size=2 * 1024, - fap_category="Sub-GHz", - # Optional values - # fap_version="0.1", - fap_icon="chief_cooker.png", # 10x10 1-bit PNG - # fap_description="A simple app", - fap_author="Denr01", - fap_weburl="https://github.com/denr01/FZ-ChiefCooker", - fap_icon_assets="images", # Image assets to compile for this application -) diff --git a/applications/system/chief_cooker/chief_cooker.cpp b/applications/system/chief_cooker/chief_cooker.cpp deleted file mode 100644 index 8f0a0b1f..00000000 --- a/applications/system/chief_cooker/chief_cooker.cpp +++ /dev/null @@ -1,13 +0,0 @@ -/* generated by fbt from .png files in images folder */ -#include - -#include "app/App.hpp" - -extern "C" int32_t chief_cooker_app(void* p) { - UNUSED(p); - - App app; - app.Run(); - - return 0; -} diff --git a/applications/system/chief_cooker/chief_cooker.png b/applications/system/chief_cooker/chief_cooker.png deleted file mode 100644 index f43beb3c..00000000 Binary files a/applications/system/chief_cooker/chief_cooker.png and /dev/null differ diff --git a/applications/system/chief_cooker/images/.gitkeep b/applications/system/chief_cooker/images/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/applications/system/chief_cooker/instructions/instructions.md b/applications/system/chief_cooker/instructions/instructions.md deleted file mode 100644 index 23c1a533..00000000 --- a/applications/system/chief_cooker/instructions/instructions.md +++ /dev/null @@ -1,127 +0,0 @@ -# Usage instructions - -## Installation -To install this app simply download the `.fap` file from [latest release](https://github.com/denr01/FZ-ChiefCooker/releases/latest). - -Then just copy it to your flipper (to `ext/apps/Sub-GHz` folder). - -On your flipper, open up Apps -> Sub-GHz and you should see it there. Just open it as a regular app. - -## Tutorial - -### Your first use -Imagine you are on a food court you want to become chief on. - -First, open the app and select "Scan for station signals". - -The app will start receiving signals and show you once it receives something - - - -Okay, now you received something. Now, let's test if transmission decoded correctly and find the restaurant who sent the transmission! - -To do this, click on center button (actions) and select the first one, "Resend to ALL": - - Description - -Where are they all running? Is the dinner ready yet? Unfortunately it's not. Just their new chief is learning... - -Let's assume that you somehow found out, that it was a restaurant called "Street Food" who sent the signal. Now let's save it's signal to your SD card. - -Go back from actions and push the "Edit >" (right arrow) button. Then scroll down to "Save signal as...", give it a name and then create a new category for it. It's convenient to use restaurant name for signal name and mall (or food court/place name where restaurant are located) for the category name to make sure that signals from different places will not mess up. - - - - - -Congratulations! Your saved your first captured signal and now can use it anytime you want to call someone to the restaurant's food pickup. - -But it would be great now to distinguish the signals from "Street Food" from the other ones. And you can do it! - -Navigate to "< Config" (left button) and select the category to the newly created one. Then go back. - - - - - -As you can see, now instead of hex value and station number there is a restaurant name you given to the signal. - -And what's this? A new signal? Yes, but not completely new. Street Food just called pager with another number (7). But your flipper successfully recognized their signal because you already saved one to the current category and showed you it's name. - - - -### Your second use - -Now imagine you came to the same food court next day and want to call somebody's pager at the Street Food restaurant (that your saved yesterday). - -Navigate to "Saved stations" and then select the category of current place / mall / food court: - - - -Here your will see your saved signal: - - - -Now your can do with it whatever you want exactly like when you captured it. - -Let's assume now you need to call only single pager with number 9. - -Go to "Edit >" menu, scroll down to "Pager" and change it value to 9. Now just press center button. Your flipper will blink purple LED - like when you were resending to all pagers, remember? This means that it sent the signal. - - - -Now imagine we want to receive more signals here. There are two ways to do it: -- Go to "Scan" menu like on your first usage -- Click on "Scan here for more". - -The second way is better because you will have all you previously saved signals in quick access in cause you urgently need one of them. New signals will appear here once your flipper receive them. - - - -Congratulations! You have successfully completed the tutorial! ~~Now go and troll someone real.~~ - -## App's screens explanation - -### Scan stations screen - - - -The values here are: -- `CBC042` - signal hex code -- `815` - station number (in current encoding) -- `4` - pager number (in current encoding) -- `RING` - action (in current encoding) -- `x8` - number of signal repeats, will not show more than `x99` - -_Note: if you change the signal's encoding in "Edit" menu, station number, pager and action here will also change._ - -### Edit station screen - -There are several things you can edit in captured signal using "Edit >" menu. - -First thing is **encoding**. App tries to detect encoding automatically when it receives signal. But in some cases you may need to specify it manually. Here you can change the encoding and see how the values (station number, pager number and action) are changing in real-time: - - - -Also you may need to change pager or action value. You can do it here and see how the hex value changes in real time: - - - -_Note: pager number is editable only if it's decoded value is less than 255 in current encoding_ - -**Also note: pressing the center button on anywhere on the edit screen (except for save as / delete options) will trigger signal transmission with current pager/action/hex value!** - -### Config screen - - - -Here some description about config parameters: -- **Category** - the category to load saved station names from. Does not affect if you use option "Scan here for more" in saved stations screen. -- **Scan frequency** - the frequency to receive signals on. For EU/Russia default is 433.92 Mhz, but 315.00 Mhz and 467.75 Mhz may be also used in US or somewhere else. -- **Max pager value** - how many pagers should signal be sent to when using "Resend to ALL" action. Also affects automatic encoding detection feature: the algorithm will use the first encoding which will give a pager number less or equal than current setting value. -- **Times to repeat signal** - speaks for itself, don't recommend changing it as the default value (10) should work in most cases. -- **Saved stations** - what to do when receive a signal from known station (saved in current category). Possible values are: - 1. **Ignore** - treat station as unknown, show signal hex and station number. - 2. **Show name** (default) - show saved station name instead of hex value and station number - 3. **Hide** - do not show signals from saved stations at all. Show only unknown signals -- **Autosave found signals** - any found signals will be saved to "Autosaved" folder in the subdirectory with current date. Useful in case app crashes or you accidentally close it without saving. diff --git a/applications/system/chief_cooker/instructions/screenshots/edit-decode-1.png b/applications/system/chief_cooker/instructions/screenshots/edit-decode-1.png deleted file mode 100644 index 4a40c5f0..00000000 Binary files a/applications/system/chief_cooker/instructions/screenshots/edit-decode-1.png and /dev/null differ diff --git a/applications/system/chief_cooker/instructions/screenshots/edit-decode-2.png b/applications/system/chief_cooker/instructions/screenshots/edit-decode-2.png deleted file mode 100644 index e7cc97ab..00000000 Binary files a/applications/system/chief_cooker/instructions/screenshots/edit-decode-2.png and /dev/null differ diff --git a/applications/system/chief_cooker/instructions/screenshots/edit-decode-3.png b/applications/system/chief_cooker/instructions/screenshots/edit-decode-3.png deleted file mode 100644 index ff623b84..00000000 Binary files a/applications/system/chief_cooker/instructions/screenshots/edit-decode-3.png and /dev/null differ diff --git a/applications/system/chief_cooker/instructions/screenshots/edit-pager-1.png b/applications/system/chief_cooker/instructions/screenshots/edit-pager-1.png deleted file mode 100644 index 071d8ed8..00000000 Binary files a/applications/system/chief_cooker/instructions/screenshots/edit-pager-1.png and /dev/null differ diff --git a/applications/system/chief_cooker/instructions/screenshots/edit-pager-2.png b/applications/system/chief_cooker/instructions/screenshots/edit-pager-2.png deleted file mode 100644 index f8cffb9f..00000000 Binary files a/applications/system/chief_cooker/instructions/screenshots/edit-pager-2.png and /dev/null differ diff --git a/applications/system/chief_cooker/instructions/screenshots/main-saved.png b/applications/system/chief_cooker/instructions/screenshots/main-saved.png deleted file mode 100644 index 285f8d15..00000000 Binary files a/applications/system/chief_cooker/instructions/screenshots/main-saved.png and /dev/null differ diff --git a/applications/system/chief_cooker/instructions/screenshots/main-scan.png b/applications/system/chief_cooker/instructions/screenshots/main-scan.png deleted file mode 100644 index 07194a2f..00000000 Binary files a/applications/system/chief_cooker/instructions/screenshots/main-scan.png and /dev/null differ diff --git a/applications/system/chief_cooker/instructions/screenshots/pager-9.png b/applications/system/chief_cooker/instructions/screenshots/pager-9.png deleted file mode 100644 index 9e4acfd9..00000000 Binary files a/applications/system/chief_cooker/instructions/screenshots/pager-9.png and /dev/null differ diff --git a/applications/system/chief_cooker/instructions/screenshots/saved-by-you.png b/applications/system/chief_cooker/instructions/screenshots/saved-by-you.png deleted file mode 100644 index 710865ca..00000000 Binary files a/applications/system/chief_cooker/instructions/screenshots/saved-by-you.png and /dev/null differ diff --git a/applications/system/chief_cooker/instructions/screenshots/saved-category-scan-here.png b/applications/system/chief_cooker/instructions/screenshots/saved-category-scan-here.png deleted file mode 100644 index 7e30c66f..00000000 Binary files a/applications/system/chief_cooker/instructions/screenshots/saved-category-scan-here.png and /dev/null differ diff --git a/applications/system/chief_cooker/instructions/screenshots/saved-category-scanning-new.png b/applications/system/chief_cooker/instructions/screenshots/saved-category-scanning-new.png deleted file mode 100644 index bc2d991f..00000000 Binary files a/applications/system/chief_cooker/instructions/screenshots/saved-category-scanning-new.png and /dev/null differ diff --git a/applications/system/chief_cooker/instructions/screenshots/saved-category-scanning.png b/applications/system/chief_cooker/instructions/screenshots/saved-category-scanning.png deleted file mode 100644 index b94667ec..00000000 Binary files a/applications/system/chief_cooker/instructions/screenshots/saved-category-scanning.png and /dev/null differ diff --git a/applications/system/chief_cooker/instructions/screenshots/saved-category.png b/applications/system/chief_cooker/instructions/screenshots/saved-category.png deleted file mode 100644 index bc77e84f..00000000 Binary files a/applications/system/chief_cooker/instructions/screenshots/saved-category.png and /dev/null differ diff --git a/applications/system/chief_cooker/instructions/screenshots/scan-capture1-actions.png b/applications/system/chief_cooker/instructions/screenshots/scan-capture1-actions.png deleted file mode 100644 index fb778d53..00000000 Binary files a/applications/system/chief_cooker/instructions/screenshots/scan-capture1-actions.png and /dev/null differ diff --git a/applications/system/chief_cooker/instructions/screenshots/scan-capture1-categories-with-new.png b/applications/system/chief_cooker/instructions/screenshots/scan-capture1-categories-with-new.png deleted file mode 100644 index 51e39643..00000000 Binary files a/applications/system/chief_cooker/instructions/screenshots/scan-capture1-categories-with-new.png and /dev/null differ diff --git a/applications/system/chief_cooker/instructions/screenshots/scan-capture1-categories.png b/applications/system/chief_cooker/instructions/screenshots/scan-capture1-categories.png deleted file mode 100644 index b8d6953c..00000000 Binary files a/applications/system/chief_cooker/instructions/screenshots/scan-capture1-categories.png and /dev/null differ diff --git a/applications/system/chief_cooker/instructions/screenshots/scan-capture1-category-name.png b/applications/system/chief_cooker/instructions/screenshots/scan-capture1-category-name.png deleted file mode 100644 index f8198bc9..00000000 Binary files a/applications/system/chief_cooker/instructions/screenshots/scan-capture1-category-name.png and /dev/null differ diff --git a/applications/system/chief_cooker/instructions/screenshots/scan-capture1-conf-cat-selected.png b/applications/system/chief_cooker/instructions/screenshots/scan-capture1-conf-cat-selected.png deleted file mode 100644 index 821663ee..00000000 Binary files a/applications/system/chief_cooker/instructions/screenshots/scan-capture1-conf-cat-selected.png and /dev/null differ diff --git a/applications/system/chief_cooker/instructions/screenshots/scan-capture1-conf-select-cat.png b/applications/system/chief_cooker/instructions/screenshots/scan-capture1-conf-select-cat.png deleted file mode 100644 index dd3c04d7..00000000 Binary files a/applications/system/chief_cooker/instructions/screenshots/scan-capture1-conf-select-cat.png and /dev/null differ diff --git a/applications/system/chief_cooker/instructions/screenshots/scan-capture1-config.png b/applications/system/chief_cooker/instructions/screenshots/scan-capture1-config.png deleted file mode 100644 index 67a4ae59..00000000 Binary files a/applications/system/chief_cooker/instructions/screenshots/scan-capture1-config.png and /dev/null differ diff --git a/applications/system/chief_cooker/instructions/screenshots/scan-capture1-edit-save.png b/applications/system/chief_cooker/instructions/screenshots/scan-capture1-edit-save.png deleted file mode 100644 index 58991811..00000000 Binary files a/applications/system/chief_cooker/instructions/screenshots/scan-capture1-edit-save.png and /dev/null differ diff --git a/applications/system/chief_cooker/instructions/screenshots/scan-capture1-resend.png b/applications/system/chief_cooker/instructions/screenshots/scan-capture1-resend.png deleted file mode 100644 index 51dd8a75..00000000 Binary files a/applications/system/chief_cooker/instructions/screenshots/scan-capture1-resend.png and /dev/null differ diff --git a/applications/system/chief_cooker/instructions/screenshots/scan-capture1-save-name.png b/applications/system/chief_cooker/instructions/screenshots/scan-capture1-save-name.png deleted file mode 100644 index ac15b7f8..00000000 Binary files a/applications/system/chief_cooker/instructions/screenshots/scan-capture1-save-name.png and /dev/null differ diff --git a/applications/system/chief_cooker/instructions/screenshots/scan-capture1-with-name.png b/applications/system/chief_cooker/instructions/screenshots/scan-capture1-with-name.png deleted file mode 100644 index a43a8ebb..00000000 Binary files a/applications/system/chief_cooker/instructions/screenshots/scan-capture1-with-name.png and /dev/null differ diff --git a/applications/system/chief_cooker/instructions/screenshots/scan-capture1.png b/applications/system/chief_cooker/instructions/screenshots/scan-capture1.png deleted file mode 100644 index de489f45..00000000 Binary files a/applications/system/chief_cooker/instructions/screenshots/scan-capture1.png and /dev/null differ diff --git a/applications/system/chief_cooker/instructions/screenshots/scan-capture2.png b/applications/system/chief_cooker/instructions/screenshots/scan-capture2.png deleted file mode 100644 index 5a6cb319..00000000 Binary files a/applications/system/chief_cooker/instructions/screenshots/scan-capture2.png and /dev/null differ diff --git a/applications/system/chief_cooker/instructions/screenshots/scan-empty.png b/applications/system/chief_cooker/instructions/screenshots/scan-empty.png deleted file mode 100644 index eeed9342..00000000 Binary files a/applications/system/chief_cooker/instructions/screenshots/scan-empty.png and /dev/null differ diff --git a/applications/system/chief_cooker/lib/FlipperDolphin.hpp b/applications/system/chief_cooker/lib/FlipperDolphin.hpp deleted file mode 100644 index 554d7aca..00000000 --- a/applications/system/chief_cooker/lib/FlipperDolphin.hpp +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#include - -class FlipperDolphin { -private: -public: - static void Deed(DolphinDeed deed) { - dolphin_deed(deed); - } -}; diff --git a/applications/system/chief_cooker/lib/HandlerContext.hpp b/applications/system/chief_cooker/lib/HandlerContext.hpp deleted file mode 100644 index f5e0fb38..00000000 --- a/applications/system/chief_cooker/lib/HandlerContext.hpp +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once - -#define HANDLER(handlerMethod) bind(handlerMethod, this) -#define HANDLER_1ARG(handlerMethod) bind(handlerMethod, this, placeholders::_1) -#define HANDLER_2ARG(handlerMethod) bind(handlerMethod, this, placeholders::_1, placeholders::_2) -#define HANDLER_3ARG(handlerMethod) bind(handlerMethod, this, placeholders::_1, placeholders::_2, placeholders::_3) - -template -class HandlerContext { -private: - T handler; - -public: - HandlerContext(T handler) { - this->handler = handler; - } - - T GetHandler() { - return handler; - } -}; - -template -class HandlerContextExt : public HandlerContext { -private: - void* extContext; - -public: - HandlerContextExt(T handler, void* extContext) : HandlerContext(handler) { - this->extContext = extContext; - } - - void* GetExtContext() { - return extContext; - } -}; diff --git a/applications/system/chief_cooker/lib/String.hpp b/applications/system/chief_cooker/lib/String.hpp deleted file mode 100644 index 35d70656..00000000 --- a/applications/system/chief_cooker/lib/String.hpp +++ /dev/null @@ -1,53 +0,0 @@ -#pragma once - -#include - -class String { -private: - FuriString* string; - -public: - String() { - string = furi_string_alloc(); - } - - String(const char* format, ...) { - va_list args; - va_start(args, format); - string = furi_string_alloc_vprintf(format, args); - va_end(args); - } - - FuriString* furiString() { - return string; - } - - const char* cstr() { - return furi_string_get_cstr(string); - } - - const char* fromInt(int value) { - return format("%d", value); - } - - const char* format(const char* format, ...) { - va_list args; - va_start(args, format); - furi_string_vprintf(string, format, args); - va_end(args); - - return cstr(); - } - - bool isEmpty() { - return furi_string_empty(string); - } - - void Reset() { - furi_string_reset(string); - } - - ~String() { - furi_string_free(string); - } -}; diff --git a/applications/system/chief_cooker/lib/file/Directory.hpp b/applications/system/chief_cooker/lib/file/Directory.hpp deleted file mode 100644 index 6ad10b82..00000000 --- a/applications/system/chief_cooker/lib/file/Directory.hpp +++ /dev/null @@ -1,63 +0,0 @@ -#pragma once - -#include -#include - -class Directory { -private: - bool isOpened; - Storage* storage; - File* dir; - -public: - Directory(Storage* storage, const char* dirPath) { - this->storage = storage; - dir = storage_file_alloc(storage); - isOpened = storage_dir_open(dir, dirPath); - } - - bool IsOpened() { - return isOpened; - } - - void Rewind() { - if(isOpened) { - storage_dir_rewind(dir); - } - } - - bool GetNextFile(char* name, uint16_t nameLength) { - if(!isOpened) { - return false; - } - - FileInfo fileInfo = FileInfo(); - do { - if(!storage_dir_read(dir, &fileInfo, name, nameLength)) { - return false; - } - } while((fileInfo.flags & FSF_DIRECTORY) > 0); // dir - - return true; - } - - bool GetNextDir(char* name, uint16_t nameLength) { - if(!isOpened) { - return false; - } - - FileInfo fileInfo = FileInfo(); - do { - if(!storage_dir_read(dir, &fileInfo, name, nameLength)) { - return false; - } - } while((fileInfo.flags & FSF_DIRECTORY) == 0); // not dir - - return true; - } - - ~Directory() { - storage_dir_close(dir); - storage_file_free(dir); - } -}; diff --git a/applications/system/chief_cooker/lib/file/FileManager.hpp b/applications/system/chief_cooker/lib/file/FileManager.hpp deleted file mode 100644 index 393e31c0..00000000 --- a/applications/system/chief_cooker/lib/file/FileManager.hpp +++ /dev/null @@ -1,74 +0,0 @@ -#pragma once - -#include "lib/String.hpp" -#include -#include - -#include "FlipperFile.hpp" -#include "Directory.hpp" - -class FileManager { -private: - Storage* storage; - -public: - FileManager() { - storage = (Storage*)furi_record_open(RECORD_STORAGE); - } - - void CreateDirIfNotExists(const char* path) { - if(!storage_dir_exists(storage, path)) { - storage_common_mkdir(storage, path); - } - } - - Directory* OpenDirectory(const char* path) { - Directory* dir = new Directory(storage, path); - if(dir->IsOpened()) { - return dir; - } - delete dir; - return NULL; - } - - FlipperFile* OpenRead(const char* path) { - FlipperFile* file = new FlipperFile(storage, path, false); - if(file->IsOpened()) { - return file; - } - delete file; - return NULL; - } - - FlipperFile* OpenRead(const char* dir, const char* file) { - String concatedPath = String("%s/%s", dir, file); - return OpenRead(concatedPath.cstr()); - } - - FlipperFile* OpenWrite(const char* path) { - FlipperFile* file = new FlipperFile(storage, path, true); - if(file->IsOpened()) { - return file; - } - delete file; - return NULL; - } - - FlipperFile* OpenWrite(const char* dir, const char* file) { - String concatedPath = String("%s/%s", dir, file); - return OpenWrite(concatedPath.cstr()); - } - - void DeleteFile(const char* dir, const char* file) { - String concatedPath = String("%s/%s", dir, file); - DeleteFile(concatedPath.cstr()); - } - - void DeleteFile(const char* filePath) { - storage_common_remove(storage, filePath); - } - - ~FileManager() { - furi_record_close(RECORD_STORAGE); - } -}; diff --git a/applications/system/chief_cooker/lib/file/FlipperFile.hpp b/applications/system/chief_cooker/lib/file/FlipperFile.hpp deleted file mode 100644 index a0fe3b37..00000000 --- a/applications/system/chief_cooker/lib/file/FlipperFile.hpp +++ /dev/null @@ -1,61 +0,0 @@ -#pragma once - -#include "flipper_format.h" -#include "lib/String.hpp" - -class FlipperFile { -private: - bool isOpened; - FlipperFormat* flipperFormat; - -public: - FlipperFile(Storage* storage, const char* path, bool write) { - flipperFormat = flipper_format_file_alloc(storage); - if(write) { - isOpened = flipper_format_file_open_always(flipperFormat, path); - } else { - isOpened = flipper_format_file_open_existing(flipperFormat, path); - } - } - - bool IsOpened() { - return isOpened; - } - - bool ReadUInt32(const char* key, uint32_t* valueTarget) { - return flipper_format_read_uint32(flipperFormat, key, valueTarget, 1); - } - - bool ReadBool(const char* key, bool* valueTarget) { - return flipper_format_read_bool(flipperFormat, key, valueTarget, 1); - } - - bool ReadString(const char* key, String* valueTarget) { - return flipper_format_read_string(flipperFormat, key, valueTarget->furiString()); - } - - bool ReadHex(const char* key, uint64_t* value) { - return flipper_format_read_hex(flipperFormat, key, (uint8_t*)value, sizeof(value)); - } - - bool WriteUInt32(const char* key, uint32_t value) { - return flipper_format_write_uint32(flipperFormat, key, &value, 1); - } - - bool WriteBool(const char* key, bool value) { - return flipper_format_write_bool(flipperFormat, key, &value, 1); - } - - bool WriteString(const char* key, const char* value) { - return flipper_format_write_string_cstr(flipperFormat, key, value); - } - - bool WriteHex(const char* key, uint64_t value) { - return flipper_format_write_hex(flipperFormat, key, (const uint8_t*)&value, sizeof(value)); - } - - ~FlipperFile() { - flipper_format_file_close(flipperFormat); - flipper_format_free(flipperFormat); - } -}; diff --git a/applications/system/chief_cooker/lib/hardware/notification/Notification.hpp b/applications/system/chief_cooker/lib/hardware/notification/Notification.hpp deleted file mode 100644 index dab25e21..00000000 --- a/applications/system/chief_cooker/lib/hardware/notification/Notification.hpp +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#include -#include -#include - -static NotificationApp* __notification_app_instance = NULL; - -class Notification { -private: - static NotificationApp* getApp() { - if(__notification_app_instance == NULL) { - __notification_app_instance = (NotificationApp*)furi_record_open(RECORD_NOTIFICATION); - } - return __notification_app_instance; - } - -public: - static void Play(const NotificationSequence* nullTerminatedSequence) { - notification_message(getApp(), nullTerminatedSequence); - } - - static void Dispose() { - if(__notification_app_instance != NULL) { - furi_record_close(RECORD_NOTIFICATION); - __notification_app_instance = NULL; - } - } -}; diff --git a/applications/system/chief_cooker/lib/hardware/subghz/FrequencyManager.hpp b/applications/system/chief_cooker/lib/hardware/subghz/FrequencyManager.hpp deleted file mode 100644 index 9b5539c9..00000000 --- a/applications/system/chief_cooker/lib/hardware/subghz/FrequencyManager.hpp +++ /dev/null @@ -1,66 +0,0 @@ -#pragma once - -#include "lib/subghz/subghz_setting.h" - -static void* __freq_manager_instance = NULL; - -class FrequencyManager { -private: - uint32_t* frequencies; - uint8_t frequencyCount; - uint8_t defaultFreqIndex; - - FrequencyManager() { - SubGhzSetting* setting = subghz_setting_alloc(); - subghz_setting_load(setting, EXT_PATH("subghz/assets/setting_user")); - - frequencyCount = subghz_setting_get_frequency_count(setting); - defaultFreqIndex = subghz_setting_get_frequency_default_index(setting); - frequencies = new uint32_t[frequencyCount]; - - for(int i = 0; i < frequencyCount; i++) { - frequencies[i] = subghz_setting_get_frequency(setting, i); - } - - subghz_setting_free(setting); - } - -public: - static FrequencyManager* GetInstance() { - if(__freq_manager_instance == NULL) { - __freq_manager_instance = new FrequencyManager(); - } - return (FrequencyManager*)__freq_manager_instance; - } - - uint32_t GetFrequency(size_t index) { - return frequencies[index]; - } - - uint32_t GetDefaultFrequency() { - return frequencies[defaultFreqIndex]; - } - - size_t GetDefaultFrequencyIndex() { - return defaultFreqIndex; - } - - size_t GetFrequencyIndex(uint32_t freq) { - for(size_t i = 0; i < GetFrequencyCount(); i++) { - if(GetFrequency(i) == freq) { - return i; - } - } - return GetDefaultFrequencyIndex(); - } - - size_t GetFrequencyCount() { - return frequencyCount; - } - - ~FrequencyManager() { - if(frequencies != NULL) { - delete[] frequencies; - } - } -}; diff --git a/applications/system/chief_cooker/lib/hardware/subghz/SubGhzModule.hpp b/applications/system/chief_cooker/lib/hardware/subghz/SubGhzModule.hpp deleted file mode 100644 index 5cba16c3..00000000 --- a/applications/system/chief_cooker/lib/hardware/subghz/SubGhzModule.hpp +++ /dev/null @@ -1,287 +0,0 @@ -#pragma once - -#include "lib/hardware/subghz/SubGhzPayload.hpp" -#include - -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "SubGhzState.hpp" -#include "data/SubGhzReceivedDataImpl.hpp" - -#include "lib/hardware/notification/Notification.hpp" - -using namespace std; - -#undef LOG_TAG -#define LOG_TAG "SUB_GHZ" - -class SubGhzModule { -private: - SubGhzEnvironment* environment; - const SubGhzDevice* device; - SubGhzReceiver* receiver; - SubGhzWorker* worker; - SubGhzTransmitter* transmitter; - function receiveHandler; - FuriTimer* txCompleteCheckTimer; - function txCompleteHandler; - int repeatsLeft = 0; - SubGhzPayload* currentPayload; - uint32_t receiveFrequency = 0; - - bool isExternal; - SubGhzState state = IDLE; - bool receiveAfterTransmission = false; - - static void captureCallback(SubGhzReceiver* receiver, SubGhzProtocolDecoderBase* decoderBase, void* context) { - UNUSED(receiver); - - if(context == NULL) { - return; - } - - SubGhzModule* subghz = (SubGhzModule*)context; - if(subghz->receiveHandler != NULL) { - subghz->receiveHandler(new SubGhzReceivedDataImpl(decoderBase, subghz->receiveFrequency)); - } - } - - static void txCompleteCheckCallback(void* context) { - SubGhzModule* subghz = (SubGhzModule*)context; - if(subghz_devices_is_async_complete_tx(subghz->device)) { - if(subghz->repeatsLeft-- > 0 && subghz->currentPayload != NULL) { - subghz->startTransmission(0); - return; - } - - furi_timer_stop(subghz->txCompleteCheckTimer); - - if(subghz->txCompleteHandler != NULL) { - subghz->txCompleteHandler(); - } else { - subghz->DefaultAfterTransmissionHandler(); - } - } - } - - void prepareReceiver() { - receiver = subghz_receiver_alloc_init(environment); - subghz_receiver_set_filter(receiver, SubGhzProtocolFlag_Decodable); - subghz_receiver_set_rx_callback(receiver, captureCallback, this); - - worker = subghz_worker_alloc(); - subghz_worker_set_overrun_callback(worker, (SubGhzWorkerOverrunCallback)subghz_receiver_reset); - subghz_worker_set_pair_callback(worker, (SubGhzWorkerPairCallback)subghz_receiver_decode); - subghz_worker_set_context(worker, receiver); - } - - void setFrequencyIgnoringStateChecks(uint32_t frequency) { - if(subghz_devices_is_frequency_valid(device, frequency)) { - subghz_devices_set_frequency(device, frequency); - } - } - -public: - SubGhzModule(uint32_t frequency) { - environment = subghz_environment_alloc(); - subghz_environment_set_protocol_registry(environment, &subghz_protocol_registry); - - subghz_devices_init(); - furi_hal_power_enable_otg(); - device = subghz_devices_get_by_name(SUBGHZ_DEVICE_CC1101_EXT_NAME); - if(!subghz_devices_is_connect(device)) { - furi_hal_power_disable_otg(); - device = subghz_devices_get_by_name(SUBGHZ_DEVICE_CC1101_INT_NAME); - isExternal = false; - } else { - isExternal = true; - } - - subghz_devices_begin(device); - subghz_devices_load_preset(device, FuriHalSubGhzPresetOok650Async, NULL); - - SetReceiveFrequency(frequency); - - txCompleteCheckTimer = furi_timer_alloc(txCompleteCheckCallback, FuriTimerTypePeriodic, this); - } - - void SetReceiveFrequency(uint32_t frequency) { - if(receiveFrequency == frequency) { - return; - } else { - receiveFrequency = frequency; - } - - bool restoreReceive = state == RECEIVING; - PutToIdle(); - - setFrequencyIgnoringStateChecks(frequency); - - if(restoreReceive) { - ReceiveAsync(); - } - } - - void SetReceiveAfterTransmission(bool value) { - this->receiveAfterTransmission = value; - } - - void DefaultAfterTransmissionHandler() { - if(receiveAfterTransmission) { - ReceiveAsync(); - } else { - PutToIdle(); - } - } - - void SetReceiveHandler(function handler) { - receiveHandler = handler; - } - - void ReceiveAsync() { - if(receiver == NULL) { - prepareReceiver(); - } - - PutToIdle(); - - setFrequencyIgnoringStateChecks(receiveFrequency); - - subghz_devices_flush_rx(device); - subghz_devices_start_async_rx(device, (void*)subghz_worker_rx_callback, worker); - subghz_worker_start(worker); - - state = RECEIVING; - } - - void SetTransmitCompleteHandler(function txCompleteHandler) { - this->txCompleteHandler = txCompleteHandler; - } - - void Transmit(SubGhzPayload* payload, uint32_t frequency) { - if(state != TRANSMITTING) { - PutToIdle(); - state = TRANSMITTING; - } else { - furi_timer_stop(txCompleteCheckTimer); - delete currentPayload; - } - - Notification::Play(&sequence_blink_start_magenta); - - currentPayload = payload; - repeatsLeft = payload->GetRequiredSofwareRepeats() - 1; - - startTransmission(frequency); - - uint32_t interval = furi_kernel_get_tick_frequency() / 100; // every 10 ms - furi_timer_start(txCompleteCheckTimer, interval); - } - -private: - void startTransmission(uint32_t frequency) { - stopTransmission(); - - if(frequency > 0) { - setFrequencyIgnoringStateChecks(frequency); - } - - transmitter = subghz_transmitter_alloc_init(environment, currentPayload->GetProtocol()); - subghz_transmitter_deserialize(transmitter, currentPayload->GetFlipperFormat()); - subghz_devices_flush_tx(device); - subghz_devices_start_async_tx(device, (void*)subghz_transmitter_yield, transmitter); - } - - void stopTransmission() { - if(transmitter != NULL) { - subghz_devices_stop_async_tx(device); - subghz_transmitter_free(transmitter); - transmitter = NULL; - } - } - -public: - void StopReceive() { - subghz_worker_stop(worker); - subghz_devices_stop_async_rx(device); - subghz_devices_idle(device); - state = IDLE; - } - - void StopTranmit() { - Notification::Play(&sequence_blink_stop); - - repeatsLeft = 0; - delete currentPayload; - - furi_timer_stop(txCompleteCheckTimer); - stopTransmission(); - subghz_devices_idle(device); - - state = IDLE; - } - - void PutToIdle() { - switch(state) { - case RECEIVING: - StopReceive(); - break; - - case TRANSMITTING: - StopTranmit(); - break; - - default: - case IDLE: - break; - } - } - - bool IsExternal() { - return isExternal; - } - - ~SubGhzModule() { - PutToIdle(); - - if(txCompleteCheckTimer != NULL) { - furi_timer_free(txCompleteCheckTimer); - } - - if(furi_hal_power_is_otg_enabled()) { - furi_hal_power_disable_otg(); - } - - if(worker != NULL) { - subghz_worker_free(worker); - worker = NULL; - } - - if(receiver != NULL) { - subghz_receiver_free(receiver); - receiver = NULL; - } - - if(environment != NULL) { - subghz_environment_free(environment); - environment = NULL; - } - - if(device != NULL) { - subghz_devices_end(device); - subghz_devices_deinit(); - device = NULL; - } - } -}; diff --git a/applications/system/chief_cooker/lib/hardware/subghz/SubGhzPayload.hpp b/applications/system/chief_cooker/lib/hardware/subghz/SubGhzPayload.hpp deleted file mode 100644 index 74be7cad..00000000 --- a/applications/system/chief_cooker/lib/hardware/subghz/SubGhzPayload.hpp +++ /dev/null @@ -1,65 +0,0 @@ -#pragma once - -#include -#include "flipper_format.h" - -using namespace std; - -#undef LOG_TAG -#define LOG_TAG "SG_PLD" - -class SubGhzPayload { -private: - const char* protocol; - FlipperFormat* flipperFormat; - int requiredSoftwareRepeats = 1; - -public: - SubGhzPayload(const char* protocol) { - this->protocol = protocol; - - flipperFormat = flipper_format_string_alloc(); - flipper_format_write_string_cstr(flipperFormat, "Protocol", protocol); - } - - void SetKey(uint64_t key) { - char* dataBytes = (char*)&key; - reverse(dataBytes, dataBytes + sizeof(key)); - flipper_format_write_hex(flipperFormat, "Key", (const uint8_t*)dataBytes, sizeof(key)); - } - - void SetBits(uint32_t bits) { - flipper_format_write_uint32(flipperFormat, "Bit", &bits, 1); - } - - void SetTE(uint32_t te) { - flipper_format_write_uint32(flipperFormat, "TE", &te, 1); - } - - void SetRepeat(uint32_t repeats) { - flipper_format_write_uint32(flipperFormat, "Repeat", &repeats, 1); - } - - void SetSoftwareRepeats(uint32_t repeats) { - this->requiredSoftwareRepeats = repeats; - } - - FlipperFormat* GetFlipperFormat() { - return flipperFormat; - } - - int GetRequiredSofwareRepeats() { - return requiredSoftwareRepeats; - } - - const char* GetProtocol() { - return protocol; - } - - ~SubGhzPayload() { - if(flipperFormat != NULL) { - flipper_format_free(flipperFormat); - flipperFormat = NULL; - } - } -}; diff --git a/applications/system/chief_cooker/lib/hardware/subghz/SubGhzState.hpp b/applications/system/chief_cooker/lib/hardware/subghz/SubGhzState.hpp deleted file mode 100644 index 1f15f292..00000000 --- a/applications/system/chief_cooker/lib/hardware/subghz/SubGhzState.hpp +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -enum SubGhzState { - IDLE, - RECEIVING, - TRANSMITTING, -}; diff --git a/applications/system/chief_cooker/lib/hardware/subghz/data/SubGhzReceivedData.hpp b/applications/system/chief_cooker/lib/hardware/subghz/data/SubGhzReceivedData.hpp deleted file mode 100644 index c615a021..00000000 --- a/applications/system/chief_cooker/lib/hardware/subghz/data/SubGhzReceivedData.hpp +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -#include - -class SubGhzReceivedData { -public: - virtual const char* GetProtocolName() = 0; - virtual uint32_t GetHash() = 0; - virtual ~SubGhzReceivedData() {}; - virtual int GetTE() = 0; - virtual uint32_t GetFrequency() = 0; -}; diff --git a/applications/system/chief_cooker/lib/hardware/subghz/data/SubGhzReceivedDataImpl.hpp b/applications/system/chief_cooker/lib/hardware/subghz/data/SubGhzReceivedDataImpl.hpp deleted file mode 100644 index 059e5f57..00000000 --- a/applications/system/chief_cooker/lib/hardware/subghz/data/SubGhzReceivedDataImpl.hpp +++ /dev/null @@ -1,47 +0,0 @@ -#pragma once - -#include - -#include "SubGhzReceivedData.hpp" - -class SubGhzReceivedDataImpl : public SubGhzReceivedData { -private: - uint32_t frequency; - SubGhzProtocolDecoderBase* decoder; - -public: - SubGhzReceivedDataImpl(SubGhzProtocolDecoderBase* decoder, uint32_t frequency) { - this->frequency = frequency; - this->decoder = decoder; - } - - const char* GetProtocolName() { - return decoder->protocol->name; - } - - uint32_t GetHash() { - return decoder->protocol->decoder->get_hash_data(decoder); - } - - int GetTE() { - FuriString* dataString = furi_string_alloc(); - decoder->protocol->decoder->get_string(decoder, dataString); - - const char* tePrefix = "Te:"; - size_t teStart = furi_string_search_str(dataString, tePrefix, 0); - if(teStart == FURI_STRING_FAILURE) { - return -1; - } - - const char* cstr = furi_string_get_cstr(dataString); - const char* startPtr = cstr + teStart + strlen(tePrefix); - int te = strtol(startPtr, NULL, 10); - furi_string_free(dataString); - - return te; - } - - uint32_t GetFrequency() { - return frequency; - } -}; diff --git a/applications/system/chief_cooker/lib/hardware/subghz/data/SubGhzReceivedDataStub.hpp b/applications/system/chief_cooker/lib/hardware/subghz/data/SubGhzReceivedDataStub.hpp deleted file mode 100644 index cebf0156..00000000 --- a/applications/system/chief_cooker/lib/hardware/subghz/data/SubGhzReceivedDataStub.hpp +++ /dev/null @@ -1,40 +0,0 @@ -#pragma once - -#include - -#include "SubGhzReceivedData.hpp" - -class SubGhzReceivedDataStub : public SubGhzReceivedData { -private: - const char* protocolName; - uint32_t frequency; - uint32_t hash; - int te; - -public: - SubGhzReceivedDataStub(const char* protocolName, uint32_t hash) : SubGhzReceivedDataStub(protocolName, 433920000, hash, 212) { - } - - SubGhzReceivedDataStub(const char* protocolName, uint32_t frequency, uint32_t hash, int te) { - this->protocolName = protocolName; - this->frequency = frequency; - this->hash = hash; - this->te = te; - } - - const char* GetProtocolName() { - return protocolName; - } - - uint32_t GetHash() { - return hash; - } - - int GetTE() { - return te; - } - - uint32_t GetFrequency() { - return frequency; - } -}; diff --git a/applications/system/chief_cooker/lib/ui/UiManager.hpp b/applications/system/chief_cooker/lib/ui/UiManager.hpp deleted file mode 100644 index 7ee4da2d..00000000 --- a/applications/system/chief_cooker/lib/ui/UiManager.hpp +++ /dev/null @@ -1,139 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -#include "view/UiView.hpp" - -#undef LOG_TAG -#define LOG_TAG "UI_MGR" - -using namespace std; - -static void* __ui_manager_instance = NULL; - -class UiManager { -private: - Gui* gui = NULL; - ViewDispatcher* viewDispatcher = NULL; - forward_list viewStack; - uint8_t viewStackSize = 0; - - uint32_t loadingId = 9999; - Loading* loading = NULL; - - UiManager() { - } - - static uint32_t backCallback(void*) { - UiManager* uiManager = GetInstance(); - UiView* currentView = uiManager->viewStack.front(); - if(currentView->GoBack()) { - uiManager->PopView(false); - } - return uiManager->currentViewId(); - } - - uint32_t currentViewId() { - if(viewStack.empty()) { - return VIEW_NONE; - } - return viewStackSize; - } - - void freeLoading() { - if(loading != NULL) { - view_dispatcher_remove_view(viewDispatcher, loadingId); - loading_free(loading); - loading = NULL; - } - } - - void showView(uint32_t viewId) { - freeLoading(); - view_dispatcher_switch_to_view(viewDispatcher, viewId); - } - -public: - void ShowLoading() { - if(loading == NULL) { - loading = loading_alloc(); - View* loadingView = loading_get_view(loading); - view_dispatcher_add_view(viewDispatcher, loadingId, loadingView); - view_dispatcher_switch_to_view(viewDispatcher, loadingId); - } - } - - static UiManager* GetInstance() { - if(__ui_manager_instance == NULL) { - __ui_manager_instance = new UiManager(); - } - return (UiManager*)__ui_manager_instance; - } - - void InitGui() { - gui = (Gui*)furi_record_open(RECORD_GUI); - viewDispatcher = view_dispatcher_alloc(); - view_dispatcher_attach_to_gui(viewDispatcher, gui, ViewDispatcherTypeFullscreen); - } - - void PushView(UiView* view) { - if(!viewStack.empty()) { - viewStack.front()->SetOnTop(false); - } - - viewStackSize++; - viewStack.push_front(view); - view->SetOnTop(true); - - view_set_previous_callback(view->GetNativeView(), backCallback); - view_dispatcher_add_view(viewDispatcher, currentViewId(), view->GetNativeView()); - showView(currentViewId()); - } - - void PopView(bool preserveView) { - UiView* currentView = viewStack.front(); - currentView->SetOnTop(false); - view_dispatcher_remove_view(viewDispatcher, currentViewId()); - viewStack.pop_front(); - viewStackSize--; - - if(!viewStack.empty()) { - UiView* viewReturningTo = viewStack.front(); - viewReturningTo->SetOnTop(true); - viewReturningTo->OnReturn(); - } - - showView(currentViewId()); - - if(!preserveView) { - delete currentView; - } - } - - void RunEventLoop() { - while(!viewStack.empty()) { - view_dispatcher_run(viewDispatcher); - } - } - - ~UiManager() { - while(!viewStack.empty()) { - PopView(false); - } - - freeLoading(); - - if(viewDispatcher != NULL) { - view_dispatcher_free(viewDispatcher); - viewDispatcher = NULL; - } - - if(gui != NULL) { - furi_record_close(RECORD_GUI); - gui = NULL; - } - } -}; diff --git a/applications/system/chief_cooker/lib/ui/view/ColumnOrientedListUiView.hpp b/applications/system/chief_cooker/lib/ui/view/ColumnOrientedListUiView.hpp deleted file mode 100644 index 63d0a31c..00000000 --- a/applications/system/chief_cooker/lib/ui/view/ColumnOrientedListUiView.hpp +++ /dev/null @@ -1,281 +0,0 @@ -#pragma once - -#include -#include -#include - -#include "UiView.hpp" -#include "lib/String.hpp" - -#undef LOG_TAG -#define LOG_TAG "UI_ADV_SUBMENU" - -using namespace std; - -// Inspired by https://github.com/flipperdevices/flipperzero-firmware/blob/dev/applications/main/subghz/views/receiver.c - -#define FRAME_HEIGHT 12 -#define ITEMS_ON_SCREEN 4 - -class ColumnOrientedListUiView : public UiView { -private: - View* view = NULL; - const char* noElementsCapton = NULL; - - const char* leftButtonCaption = NULL; - const char* ceneterButtonCaption = NULL; - const char* rightButtonCaption = NULL; - - function leftButtonPress = NULL; - function centerButtonPress = NULL; - function rightButtonPress = NULL; - - int listOffset = 0; - int selectedIndex = 0; - int elementsCount = 0; - - int8_t columnCount; - int8_t* columnOffsets; - Font* columnFonts = NULL; - Align* columnAlignments = NULL; - - function getColumnElementName; - -public: - ColumnOrientedListUiView( - int8_t* columnOffsets, - int8_t columnCount, - function columnElementNameGetter - ) { - this->columnCount = columnCount; - this->columnOffsets = columnOffsets; - this->getColumnElementName = columnElementNameGetter; - - view = view_alloc(); - view_set_context(view, this); - - view_set_draw_callback(view, drawCallback); - view_set_input_callback(view, inputCallback); - view_set_enter_callback(view, enterCallback); - view_set_exit_callback(view, exitCallback); - - view_allocate_model(view, ViewModelTypeLockFree, sizeof(UiVIewPointerViewModel*)); - with_view_model_cpp(view, UiVIewPointerViewModel*, model, model->uiVIew = this;, false); - } - - void SetNoElementCaption(const char* noElementsCapton) { - this->noElementsCapton = noElementsCapton; - } - - void SetColumnFonts(Font* columnFonts) { - this->columnFonts = columnFonts; - } - - void SetColumnAlignments(Align* columnAlignments) { - this->columnAlignments = columnAlignments; - } - - void SetLeftButton(const char* caption, function pressHandler) { - leftButtonCaption = caption; - leftButtonPress = pressHandler; - } - - void SetCenterButton(const char* caption, function pressHandler) { - ceneterButtonCaption = caption; - centerButtonPress = pressHandler; - } - - void SetRightButton(const char* caption, function pressHandler) { - rightButtonCaption = caption; - rightButtonPress = pressHandler; - } - - void AddElement() { - if(elementsCount == 0 || selectedIndex == elementsCount - 1) { - if(IsOnTop()) { - setIndex(elementsCount); - } - } - elementsCount++; - } - - void Refresh() { - view_commit_model(view, true); - } - - View* GetNativeView() { - return view; - } - - int GetElementsCount() { - return elementsCount; - } - - ~ColumnOrientedListUiView() { - if(view != NULL) { - OnDestory(); - view_free_model(view); - view_free(view); - view = NULL; - } - } - -private: - void draw(Canvas* canvas) { - if(!IsOnTop()) { - return; - } - - canvas_clear(canvas); - canvas_set_color(canvas, ColorBlack); - canvas_set_font(canvas, FontSecondary); - - if(leftButtonCaption != NULL) elements_button_left(canvas, leftButtonCaption); - if(ceneterButtonCaption != NULL) elements_button_center(canvas, ceneterButtonCaption); - if(rightButtonCaption != NULL) elements_button_right(canvas, rightButtonCaption); - - if(elementsCount == 0 && noElementsCapton != NULL) { - int wCenter = canvas_width(canvas) / 2; - int hCenter = canvas_height(canvas) / 2; - canvas_set_font(canvas, FontPrimary); - canvas_draw_str_aligned(canvas, wCenter, hCenter, AlignCenter, AlignCenter, noElementsCapton); - canvas_set_font(canvas, FontSecondary); - } - - String stringBuffer; - bool scrollbar = elementsCount > 4; - - for(int i = 0; i < MIN(elementsCount, ITEMS_ON_SCREEN); i++) { - int idx = CLAMP(i + listOffset, elementsCount, 0); - - if(selectedIndex == idx) { - canvas_set_color(canvas, ColorBlack); - canvas_draw_box(canvas, 0, 0 + i * FRAME_HEIGHT, scrollbar ? 122 : 127, FRAME_HEIGHT); - - canvas_set_color(canvas, ColorWhite); - canvas_draw_dot(canvas, 0, 0 + i * FRAME_HEIGHT); - canvas_draw_dot(canvas, 1, 0 + i * FRAME_HEIGHT); - canvas_draw_dot(canvas, 0, (0 + i * FRAME_HEIGHT) + 1); - - canvas_draw_dot(canvas, 0, (0 + i * FRAME_HEIGHT) + 11); - canvas_draw_dot(canvas, scrollbar ? 121 : 126, 0 + i * FRAME_HEIGHT); - canvas_draw_dot(canvas, scrollbar ? 121 : 126, (0 + i * FRAME_HEIGHT) + 11); - } else { - canvas_set_color(canvas, ColorBlack); - } - - for(int8_t column = 0; column < columnCount; column++) { - if(columnFonts != NULL) { - canvas_set_font(canvas, columnFonts[column]); - } - - int8_t columnOffset = columnOffsets[column]; - getColumnElementName(idx, column, &stringBuffer); - // elements_string_fit_width(canvas, stringBuffer.furiString(), maxWidth); - - if(columnAlignments == NULL) { - canvas_draw_str(canvas, columnOffset, 9 + i * FRAME_HEIGHT, stringBuffer.cstr()); - } else { - canvas_draw_str_aligned( - canvas, columnOffset, 9 + i * FRAME_HEIGHT, columnAlignments[column], AlignBottom, stringBuffer.cstr() - ); - } - - canvas_set_font(canvas, FontSecondary); - - stringBuffer.Reset(); - } - } - - if(scrollbar) { - elements_scrollbar_pos(canvas, 128, 0, 49, selectedIndex, elementsCount); - } - } - - bool input(InputEvent* event) { - switch(event->key) { - case InputKeyUp: - if(event->type == InputTypePress || event->type == InputTypeRepeat) { - if(selectedIndex == 0) { - setIndex(elementsCount - 1); - } else { - setIndex(selectedIndex - 1); - } - return true; - } - break; - - case InputKeyDown: - if(event->type == InputTypePress || event->type == InputTypeRepeat) { - if(selectedIndex >= elementsCount - 1) { - setIndex(0); - } else { - setIndex(selectedIndex + 1); - } - return true; - } - break; - - case InputKeyLeft: - if(event->type == InputTypePress && leftButtonPress != NULL) { - leftButtonPress(selectedIndex); - return true; - } - break; - - case InputKeyOk: - if(event->type == InputTypePress && centerButtonPress != NULL) { - centerButtonPress(selectedIndex); - return true; - } - break; - - case InputKeyRight: - if(event->type == InputTypePress && rightButtonPress != NULL) { - rightButtonPress(selectedIndex); - return true; - } - break; - - default: - break; - } - - return false; - } - - void setIndex(int index) { - selectedIndex = index; - - int bounds = elementsCount > 3 ? 2 : elementsCount; - if(elementsCount > 3 && selectedIndex >= elementsCount - 1) { - listOffset = selectedIndex - 3; - } else if(listOffset < selectedIndex - bounds) { - listOffset = CLAMP(listOffset + 1, elementsCount - bounds, 0); - } else if(listOffset > selectedIndex - bounds) { - listOffset = CLAMP(selectedIndex - 1, elementsCount - bounds, 0); - } - } - - static void drawCallback(Canvas* canvas, void* model) { - ColumnOrientedListUiView* uiView = (ColumnOrientedListUiView*)((UiVIewPointerViewModel*)model)->uiVIew; - uiView->draw(canvas); - } - - static bool inputCallback(InputEvent* event, void* context) { - ColumnOrientedListUiView* uiView = (ColumnOrientedListUiView*)context; - if(uiView->input(event)) { - uiView->Refresh(); - return true; - } - return false; - } - - static void enterCallback(void* context) { - UNUSED(context); - } - - static void exitCallback(void* context) { - UNUSED(context); - } -}; diff --git a/applications/system/chief_cooker/lib/ui/view/DialogUiView.hpp b/applications/system/chief_cooker/lib/ui/view/DialogUiView.hpp deleted file mode 100644 index 5733eb0a..00000000 --- a/applications/system/chief_cooker/lib/ui/view/DialogUiView.hpp +++ /dev/null @@ -1,54 +0,0 @@ -#pragma once - -#include -#include "lib/ui/UiManager.hpp" - -#include "UiView.hpp" - -class DialogUiView : public UiView { -private: - DialogEx* dialog; - function resultHandler; - - static void resultCallback(DialogExResult result, void* context) { - DialogUiView* dialog = (DialogUiView*)context; - if(dialog->resultHandler != NULL) { - dialog->resultHandler(result); - } - UiManager::GetInstance()->PopView(false); - } - -public: - DialogUiView(const char* header, const char* text) { - dialog = dialog_ex_alloc(); - dialog_ex_set_header(dialog, header, 128 / 2, 64 / 4, AlignCenter, AlignCenter); - dialog_ex_set_text(dialog, text, 128 / 2, 64 / 2, AlignCenter, AlignCenter); - } - - void AddLeftButton(const char* label) { - dialog_ex_set_left_button_text(dialog, label); - } - - void AddRightButton(const char* label) { - dialog_ex_set_right_button_text(dialog, label); - } - - void AddCenterButton(const char* label) { - dialog_ex_set_center_button_text(dialog, label); - } - - void SetResultHandler(function handler) { - resultHandler = handler; - dialog_ex_set_context(dialog, this); - dialog_ex_set_result_callback(dialog, resultCallback); - } - - View* GetNativeView() { - return dialog_ex_get_view(dialog); - } - - ~DialogUiView() { - OnDestory(); - dialog_ex_free(dialog); - } -}; diff --git a/applications/system/chief_cooker/lib/ui/view/ProgressbarPopupUiView.hpp b/applications/system/chief_cooker/lib/ui/view/ProgressbarPopupUiView.hpp deleted file mode 100644 index c7aaca22..00000000 --- a/applications/system/chief_cooker/lib/ui/view/ProgressbarPopupUiView.hpp +++ /dev/null @@ -1,73 +0,0 @@ -#pragma once - -#include "gui/elements.h" -#include -#include -#include - -#include "UiView.hpp" - -#undef LOG_TAG -#define LOG_TAG "UI_VARITEMLST" - -using namespace std; - -class ProgressbarPopupUiView : public UiView { -private: - View* view; - const char* header; - const char* progressText; - float progressValue = 0.0f; - -public: - ProgressbarPopupUiView(const char* header) { - this->header = header; - - view = view_alloc(); - view_set_context(view, this); - view_set_draw_callback(view, drawCallback); - view_allocate_model(view, ViewModelTypeLockFree, sizeof(ProgressbarPopupUiView*)); - with_view_model_cpp(view, UiVIewPointerViewModel*, model, model->uiVIew = this;, false); - } - - void draw(Canvas* canvas) { - canvas_clear(canvas); - canvas_set_color(canvas, ColorBlack); - - canvas_set_font(canvas, FontPrimary); - canvas_draw_str_aligned(canvas, 64, 22, AlignCenter, AlignCenter, header); - - canvas_set_font(canvas, FontSecondary); - elements_progress_bar_with_text(canvas, 4, 32, 120, progressValue, progressText); - } - - void SetProgress(const char* progressText, float progressValue) { - this->progressText = progressText; - this->progressValue = progressValue; - - Refresh(); - } - - void Refresh() { - view_commit_model(view, true); - } - - View* GetNativeView() { - return view; - } - - ~ProgressbarPopupUiView() { - if(view != NULL) { - OnDestory(); - view_free_model(view); - view_free(view); - view = NULL; - } - } - -private: - static void drawCallback(Canvas* canvas, void* model) { - ProgressbarPopupUiView* uiView = (ProgressbarPopupUiView*)((UiVIewPointerViewModel*)model)->uiVIew; - uiView->draw(canvas); - } -}; diff --git a/applications/system/chief_cooker/lib/ui/view/SubMenuUiView.hpp b/applications/system/chief_cooker/lib/ui/view/SubMenuUiView.hpp deleted file mode 100644 index 56c778ea..00000000 --- a/applications/system/chief_cooker/lib/ui/view/SubMenuUiView.hpp +++ /dev/null @@ -1,83 +0,0 @@ -#pragma once - -#include -#include -#include - -#include "UiView.hpp" -#include "lib/HandlerContext.hpp" -#include - -#undef LOG_TAG -#define LOG_TAG "UI_SUBMENU" - -using namespace std; - -class SubMenuUiView : public UiView { -private: - Submenu* menu; - uint32_t elementCount = 0; - forward_list>*> handlers; - - static void executeCallback(void* context, uint32_t index) { - if(context == NULL) { - return; - } - - HandlerContext>* handlerContext = (HandlerContext>*)context; - handlerContext->GetHandler()(index); - } - -public: - SubMenuUiView() { - menu = submenu_alloc(); - } - - SubMenuUiView(const char* header) : SubMenuUiView() { - SetHeader(header); - } - - void SetHeader(const char* header) { - submenu_set_header(menu, header); - } - - void AddItem(const char* label, function handler) { - AddItemAt(elementCount, label, handler); - } - - void AddItemAt(uint32_t index, const char* label, function handler) { - auto handlerContext = new HandlerContext(handler); - handlers.push_front(handlerContext); - submenu_add_item(menu, label, index, executeCallback, handlerContext); - elementCount++; - } - - void SetItemLabel(uint32_t index, const char* label) { - submenu_change_item_label(menu, index, label); - } - - void SetSelectedItem(uint32_t index) { - submenu_set_selected_item(menu, index); - } - - View* GetNativeView() { - return submenu_get_view(menu); - } - - uint32_t GetCurrentIndex() { - return submenu_get_selected_item(menu); - } - - ~SubMenuUiView() { - if(menu != NULL) { - OnDestory(); - - for(auto handlerContext : handlers) { - delete handlerContext; - } - - submenu_free(menu); - menu = NULL; - } - } -}; diff --git a/applications/system/chief_cooker/lib/ui/view/TextInputUiView.hpp b/applications/system/chief_cooker/lib/ui/view/TextInputUiView.hpp deleted file mode 100644 index a8eda70f..00000000 --- a/applications/system/chief_cooker/lib/ui/view/TextInputUiView.hpp +++ /dev/null @@ -1,52 +0,0 @@ -#pragma once - -#include "lib/String.hpp" -#include -#include -#include - -#include "UiView.hpp" - -class TextInputUiView : public UiView { -private: - TextInput* textInput; - char* textBuffer; - size_t bufferSize; - function inputHandler; - - static void inputCallback(void* context) { - TextInputUiView* instance = (TextInputUiView*)context; - if(instance->inputHandler != NULL) { - instance->inputHandler(instance->textBuffer); - } - } - -public: - TextInputUiView(const char* header, size_t minLength, size_t maxLength) { - textInput = text_input_alloc(); - text_input_set_header_text(textInput, header); - text_input_set_minimum_length(textInput, minLength); - textBuffer = new char[maxLength]; - bufferSize = maxLength; - } - - void SetDefaultText(String* text) { - strcpy(textBuffer, text->cstr()); - } - - void SetResultHandler(function handler) { - inputHandler = handler; - text_input_set_result_callback(textInput, inputCallback, this, textBuffer, bufferSize, false); - } - - View* GetNativeView() { - return text_input_get_view(textInput); - } - - ~TextInputUiView() { - OnDestory(); - - text_input_free(textInput); - delete[] textBuffer; - } -}; diff --git a/applications/system/chief_cooker/lib/ui/view/UiView.hpp b/applications/system/chief_cooker/lib/ui/view/UiView.hpp deleted file mode 100644 index 93444b1f..00000000 --- a/applications/system/chief_cooker/lib/ui/view/UiView.hpp +++ /dev/null @@ -1,66 +0,0 @@ -#pragma once - -#include - -#include -#include - -using namespace std; - -class UiView { -private: - function onDestroyHandler = NULL; - function onReturnToView = NULL; - function goBackHandler = NULL; - bool isOnTop = false; - -public: - virtual View* GetNativeView() = 0; - virtual ~UiView() { - } - - void SetOnDestroyHandler(function handler) { - onDestroyHandler = handler; - } - - void SetOnReturnToViewHandler(function handler) { - onReturnToView = handler; - } - - void SetGoBackHandler(function handler) { - goBackHandler = handler; - } - - void OnReturn() { - if(onReturnToView != NULL) { - onReturnToView(); - } - } - - bool IsOnTop() { - return isOnTop; - } - - void SetOnTop(bool value) { - this->isOnTop = value; - } - - bool GoBack() { - if(goBackHandler != NULL) { - return goBackHandler(); - } - return true; - } - -protected: - // Must be called from parent class destructor's! - void OnDestory() { - if(onDestroyHandler != NULL) { - onDestroyHandler(); - } - } -}; - -struct UiVIewPointerViewModel { - UiView* uiVIew; -}; diff --git a/applications/system/chief_cooker/lib/ui/view/VariableItemListUiView.hpp b/applications/system/chief_cooker/lib/ui/view/VariableItemListUiView.hpp deleted file mode 100644 index 88429be7..00000000 --- a/applications/system/chief_cooker/lib/ui/view/VariableItemListUiView.hpp +++ /dev/null @@ -1,53 +0,0 @@ -#pragma once - -#include -#include -#include - -#include "UiView.hpp" -#include "item/UiVariableItem.hpp" - -#undef LOG_TAG -#define LOG_TAG "UI_VARITEMLST" - -using namespace std; - -class VariableItemListUiView : public UiView { -private: - uint32_t itemCounter = 0; - VariableItemList* varItemList; - function enterPressHandler; - - static void onEnterCallback(void* context, uint32_t index) { - VariableItemListUiView* view = (VariableItemListUiView*)context; - view->enterPressHandler(index); - } - -public: - VariableItemListUiView() { - varItemList = variable_item_list_alloc(); - } - - uint32_t AddItem(UiVariableItem* item) { - item->AddTo(varItemList); - return itemCounter++; - } - - void SetEnterPressHandler(function handler) { - enterPressHandler = handler; - variable_item_list_set_enter_callback(varItemList, onEnterCallback, this); - } - - View* GetNativeView() { - return variable_item_list_get_view(varItemList); - } - - ~VariableItemListUiView() { - if(varItemList != NULL) { - OnDestory(); - - variable_item_list_free(varItemList); - varItemList = NULL; - } - } -}; diff --git a/applications/system/chief_cooker/lib/ui/view/item/UiVariableItem.hpp b/applications/system/chief_cooker/lib/ui/view/item/UiVariableItem.hpp deleted file mode 100644 index d9b6af0b..00000000 --- a/applications/system/chief_cooker/lib/ui/view/item/UiVariableItem.hpp +++ /dev/null @@ -1,68 +0,0 @@ -#pragma once - -#include - -#include "gui/modules/variable_item_list.h" - -using namespace std; - -class UiVariableItem { -private: - VariableItem* item = NULL; - const char* label; - - uint8_t selectedIndex; - uint8_t valuesCount; - - function changeHandler; - - static void itemChangeCallback(VariableItem* item) { - UiVariableItem* uiItem = (UiVariableItem*)variable_item_get_context(item); - uint8_t index = variable_item_get_current_value_index(item); - variable_item_set_current_value_text(item, uiItem->changeHandler(index)); - } - -public: - UiVariableItem(const char* label, const char* staticValue) : - UiVariableItem(label, [staticValue](uint8_t) { return staticValue; }) { - } - - UiVariableItem(const char* label, function changeHandler) : UiVariableItem(label, 0, 1, changeHandler) { - } - - UiVariableItem(const char* label, uint8_t selectedIndex, uint8_t valuesCount, function changeHandler) { - this->label = label; - this->selectedIndex = selectedIndex; - this->valuesCount = valuesCount; - this->changeHandler = changeHandler; - } - - void AddTo(VariableItemList* varItemList) { - item = variable_item_list_add(varItemList, label, valuesCount, itemChangeCallback, this); - Refresh(); - } - - void SetSelectedItem(uint8_t selectedIndex, uint8_t valuesCount) { - this->selectedIndex = selectedIndex; - this->valuesCount = valuesCount; - - Refresh(); - } - - void Refresh() { - if(item == NULL) { - return; - } - - variable_item_set_values_count(item, valuesCount); - variable_item_set_current_value_index(item, selectedIndex); - itemChangeCallback(item); - } - - bool Editable() { - return valuesCount > 1; - } - - ~UiVariableItem() { - } -}; diff --git a/applications/system/chief_cooker/scripts/add-to-vscode-tasks-json.txt b/applications/system/chief_cooker/scripts/add-to-vscode-tasks-json.txt deleted file mode 100644 index d085f8d8..00000000 --- a/applications/system/chief_cooker/scripts/add-to-vscode-tasks-json.txt +++ /dev/null @@ -1,6 +0,0 @@ - { - "label": "Build, Clear & Launch", - "group": "build", - "type": "shell", - "command": "python scripts/build-and-clear.py" - }, diff --git a/applications/system/chief_cooker/scripts/build-and-clear.py b/applications/system/chief_cooker/scripts/build-and-clear.py deleted file mode 100644 index 5ae219c9..00000000 --- a/applications/system/chief_cooker/scripts/build-and-clear.py +++ /dev/null @@ -1,33 +0,0 @@ -import os -import lief -import pathlib - -UFBT_PATH = pathlib.Path.home() / ".ufbt" - -FAP_LOCATION_AFTER_BUILD = "dist/chief_cooker.fap" -FAP_LOCATION_ON_FLIPPER = "/ext/apps/Sub-GHz/chief_cooker.fap" -OBJCOPY_PATH = UFBT_PATH / "toolchain/current/bin/arm-none-eabi-objcopy" - - -def clearSections(): - binary = lief.parse(FAP_LOCATION_AFTER_BUILD) - - for i, sect in enumerate(binary.sections): - if sect.name.find("_Z") >= 0: - newSectName = "_s%d" % i - cmd = '%s "%s" --rename-section %s=%s' % ( - OBJCOPY_PATH, - FAP_LOCATION_AFTER_BUILD, - sect.name, - newSectName, - ) - print("Renaming to %s from %s" % (newSectName, sect.name)) - os.system(cmd) - - -os.system("ufbt") -clearSections() -os.system( - "%s/toolchain/current/python/python %s/current/scripts/runfap.py -p auto -s %s -t %s" - % (UFBT_PATH, UFBT_PATH, FAP_LOCATION_AFTER_BUILD, FAP_LOCATION_ON_FLIPPER) -) diff --git a/applications/system/chief_cooker/todo-decode.txt b/applications/system/chief_cooker/todo-decode.txt deleted file mode 100644 index 1b6dd2e3..00000000 --- a/applications/system/chief_cooker/todo-decode.txt +++ /dev/null @@ -1,11 +0,0 @@ -8028a0 = 1000 0000 0010 1000 1010 0000 -84e8a0 = 1000 0100 1110 1000 1010 0000 - -e6f810 = 1110 0110 1111 1000 0001 0000 -e6b810 = 1110 0110 1011 1000 0001 0000 - -From https://dev.xcjs.com/r0073dl053r/flipper-playground/-/tree/main/Sub-GHz/Restaurant_Pagers/Retekess_Pagers/T111?ref_type=heads -Pager1 = A21080 = 1010 0010 0001 0000 1000 0000 -Pager2 = A21040 = 1010 0010 0001 0000 0100 0000 -last 8 bits reversed seems to be number -will name it L8R - Last 8 bits Reversed diff --git a/lib/subghz/protocols/allstar_firefly.c b/lib/subghz/protocols/allstar_firefly.c index 7430aa2a..99eecf24 100644 --- a/lib/subghz/protocols/allstar_firefly.c +++ b/lib/subghz/protocols/allstar_firefly.c @@ -276,21 +276,11 @@ void subghz_protocol_decoder_allstar_firefly_get_string(void* context, FuriStrin furi_assert(context); SubGhzProtocolDecoderAllstarFirefly* instance = context; - uint64_t code_found_reverse = subghz_protocol_blocks_reverse_key( - instance->generic.data, instance->generic.data_count_bit); - furi_string_cat_printf( output, - "%s %db\r\n" - "Key:0x%05lX Yek:0x%05lX\r\n" - " +: " DIP_PATTERN "\r\n" - " o: " DIP_PATTERN "\r\n" - " -: " DIP_PATTERN "\r\n", + "%s %dbit\r\n" + "Key:0x%05lX\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, - (uint32_t)(instance->generic.data & 0xFFFFF), - (uint32_t)(code_found_reverse & 0xFFFFF), - SHOW_DIP_P(instance->generic.data, DIP_P), - SHOW_DIP_P(instance->generic.data, DIP_O), - SHOW_DIP_P(instance->generic.data, DIP_N)); + (uint32_t)(instance->generic.data & 0xFFFFF)); } diff --git a/lib/subghz/protocols/alutech_at_4n.c b/lib/subghz/protocols/alutech_at_4n.c index 959e3dbd..21cc5059 100644 --- a/lib/subghz/protocols/alutech_at_4n.c +++ b/lib/subghz/protocols/alutech_at_4n.c @@ -916,16 +916,16 @@ void subghz_protocol_decoder_alutech_at_4n_get_string(void* context, FuriString* furi_string_cat_printf( output, - "%s\r\n" - "Key:0x%08lX%08lX\nCRC:%02X %dbit\r\n" - "Sn:0x%08lX Btn:0x%01X\r\n" - "Cnt:%04lX\r\n", + "%s %dbit\r\n" + "Key:0x%08lX%08lX\r\n" + "SN:0x%08lX Btn:%X\r\n" + "CRC:%02X Cnt:%04lX\r\n", instance->generic.protocol_name, + instance->generic.data_count_bit, code_found_hi, code_found_lo, - (uint8_t)instance->crc, - instance->generic.data_count_bit, instance->generic.serial, instance->generic.btn, + (uint8_t)instance->crc, instance->generic.cnt); } diff --git a/lib/subghz/protocols/ansonic.c b/lib/subghz/protocols/ansonic.c index 692e4aea..cfce6015 100644 --- a/lib/subghz/protocols/ansonic.c +++ b/lib/subghz/protocols/ansonic.c @@ -333,12 +333,10 @@ void subghz_protocol_decoder_ansonic_get_string(void* context, FuriString* outpu furi_string_cat_printf( output, "%s %dbit\r\n" - "Key:%03lX\r\n" - "Btn:%X\r\n" - "DIP:" DIP_PATTERN "\r\n", + "Key:0x%03lX\r\n" + "Btn:%X\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, (uint32_t)(instance->generic.data & 0xFFFFFFFF), - instance->generic.btn, - CNT_TO_DIP(instance->generic.cnt)); + instance->generic.btn); } diff --git a/lib/subghz/protocols/beninca_arc.c b/lib/subghz/protocols/beninca_arc.c index 2cfce60c..bbb4bcda 100644 --- a/lib/subghz/protocols/beninca_arc.c +++ b/lib/subghz/protocols/beninca_arc.c @@ -662,8 +662,7 @@ void subghz_protocol_decoder_beninca_arc_get_string(void* context, FuriString* o furi_assert(context); SubGhzProtocolDecoderBenincaARC* instance = context; - uint64_t middle_bytes_dec = - subghz_protocol_beninca_arc_decrypt(&instance->generic, instance->keystore); + subghz_protocol_beninca_arc_decrypt(&instance->generic, instance->keystore); // push protocol data to global variable subghz_block_generic_global.cnt_is_available = true; @@ -677,19 +676,14 @@ void subghz_protocol_decoder_beninca_arc_get_string(void* context, FuriString* o furi_string_printf( output, - "%s %db\r\n" - "Key1:%08llX\r\n" - "Key2:%08llX\r\n" - "Sn:%08lX Btn:%02X\r\n" - "Mc:%0lX Cnt:%0lX\r\n" - "Fx:%04lX", + "%s %dbit\r\n" + "Key:0x%08llX\r\n" + "SN:0x%08lX Btn:%X\r\n" + "Cnt:%0lX\r\n", instance->base.protocol->name, instance->generic.data_count_bit, instance->generic.data, - instance->generic.data_2, instance->generic.serial, instance->generic.btn, - (uint32_t)(middle_bytes_dec & 0xFFFFFFFF), - instance->generic.cnt, - instance->generic.seed & 0xFFFF); + instance->generic.cnt); } diff --git a/lib/subghz/protocols/bett.c b/lib/subghz/protocols/bett.c index 2d61e33a..9d5963a0 100644 --- a/lib/subghz/protocols/bett.c +++ b/lib/subghz/protocols/bett.c @@ -320,14 +320,8 @@ void subghz_protocol_decoder_bett_get_string(void* context, FuriString* output) furi_string_cat_printf( output, "%s %dbit\r\n" - "Key:%05lX\r\n" - " +: " DIP_PATTERN "\r\n" - " o: " DIP_PATTERN "\r\n" - " -: " DIP_PATTERN "\r\n", + "Key:0x%05lX\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, - data, - SHOW_DIP_P(data, DIP_P), - SHOW_DIP_P(data, DIP_O), - SHOW_DIP_P(data, DIP_N)); + data); } diff --git a/lib/subghz/protocols/bmw_cas4.c b/lib/subghz/protocols/bmw_cas4.c index 14eba7b8..223a23ea 100644 --- a/lib/subghz/protocols/bmw_cas4.c +++ b/lib/subghz/protocols/bmw_cas4.c @@ -294,12 +294,8 @@ void subghz_protocol_decoder_bmw_cas4_get_string(void* context, FuriString* outp furi_string_cat_printf( output, "%s %dbit\r\n" - "Raw:%02X %02X%02X%02X%02X%02X %02X %02X\r\n", + "Key:0x%016llX\r\n", instance->generic.protocol_name, (int)instance->generic.data_count_bit, - instance->raw_data[0], - instance->raw_data[1], instance->raw_data[2], - instance->raw_data[3], instance->raw_data[4], instance->raw_data[5], - instance->raw_data[6], - instance->raw_data[7]); + (unsigned long long)instance->generic.data); } diff --git a/lib/subghz/protocols/came.c b/lib/subghz/protocols/came.c index 04ea1767..54657c6c 100644 --- a/lib/subghz/protocols/came.c +++ b/lib/subghz/protocols/came.c @@ -358,11 +358,6 @@ void subghz_protocol_decoder_came_get_string(void* context, FuriString* output) uint32_t code_found_lo = instance->generic.data & 0x000003ffffffffff; - uint64_t code_found_reverse = subghz_protocol_blocks_reverse_key( - instance->generic.data, instance->generic.data_count_bit); - - uint32_t code_found_reverse_lo = code_found_reverse & 0x000003ffffffffff; - const char* name = instance->generic.protocol_name; switch(instance->generic.data_count_bit) { case PRASTEL_25_COUNT_BIT: @@ -377,10 +372,8 @@ void subghz_protocol_decoder_came_get_string(void* context, FuriString* output) furi_string_cat_printf( output, "%s %dbit\r\n" - "Key:0x%08lX\r\n" - "Yek:0x%08lX\r\n", + "Key:0x%08lX\r\n", name, instance->generic.data_count_bit, - code_found_lo, - code_found_reverse_lo); + code_found_lo); } diff --git a/lib/subghz/protocols/came_atomo.c b/lib/subghz/protocols/came_atomo.c index bac232e4..ebd60df5 100644 --- a/lib/subghz/protocols/came_atomo.c +++ b/lib/subghz/protocols/came_atomo.c @@ -904,18 +904,15 @@ void subghz_protocol_decoder_came_atomo_get_string(void* context, FuriString* ou furi_string_cat_printf( output, - "%s %db\r\n" - "Key:%08lX%08lX\r\n" - "Sn:0x%08lX Btn:%01X\r\n" - "Cnt:%04lX\r\n" - "Btn_Cnt:0x%02X", - + "%s %dbit\r\n" + "Key:0x%08lX%08lX\r\n" + "SN:0x%08lX Btn:%X\r\n" + "Cnt:%04lX\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, code_found_hi, code_found_lo, instance->generic.serial, instance->generic.btn, - instance->generic.cnt, - instance->generic.cnt_2); + instance->generic.cnt); } diff --git a/lib/subghz/protocols/came_twee.c b/lib/subghz/protocols/came_twee.c index d6b656a5..d517d54c 100644 --- a/lib/subghz/protocols/came_twee.c +++ b/lib/subghz/protocols/came_twee.c @@ -452,14 +452,12 @@ void subghz_protocol_decoder_came_twee_get_string(void* context, FuriString* out furi_string_cat_printf( output, - "%s %db\r\n" + "%s %dbit\r\n" "Key:0x%lX%08lX\r\n" - "Btn:%X\r\n" - "DIP:" DIP_PATTERN "\r\n", + "Btn:%X\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, code_found_hi, code_found_lo, - instance->generic.btn, - CNT_TO_DIP(instance->generic.cnt)); + instance->generic.btn); } diff --git a/lib/subghz/protocols/chamberlain_code.c b/lib/subghz/protocols/chamberlain_code.c index 3e003d4b..474509e3 100644 --- a/lib/subghz/protocols/chamberlain_code.c +++ b/lib/subghz/protocols/chamberlain_code.c @@ -464,42 +464,11 @@ void subghz_protocol_decoder_chamb_code_get_string(void* context, FuriString* ou uint32_t code_found_lo = instance->generic.data & 0x00000000ffffffff; - uint64_t code_found_reverse = subghz_protocol_blocks_reverse_key( - instance->generic.data, instance->generic.data_count_bit); - - uint32_t code_found_reverse_lo = code_found_reverse & 0x00000000ffffffff; - furi_string_cat_printf( output, - "%s %db\r\n" - "Key:0x%03lX\r\n" - "Yek:0x%03lX\r\n", + "%s %dbit\r\n" + "Key:0x%03lX\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, - code_found_lo, - code_found_reverse_lo); - - switch(instance->generic.data_count_bit) { - case 7: - furi_string_cat_printf( - output, - "DIP:" CHAMBERLAIN_7_CODE_DIP_PATTERN "\r\n", - CHAMBERLAIN_7_CODE_DATA_TO_DIP(code_found_lo)); - break; - case 8: - furi_string_cat_printf( - output, - "DIP:" CHAMBERLAIN_8_CODE_DIP_PATTERN "\r\n", - CHAMBERLAIN_8_CODE_DATA_TO_DIP(code_found_lo)); - break; - case 9: - furi_string_cat_printf( - output, - "DIP:" CHAMBERLAIN_9_CODE_DIP_PATTERN "\r\n", - CHAMBERLAIN_9_CODE_DATA_TO_DIP(code_found_lo)); - break; - - default: - break; - } + code_found_lo); } diff --git a/lib/subghz/protocols/chrysler.c b/lib/subghz/protocols/chrysler.c index b04142b3..f62a6abd 100644 --- a/lib/subghz/protocols/chrysler.c +++ b/lib/subghz/protocols/chrysler.c @@ -840,36 +840,33 @@ void subghz_protocol_decoder_chrysler_get_string(void* context, FuriString* outp furi_string_cat_printf( output, "%s %dbit\r\n" - "Key:%016llX\r\n" - "Key2:%04X\r\n", + "Key:0x%016llX\r\n", instance->generic.protocol_name, instance->packet_bit_count, - (unsigned long long)instance->generic.data, - instance->data_2); + (unsigned long long)instance->generic.data); if(instance->plain_a_present) { if(instance->plain_b_present) { furi_string_cat_printf( output, - "SnA:%08lX\r\nSnB:%08lX\r\n", + "SnA:%08lX SnB:%08lX\r\n", (unsigned long)instance->generic.cnt, (unsigned long)chrysler_v0_get_sn_b(instance)); } else { furi_string_cat_printf( - output, "SnA:%08lX\r\n", (unsigned long)instance->generic.cnt); + output, "SN:0x%08lX\r\n", (unsigned long)instance->generic.cnt); } } else if(instance->plain_b_present) { furi_string_cat_printf( - output, "SnB:%08lX\r\n", (unsigned long)chrysler_v0_get_sn_b(instance)); + output, "SN:0x%08lX\r\n", (unsigned long)chrysler_v0_get_sn_b(instance)); } furi_string_cat_printf( output, - "Btn:%02X [%s]\r\n" - "Cnt:%02X\r\n" - "Chk:%s", + "Btn:%X [%s]\r\n" + "CRC:%s Cnt:%02X", instance->decoded_button, chrysler_v0_get_button_name(instance->decoded_button), - instance->seed, - instance->check_ok ? "OK" : "ERR"); + instance->check_ok ? "OK" : "ERR", + instance->seed); } diff --git a/lib/subghz/protocols/clemsa.c b/lib/subghz/protocols/clemsa.c index 27c2e26c..8e8282ce 100644 --- a/lib/subghz/protocols/clemsa.c +++ b/lib/subghz/protocols/clemsa.c @@ -348,15 +348,10 @@ void subghz_protocol_decoder_clemsa_get_string(void* context, FuriString* output furi_string_cat_printf( output, "%s %dbit\r\n" - "Key:%05lX Btn:%X\r\n" - " +: " DIP_PATTERN "\r\n" - " o: " DIP_PATTERN "\r\n" - " -: " DIP_PATTERN "\r\n", + "Key:0x%05lX\r\n" + "Btn:%X\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, (uint32_t)(instance->generic.data & 0x3FFFF), - instance->generic.btn, - SHOW_DIP_P(instance->generic.serial, DIP_P), - SHOW_DIP_P(instance->generic.serial, DIP_O), - SHOW_DIP_P(instance->generic.serial, DIP_N)); + instance->generic.btn); } diff --git a/lib/subghz/protocols/dickert_mahs.c b/lib/subghz/protocols/dickert_mahs.c index 4d8ad360..bdf3bdd2 100644 --- a/lib/subghz/protocols/dickert_mahs.c +++ b/lib/subghz/protocols/dickert_mahs.c @@ -77,52 +77,13 @@ const SubGhzProtocol subghz_protocol_dickert_mahs = { static void subghz_protocol_encoder_dickert_mahs_parse_buffer( SubGhzProtocolDecoderDickertMAHS* instance, FuriString* output) { - // We assume we have only decodes < 64 bit! - uint64_t data = instance->generic.data; - uint8_t bits[36] = {}; - - // Convert uint64_t into bit array - for(int i = 35; i >= 0; i--) { - if(data & 1) { - bits[i] = 1; - } - data >>= 1; - } - - // Decode symbols - FuriString* code = furi_string_alloc(); - for(size_t i = 0; i < 35; i += 2) { - uint8_t dip = (bits[i] << 1) + bits[i + 1]; - // PLUS = 3, // 0b11 - // ZERO = 1, // 0b01 - // MINUS = 0, // 0x00 - if(dip == 0x01) { - furi_string_cat(code, "0"); - } else if(dip == 0x00) { - furi_string_cat(code, "-"); - } else if(dip == 0x03) { - furi_string_cat(code, "+"); - } else { - furi_string_cat(code, "?"); - } - } - - FuriString* user_dips = furi_string_alloc(); - FuriString* fact_dips = furi_string_alloc(); - furi_string_set_n(user_dips, code, 0, 10); - furi_string_set_n(fact_dips, code, 10, 8); - furi_string_cat_printf( output, - "%s\r\n" - "User-Dips:\t%s\r\n" - "Fac-Code:\t%s\r\n", + "%s %dbit\r\n" + "Key:0x%09llX\r\n", instance->generic.protocol_name, - furi_string_get_cstr(user_dips), - furi_string_get_cstr(fact_dips)); - furi_string_free(user_dips); - furi_string_free(fact_dips); - furi_string_free(code); + instance->generic.data_count_bit, + (unsigned long long)instance->generic.data); } void* subghz_protocol_encoder_dickert_mahs_alloc(SubGhzEnvironment* environment) { diff --git a/lib/subghz/protocols/ditec_gol4.c b/lib/subghz/protocols/ditec_gol4.c index 1f689364..c802a368 100644 --- a/lib/subghz/protocols/ditec_gol4.c +++ b/lib/subghz/protocols/ditec_gol4.c @@ -659,17 +659,15 @@ void subghz_protocol_decoder_ditec_gol4_get_string(void* context, FuriString* ou furi_string_cat_printf( output, - "%s %db\r\n" + "%s %dbit\r\n" "Key:0x%0lX%08lX\r\n" - "Serial:0x%08lX\r\n" - "Btn:%01X %s\r\n" - "Cnt:%04lX", + "SN:0x%08lX Btn:%X\r\n" + "Cnt:%04lX\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, (uint32_t)(instance->generic.data >> 32), (uint32_t)(instance->generic.data & 0xFFFFFFFF), instance->generic.serial, instance->generic.btn, - (instance->generic.btn == 0x0) ? "- Prog" : "", instance->generic.cnt); } diff --git a/lib/subghz/protocols/doitrand.c b/lib/subghz/protocols/doitrand.c index 1853bd16..a5d09620 100644 --- a/lib/subghz/protocols/doitrand.c +++ b/lib/subghz/protocols/doitrand.c @@ -343,13 +343,11 @@ void subghz_protocol_decoder_doitrand_get_string(void* context, FuriString* outp furi_string_cat_printf( output, "%s %dbit\r\n" - "Key:%02lX%08lX\r\n" - "Btn:%X\r\n" - "DIP:" DIP_PATTERN "\r\n", + "Key:0x%02lX%08lX\r\n" + "Btn:%X\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, (uint32_t)(instance->generic.data >> 32) & 0xFFFFFFFF, (uint32_t)(instance->generic.data & 0xFFFFFFFF), - instance->generic.btn, - CNT_TO_DIP(instance->generic.cnt)); + instance->generic.btn); } diff --git a/lib/subghz/protocols/dooya.c b/lib/subghz/protocols/dooya.c index 07dec534..99b06d44 100644 --- a/lib/subghz/protocols/dooya.c +++ b/lib/subghz/protocols/dooya.c @@ -375,43 +375,6 @@ SubGhzProtocolStatus * Get button name. * @param btn Button number, 8 bit */ -static const char* subghz_protocol_dooya_get_name_button(uint8_t btn) { - const char* btn_name; - switch(btn) { - case 0b00010001: - btn_name = "Up_Long"; - break; - case 0b00011110: - btn_name = "Up_Short"; - break; - case 0b00110011: - btn_name = "Down_Long"; - break; - case 0b00111100: - btn_name = "Down_Short"; - break; - case 0b01010101: - btn_name = "Stop"; - break; - case 0b01111001: - btn_name = "Up+Down"; - break; - case 0b10000000: - btn_name = "Up+Stop"; - break; - case 0b10000001: - btn_name = "Down+Stop"; - break; - case 0b11001100: - btn_name = "P2"; - break; - default: - btn_name = "Unknown"; - break; - } - return btn_name; -} - void subghz_protocol_decoder_dooya_get_string(void* context, FuriString* output) { furi_assert(context); SubGhzProtocolDecoderDooya* instance = context; @@ -428,17 +391,10 @@ void subghz_protocol_decoder_dooya_get_string(void* context, FuriString* output) output, "%s %dbit\r\n" "Key:0x%010llX\r\n" - "Sn:0x%08lX\r\n" - "Btn:%X - %s\r\n", + "SN:0x%lX Btn:%X\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, instance->generic.data, instance->generic.serial, - instance->generic.btn, - subghz_protocol_dooya_get_name_button(instance->generic.btn)); - if(instance->generic.cnt == DOYA_SINGLE_CHANNEL) { - furi_string_cat_printf(output, "Ch:Single\r\n"); - } else { - furi_string_cat_printf(output, "Ch:%lu\r\n", instance->generic.cnt); - } + instance->generic.btn); } diff --git a/lib/subghz/protocols/elplast.c b/lib/subghz/protocols/elplast.c index ee029bfc..3fc926b4 100644 --- a/lib/subghz/protocols/elplast.c +++ b/lib/subghz/protocols/elplast.c @@ -305,18 +305,11 @@ void subghz_protocol_decoder_elplast_get_string(void* context, FuriString* outpu furi_assert(context); SubGhzProtocolDecoderElplast* instance = context; - uint64_t code_found_reverse = subghz_protocol_blocks_reverse_key( - instance->generic.data, instance->generic.data_count_bit); - - uint32_t code_found_reverse_lo = code_found_reverse & 0x000003ffffffffff; - furi_string_cat_printf( output, - "%s %db\r\n" - "Key: 0x%05lX\r\n" - "Yek: 0x%05lX", + "%s %dbit\r\n" + "Key:0x%05lX\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, - (uint32_t)(instance->generic.data & 0xFFFFFF), - code_found_reverse_lo); + (uint32_t)(instance->generic.data & 0xFFFFFF)); } diff --git a/lib/subghz/protocols/faac_slh.c b/lib/subghz/protocols/faac_slh.c index fb82b137..de85049e 100644 --- a/lib/subghz/protocols/faac_slh.c +++ b/lib/subghz/protocols/faac_slh.c @@ -723,25 +723,16 @@ void subghz_protocol_decoder_faac_slh_get_string(void* context, FuriString* outp SubGhzProtocolDecoderFaacSLH* instance = context; subghz_protocol_faac_slh_check_remote_controller( &instance->generic, instance->keystore, &instance->manufacture_name); - uint32_t code_fix = instance->generic.data >> 32; - uint32_t code_hop = instance->generic.data & 0xFFFFFFFF; if(faac_prog_mode == true) { furi_string_cat_printf( output, "%s %dbit\r\n" - "Master Remote Prog Mode\r\n" - "Ke:%lX%08lX\r\n" - "Kd:%lX%08lX\r\n" - "Seed:%08lX mCnt:%02X", + "Key:0x%lX%08lX\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, (uint32_t)(instance->generic.data >> 32), - (uint32_t)instance->generic.data, - (uint32_t)(instance->generic.data_2 >> 32), - (uint32_t)instance->generic.data_2, - instance->generic.seed, - (uint8_t)(instance->generic.cnt & 0xFF)); + (uint32_t)instance->generic.data); } else if((allow_zero_seed == false) && (instance->generic.seed == 0x0)) { // push protocol data to global variable subghz_block_generic_global.btn_is_available = true; @@ -751,18 +742,14 @@ void subghz_protocol_decoder_faac_slh_get_string(void* context, FuriString* outp furi_string_cat_printf( output, "%s %dbit\r\n" - "Key:%lX%08lX\r\n" - "Fix:%08lX\r\n" - "Hop:%08lX Btn:%X\r\n" - "Sn:%07lX Sd:Unknown", + "Key:0x%lX%08lX\r\n" + "SN:0x%lX Btn:%X\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, (uint32_t)(instance->generic.data >> 32), (uint32_t)instance->generic.data, - code_fix, - code_hop, - instance->generic.btn, - instance->generic.serial); + instance->generic.serial, + instance->generic.btn); } else { // push protocol data to global variable subghz_block_generic_global.cnt_is_available = true; @@ -777,19 +764,15 @@ void subghz_protocol_decoder_faac_slh_get_string(void* context, FuriString* outp furi_string_cat_printf( output, "%s %dbit\r\n" - "Key:%lX%08lX\r\n" - "Fix:%08lX Cnt:%05lX\r\n" - "Hop:%08lX Btn:%X\r\n" - "Sn:%07lX Sd:%08lX", + "Key:0x%lX%08lX\r\n" + "SN:0x%lX Btn:%X\r\n" + "Cnt:%05lX\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, (uint32_t)(instance->generic.data >> 32), (uint32_t)instance->generic.data, - code_fix, - instance->generic.cnt, - code_hop, - instance->generic.btn, instance->generic.serial, - instance->generic.seed); + instance->generic.btn, + instance->generic.cnt); } } diff --git a/lib/subghz/protocols/feron.c b/lib/subghz/protocols/feron.c index 61dd5e44..b11a37cb 100644 --- a/lib/subghz/protocols/feron.c +++ b/lib/subghz/protocols/feron.c @@ -339,13 +339,11 @@ void subghz_protocol_decoder_feron_get_string(void* context, FuriString* output) furi_string_cat_printf( output, - "%s %db\r\n" - "Key: 0x%08lX\r\n" - "Serial: 0x%04lX\r\n" - "Command: 0x%04lX\r\n", + "%s %dbit\r\n" + "Key:0x%08lX\r\n" + "SN:0x%lX\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, (uint32_t)(instance->generic.data & 0xFFFFFFFF), - instance->generic.serial, - (uint32_t)(instance->generic.data & 0xFFFF)); + instance->generic.serial); } diff --git a/lib/subghz/protocols/fiat_marelli.c b/lib/subghz/protocols/fiat_marelli.c index 5a428f20..b6abcff3 100644 --- a/lib/subghz/protocols/fiat_marelli.c +++ b/lib/subghz/protocols/fiat_marelli.c @@ -662,59 +662,31 @@ SubGhzProtocolStatus subghz_protocol_decoder_fiat_marelli_deserialize( return ret; } -static const char* fiat_marelli_button_name(uint8_t btn) { - switch(btn) { - case 0x7: - return "Lock"; - case 0xB: - return "Unlock"; - case 0xD: - return "Trunk"; - default: - return "Unknown"; - } -} - void subghz_protocol_decoder_fiat_marelli_get_string(void* context, FuriString* output) { furi_check(context); SubGhzProtocolDecoderFiatMarelli* instance = context; - uint8_t epoch = instance->raw_data[6] & 0xF; uint8_t counter = (instance->raw_data[7] >> 3) & 0x1F; - const char* variant = (instance->te_detected && - instance->te_detected < FIAT_MARELLI_TE_TYPE_AB_BOUNDARY) - ? "B" - : "A"; - uint8_t scramble = (instance->raw_data[7] >> 1) & 0x3; - uint8_t fixed = instance->raw_data[7] & 0x1; const char* crc_str = ""; if(instance->bit_count >= 104) { uint8_t calc = fiat_marelli_crc8(instance->raw_data, 12); - crc_str = (calc == instance->raw_data[12]) ? " CRC:OK" : " CRC:FAIL"; + crc_str = (calc == instance->raw_data[12]) ? "OK" : "FAIL"; } furi_string_cat_printf( output, - "%s %dbit%s\r\n" - "Enc:%02X%02X%02X%02X%02X Scr:%02X\r\n" - "Raw:%02X%02X Fixed:%X\r\n" - "Sn:%08X Cnt:%02X\r\n" - "Btn:%02X:[%s] Ep:%02X\r\n" - "Tp:%s\r\n", + "%s %dbit\r\n" + "Key:%02X%02X%02X%02X%02X\r\n" + "SN:0x%X Btn:%02X\r\n" + "CRC:%s Cnt:%02X\r\n", instance->generic.protocol_name, (int)instance->bit_count, - crc_str, instance->raw_data[8], instance->raw_data[9], instance->raw_data[10], instance->raw_data[11], instance->raw_data[12], - (unsigned)scramble, - instance->raw_data[6], instance->raw_data[7], - (unsigned)fixed, (unsigned int)instance->generic.serial, - (unsigned)counter, (unsigned)instance->generic.btn, - fiat_marelli_button_name(instance->generic.btn), - (unsigned)epoch, - variant); + crc_str, + (unsigned)counter); } diff --git a/lib/subghz/protocols/fiat_spa.c b/lib/subghz/protocols/fiat_spa.c index 4dad650b..2bd180c5 100644 --- a/lib/subghz/protocols/fiat_spa.c +++ b/lib/subghz/protocols/fiat_spa.c @@ -355,16 +355,13 @@ void subghz_protocol_decoder_fiat_spa_get_string(void* context, FuriString* outp furi_string_cat_printf( output, "%s %dbit\r\n" - "Key:%08lX%08lX\r\n" - "Fix:%08lX\r\n" - "Hop:%08lX\r\n" - "EndByte:%02X", + "Key:0x%08lX%08lX\r\n" + "SN:0x%lX Btn:%X\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, (uint32_t)(instance->generic.data >> 32), (uint32_t)(instance->generic.data & 0xFFFFFFFF), instance->generic.serial, - instance->generic.cnt, instance->generic.btn); } diff --git a/lib/subghz/protocols/fiat_v0.c b/lib/subghz/protocols/fiat_v0.c index 28d69fb6..3f711e9e 100644 --- a/lib/subghz/protocols/fiat_v0.c +++ b/lib/subghz/protocols/fiat_v0.c @@ -597,12 +597,8 @@ void subghz_protocol_decoder_fiat_v0_get_string(void* context, FuriString* outpu furi_string_cat_printf( output, "%s %dbit\r\n" - "Sn:%08lX\r\n" - "Hop:%08lX\r\n" - "EndByte:%02X\r\n", + "SN:0x%lX\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, - (unsigned long)instance->fix, - (unsigned long)instance->hop, - instance->endbyte & 0x3F); + (unsigned long)instance->fix); } diff --git a/lib/subghz/protocols/fiat_v1.c b/lib/subghz/protocols/fiat_v1.c index 37e923b5..55dd101c 100644 --- a/lib/subghz/protocols/fiat_v1.c +++ b/lib/subghz/protocols/fiat_v1.c @@ -167,21 +167,6 @@ static bool fiat_v1_button_valid(uint8_t button) { return button == 0x1U || button == 0x2U || button == 0x4U || button == 0x8U; } -static const char* fiat_v1_button_name(uint8_t button) { - switch(button) { - case 0x8U: - return "Unlock"; - case 0x4U: - return "Lock"; - case 0x2U: - return "Trunk"; - case 0x1U: - return "Close"; - default: - return "Unknown"; - } -} - static uint8_t fiat_v1_frame_xor(const uint8_t raw[FIAT_V1_WIRE_BYTES]) { uint8_t value = 0x01U; for(uint8_t i = 0U; i < FIAT_V1_WIRE_BYTES - 1U; i++) { @@ -1035,25 +1020,14 @@ void subghz_protocol_decoder_fiat_v1_get_string(void* context, FuriString* outpu furi_string_cat_printf( output, - "%s %ubit %s\r\n" - "Sn:%08lX\r\n" - "UID:%08lX\r\n" - "Hop:%08lX\r\n" - "Btn:%02X [%s]\r\n" - "Ctrl:%03lX Sync:%02X\r\n" - "Tail:%u XOR:%02X\r\n", + "%s %ubit\r\n" + "SN:0x%lX Btn:%02X\r\n" + "Cnt:%03lX\r\n", instance->generic.protocol_name, FIAT_V1_LOGICAL_BITS, - instance->hitag2_key_valid ? "KEY:OK" : "KEY:??", (unsigned long)instance->generic.serial, - (unsigned long)instance->uid, - (unsigned long)instance->hop, instance->generic.btn, - fiat_v1_button_name(instance->generic.btn), - (unsigned long)instance->generic.cnt, - instance->family, - instance->tail_bits, - instance->frame_xor); + (unsigned long)instance->generic.cnt); } // [HITAG2_BF] Public API for Hitag2 bruteforce helper diff --git a/lib/subghz/protocols/fiat_v2.c b/lib/subghz/protocols/fiat_v2.c index 1a086c8e..eae5db7e 100644 --- a/lib/subghz/protocols/fiat_v2.c +++ b/lib/subghz/protocols/fiat_v2.c @@ -112,19 +112,6 @@ static bool fiat_v2_button_valid(uint8_t button) { sel == FIAT_V2_BUTTON_TRUNK; } -static const char* fiat_v2_button_name(uint8_t button) { - switch(button >> FIAT_V2_BTN_SHIFT) { - case FIAT_V2_BUTTON_LOCK: - return "Lock"; - case FIAT_V2_BUTTON_UNLOCK: - return "Unlock"; - case FIAT_V2_BUTTON_TRUNK: - return "Trunk"; - default: - return "Unknown"; - } -} - static uint32_t fiat_v2_uid(const uint8_t raw[FIAT_V2_WIRE_BYTES]) { return ((uint32_t)raw[2] << 24U) | ((uint32_t)raw[3] << 16U) | ((uint32_t)raw[4] << 8U) | raw[5]; @@ -412,15 +399,11 @@ void subghz_protocol_decoder_fiat_v2_get_string(void* context, FuriString* outpu furi_string_cat_printf( output, "%s %ubit\r\n" - "UID:%08lX\r\n" - "Hop:%08lX Type:%01X\r\n" - "Btn:%02X [%s] Cnt:%02lX\r\n", + "SN:0x%lX Btn:%02X\r\n" + "Cnt:%02lX\r\n", instance->generic.protocol_name, FIAT_V2_LOGICAL_BITS, (unsigned long)instance->uid, - (unsigned long)instance->hop, - (unsigned)(instance->raw_data[6] >> 4), instance->button, - fiat_v2_button_name(instance->button), (unsigned long)instance->generic.cnt); } diff --git a/lib/subghz/protocols/ford_v0.c b/lib/subghz/protocols/ford_v0.c index f6c1d02d..8e395232 100644 --- a/lib/subghz/protocols/ford_v0.c +++ b/lib/subghz/protocols/ford_v0.c @@ -896,32 +896,18 @@ void subghz_protocol_decoder_ford_v0_get_string(void* context, FuriString* outpu bool crc_ok = ford_v0_verify_crc(instance->key1, instance->key2); - const char* button_name = "??"; - if(instance->button == 0x01) - button_name = "Panic"; - else if(instance->button == 0x02) - button_name = "Lock"; - else if(instance->button == 0x04) - button_name = "Unlock"; - else if(instance->button == 0x08) - button_name = "Boot"; - furi_string_cat_printf( output, - "%s %dbit CRC:%s\r\n" - "Key1: %08lX%08lX\r\n" - "Key2: %04X\r\n" - "Sn: %08lX\r\n" - "Cnt: %05lX\r\n" - "Btn: %02X - %s\r\n", + "%s %dbit\r\n" + "Key:0x%08lX%08lX\r\n" + "SN:0x%lX Btn:%02X\r\n" + "CRC:%s Cnt:%05lX\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, - crc_ok ? "OK" : "BAD", (unsigned long)code_found_hi, (unsigned long)code_found_lo, - instance->key2, (unsigned long)instance->serial, - (unsigned long)instance->count, instance->button, - button_name); + crc_ok ? "OK" : "BAD", + (unsigned long)instance->count); } diff --git a/lib/subghz/protocols/ford_v1.c b/lib/subghz/protocols/ford_v1.c index 59a87ffc..d7367473 100644 --- a/lib/subghz/protocols/ford_v1.c +++ b/lib/subghz/protocols/ford_v1.c @@ -49,7 +49,6 @@ typedef enum { FordV1DecoderStepData = 3, } FordV1DecoderStep; -static const char* ford_v1_get_button_name(uint8_t btn); static void ford_v1_decode_with_flag(uint8_t* raw, size_t len, uint8_t flag_byte); static void ford_v1_decode(uint8_t* raw, size_t len); static void ford_v1_encode_inverse_block(uint8_t block[9]); @@ -101,23 +100,6 @@ const SubGhzProtocol ford_protocol_v1 = { #define ford_v1_crc16(data, len) subghz_protocol_blocks_crc16((data), (len), 0x1021, 0x0000) -static const char* ford_v1_get_button_name(uint8_t btn) { - switch(btn) { - case 0: - return "Sync"; - case 1: - return "Lock"; - case 2: - return "Unlock"; - case 4: - return "Trunk"; - case 8: - return "Panic"; - default: - return "??"; - } -} - static void ford_v1_decode_with_flag(uint8_t* raw, size_t len, uint8_t flag_byte) { if(len < 9) return; @@ -860,8 +842,6 @@ void subghz_protocol_decoder_ford_v1_get_string(void* context, FuriString* outpu uint16_t crc16 = crc & 0xFFFF; if(instance->encryption_supported) { - const char* btn_name = ford_v1_get_button_name(instance->generic.btn); - uint16_t calc_crc = crc16; bool crc_ok; @@ -876,21 +856,17 @@ void subghz_protocol_decoder_ford_v1_get_string(void* context, FuriString* outpu furi_string_cat_printf( output, "%s %dbit\r\n" - "%014llX%06llX\r\n" - "%010llX%04lX\r\n" - "Sn:%08lX Bt:%01X [%s]\r\n" - "Cnt:%05lX CRC:%04lX [%s]\r\n", + "Key:0x%014llX\r\n" + "SN:0x%lX Btn:%01X\r\n" + "CRC:%04lX Cnt:%05lX\r\n" + "[%s]\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, (unsigned long long)key1, - (unsigned long long)(key2 >> 40), - (unsigned long long)(key2 & 0xFFFFFFFFFFULL), - (unsigned long)crc16, (unsigned long)instance->generic.serial, instance->generic.btn, - btn_name, - (unsigned long)instance->generic.cnt, (unsigned long)crc16, + (unsigned long)instance->generic.cnt, crc_ok ? "OK" : "ERR"); } else { uint8_t raw[FORD_V1_DATA_BYTES]; @@ -907,17 +883,12 @@ void subghz_protocol_decoder_ford_v1_get_string(void* context, FuriString* outpu furi_string_cat_printf( output, "%s %dbit\r\n" - "%014llX%06llX\r\n" - "%010llX%04lX\r\n" - "Sn:%08lX\r\n" - "CRC:%04lX [%s]\r\n" - "Encryption not supported !\r\n", + "Key:0x%014llX\r\n" + "SN:0x%lX\r\n" + "CRC:%04lX [%s]\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, (unsigned long long)key1, - (unsigned long long)(key2 >> 40), - (unsigned long long)(key2 & 0xFFFFFFFFFFULL), - (unsigned long)crc16, (unsigned long)device_id, (unsigned long)crc16, crc_ok ? "OK" : "ERR"); diff --git a/lib/subghz/protocols/ford_v2.c b/lib/subghz/protocols/ford_v2.c index 2308990b..6011b290 100644 --- a/lib/subghz/protocols/ford_v2.c +++ b/lib/subghz/protocols/ford_v2.c @@ -132,23 +132,6 @@ static uint8_t ford_v2_uint8_parity(uint8_t value) { return parity; } -static const char* ford_v2_button_name(uint8_t btn) { - switch(btn) { - case 0x10: - return "Lock"; - case 0x11: - return "Unlock"; - case 0x13: - return "Trunk"; - case 0x14: - return "Panic"; - case 0x15: - return "RemoteStart"; - default: - return "Unknown"; - } -} - static void ford_v2_decoder_extract_from_raw(SubGhzProtocolDecoderFordV2* instance) { const uint8_t* k = instance->raw_bytes; @@ -786,11 +769,9 @@ void subghz_protocol_decoder_ford_v2_get_string(void* context, FuriString* outpu furi_string_cat_printf( output, "%s %dbit\r\n" - "Key:%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X\r\n" - "Sn:%08lX\r\n" - "Btn:%02X [%s]\r\n" - "Cnt:%u\r\n" - "Struct:%s\r\n", + "Key:%02X%02X%02X%02X%02X%02X\r\n" + "SN:0x%lX Btn:%02X\r\n" + "Cnt:%u\r\n", instance->generic.protocol_name, (int)instance->generic.data_count_bit, k[2], @@ -799,16 +780,9 @@ void subghz_protocol_decoder_ford_v2_get_string(void* context, FuriString* outpu k[5], k[6], k[7], - k[8], - k[9], - k[10], - k[11], - k[12], (unsigned long)instance->generic.serial, instance->generic.btn, - ford_v2_button_name(instance->generic.btn), - (unsigned)instance->counter16, - instance->structure_ok ? "OK" : "BAD"); + (unsigned)instance->counter16); } const SubGhzProtocolDecoder subghz_protocol_ford_v2_decoder = { diff --git a/lib/subghz/protocols/ford_v3.c b/lib/subghz/protocols/ford_v3.c index ceb1f878..b35f7447 100644 --- a/lib/subghz/protocols/ford_v3.c +++ b/lib/subghz/protocols/ford_v3.c @@ -83,29 +83,6 @@ static void ford_v3_cell_process(SubGhzProtocolDecoderFordV3* instance); static void ford_v3_cell_feed(SubGhzProtocolDecoderFordV3* instance, bool level, uint32_t duration); static void ford_v3_manchester_feed(SubGhzProtocolDecoderFordV3* instance, bool level, uint32_t duration); -static const char* ford_v3_button_name(uint8_t btn, uint8_t variant); - -static const char* ford_v3_button_name(uint8_t btn, uint8_t variant) { - if(variant == FORD_V3_VARIANT_US) { - switch(btn) { - case FORD_V3_BTN_LOCK: - return "Lock"; - case FORD_V3_BTN_UNLOCK: - return "Unlock"; - default: - return "?"; - } - } - - switch(btn) { - case FORD_V3_BTN_LOCK: - return "Lock"; - case FORD_V3_BTN_UNLOCK: - return "Unlock"; - default: - return "?"; - } -} static bool ford_v3_cell_frame_valid(const uint8_t* raw) { if(raw[0] != 0xFFU) { @@ -484,9 +461,8 @@ void subghz_protocol_decoder_ford_v3_get_string(void* context, FuriString* outpu furi_string_cat_printf( output, "%s US %dbit\r\n" - "Key:%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X\r\n" - "Sn:%08lX\r\n" - "Btn:%02X %s\r\n" + "Key:%02X%02X%02X%02X%02X%02X\r\n" + "SN:0x%lX Btn:%02X\r\n" "Cnt:%04X\r\n", instance->generic.protocol_name, (int)instance->generic.data_count_bit, @@ -496,16 +472,8 @@ void subghz_protocol_decoder_ford_v3_get_string(void* context, FuriString* outpu k[3], k[4], k[5], - k[6], - k[7], - k[8], - k[9], - k[10], - k[11], - k[12], (unsigned long)instance->generic.serial, instance->generic.btn, - ford_v3_button_name(instance->generic.btn, FORD_V3_VARIANT_US), (unsigned)instance->counter); return; } @@ -513,9 +481,8 @@ void subghz_protocol_decoder_ford_v3_get_string(void* context, FuriString* outpu furi_string_cat_printf( output, "%s %dbit\r\n" - "Key:%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X\r\n" - "Sn:%08lX\r\n" - "Btn:%02X %s\r\n" + "Key:%02X%02X%02X%02X%02X%02X\r\n" + "SN:0x%lX Btn:%02X\r\n" "Cnt:%04X\r\n", instance->generic.protocol_name, (int)instance->generic.data_count_bit, @@ -525,16 +492,8 @@ void subghz_protocol_decoder_ford_v3_get_string(void* context, FuriString* outpu k[3], k[4], k[5], - k[6], - k[7], - k[8], - k[9], - k[10], - k[11], - k[12], (unsigned long)instance->generic.serial, instance->generic.btn, - ford_v3_button_name(instance->generic.btn, FORD_V3_VARIANT_EU), (unsigned)instance->counter); } diff --git a/lib/subghz/protocols/gangqi.c b/lib/subghz/protocols/gangqi.c index f3e9c0da..fac2a848 100644 --- a/lib/subghz/protocols/gangqi.c +++ b/lib/subghz/protocols/gangqi.c @@ -404,27 +404,6 @@ void subghz_protocol_decoder_gangqi_feed(void* context, bool level, volatile uin * Get button name. * @param btn Button number, 4 bit */ -static const char* subghz_protocol_gangqi_get_button_name(uint8_t btn) { - const char* name_btn[16] = { - "Unknown", - "Exit settings", - "Volume setting", - "0x3", - "Vibro sens. setting", - "Settings mode", - "Ringtone setting", - "Ring", // D - "0x8", - "0x9", - "0xA", - "Alarm", // C - "0xC", - "Arm", // A - "Disarm", // B - "0xF"}; - return btn <= 0xf ? name_btn[btn] : name_btn[0]; -} - uint8_t subghz_protocol_decoder_gangqi_get_hash_data(void* context) { furi_assert(context); SubGhzProtocolDecoderGangQi* instance = context; @@ -456,15 +435,6 @@ void subghz_protocol_decoder_gangqi_get_string(void* context, FuriString* output // Parse serial subghz_protocol_gangqi_remote_controller(&instance->generic); - // Get byte sum - uint16_t serial = (uint16_t)((instance->generic.data >> 18) & 0xFFFF); - uint8_t const_and_button = (uint8_t)(0xD0 | instance->generic.btn); - uint8_t serial_high = (uint8_t)(serial >> 8); - uint8_t serial_low = (uint8_t)(serial & 0xFF); - // Type 1 is what original remotes use, type 2 is "backdoor" sum that receiver accepts too - uint8_t sum_type1 = (uint8_t)(0xC8 - serial_high - serial_low - const_and_button); - uint8_t sum_type2 = (uint8_t)(0x02 + serial_high + serial_low + const_and_button); - // push protocol data to global variable subghz_block_generic_global.btn_is_available = true; subghz_block_generic_global.current_btn = instance->generic.btn; @@ -473,18 +443,13 @@ void subghz_protocol_decoder_gangqi_get_string(void* context, FuriString* output furi_string_cat_printf( output, - "%s %db\r\n" - "Key: 0x%X%08lX\r\n" - "Serial: 0x%05lX\r\n" - "Sum: 0x%02X Sum2: 0x%02X\r\n" - "Btn: 0x%01X - %s\r\n", + "%s %dbit\r\n" + "Key:0x%X%08lX\r\n" + "SN:0x%lX Btn:%01X\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, (uint8_t)(instance->generic.data >> 32), (uint32_t)(instance->generic.data & 0xFFFFFFFF), instance->generic.serial, - sum_type1, - sum_type2, - instance->generic.btn, - subghz_protocol_gangqi_get_button_name(instance->generic.btn)); + instance->generic.btn); } diff --git a/lib/subghz/protocols/gate_tx.c b/lib/subghz/protocols/gate_tx.c index 83a36be3..6d0b7b0b 100644 --- a/lib/subghz/protocols/gate_tx.c +++ b/lib/subghz/protocols/gate_tx.c @@ -321,8 +321,8 @@ void subghz_protocol_decoder_gate_tx_get_string(void* context, FuriString* outpu furi_string_cat_printf( output, "%s %dbit\r\n" - "Key:%06lX\r\n" - "Sn:%05lX Btn:%X\r\n", + "Key:0x%06lX\r\n" + "SN:0x%lX Btn:%X\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, (uint32_t)(instance->generic.data & 0xFFFFFF), diff --git a/lib/subghz/protocols/hay21.c b/lib/subghz/protocols/hay21.c index 19995932..6a9a31c0 100644 --- a/lib/subghz/protocols/hay21.c +++ b/lib/subghz/protocols/hay21.c @@ -417,25 +417,6 @@ void subghz_protocol_decoder_hay21_feed(void* context, bool level, volatile uint * Get button name. * @param btn Button number, 4 bit */ -static const char* subghz_protocol_hay21_get_button_name(uint8_t btn) { - const char* btn_name; - switch(btn) { - case 0x5A: - btn_name = "On/Off"; - break; - case 0xC3: - btn_name = "Mode"; - break; - case 0x88: - btn_name = "Hold"; - break; - default: - btn_name = "Unknown"; - break; - } - return btn_name; -} - uint8_t subghz_protocol_decoder_hay21_get_hash_data(void* context) { furi_assert(context); SubGhzProtocolDecoderHay21* instance = context; @@ -479,16 +460,14 @@ void subghz_protocol_decoder_hay21_get_string(void* context, FuriString* output) furi_string_cat_printf( output, - "%s - %dbit\r\n" + "%s %dbit\r\n" "Key:0x%06lX\r\n" - "Serial:0x%02X\r\n" - "Btn:0x%01X - %s\r\n" + "SN:0x%02X Btn:%X\r\n" "Cnt:%01X\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, (uint32_t)(instance->generic.data & 0xFFFFFFFF), (uint8_t)(instance->generic.serial & 0xFF), instance->generic.btn, - subghz_protocol_hay21_get_button_name(instance->generic.btn), (uint8_t)(instance->generic.cnt & 0xF)); } diff --git a/lib/subghz/protocols/hollarm.c b/lib/subghz/protocols/hollarm.c index fade9127..5e696256 100644 --- a/lib/subghz/protocols/hollarm.c +++ b/lib/subghz/protocols/hollarm.c @@ -416,27 +416,6 @@ void subghz_protocol_decoder_hollarm_feed(void* context, bool level, volatile ui * Get button name. * @param btn Button number, 4 bit */ -static const char* subghz_protocol_hollarm_get_button_name(uint8_t btn) { - const char* name_btn[16] = { - "Unknown", - "Disarm", // B (2) - "Arm", // A (1) - "0x3", - "Ringtone/Alarm", // C (3) - "0x5", - "0x6", - "0x7", - "Ring", // D (4) - "Settings mode", - "Exit settings", - "Vibro sens. setting", - "Not used\n(in settings)", - "Volume setting", - "0xE", - "0xF"}; - return btn <= 0xf ? name_btn[btn] : name_btn[0]; -} - uint8_t subghz_protocol_decoder_hollarm_get_hash_data(void* context) { furi_assert(context); SubGhzProtocolDecoderHollarm* instance = context; @@ -467,10 +446,6 @@ void subghz_protocol_decoder_hollarm_get_string(void* context, FuriString* outpu // Parse serial subghz_protocol_hollarm_remote_controller(&instance->generic); - // Get byte sum - uint8_t bytesum = - ((instance->generic.data >> 32) & 0xFF) + ((instance->generic.data >> 24) & 0xFF) + - ((instance->generic.data >> 16) & 0xFF) + ((instance->generic.data >> 8) & 0xFF); // push protocol data to global variable subghz_block_generic_global.btn_is_available = true; @@ -480,16 +455,13 @@ void subghz_protocol_decoder_hollarm_get_string(void* context, FuriString* outpu furi_string_cat_printf( output, - "%s %db\r\n" - "Key: 0x%02lX%08lX\r\n" - "Serial: 0x%06lX Sum: %02X\r\n" - "Btn: 0x%01X - %s\r\n", + "%s %dbit\r\n" + "Key:0x%02lX%08lX\r\n" + "SN:0x%06lX Btn:%X\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, (uint32_t)(instance->generic.data >> 32), (uint32_t)instance->generic.data, instance->generic.serial, - bytesum, - instance->generic.btn, - subghz_protocol_hollarm_get_button_name(instance->generic.btn)); + instance->generic.btn); } diff --git a/lib/subghz/protocols/holtek.c b/lib/subghz/protocols/holtek.c index 908d36a5..82887d2e 100644 --- a/lib/subghz/protocols/holtek.c +++ b/lib/subghz/protocols/holtek.c @@ -354,7 +354,7 @@ void subghz_protocol_decoder_holtek_get_string(void* context, FuriString* output output, "%s %dbit\r\n" "Key:0x%lX%08lX\r\n" - "Sn:0x%05lX Btn:%X ", + "SN:0x%05lX Btn:%X ", instance->generic.protocol_name, instance->generic.data_count_bit, (uint32_t)((instance->generic.data >> 32) & 0xFFFFFFFF), diff --git a/lib/subghz/protocols/holtek_ht12x.c b/lib/subghz/protocols/holtek_ht12x.c index 25dfdb5c..2a7b442e 100644 --- a/lib/subghz/protocols/holtek_ht12x.c +++ b/lib/subghz/protocols/holtek_ht12x.c @@ -397,17 +397,12 @@ void subghz_protocol_decoder_holtek_th12x_get_string(void* context, FuriString* furi_string_cat_printf( output, - "%s %db\r\n" + "%s %dbit\r\n" "Key:0x%03lX\r\n" - "Btn: ", + "Btn:", instance->generic.protocol_name, instance->generic.data_count_bit, (uint32_t)(instance->generic.data & 0xFFF)); subghz_protocol_holtek_th12x_event_serialize(instance->generic.btn, output); - furi_string_cat_printf( - output, - "DIP:" DIP_PATTERN "\r\n" - "Te:%luus\r\n", - CNT_TO_DIP(instance->generic.cnt), - instance->te); + furi_string_cat_printf(output, "\r\n"); } diff --git a/lib/subghz/protocols/honda_static.c b/lib/subghz/protocols/honda_static.c index c5aad700..5911cc8e 100644 --- a/lib/subghz/protocols/honda_static.c +++ b/lib/subghz/protocols/honda_static.c @@ -669,14 +669,15 @@ void subghz_protocol_decoder_honda_static_get_string(void* context, FuriString* furi_string_printf( output, - "%s\r\n" + "%s %dbit\r\n" "Key:%016llX\r\n" - "Btn:%s\r\n" - "Ser:%07lX Cnt:%06lX", + "SN:%07lX Btn:%s\r\n" + "Cnt:%06lX", instance->generic.protocol_name, + instance->generic.data_count_bit, (unsigned long long)instance->generic.data, - honda_static_button_name(decoded.button), (unsigned long)decoded.serial, + honda_static_button_name(decoded.button), (unsigned long)decoded.counter); } diff --git a/lib/subghz/protocols/honda_v1.c b/lib/subghz/protocols/honda_v1.c index bba51f4c..1fe45ede 100644 --- a/lib/subghz/protocols/honda_v1.c +++ b/lib/subghz/protocols/honda_v1.c @@ -822,15 +822,14 @@ void subghz_protocol_decoder_honda_v1_get_string(void* context, FuriString* outp output, "%s %dbit\r\n" "Key:%016llX\r\n" - "Btn:%s\r\n" - "Sn:%07lX Cnt:%04lX\r\n" - "Crc:%X [%s]", + "SN:%07lX Btn:%s\r\n" + "CRC:%X [%s] Cnt:%04lX", instance->generic.protocol_name, (int)instance->generic.data_count_bit, (unsigned long long)instance->generic.data, - honda_v1_button_name((uint8_t)instance->generic.btn), (unsigned long)instance->generic.serial, - (unsigned long)instance->generic.cnt, + honda_v1_button_name((uint8_t)instance->generic.btn), k2, - crc_ok ? "OK" : "ERR"); + crc_ok ? "OK" : "ERR", + (unsigned long)instance->generic.cnt); } diff --git a/lib/subghz/protocols/honda_v2.c b/lib/subghz/protocols/honda_v2.c index d2cdac7f..e45620ac 100644 --- a/lib/subghz/protocols/honda_v2.c +++ b/lib/subghz/protocols/honda_v2.c @@ -96,7 +96,6 @@ static uint64_t honda_v2_bytes_to_u64_be(const uint8_t bytes[8]) { } static uint8_t honda_v2_button_from_signature(uint32_t signature); -static const char* honda_v2_button_name(uint8_t button); static uint8_t honda_v2_calculate_check(uint32_t count); static bool honda_v2_calculate_tail_msb(uint32_t count); static uint16_t honda_v2_calculate_tail(uint32_t count); @@ -155,17 +154,6 @@ static uint8_t honda_v2_button_from_signature(uint32_t signature) { return HONDA_V2_BTN_UNKNOWN; } -static const char* honda_v2_button_name(uint8_t button) { - switch(button) { - case HONDA_V2_BTN_LOCK: - return "Lock"; - case HONDA_V2_BTN_UNLOCK: - return "Unlock"; - default: - return "Unknown"; - } -} - static uint8_t honda_v2_calculate_check(uint32_t count) { const uint8_t c0 = ((count >> 1) ^ (count >> 2) ^ (count >> 3) ^ (count >> 4) ^ (count >> 6)) & 1U; @@ -733,24 +721,16 @@ void subghz_protocol_decoder_honda_v2_get_string(void* context, FuriString* outp output, "%s %dbit\r\n" "Key:%016llX\r\n" - "Sn:%06lX\r\n" - "Btn:%02X - %s\r\n" - "BtnSig:%06lX\r\n" - "Cnt:%05lX\r\n" - "Chk:%02X [%s]\r\n" - "Tail:%05lX [%s]\r\n", + "SN:%06lX Btn:%02X\r\n" + "CRC:%02X [%s] Cnt:%05lX", instance->generic.protocol_name, instance->generic.data_count_bit, (unsigned long long)instance->key, (unsigned long)instance->serial, instance->button, - honda_v2_button_name(instance->button), - (unsigned long)instance->command_signature, - (unsigned long)instance->count, instance->check, instance->check_ok ? "OK" : "BAD", - (unsigned long)(((instance->tail >> 15) & 1U) ? 0x1FFFFUL : 0x0FFFFUL), - instance->tail_ok ? "OK" : "BAD"); + (unsigned long)instance->count); } void* subghz_protocol_encoder_honda_v2_alloc(SubGhzEnvironment* environment) { diff --git a/lib/subghz/protocols/honeywell.c b/lib/subghz/protocols/honeywell.c index 30e3f4e9..3eb47401 100644 --- a/lib/subghz/protocols/honeywell.c +++ b/lib/subghz/protocols/honeywell.c @@ -404,34 +404,15 @@ void subghz_protocol_decoder_honeywell_get_string(void* context, FuriString* out uint32_t code_found_lo = instance->generic.data & 0x00000000ffffffff; instance->generic.serial = (instance->generic.data >> 24) & 0xFFFFF; - uint8_t sensor_status = (instance->generic.data >> 16) & 0xFF; - - uint8_t channel = (instance->generic.data >> 44) & 0xF; - uint8_t contact = (sensor_status & 0x80) >> 7; - uint8_t tamper = (sensor_status & 0x40) >> 6; - uint8_t reed = (sensor_status & 0x20) >> 5; - uint8_t alarm = (sensor_status & 0x10) >> 4; - uint8_t battery_low = (sensor_status & 0x08) >> 3; - uint8_t heartbeat = (sensor_status & 0x04) >> 2; furi_string_cat_printf( output, - "%s\r\n%dbit " - "Sn:%07lu Ch:%u\r\n" - "LowBat:%d HB: %d Cont: %s\r\n" + "%s %dbit\r\n" "Key:%08lX%08lX\r\n" - "State: L1:%u L2:%u L3:%u L4:%u", + "SN:%07lu", instance->generic.protocol_name, instance->generic.data_count_bit, - instance->generic.serial, - channel, - battery_low, - heartbeat, - contact ? "open" : "closed", code_found_hi, code_found_lo, - contact, - reed, - alarm, - tamper); + instance->generic.serial); } diff --git a/lib/subghz/protocols/honeywell_wdb.c b/lib/subghz/protocols/honeywell_wdb.c index fb421d09..4a5f724e 100644 --- a/lib/subghz/protocols/honeywell_wdb.c +++ b/lib/subghz/protocols/honeywell_wdb.c @@ -373,17 +373,10 @@ void subghz_protocol_decoder_honeywell_wdb_get_string(void* context, FuriString* output, "%s %dbit\r\n" "Key:0x%lX%08lX\r\n" - "Sn:0x%05lX\r\n" - "DT:%s Al:%s\r\n" - "SK:%01X R:%01X LBat:%01X\r\n", + "SN:0x%05lX", instance->generic.protocol_name, instance->generic.data_count_bit, (uint32_t)((instance->generic.data >> 32) & 0xFFFFFFFF), (uint32_t)(instance->generic.data & 0xFFFFFFFF), - instance->generic.serial, - instance->device_type, - instance->alert, - instance->secret_knock, - instance->relay, - instance->lowbat); + instance->generic.serial); } diff --git a/lib/subghz/protocols/hormann.c b/lib/subghz/protocols/hormann.c index f8a2a9ed..a46e3903 100644 --- a/lib/subghz/protocols/hormann.c +++ b/lib/subghz/protocols/hormann.c @@ -327,10 +327,9 @@ void subghz_protocol_decoder_hormann_get_string(void* context, FuriString* outpu furi_string_cat_printf( output, - "%s\r\n" - "%dbit\r\n" + "%s %dbit\r\n" "Key:0x%03lX%08lX\r\n" - "Btn:0x%01X\r\n", + "Btn:%X", instance->generic.protocol_name, instance->generic.data_count_bit, (uint32_t)(instance->generic.data >> 32), diff --git a/lib/subghz/protocols/ido.c b/lib/subghz/protocols/ido.c index 3e82b95f..133b2be5 100644 --- a/lib/subghz/protocols/ido.c +++ b/lib/subghz/protocols/ido.c @@ -202,10 +202,6 @@ void subghz_protocol_decoder_ido_get_string(void* context, FuriString* output) { SubGhzProtocolDecoderIDo* instance = context; subghz_protocol_ido_check_remote_controller(&instance->generic); - uint64_t code_found_reverse = subghz_protocol_blocks_reverse_key( - instance->generic.data, instance->generic.data_count_bit); - uint32_t code_fix = code_found_reverse & 0xFFFFFF; - uint32_t code_hop = (code_found_reverse >> 24) & 0xFFFFFF; // push protocol data to global variable subghz_block_generic_global.btn_is_available = false; @@ -217,15 +213,11 @@ void subghz_protocol_decoder_ido_get_string(void* context, FuriString* output) { output, "%s %dbit\r\n" "Key:0x%lX%08lX\r\n" - "Fix:%06lX \r\n" - "Hop:%06lX \r\n" - "Sn:%05lX Btn:%X\r\n", + "SN:0x%05lX Btn:%X", instance->generic.protocol_name, instance->generic.data_count_bit, (uint32_t)(instance->generic.data >> 32), (uint32_t)instance->generic.data, - code_fix, - code_hop, instance->generic.serial, instance->generic.btn); } diff --git a/lib/subghz/protocols/intertechno_v3.c b/lib/subghz/protocols/intertechno_v3.c index fe9ad795..5367d06b 100644 --- a/lib/subghz/protocols/intertechno_v3.c +++ b/lib/subghz/protocols/intertechno_v3.c @@ -450,9 +450,9 @@ void subghz_protocol_decoder_intertechno_v3_get_string(void* context, FuriString furi_string_cat_printf( output, - "%.11s %db\r\n" + "%.11s %dbit\r\n" "Key:0x%08llX\r\n" - "Sn:%07lX\r\n", + "SN:0x%07lX", instance->generic.protocol_name, instance->generic.data_count_bit, instance->generic.data, @@ -460,26 +460,9 @@ void subghz_protocol_decoder_intertechno_v3_get_string(void* context, FuriString if(instance->generic.data_count_bit == subghz_protocol_intertechno_v3_const.min_count_bit_for_found) { - if(instance->generic.cnt >> 5) { - furi_string_cat_printf( - output, "Ch: All Btn:%s\r\n", (instance->generic.btn ? "On" : "Off")); - subghz_block_generic_global.btn_is_available = false; - subghz_block_generic_global.btn_length_bit = 1; - } else { - furi_string_cat_printf( - output, - "Ch:" CH_PATTERN " Btn:%s\r\n", - CNT_TO_CH(instance->generic.cnt), - (instance->generic.btn ? "On" : "Off")); - subghz_block_generic_global.btn_is_available = false; - subghz_block_generic_global.btn_length_bit = 1; - } + subghz_block_generic_global.btn_is_available = false; + subghz_block_generic_global.btn_length_bit = 1; } else if(instance->generic.data_count_bit == INTERTECHNO_V3_DIMMING_COUNT_BIT) { - furi_string_cat_printf( - output, - "Ch:" CH_PATTERN " Dimm:%d%%\r\n", - CNT_TO_CH(instance->generic.cnt), - (int)(6.67f * (float)instance->generic.btn)); subghz_block_generic_global.btn_is_available = false; subghz_block_generic_global.btn_length_bit = 4; } diff --git a/lib/subghz/protocols/jarolift.c b/lib/subghz/protocols/jarolift.c index eae35bb3..6bc891e2 100644 --- a/lib/subghz/protocols/jarolift.c +++ b/lib/subghz/protocols/jarolift.c @@ -541,28 +541,6 @@ void subghz_protocol_decoder_jarolift_feed(void* context, bool level, uint32_t d * Get button name. * @param btn Button number, 4 bit */ -static const char* subghz_protocol_jarolift_get_button_name(uint8_t btn) { - const char* btn_name; - switch(btn) { - case 0x1: - btn_name = "Learn"; - break; - case 0x2: - btn_name = "Down"; - break; - case 0x4: - btn_name = "Stop"; - break; - case 0x8: - btn_name = "Up"; - break; - default: - btn_name = "Unkn"; - break; - } - return btn_name; -} - /** * Analysis of received data * @param instance Pointer to a SubGhzBlockGeneric* instance @@ -772,15 +750,13 @@ void subghz_protocol_decoder_jarolift_get_string(void* context, FuriString* outp furi_string_cat_printf( output, "%s %dbit\r\n" - "Key:%0llX\r\n" - "Sn:%07lX Btn:%01X - %s\r\n" - "Cnt:%04lX Group:%04lX\r\n", + "Key:0x%0llX\r\n" + "SN:0x%07lX Btn:%X\r\n" + "Cnt:%04lX\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, instance->generic.data, instance->generic.serial, instance->generic.btn, - subghz_protocol_jarolift_get_button_name(instance->generic.btn), - instance->generic.cnt, - instance->generic.seed); + instance->generic.cnt); } diff --git a/lib/subghz/protocols/keeloq.c b/lib/subghz/protocols/keeloq.c index 7451e672..4799ea29 100644 --- a/lib/subghz/protocols/keeloq.c +++ b/lib/subghz/protocols/keeloq.c @@ -1788,19 +1788,12 @@ void subghz_protocol_decoder_keeloq_get_string(void* context, FuriString* output furi_assert(context); SubGhzProtocolDecoderKeeloq* instance = context; - uint32_t hopdecrypt = 0; - - hopdecrypt = subghz_protocol_keeloq_check_remote_controller( + subghz_protocol_keeloq_check_remote_controller( &instance->generic, instance->keystore, &instance->manufacture_name); uint32_t code_found_hi = instance->generic.data >> 32; uint32_t code_found_lo = instance->generic.data & 0x00000000ffffffff; - uint64_t code_found_reverse = subghz_protocol_blocks_reverse_key( - instance->generic.data, instance->generic.data_count_bit); - uint32_t code_found_reverse_hi = code_found_reverse >> 32; - uint32_t code_found_reverse_lo = code_found_reverse & 0x00000000ffffffff; - if(strcmp(instance->manufacture_name, "BFT") == 0) { // push protocol data to global variable subghz_block_generic_global.cnt_is_available = true; @@ -1812,44 +1805,17 @@ void subghz_protocol_decoder_keeloq_get_string(void* context, FuriString* output subghz_block_generic_global.btn_length_bit = 4; // - ProgMode prog_mode = subghz_custom_btn_get_prog_mode(); - if(prog_mode == PROG_MODE_KEELOQ_BFT) { - furi_string_cat_printf( - output, - "%s %dbit\r\n" - "Key:%08lX%08lX\r\n" - "Fix:0x%08lX Cnt:%04lX\r\n" - "Hop:0x%08lX Btn:%01X\r\n" - "MF:%s PRG Sd:%08lX", - instance->generic.protocol_name, - instance->generic.data_count_bit, - code_found_hi, - code_found_lo, - code_found_reverse_hi, - instance->generic.cnt, - code_found_reverse_lo, - instance->generic.btn, - instance->manufacture_name, - instance->generic.seed); - } else { - furi_string_cat_printf( - output, - "%s %dbit\r\n" - "Key:%08lX%08lX\r\n" - "Fix:0x%08lX Cnt:%04lX\r\n" - "Hop:0x%08lX Btn:%01X\r\n" - "MF:%s Sd:%08lX", - instance->generic.protocol_name, - instance->generic.data_count_bit, - code_found_hi, - code_found_lo, - code_found_reverse_hi, - instance->generic.cnt, - hopdecrypt, - instance->generic.btn, - instance->manufacture_name, - instance->generic.seed); - } + furi_string_cat_printf( + output, + "%s %dbit\r\n" + "Key:%08lX%08lX\r\n" + "Btn:%01X Cnt:%04lX", + instance->generic.protocol_name, + instance->generic.data_count_bit, + code_found_hi, + code_found_lo, + instance->generic.btn, + instance->generic.cnt); } else if(strcmp(instance->manufacture_name, "Unknown") == 0) { subghz_block_generic_global.btn_is_available = true; subghz_block_generic_global.current_btn = instance->generic.btn; @@ -1859,17 +1825,12 @@ void subghz_protocol_decoder_keeloq_get_string(void* context, FuriString* output output, "%s %dbit\r\n" "Key:%08lX%08lX\r\n" - "Fix:0x%08lX Cnt:????\r\n" - "Hop:0x%08lX Btn:%01X\r\n" - "MF:%s", + "Btn:%01X Cnt:????", instance->generic.protocol_name, instance->generic.data_count_bit, code_found_hi, code_found_lo, - code_found_reverse_hi, - code_found_reverse_lo, - instance->generic.btn, - instance->manufacture_name); + instance->generic.btn); } else { subghz_block_generic_global.cnt_is_available = true; subghz_block_generic_global.cnt_length_bit = 16; @@ -1884,36 +1845,26 @@ void subghz_protocol_decoder_keeloq_get_string(void* context, FuriString* output output, "%s %dbit\r\n" "Key:%08lX%08lX\r\n" - "Fix:0x%08lX Cnt:%04lX\r\n" - "Hop:0x%08lX Btn:%lX(B%lu)\r\n" - "MF:%s", + "Btn:%lX(B%lu) Cnt:%04lX", instance->generic.protocol_name, instance->generic.data_count_bit, code_found_hi, code_found_lo, - code_found_reverse_hi, - instance->generic.cnt, - hopdecrypt, (uint32_t)instance->generic.btn, (uint32_t)btn_pos, - instance->manufacture_name); + instance->generic.cnt); } else { furi_string_cat_printf( output, "%s %dbit\r\n" "Key:%08lX%08lX\r\n" - "Fix:0x%08lX Cnt:%04lX\r\n" - "Hop:0x%08lX Btn:%01X\r\n" - "MF:%s", + "Btn:%01X Cnt:%04lX", instance->generic.protocol_name, instance->generic.data_count_bit, code_found_hi, code_found_lo, - code_found_reverse_hi, - instance->generic.cnt, - hopdecrypt, instance->generic.btn, - instance->manufacture_name); + instance->generic.cnt); } } } diff --git a/lib/subghz/protocols/keyfinder.c b/lib/subghz/protocols/keyfinder.c index beb8f088..720f912e 100644 --- a/lib/subghz/protocols/keyfinder.c +++ b/lib/subghz/protocols/keyfinder.c @@ -337,9 +337,6 @@ void subghz_protocol_decoder_keyfinder_get_string(void* context, FuriString* out subghz_protocol_keyfinder_check_remote_controller(&instance->generic); - uint64_t code_found_reverse = subghz_protocol_blocks_reverse_key( - instance->generic.data, instance->generic.data_count_bit); - // for future use // // push protocol data to global variable // subghz_block_generic_global.btn_is_available = false; @@ -349,15 +346,12 @@ void subghz_protocol_decoder_keyfinder_get_string(void* context, FuriString* out furi_string_cat_printf( output, - "%s %db\r\n" - "Key: 0x%06lX\r\n" - "Yek: 0x%06lX\r\n" - "Serial: 0x%05lX\r\n" - "ID: 0x%0X", + "%s %dbit\r\n" + "Key:0x%06lX\r\n" + "SN:0x%05lX Btn:%X", instance->generic.protocol_name, instance->generic.data_count_bit, (uint32_t)(instance->generic.data & 0xFFFFFF), - (uint32_t)(code_found_reverse & 0xFFFFFF), instance->generic.serial, instance->generic.btn); } diff --git a/lib/subghz/protocols/kia_v0.c b/lib/subghz/protocols/kia_v0.c index 4e867e3f..350cfa33 100644 --- a/lib/subghz/protocols/kia_v0.c +++ b/lib/subghz/protocols/kia_v0.c @@ -105,17 +105,6 @@ static const uint8_t kia_v0_honda_crc_table[16] = { 0xDB, }; -// [PROTOPIRATE_PORT] Honda button names -static const char* const kia_v0_honda_button_names[7] = { - "Unlock", - "Trunk", - "Lock2", - "Unlock2", - "Trunk2", - "Unlock3", - "Trunk3", -}; - // ============================================================================ // [PROTOPIRATE_PORT] Inlined helpers replacing protocols_common.c dependencies // ============================================================================ @@ -397,38 +386,6 @@ static const char* kia_v0_protocol_subtype_name(uint8_t type) { } } -static const char* kia_v0_button_name(uint8_t button, uint8_t type) { - if(type == KIA_V0_TYPE_HONDA) { - if((button >= 1U) && (button <= (uint8_t)(sizeof(kia_v0_honda_button_names) / - sizeof(kia_v0_honda_button_names[0])))) { - return kia_v0_honda_button_names[button - 1U]; - } - return "??"; - } - if(type == KIA_V0_TYPE_SUZUKI) { - switch(button) { - case 0x03: - return "Lock"; - case 0x04: - return "Unlock"; - case 0x02: - return "Trunk"; - default: - return "??"; - } - } - switch(button) { - case 0x01: - return "Lock"; - case 0x02: - return "Unlock"; - case 0x03: - return "Trunk"; - default: - return "??"; - } -} - // [PROTOPIRATE_PORT] custom_btn D-pad -> per-subtype button code mapping. // Codes taken from kia_v0_button_name(): // KIA: Lock=0x01, Unlock=0x02, Trunk=0x03 @@ -1312,8 +1269,8 @@ void subghz_protocol_decoder_kia_get_string(void* context, FuriString* output) { // [PROTOPIRATE_PORT] Honda serial is 24-bit (6 hex), others 28-bit (7 hex) const char* sn_fmt = (instance->type == KIA_V0_TYPE_HONDA) ? - "%s %dbit\r\nKey:%016llX\r\nSn:%06lX Btn:%01X [%s]\r\nCnt:%04X CRC:%02X [%s]\r\n" : - "%s %dbit\r\nKey:%016llX\r\nSn:%07lX Btn:%01X [%s]\r\nCnt:%04X CRC:%02X [%s]\r\n"; + "%s %dbit\r\nKey:0x%llX\r\nSN:0x%06lX Btn:%X\r\nCRC:%02X [%s] Cnt:%04X\r\n" : + "%s %dbit\r\nKey:0x%llX\r\nSN:0x%07lX Btn:%X\r\nCRC:%02X [%s] Cnt:%04X\r\n"; furi_string_cat_printf( output, sn_fmt, @@ -1322,8 +1279,7 @@ void subghz_protocol_decoder_kia_get_string(void* context, FuriString* output) { (unsigned long long)instance->generic.data, (unsigned long)fields.serial, fields.button, - kia_v0_button_name(fields.button, instance->type), - fields.counter, fields.crc, - fields.crc_valid ? "OK" : "ERR"); + fields.crc_valid ? "OK" : "ERR", + fields.counter); } diff --git a/lib/subghz/protocols/kia_v1.c b/lib/subghz/protocols/kia_v1.c index 8559c47a..910e6fbd 100644 --- a/lib/subghz/protocols/kia_v1.c +++ b/lib/subghz/protocols/kia_v1.c @@ -118,25 +118,6 @@ static void subghz_protocol_kia_v1_check_remote_controller(SubGhzProtocolDecoder instance->crc_check = (crc == (instance->generic.data & 0xF)); } -static const char* subghz_protocol_kia_v1_get_name_button(uint8_t btn) { - const char* name; - switch(btn) { - case 0x1: - name = "Close"; - break; - case 0x2: - name = "Open"; - break; - case 0x3: - name = "Boot"; - break; - default: - name = "??"; - break; - } - return name; -} - void* subghz_protocol_encoder_kia_v1_alloc(SubGhzEnvironment* environment) { UNUSED(environment); SubGhzProtocolEncoderKiaV1* instance = calloc(1, sizeof(SubGhzProtocolEncoderKiaV1)); @@ -500,18 +481,16 @@ void subghz_protocol_decoder_kia_v1_get_string(void* context, FuriString* output furi_string_cat_printf( output, "%s %dbit\r\n" - "Key:%06lX%08lX\r\n" - "Serial:%08lX\r\n" - "Cnt:%03lX CRC:%01X %s\r\n" - "Btn:%02X:%s\r\n", + "Key:0x%06lX%08lX\r\n" + "SN:0x%lX Btn:%X\r\n" + "CRC:%01X %s Cnt:%03lX\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, code_found_hi, code_found_lo, instance->generic.serial, - instance->generic.cnt, + instance->generic.btn, instance->crc, instance->crc_check ? "OK" : "WRONG", - instance->generic.btn, - subghz_protocol_kia_v1_get_name_button(instance->generic.btn)); + instance->generic.cnt); } diff --git a/lib/subghz/protocols/kia_v2.c b/lib/subghz/protocols/kia_v2.c index f02dd262..030d9c63 100644 --- a/lib/subghz/protocols/kia_v2.c +++ b/lib/subghz/protocols/kia_v2.c @@ -456,15 +456,15 @@ void subghz_protocol_decoder_kia_v2_get_string(void* context, FuriString* output furi_string_cat_printf( output, "%s %dbit\r\n" - "Key:%013llX\r\n" - "Sn:%08lX Btn:%X\r\n" - "Cnt:%03lX CRC:%X - %s\r\n", + "Key:0x%013llX\r\n" + "SN:0x%lX Btn:%X\r\n" + "CRC:%X Cnt:%03lX - %s\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, instance->generic.data, instance->generic.serial, instance->generic.btn, - instance->generic.cnt, crc, + instance->generic.cnt, crc_valid ? "OK" : "BAD"); } diff --git a/lib/subghz/protocols/kia_v3_v4.c b/lib/subghz/protocols/kia_v3_v4.c index bc9595ff..be88d7ff 100644 --- a/lib/subghz/protocols/kia_v3_v4.c +++ b/lib/subghz/protocols/kia_v3_v4.c @@ -197,23 +197,6 @@ const SubGhzProtocol subghz_protocol_kia_v3_v4 = { .encoder = &subghz_protocol_kia_v3_v4_encoder, }; -static const char* subghz_protocol_kia_v3_v4_get_name_button(uint8_t btn) { - switch(btn) { - case 0x1: - return "Lock"; - case 0x2: - return "Unlock"; - case 0x3: - return "Trunk"; - case 0x4: - return "Panic"; - case 0x8: - return "Horn"; - default: - return "Unknown"; - } -} - // ============================================================================ // ENCODER IMPLEMENTATION // ============================================================================ @@ -808,40 +791,25 @@ SubGhzProtocolStatus return ret; } -static uint64_t compute_yek(uint64_t key) { - uint64_t yek = 0; - for(int i = 0; i < 64; i++) { - yek |= ((key >> i) & 1) << (63 - i); - } - return yek; -} - void subghz_protocol_decoder_kia_v3_v4_get_string(void* context, FuriString* output) { furi_assert(context); SubGhzProtocolDecoderKiaV3V4* instance = context; - uint64_t yek = compute_yek(instance->generic.data); uint32_t key_hi = (uint32_t)(instance->generic.data >> 32); uint32_t key_lo = (uint32_t)(instance->generic.data & 0xFFFFFFFF); - uint32_t yek_hi = (uint32_t)(yek >> 32); - uint32_t yek_lo = (uint32_t)(yek & 0xFFFFFFFF); furi_string_cat_printf( output, "%s %dbit\r\n" - "Key:%08lX%08lX\r\n" - "Yek:%08lX%08lX\r\n" - "Serial:%07lX Btn:%01X [%s]\r\n" - "Cnt:%04lX CRC:%01X\r\n", + "Key:0x%08lX%08lX\r\n" + "SN:0x%07lX Btn:%X\r\n" + "CRC:%01X Cnt:%04lX\r\n", kia_version_names[instance->version], instance->generic.data_count_bit, key_hi, key_lo, - yek_hi, - yek_lo, instance->generic.serial, instance->generic.btn, - subghz_protocol_kia_v3_v4_get_name_button(instance->generic.btn), - instance->generic.cnt, - instance->crc); + instance->crc, + instance->generic.cnt); } diff --git a/lib/subghz/protocols/kia_v5.c b/lib/subghz/protocols/kia_v5.c index ba9afca9..469d7e14 100644 --- a/lib/subghz/protocols/kia_v5.c +++ b/lib/subghz/protocols/kia_v5.c @@ -827,51 +827,25 @@ SubGhzProtocolStatus return ret; } -static const char* subghz_protocol_kia_v5_get_name_button(uint8_t btn) { - switch(btn) { - case 0x01: - return "Unlock"; - case 0x02: - return "Lock"; - case 0x04: - return "Trunk"; - case 0x08: - return "Horn"; - default: - return "Unknown"; - } -} - void subghz_protocol_decoder_kia_v5_get_string(void* context, FuriString* output) { furi_assert(context); SubGhzProtocolDecoderKiaV5* instance = context; - uint8_t kb[8]; - for(int i = 0; i < 8; i++) { - kb[i] = (instance->generic.data >> ((7 - i) * 8)) & 0xFF; - } - uint8_t calculated_crc = kia_v5_calculate_crc(instance->yek); bool crc_valid = (instance->crc == calculated_crc); - uint16_t seed = ((uint16_t)(instance->generic.btn & 0x0F) << 12) | - (instance->generic.serial & 0x0FFF); - furi_string_cat_printf( output, "%s %dbit\r\n" - "Key:%02X %02X %02X %02X %02X %02X %02X %02X\r\n" - "Sn:%07lX Cnt:%04lX\r\n" - "Btn:%02X [%s] Seed:%04X\r\n" - "CRC:%u %s", + "Key:0x%llX\r\n" + "SN:0x%07lX Btn:%X\r\n" + "CRC:%u Cnt:%04lX %s", instance->generic.protocol_name, instance->generic.data_count_bit, - kb[0], kb[1], kb[2], kb[3], kb[4], kb[5], kb[6], kb[7], + (unsigned long long)instance->generic.data, (unsigned long)instance->generic.serial, - (unsigned long)instance->generic.cnt, (unsigned)instance->generic.btn, - subghz_protocol_kia_v5_get_name_button(instance->generic.btn), - (unsigned)seed, (unsigned)instance->crc, + (unsigned long)instance->generic.cnt, crc_valid ? "(OK)" : "(FAIL)"); } diff --git a/lib/subghz/protocols/kia_v6.c b/lib/subghz/protocols/kia_v6.c index 0ada6809..a831f28e 100644 --- a/lib/subghz/protocols/kia_v6.c +++ b/lib/subghz/protocols/kia_v6.c @@ -736,60 +736,23 @@ void subghz_protocol_decoder_kia_v6_get_string(void* context, FuriString* output uint32_t key1_hi = instance->stored_part1_high; uint32_t key1_lo = instance->stored_part1_low; - uint32_t key2_hi = instance->stored_part2_high; - uint32_t key2_lo = instance->stored_part2_low; - - uint32_t key2_uVar4 = key2_hi << 16; - uint32_t key2_uVar2 = key2_lo >> 16; - uint32_t key2_uVar1 = key2_hi >> 16; - uint32_t key2_combined = key2_uVar4 | key2_uVar2; - - uint32_t key2_uVar3 = key2_lo << 16; - uint32_t key2_second = (instance->data_part3 & 0xFFFF) | key2_uVar3; - uint32_t serial_6 = instance->generic.serial & 0xFFFFFF; - const char* btn_name; - switch(instance->generic.btn & 0x0F) { - case 0x01: - btn_name = "Lock"; - break; - case 0x02: - btn_name = "Unlock"; - break; - case 0x03: - btn_name = "Trunk"; - break; - case 0x04: - btn_name = "Panic"; - break; - default: - btn_name = "Unknown"; - break; - } - furi_string_printf( output, "%s %dbit\r\n" - "Key:%08lX%08lX%04lX\r\n" - " %08lX%08lX\r\n" - "Fx:%02X\r\n" - "Ser:%06lX Btn:%01X [%s]\r\n" - "Cnt:%08lX CRC:%02X-%02X\r\n", + "Key:0x%08lX%08lX\r\n" + "SN:0x%06lX Btn:%X\r\n" + "CRC:%02X-%02X Cnt:%08lX\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, key1_hi, key1_lo, - key2_uVar1, - key2_combined, - key2_second, - instance->fx_field, serial_6, instance->generic.btn & 0x0F, - btn_name, - instance->generic.cnt, instance->crc1_field, - instance->crc2_field); + instance->crc2_field, + instance->generic.cnt); } static inline void kia_v6_encode_manchester_bit( diff --git a/lib/subghz/protocols/kia_v7.c b/lib/subghz/protocols/kia_v7.c index 573d2c1e..3a57dc83 100644 --- a/lib/subghz/protocols/kia_v7.c +++ b/lib/subghz/protocols/kia_v7.c @@ -631,17 +631,16 @@ void kia_protocol_decoder_v7_get_string(void* context, FuriString* output) { furi_string_cat_printf( output, "%s %dbit\r\n" - "Key:%016llX\r\n" - "Sn:%07lX Cnt:%04lX\r\n" - "Btn:%01X [%s] CRC:%02X [%s]", + "Key:0x%llX\r\n" + "SN:0x%07lX Btn:%X\r\n" + "CRC:%02X Cnt:%04lX [%s]", instance->generic.protocol_name, instance->generic.data_count_bit, instance->generic.data, instance->generic.serial & 0x0FFFFFFFU, - instance->generic.cnt & 0xFFFFU, instance->decoded_button & 0x0FU, - kia_v7_get_button_name(instance->decoded_button), instance->crc_calculated, + instance->generic.cnt & 0xFFFFU, instance->crc_valid ? "OK" : "ERR"); } diff --git a/lib/subghz/protocols/kinggates_stylo_4k.c b/lib/subghz/protocols/kinggates_stylo_4k.c index 29922c10..1d2b08a5 100644 --- a/lib/subghz/protocols/kinggates_stylo_4k.c +++ b/lib/subghz/protocols/kinggates_stylo_4k.c @@ -738,14 +738,14 @@ void subghz_protocol_decoder_kinggates_stylo_4k_get_string(void* context, FuriSt furi_string_cat_printf( output, - "%s\r\n" - "Key:0x%llX%07llX %dbit\r\n" - "Sn:0x%08lX Btn:0x%01X\r\n" + "%s %dbit\r\n" + "Key:0x%llX%07llX\r\n" + "SN:0x%lX Btn:%X\r\n" "Cnt:%04lX\r\n", instance->generic.protocol_name, + instance->generic.data_count_bit, instance->generic.data, instance->generic.data_2, - instance->generic.data_count_bit, instance->generic.serial, instance->generic.btn, instance->generic.cnt); diff --git a/lib/subghz/protocols/land_rover_v0.c b/lib/subghz/protocols/land_rover_v0.c index 0570f09c..718cddda 100644 --- a/lib/subghz/protocols/land_rover_v0.c +++ b/lib/subghz/protocols/land_rover_v0.c @@ -164,7 +164,6 @@ static uint16_t lr_encoder_read_repeat(FlipperFormat* ff, uint16_t default_val) * Forward declarations for internal (static) helpers * ═════════════════════════════════════════════════════════════════════════*/ static uint8_t land_rover_v0_button_from_signature(uint32_t signature); -static const char* land_rover_v0_button_name(uint8_t button); static uint8_t land_rover_v0_calculate_check(uint32_t count); static bool land_rover_v0_calculate_tail_msb(uint32_t count); static uint16_t land_rover_v0_calculate_tail(uint32_t count); @@ -248,14 +247,6 @@ static uint8_t land_rover_v0_button_from_signature(uint32_t signature) { return LAND_ROVER_V0_BTN_UNKNOWN; } -static const char* land_rover_v0_button_name(uint8_t button) { - switch(button) { - case LAND_ROVER_V0_BTN_LOCK: return "Lock"; - case LAND_ROVER_V0_BTN_UNLOCK: return "Unlock"; - default: return "Unknown"; - } -} - static uint8_t land_rover_v0_calculate_check(uint32_t count) { const uint8_t c0 = ((count >> 1) ^ (count >> 2) ^ (count >> 3) ^ (count >> 4) ^ (count >> 6)) & 1U; @@ -759,25 +750,17 @@ void subghz_protocol_decoder_land_rover_v0_get_string(void* context, FuriString* furi_string_cat_printf( output, "%s %dbit\r\n" - "Key:%016llX\r\n" - "Sn:%06lX\r\n" - "Btn:%02X [%s]\r\n" - "BtnSig:%06lX\r\n" - "Cnt:%05lX\r\n" - "Chk:%02X [%s]\r\n" - "Tail:%05lX [%s]", + "Key:0x%llX\r\n" + "SN:0x%06lX Btn:%X\r\n" + "CRC:%02X Cnt:%05lX [%s]", instance->generic.protocol_name, instance->generic.data_count_bit, (unsigned long long)instance->key, (unsigned long)instance->serial, instance->button, - land_rover_v0_button_name(instance->button), - (unsigned long)instance->command_signature, - (unsigned long)instance->count, instance->check, - instance->check_ok ? "OK" : "BAD", - (unsigned long)(((instance->tail >> 15) & 1U) ? 0x1FFFFUL : 0x0FFFFUL), - instance->tail_ok ? "OK" : "BAD"); + (unsigned long)instance->count, + instance->check_ok ? "OK" : "BAD"); } /* ═══════════════════════════════════════════════════════════════════════════ diff --git a/lib/subghz/protocols/legrand.c b/lib/subghz/protocols/legrand.c index 2a5078bd..fc859d53 100644 --- a/lib/subghz/protocols/legrand.c +++ b/lib/subghz/protocols/legrand.c @@ -370,10 +370,8 @@ void subghz_protocol_decoder_legrand_get_string(void* context, FuriString* outpu furi_string_cat_printf( output, "%s %dbit\r\n" - "Key:0x%05lX\r\n" - "Te:%luus\r\n", + "Key:0x%05lX\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, - (uint32_t)(instance->generic.data & 0xFFFFFF), - instance->te); + (uint32_t)(instance->generic.data & 0xFFFFFF)); } diff --git a/lib/subghz/protocols/linear.c b/lib/subghz/protocols/linear.c index f97b96e2..8d7cac9e 100644 --- a/lib/subghz/protocols/linear.c +++ b/lib/subghz/protocols/linear.c @@ -326,20 +326,11 @@ void subghz_protocol_decoder_linear_get_string(void* context, FuriString* output // only the display here is inverted (~) to show correct values. uint32_t code_found_lo = ~instance->generic.data & 0x00000000000003ff; - uint64_t code_found_reverse = subghz_protocol_blocks_reverse_key( - ~instance->generic.data, instance->generic.data_count_bit); - - uint32_t code_found_reverse_lo = code_found_reverse & 0x00000000000003ff; - furi_string_cat_printf( output, "%s %dbit\r\n" - "Key:0x%03lX\r\n" - "Yek:0x%03lX\r\n" - "DIP:" DIP_PATTERN "\r\n", + "Key:0x%03lX\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, - code_found_lo, - code_found_reverse_lo, - DATA_TO_DIP(code_found_lo)); + code_found_lo); } diff --git a/lib/subghz/protocols/linear_delta3.c b/lib/subghz/protocols/linear_delta3.c index 133f2b10..0835d8ba 100644 --- a/lib/subghz/protocols/linear_delta3.c +++ b/lib/subghz/protocols/linear_delta3.c @@ -340,10 +340,8 @@ void subghz_protocol_decoder_linear_delta3_get_string(void* context, FuriString* furi_string_cat_printf( output, "%s %dbit\r\n" - "Key:0x%lX\r\n" - "DIP:" DIP_PATTERN "\r\n", + "Key:0x%lX\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, - data, - DATA_TO_DIP(data)); + data); } diff --git a/lib/subghz/protocols/magellan.c b/lib/subghz/protocols/magellan.c index ed1b3b95..8e11a8c1 100644 --- a/lib/subghz/protocols/magellan.c +++ b/lib/subghz/protocols/magellan.c @@ -401,74 +401,6 @@ static void subghz_protocol_magellan_check_remote_controller(SubGhzBlockGeneric* instance->btn = (data_rev >> 16) & 0xFF; } -static void subghz_protocol_magellan_get_event_serialize(uint8_t event, FuriString* output) { - const char* event_type; - const char* event_subtype; - - switch((event >> 4) & 0x0F) { - case 0x00: - event_type = "Nothing"; - break; - case 0x01: - event_type = "Door"; - break; - case 0x02: - event_type = "Motion"; - break; - case 0x03: - event_type = "Smoke Alarm"; - break; - case 0x04: - event_type = "REM1"; - break; - case 0x05: - event_type = "REM1"; - event_subtype = "Off1"; - furi_string_cat_printf(output, "%s - %s", event_type, event_subtype); - return; - case 0x06: - event_type = "REM2"; - event_subtype = "Off1"; - furi_string_cat_printf(output, "%s - %s", event_type, event_subtype); - return; - default: - event_type = "Unknown"; - break; - } - - switch(event & 0x0F) { - case 0x00: - event_subtype = (((event >> 4) & 0x0F) > 0x03) ? "Arm1" : "Sealed"; - break; - case 0x01: - event_subtype = (((event >> 4) & 0x0F) > 0x03) ? "Btn1" : "Alarm"; - break; - case 0x02: - event_subtype = (((event >> 4) & 0x0F) > 0x03) ? "Btn2" : "Tamper"; - break; - case 0x03: - event_subtype = (((event >> 4) & 0x0F) > 0x03) ? "Btn3" : "Alarm + Tamper"; - break; - case 0x08: - event_subtype = "Reset"; - break; - case 0x09: - event_subtype = "LowBatt"; - break; - case 0x0A: - event_subtype = "BattOk"; - break; - case 0x0B: - event_subtype = "Learn"; - break; - default: - event_subtype = "Unknown"; - break; - } - - furi_string_cat_printf(output, "%s - %s", event_type, event_subtype); -} - uint8_t subghz_protocol_decoder_magellan_get_hash_data(void* context) { furi_assert(context); SubGhzProtocolDecoderMagellan* instance = context; @@ -510,14 +442,10 @@ void subghz_protocol_decoder_magellan_get_string(void* context, FuriString* outp output, "%s %dbit\r\n" "Key:0x%08lX\r\n" - "Sn:%03ld%03ld, Event:0x%02X\r\n" - "Stat:", + "SN:0x%lX Btn:%X\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, (uint32_t)(instance->generic.data & 0xFFFFFFFF), - (instance->generic.serial >> 8) & 0xFF, - instance->generic.serial & 0xFF, + instance->generic.serial, instance->generic.btn); - - subghz_protocol_magellan_get_event_serialize(instance->generic.btn, output); } diff --git a/lib/subghz/protocols/marantec.c b/lib/subghz/protocols/marantec.c index a07a559f..b9a15dbf 100644 --- a/lib/subghz/protocols/marantec.c +++ b/lib/subghz/protocols/marantec.c @@ -401,17 +401,16 @@ void subghz_protocol_decoder_marantec_get_string(void* context, FuriString* outp furi_string_cat_printf( output, - "%s %db\r\n" - "Key: 0x%lX%08lX\r\n" - "Sn: 0x%07lX \r\n" - "CRC: 0x%02X - %s\r\n" - "Btn: %X\r\n", + "%s %dbit\r\n" + "Key:0x%lX%08lX\r\n" + "SN:0x%07lX Btn:%X\r\n" + "CRC:0x%02X - %s\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, (uint32_t)(instance->generic.data >> 32), (uint32_t)(instance->generic.data & 0xFFFFFFFF), instance->generic.serial, + instance->generic.btn, crc, - crc_ok ? "Valid" : "Invalid", - instance->generic.btn); + crc_ok ? "Valid" : "Invalid"); } diff --git a/lib/subghz/protocols/marantec24.c b/lib/subghz/protocols/marantec24.c index b03fa209..29c2bc5a 100644 --- a/lib/subghz/protocols/marantec24.c +++ b/lib/subghz/protocols/marantec24.c @@ -340,10 +340,9 @@ void subghz_protocol_decoder_marantec24_get_string(void* context, FuriString* ou furi_string_cat_printf( output, - "%s %db\r\n" - "Key: 0x%06lX\r\n" - "Serial: 0x%05lX\r\n" - "Btn: %01X", + "%s %dbit\r\n" + "Key:0x%06lX\r\n" + "SN:0x%05lX Btn:%X", instance->generic.protocol_name, instance->generic.data_count_bit, (uint32_t)(instance->generic.data & 0xFFFFFF), diff --git a/lib/subghz/protocols/mastercode.c b/lib/subghz/protocols/mastercode.c index 1dc924c7..f30080f9 100644 --- a/lib/subghz/protocols/mastercode.c +++ b/lib/subghz/protocols/mastercode.c @@ -353,15 +353,11 @@ void subghz_protocol_decoder_mastercode_get_string(void* context, FuriString* ou furi_string_cat_printf( output, "%s %dbit\r\n" - "Key:%llX Btn:%X\r\n" - " +: " DIP_PATTERN "\r\n" - " o: " DIP_PATTERN "\r\n" - " -: " DIP_PATTERN "\r\n", + "Key:0x%llX\r\n" + "SN:0x%lX Btn:%X\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, (uint64_t)(instance->generic.data), - instance->generic.btn, - SHOW_DIP_P(instance->generic.serial, DIP_P), - SHOW_DIP_P(instance->generic.serial, DIP_O), - SHOW_DIP_P(instance->generic.serial, DIP_N)); + instance->generic.serial, + instance->generic.btn); } diff --git a/lib/subghz/protocols/mazda_siemens.c b/lib/subghz/protocols/mazda_siemens.c index 17d7537c..3631ff78 100644 --- a/lib/subghz/protocols/mazda_siemens.c +++ b/lib/subghz/protocols/mazda_siemens.c @@ -209,19 +209,6 @@ static void mazda_xor_obfuscate(uint8_t* data) { } } -static const char* mazda_get_btn_name(uint8_t btn) { - switch(btn) { - case 0x10: - return "Lock"; - case 0x20: - return "Unlock"; - case 0x40: - return "Trunk"; - default: - return "Unknown"; - } -} - // ============================================================================ // Encoder // ============================================================================ @@ -571,31 +558,19 @@ void subghz_protocol_decoder_mazda_siemens_get_string(void* context, FuriString* subghz_block_generic_global.current_btn = instance->generic.btn; subghz_block_generic_global.btn_length_bit = 8; - uint8_t data[8]; - for(int i = 0; i < 8; i++) { - data[i] = (instance->generic.data >> (56 - 8 * i)) & 0xFF; - } + const uint8_t chk = instance->generic.data & 0xFF; furi_string_cat_printf( output, "%s %dbit\r\n" - "Key:%02X %02X %02X %02X %02X %02X %02X %02X\r\n" - "Sn:%08lX\r\n" - "Btn:%s\r\n" - "Cnt:%04lX\r\n" - "Chk:%02X\r\n", + "Key:0x%llX\r\n" + "SN:0x%lX Btn:%X\r\n" + "CRC:%02X Cnt:%04lX\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, - data[0], - data[1], - data[2], - data[3], - data[4], - data[5], - data[6], - data[7], + (uint64_t)instance->generic.data, (uint32_t)instance->generic.serial, - mazda_get_btn_name(instance->generic.btn), - (uint32_t)instance->generic.cnt, - data[7]); + instance->generic.btn, + chk, + (uint32_t)instance->generic.cnt); } diff --git a/lib/subghz/protocols/mazda_v0.c b/lib/subghz/protocols/mazda_v0.c index f26660f4..774d60f2 100644 --- a/lib/subghz/protocols/mazda_v0.c +++ b/lib/subghz/protocols/mazda_v0.c @@ -742,18 +742,15 @@ void subghz_protocol_decoder_mazda_v0_get_string(void* context, FuriString* outp furi_string_cat_printf( output, "%s %dbit\r\n" - "Key:%016llX\r\n" - "Sn:%08lX\r\n" - "Btn:%02X - %s\r\n" - "Cnt:%05lX\r\n" - "Chk:%02X [%s]\r\n", + "Key:0x%016llX\r\n" + "SN:0x%lX Btn:%X\r\n" + "CRC:%02X Cnt:%05lX [%s]\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, (unsigned long long)instance->generic.data, (unsigned long)instance->generic.serial, instance->generic.btn, - mazda_v0_get_button_name(instance->generic.btn), - (unsigned long)(instance->generic.cnt & 0xFFFFFU), raw_crc, + (unsigned long)(instance->generic.cnt & 0xFFFFFU), (raw_crc == calc_crc) ? "OK" : "BAD"); } diff --git a/lib/subghz/protocols/megacode.c b/lib/subghz/protocols/megacode.c index cf7737aa..310a73db 100644 --- a/lib/subghz/protocols/megacode.c +++ b/lib/subghz/protocols/megacode.c @@ -415,13 +415,10 @@ void subghz_protocol_decoder_megacode_get_string(void* context, FuriString* outp output, "%s %dbit\r\n" "Key:0x%06lX\r\n" - "Sn:0x%04lX - %lu\r\n" - "Facility:%lX Btn:%X\r\n", + "SN:0x%lX Btn:%X\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, (uint32_t)instance->generic.data, instance->generic.serial, - instance->generic.serial, - instance->generic.cnt, instance->generic.btn); } diff --git a/lib/subghz/protocols/mitsubishi_v0.c b/lib/subghz/protocols/mitsubishi_v0.c index dfde0ef9..865dee57 100644 --- a/lib/subghz/protocols/mitsubishi_v0.c +++ b/lib/subghz/protocols/mitsubishi_v0.c @@ -401,11 +401,13 @@ void subghz_protocol_decoder_mitsubishi_v0_get_string(void* context, FuriString* furi_string_cat_printf( output, "%s %dbit\r\n" - "Sn:%08lX Cnt:%04lX\r\n" - "Btn:%02X\r\n", + "Key:0x%llX\r\n" + "SN:0x%lX Btn:%X\r\n" + "Cnt:%04lX\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, + (uint64_t)instance->generic.data, instance->generic.serial, - instance->generic.cnt, - instance->generic.btn); + instance->generic.btn, + instance->generic.cnt); } diff --git a/lib/subghz/protocols/nero_radio.c b/lib/subghz/protocols/nero_radio.c index 212dc684..8c10d2f7 100644 --- a/lib/subghz/protocols/nero_radio.c +++ b/lib/subghz/protocols/nero_radio.c @@ -422,12 +422,6 @@ void subghz_protocol_decoder_nero_radio_get_string(void* context, FuriString* ou uint32_t code_found_hi = instance->generic.data >> 32; uint32_t code_found_lo = instance->generic.data & 0x00000000ffffffff; - uint64_t code_found_reverse = subghz_protocol_blocks_reverse_key( - instance->generic.data, instance->generic.data_count_bit); - - uint32_t code_found_reverse_hi = code_found_reverse >> 32; - uint32_t code_found_reverse_lo = code_found_reverse & 0x00000000ffffffff; - subghz_protocol_nero_radio_parse_data(&instance->generic); // push protocol data to global variable @@ -440,17 +434,11 @@ void subghz_protocol_decoder_nero_radio_get_string(void* context, FuriString* ou output, "%s %dbit\r\n" "Key:0x%lX%08lX\r\n" - "Yek:0x%lX%08lX\r\n" - "Sn: 0x%llX \r\n" - "CRC?: 0x%02X\r\n" - "Btn: %X\r\n", + "SN:0x%llX Btn:%X\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, code_found_hi, code_found_lo, - code_found_reverse_hi, - code_found_reverse_lo, instance->generic.data_2, - (uint8_t)(instance->generic.data & 0xFF), instance->generic.btn); } diff --git a/lib/subghz/protocols/nero_sketch.c b/lib/subghz/protocols/nero_sketch.c index a8a011aa..d7943599 100644 --- a/lib/subghz/protocols/nero_sketch.c +++ b/lib/subghz/protocols/nero_sketch.c @@ -354,21 +354,12 @@ void subghz_protocol_decoder_nero_sketch_get_string(void* context, FuriString* o uint32_t code_found_hi = instance->generic.data >> 32; uint32_t code_found_lo = instance->generic.data & 0x00000000ffffffff; - uint64_t code_found_reverse = subghz_protocol_blocks_reverse_key( - instance->generic.data, instance->generic.data_count_bit); - - uint32_t code_found_reverse_hi = code_found_reverse >> 32; - uint32_t code_found_reverse_lo = code_found_reverse & 0x00000000ffffffff; - furi_string_cat_printf( output, "%s %dbit\r\n" - "Key:0x%lX%08lX\r\n" - "Yek:0x%lX%08lX\r\n", + "Key:0x%lX%08lX\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, code_found_hi, - code_found_lo, - code_found_reverse_hi, - code_found_reverse_lo); + code_found_lo); } diff --git a/lib/subghz/protocols/nice_flo.c b/lib/subghz/protocols/nice_flo.c index f7c8fe75..f5fdaa31 100644 --- a/lib/subghz/protocols/nice_flo.c +++ b/lib/subghz/protocols/nice_flo.c @@ -319,17 +319,12 @@ void subghz_protocol_decoder_nice_flo_get_string(void* context, FuriString* outp SubGhzProtocolDecoderNiceFlo* instance = context; uint32_t code_found_lo = instance->generic.data & 0x00000000ffffffff; - uint64_t code_found_reverse = subghz_protocol_blocks_reverse_key( - instance->generic.data, instance->generic.data_count_bit); - uint32_t code_found_reverse_lo = code_found_reverse & 0x00000000ffffffff; furi_string_cat_printf( output, "%s %dbit\r\n" - "Key:0x%08lX\r\n" - "Yek:0x%08lX\r\n", + "Key:0x%08lX\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, - code_found_lo, - code_found_reverse_lo); + code_found_lo); } diff --git a/lib/subghz/protocols/nice_flor_s.c b/lib/subghz/protocols/nice_flor_s.c index 5b301573..77e81709 100644 --- a/lib/subghz/protocols/nice_flor_s.c +++ b/lib/subghz/protocols/nice_flor_s.c @@ -961,27 +961,27 @@ void subghz_protocol_decoder_nice_flor_s_get_string(void* context, FuriString* o output, "%s %dbit\r\n" "Key:%013llX%llX\r\n" - "Sn:%05lX\r\n" - "Cnt:%04lX Btn:%02X\r\n", + "SN:0x%lX Btn:%X\r\n" + "Cnt:%04lX\r\n", NICE_ONE_NAME, instance->generic.data_count_bit, instance->generic.data, instance->generic.data_2, instance->generic.serial, - instance->generic.cnt, - instance->generic.btn); + instance->generic.btn, + instance->generic.cnt); } else { furi_string_cat_printf( output, "%s %dbit\r\n" "Key:0x%013llX\r\n" - "Sn:%05lX\r\n" - "Cnt:%04lX Btn:%02X\r\n", + "SN:0x%lX Btn:%X\r\n" + "Cnt:%04lX\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, instance->generic.data, instance->generic.serial, - instance->generic.cnt, - instance->generic.btn); + instance->generic.btn, + instance->generic.cnt); } } diff --git a/lib/subghz/protocols/nord_ice.c b/lib/subghz/protocols/nord_ice.c index d8386994..2ffdf53d 100644 --- a/lib/subghz/protocols/nord_ice.c +++ b/lib/subghz/protocols/nord_ice.c @@ -295,9 +295,6 @@ void subghz_protocol_decoder_nord_ice_get_string(void* context, FuriString* outp subghz_protocol_nord_ice_check_remote_controller(&instance->generic); - uint64_t code_found_reverse = subghz_protocol_blocks_reverse_key( - instance->generic.data, instance->generic.data_count_bit); - // for future use // // push protocol data to global variable // subghz_block_generic_global.btn_is_available = false; @@ -307,15 +304,12 @@ void subghz_protocol_decoder_nord_ice_get_string(void* context, FuriString* outp furi_string_cat_printf( output, - "%s %db\r\n" - "Key: 0x%08llX\r\n" - "Yek: 0x%08llX\r\n" - "Serial: 0x%07lX\r\n" - "Btn: %02X", + "%s %dbit\r\n" + "Key:0x%08llX\r\n" + "SN:0x%lX Btn:%X\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, (uint64_t)(instance->generic.data & 0xFFFFFFFFF), - (code_found_reverse & 0xFFFFFFFFF), instance->generic.serial, instance->generic.btn); } diff --git a/lib/subghz/protocols/phoenix_v2.c b/lib/subghz/protocols/phoenix_v2.c index 41f4e1c7..bfc6c99a 100644 --- a/lib/subghz/protocols/phoenix_v2.c +++ b/lib/subghz/protocols/phoenix_v2.c @@ -676,13 +676,12 @@ void subghz_protocol_decoder_phoenix_v2_get_string(void* context, FuriString* ou output, "V2 Phoenix %dbit\r\n" "Key:%05lX%08lX\r\n" - "Sn:0x%07lX \r\n" - "Cnt:%04lX\r\n" - "Btn:%X\r\n", + "SN:0x%lX Btn:%X\r\n" + "Cnt:%04lX\r\n", instance->generic.data_count_bit, (uint32_t)(instance->generic.data >> 32) & 0xFFFFFFFF, (uint32_t)(instance->generic.data & 0xFFFFFFFF), instance->generic.serial, - instance->generic.cnt, - instance->generic.btn); + instance->generic.btn, + instance->generic.cnt); } diff --git a/lib/subghz/protocols/porsche_cayenne.c b/lib/subghz/protocols/porsche_cayenne.c index 59c1d574..5ee2f251 100644 --- a/lib/subghz/protocols/porsche_cayenne.c +++ b/lib/subghz/protocols/porsche_cayenne.c @@ -433,26 +433,18 @@ void subghz_protocol_decoder_porsche_cayenne_get_string(void* context, FuriStrin } subghz_custom_btn_set_max(4); - uint8_t frame_type = (uint8_t)(instance->generic.data >> 56) & 0x07; - const char* ft_name = "??"; - if(frame_type == 0b010) ft_name = "First"; - else if(frame_type == 0b001) ft_name = "Cont"; - else if(frame_type == 0b100) ft_name = "Final"; - furi_string_cat_printf( output, "%s 64bit\r\n" - "Sn:%06lX\r\n" - "Btn:%X\r\n" - "Cnt:%04lX FT:%s\r\n" - "Raw:%08lX%08lX", + "Key:0x%08lX%08lX\r\n" + "SN:0x%lX Btn:%X\r\n" + "Cnt:%04lX\r\n", instance->generic.protocol_name, + (unsigned long)(instance->generic.data >> 32), + (unsigned long)(instance->generic.data & 0xFFFFFFFF), (unsigned long)(instance->generic.serial & 0xFFFFFF), (unsigned int)instance->generic.btn, - (unsigned long)instance->generic.cnt, - ft_name, - (unsigned long)(instance->generic.data >> 32), - (unsigned long)(instance->generic.data & 0xFFFFFFFF)); + (unsigned long)instance->generic.cnt); } // ============================================================================= diff --git a/lib/subghz/protocols/power_smart.c b/lib/subghz/protocols/power_smart.c index 8acf714d..0865bf67 100644 --- a/lib/subghz/protocols/power_smart.c +++ b/lib/subghz/protocols/power_smart.c @@ -332,12 +332,6 @@ void subghz_protocol_decoder_power_smart_feed( } } -static const char* subghz_protocol_power_smart_get_name_button(uint8_t btn) { - btn &= 0x3; - const char* name_btn[0x4] = {"Unknown", "Down", "Up", "Stop"}; - return name_btn[btn]; -} - uint8_t subghz_protocol_decoder_power_smart_get_hash_data(void* context) { furi_assert(context); SubGhzProtocolDecoderPowerSmart* instance = context; @@ -377,16 +371,13 @@ void subghz_protocol_decoder_power_smart_get_string(void* context, FuriString* o furi_string_cat_printf( output, - "%s %db\r\n" + "%s %dbit\r\n" "Key:0x%lX%08lX\r\n" - "Sn:0x%07lX \r\n" - "Btn:%s\r\n" - "Channel:" CHANNEL_PATTERN "\r\n", + "SN:0x%lX Btn:%X\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, (uint32_t)(instance->generic.data >> 32), (uint32_t)(instance->generic.data & 0xFFFFFFFF), instance->generic.serial, - subghz_protocol_power_smart_get_name_button(instance->generic.btn), - CNT_TO_CHANNEL(instance->generic.cnt)); + instance->generic.btn); } diff --git a/lib/subghz/protocols/princeton.c b/lib/subghz/protocols/princeton.c index f77e0e72..54a02770 100644 --- a/lib/subghz/protocols/princeton.c +++ b/lib/subghz/protocols/princeton.c @@ -591,8 +591,6 @@ void subghz_protocol_decoder_princeton_get_string(void* context, FuriString* out furi_assert(context); SubGhzProtocolDecoderPrinceton* instance = context; subghz_protocol_princeton_check_remote_controller(&instance->generic); - uint32_t data_rev = subghz_protocol_blocks_reverse_key( - instance->generic.data, instance->generic.data_count_bit); // push protocol data to global variable subghz_block_generic_global.btn_is_available = true; @@ -606,35 +604,25 @@ void subghz_protocol_decoder_princeton_get_string(void* context, FuriString* out output, "%s %dbit\r\n" "Key:0x%08lX\r\n" - "Yek:0x%08lX\r\n" - "Sn:0x%05lX Btn:%02X (8b)\r\n" - "Te:%luus GT:Te*%lu\r\n", + "SN:0x%lX Btn:%X\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, (uint32_t)(instance->generic.data & 0xFFFFFF), - data_rev, instance->generic.serial, (instance->generic.btn == 0xF3 || instance->generic.btn == 0xFC) ? instance->generic.btn & 0xF : - instance->generic.btn, - instance->te, - instance->guard_time); + instance->generic.btn); } else { subghz_block_generic_global.btn_length_bit = 4; furi_string_cat_printf( output, "%s %dbit\r\n" "Key:0x%08lX\r\n" - "Yek:0x%08lX\r\n" - "Sn:0x%05lX Btn:%01X (4b)\r\n" - "Te:%luus GT:Te*%lu\r\n", + "SN:0x%lX Btn:%X\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, (uint32_t)(instance->generic.data & 0xFFFFFF), - data_rev, instance->generic.serial, - instance->generic.btn, - instance->te, - instance->guard_time); + instance->generic.btn); } } diff --git a/lib/subghz/protocols/protocol_items.c b/lib/subghz/protocols/protocol_items.c index 1f71ed73..bf346963 100644 --- a/lib/subghz/protocols/protocol_items.c +++ b/lib/subghz/protocols/protocol_items.c @@ -107,7 +107,7 @@ const SubGhzProtocol* const subghz_protocol_registry_items[] = { &ford_protocol_v2, &ford_protocol_v3, //&subghz_protocol_land_rover_v0, - &subghz_protocol_toyota, + //&subghz_protocol_toyota, &honda_static_protocol, &honda_v1_protocol, &honda_v2_protocol, diff --git a/lib/subghz/protocols/psa.c b/lib/subghz/protocols/psa.c index a0dcc28e..a033dd69 100644 --- a/lib/subghz/protocols/psa.c +++ b/lib/subghz/protocols/psa.c @@ -1406,9 +1406,6 @@ void subghz_protocol_decoder_psa_get_string(void* context, FuriString* output) { furi_assert(context); SubGhzProtocolDecoderPSA* instance = context; - - uint16_t key2_value = (uint16_t)(instance->key2_low & 0xFFFF); - if(instance->decrypted == 0x50 && instance->decrypted_type != 0) { // Always update original button when loading a new file subghz_custom_btn_set_original(psa_btn_to_custom(instance->generic.btn)); @@ -1418,56 +1415,42 @@ void subghz_protocol_decoder_psa_get_string(void* context, FuriString* output) { furi_string_printf( output, "%s %dbit\r\n" - "Key1:%08lX%08lX\r\n" - "Key2:%04X\r\n" - "Ser:%06lX\r\n" - "Btn:[%s] Cnt:%04lX\r\n" - "Type:%02X CRC:%02X\r\n" - "Sd:%06lX", + "Key:0x%08lX%08lX\r\n" + "SN:0x%lX Btn:%s\r\n" + "CRC:%02X Cnt:%04lX", instance->base.protocol->name, 128, instance->key1_high, instance->key1_low, - key2_value, instance->generic.serial, psa_button_name(display_btn), - instance->generic.cnt, - instance->decrypted_type, instance->decrypted_crc, - instance->decrypted_seed); + instance->generic.cnt); } else if(instance->decrypted_type == 0x36) { furi_string_printf( output, "%s %dbit\r\n" - "Key1:%08lX%08lX\r\n" - "Key2:%04X\r\n" - "Ser:%06lX\r\n" - "Btn:[%s] Cnt:%08lX\r\n" - "Type:%02X CRC:%02X\r\n" - "Sd:%06lX", + "Key:0x%08lX%08lX\r\n" + "SN:0x%lX Btn:%s\r\n" + "CRC:%02X Cnt:%08lX", instance->base.protocol->name, 128, instance->key1_high, instance->key1_low, - key2_value, instance->generic.serial, psa_button_name(display_btn), - instance->generic.cnt, - instance->decrypted_type, instance->decrypted_crc, - instance->decrypted_seed); + instance->generic.cnt); } } else { furi_string_printf( output, "%s %dbit\r\n" - "Key1:%08lX%08lX\r\n" - "Key2:%04X", + "Key:0x%08lX%08lX", instance->base.protocol->name, 128, instance->key1_high, - instance->key1_low, - key2_value); + instance->key1_low); } } diff --git a/lib/subghz/protocols/psa2.c b/lib/subghz/protocols/psa2.c index c4eb947d..3f993e57 100644 --- a/lib/subghz/protocols/psa2.c +++ b/lib/subghz/protocols/psa2.c @@ -84,13 +84,6 @@ static const uint32_t PSA_BF1_KEY_SCHEDULE[4] = { #define PSA_BF2_START 0xF3000000U #define PSA_BF2_END 0xF4000000U -static const uint32_t PSA_BF2_KEY_SCHEDULE[4] = { - 0x4039C240U, - 0xEDA92CABU, - 0x4306C02AU, - 0x02192A04U, -}; - /* Validation nibble for mode23 XOR path */ #define PSA_VALID_NIBBLE 0xA /* (validation_field & 0xF) == 0xA */ @@ -187,9 +180,6 @@ struct SubGhzProtocolEncoderPSA { * ========================================================= */ static bool psa_direct_xor_decrypt(SubGhzProtocolDecoderPSA* instance); -static bool psa_brute_force_decrypt_bf1(SubGhzProtocolDecoderPSA* instance); -static bool psa_brute_force_decrypt_bf2(SubGhzProtocolDecoderPSA* instance); -static void __attribute__((unused)) psa_decrypt_full(SubGhzProtocolDecoderPSA* instance); /* ========================================================= * PROTOCOL DESCRIPTORS @@ -228,15 +218,6 @@ const SubGhzProtocol subghz_protocol_psa2 = { * BUTTON HELPERS * ========================================================= */ -static const char* psa_button_name(uint8_t btn) { - switch(btn) { - case PSA_BTN_LOCK: return "Lock"; - case PSA_BTN_UNLOCK: return "Unlock"; - case PSA_BTN_TRUNK: return "Trunk"; - default: return "??"; - } -} - static uint8_t psa_get_btn_code(void) { uint8_t custom_btn = subghz_custom_btn_get(); uint8_t original_raw = subghz_custom_btn_get_original(); @@ -271,19 +252,6 @@ static void psa_tea_encrypt(uint32_t* v0, uint32_t* v1, const uint32_t* key) { *v0 = a; *v1 = b; } -static void psa_tea_decrypt(uint32_t* v0, uint32_t* v1, const uint32_t* key) { - uint32_t a = *v0, b = *v1; - uint32_t sum = TEA_DELTA * TEA_ROUNDS; - for(int i = 0; i < TEA_ROUNDS; i++) { - uint32_t t = key[(sum >> 11) & 3] + sum; - sum -= TEA_DELTA; - b -= t ^ ((a >> 5 ^ a << 4) + a); - t = key[sum & 3] + sum; - a -= t ^ ((b >> 5 ^ b << 4) + b); - } - *v0 = a; *v1 = b; -} - /* FUN_08028e60 — simple byte-sum CRC over 7 bytes of TEA output */ static uint8_t psa_calculate_tea_crc(uint32_t v0, uint32_t v1) { uint32_t crc = ((v0 >> 24) & 0xFF) + ((v0 >> 16) & 0xFF) + @@ -292,19 +260,6 @@ static uint8_t psa_calculate_tea_crc(uint32_t v0, uint32_t v1) { return (uint8_t)(crc & 0xFF); } -/* FUN_08029098 — CRC-16/BUYPASS (poly 0x8005, no reflection, init 0) */ -static uint16_t psa_calculate_crc16_bf2(const uint8_t* data, int len) { - uint16_t crc = 0; - for(int i = 0; i < len; i++) { - crc ^= (uint16_t)data[i] << 8; - for(int j = 0; j < 8; j++) { - if(crc & 0x8000) crc = (crc << 1) ^ 0x8005; - else crc <<= 1; - } - } - return crc; -} - /* ========================================================= * BUFFER HELPERS * ========================================================= @@ -383,14 +338,6 @@ static void psa_second_stage_xor_encrypt(uint8_t* buf) { buf[2]=E0; buf[3]=E1; buf[4]=E2; buf[5]=E3; buf[6]=E4; buf[7]=E5; } -/* FUN_08028f4c — pack buffer bytes into two TEA words */ -static void psa_prepare_tea_data(const uint8_t* buf, uint32_t* w0, uint32_t* w1) { - *w0 = ((uint32_t)buf[2] << 24) | ((uint32_t)buf[3] << 16) | - ((uint32_t)buf[4] << 8) | (uint32_t)buf[5]; - *w1 = ((uint32_t)buf[6] << 24) | ((uint32_t)buf[7] << 16) | - ((uint32_t)buf[8] << 8) | (uint32_t)buf[9]; -} - /* FUN_08028e88 — unpack TEA words back into buffer[2..9] */ static void psa_unpack_tea_result(uint8_t* buf, uint32_t v0, uint32_t v1) { buf[2] = (v0 >> 24) & 0xFF; @@ -439,16 +386,6 @@ static void psa_extract_fields_mode23(uint8_t* buf, SubGhzProtocolDecoderPSA* in inst->decrypted_seed = inst->decrypted_serial; } -static void psa_extract_fields_mode36(uint8_t* buf, SubGhzProtocolDecoderPSA* inst) { - inst->decrypted_button = (buf[5] >> 4) & 0xF; - inst->decrypted_serial = ((uint32_t)buf[2] << 16) | ((uint32_t)buf[3] << 8) | buf[4]; - inst->decrypted_counter = ((uint32_t)buf[7] << 8) | ((uint32_t)buf[6] << 16) | - (uint32_t)buf[8] | (((uint32_t)buf[5] & 0xF) << 24); - inst->decrypted_crc = buf[9]; - inst->decrypted_type = PSA_MODE_36; - inst->decrypted_seed = inst->decrypted_serial; -} - /* ========================================================= * DECRYPTION PATHS * ========================================================= @@ -494,114 +431,6 @@ static bool psa_direct_xor_decrypt(SubGhzProtocolDecoderPSA* inst) { return false; } -/* FUN_08028f94 — BF1 (range 0x23000000–0x24000000) */ -static bool psa_brute_force_decrypt_bf1(SubGhzProtocolDecoderPSA* inst) { - uint8_t buf[48] = {0}; - psa_setup_byte_buffer(buf, inst->key1_low, inst->key1_high, inst->key2_low); - uint32_t w0, w1; - psa_prepare_tea_data(buf, &w0, &w1); - - for(uint32_t counter = PSA_BF1_START; counter < PSA_BF1_END; counter++) { - /* Build working key — firmware does two TEA encrypts to derive it */ - uint32_t wk2 = PSA_BF1_CONST_U4; - uint32_t wk3 = counter; - psa_tea_encrypt(&wk2, &wk3, PSA_BF1_KEY_SCHEDULE); - - uint32_t wk0 = (counter << 8) | 0x0E; - uint32_t wk1 = PSA_BF1_CONST_U5; - psa_tea_encrypt(&wk0, &wk1, PSA_BF1_KEY_SCHEDULE); - - uint32_t wkey[4] = {wk0, wk1, wk2, wk3}; - - uint32_t dv0 = w0, dv1 = w1; - psa_tea_decrypt(&dv0, &dv1, wkey); - - /* Serial embedded in upper 24 bits of dv0 */ - if((counter & 0xFFFFFF) == (dv0 >> 8)) { - uint8_t crc = psa_calculate_tea_crc(dv0, dv1); - if(crc == (dv1 & 0xFF)) { - psa_unpack_tea_result(buf, dv0, dv1); - psa_extract_fields_mode36(buf, inst); - inst->decrypted_seed = counter; - return true; - } - } - } - return false; -} - -/* FUN_080290f8 — BF2 (range 0xF3000000–0xF4000000) - * - * CRITICAL DIFFERENCE vs your psa.c: - * - * In the firmware the CRC-16 input is packed as: - * crc_buf[0] = dv0 >> 24 - * crc_buf[1] = (dv0 >> 8) >> 8 -- NOTE: this is (dv0>>16)&0xFF - * crc_buf[2] = (dv0 >> 16) >> 8 -- NOTE: this is (dv0>>8)&0xFF ← SWAPPED - * crc_buf[3] = dv0 & 0xFF - * crc_buf[4] = dv1 >> 24 - * crc_buf[5] = (dv1 >> 16) & 0xFF - * - * Firmware code (FUN_080290f8): - * puVar2[0] = uVar8 >> 0x18 // byte0 = dv0[31:24] - * puVar2[1] = uVar6 (=(uVar8<<8)>>18) // byte1 = dv0[23:16] ← confirmed - * puVar2[2] = uVar10 (=(uVar8<<16)>>18) // byte2 = dv0[15:8] - * puVar2[3] = uVar8 & 0xFF // byte3 = dv0[7:0] - * puVar2[4] = uVar11 >> 0x18 // byte4 = dv1[31:24] - * puVar2[5] = (uVar11<<8)>>18 // byte5 = dv1[23:16] - * - * Then expected CRC = (dv1 & 0xFF) | (((dv1>>16)&0xFF) << 8) - * - * Your psa.c has the bytes in the wrong order for the CRC buffer. - * This is likely your main BF2 bug. - */ - -static bool psa_brute_force_decrypt_bf2(SubGhzProtocolDecoderPSA* inst) { - uint8_t buf[48] = {0}; - psa_setup_byte_buffer(buf, inst->key1_low, inst->key1_high, inst->key2_low); - uint32_t w0, w1; - psa_prepare_tea_data(buf, &w0, &w1); - - for(uint32_t counter = PSA_BF2_START; counter < PSA_BF2_END; counter++) { - uint32_t wkey[4] = { - PSA_BF2_KEY_SCHEDULE[0] ^ counter, - PSA_BF2_KEY_SCHEDULE[1] ^ counter, - PSA_BF2_KEY_SCHEDULE[2] ^ counter, - PSA_BF2_KEY_SCHEDULE[3] ^ counter, - }; - - uint32_t dv0 = w0, dv1 = w1; - psa_tea_decrypt(&dv0, &dv1, wkey); - - if((counter & 0xFFFFFF) == (dv0 >> 8)) { - /* FIRMWARE CRC-16 input layout (confirmed from FUN_080290f8) */ - uint8_t crc_buf[6] = { - (uint8_t)( dv0 >> 24), /* byte 0 */ - (uint8_t)((dv0 >> 16) & 0xFF), /* byte 1 */ - (uint8_t)((dv0 >> 8) & 0xFF), /* byte 2 */ - (uint8_t)( dv0 & 0xFF), /* byte 3 */ - (uint8_t)( dv1 >> 24), /* byte 4 */ - (uint8_t)((dv1 >> 16) & 0xFF), /* byte 5 */ - }; - uint16_t crc16 = psa_calculate_crc16_bf2(crc_buf, 6); - - /* FIRMWARE expected CRC encoding (confirmed from FUN_080290f8): - * expected = (dv1 & 0xFF) | (((dv1>>16)&0xFF) << 8) - * Your psa.c used: ((dv1>>16)&0xFF)<<8 | (dv1&0xFF) ← same, no bug here - */ - uint16_t expected = (uint16_t)((dv1 & 0xFF) | (((dv1 >> 16) & 0xFF) << 8)); - - if(crc16 == expected) { - psa_unpack_tea_result(buf, dv0, dv1); - psa_extract_fields_mode36(buf, inst); - inst->decrypted_seed = counter; - return true; - } - } - } - return false; -} - /* ========================================================= * MAIN DECRYPT ROUTER — FUN_080291c0 * @@ -617,62 +446,6 @@ static bool psa_brute_force_decrypt_bf2(SubGhzProtocolDecoderPSA* inst) { * on a packet that already failed brute force in this session. * ========================================================= */ -static void __attribute__((unused)) psa_decrypt_full(SubGhzProtocolDecoderPSA* inst) { - char mode = (char)inst->mode_serialize; - - if(mode == PSA_MODE_23) { - if(psa_direct_xor_decrypt(inst)) { - inst->mode_serialize = PSA_MODE_23; - inst->decrypted = 0x50; - } - return; - } - - if(mode == PSA_MODE_36) { - /* BF1 first, then BF2 */ - if(psa_brute_force_decrypt_bf1(inst)) { - inst->mode_serialize = PSA_MODE_36; - inst->decrypted = 0x50; - return; - } - if(psa_brute_force_decrypt_bf2(inst)) { - inst->mode_serialize = PSA_MODE_36; - inst->decrypted = 0x50; - } - return; - } - - /* mode == 0: try XOR first */ - if(psa_direct_xor_decrypt(inst)) { - inst->mode_serialize = PSA_MODE_23; - inst->decrypted = 0x50; - return; - } - - /* XOR failed — check BF-attempted flag before doing expensive BF */ - if(inst->bf_attempted) { - /* already tried and failed — don't retry */ - inst->decrypted = 0x00; - return; - } - - /* Run BF */ - if(psa_brute_force_decrypt_bf1(inst)) { - inst->mode_serialize = PSA_MODE_36; - inst->decrypted = 0x50; - return; - } - if(psa_brute_force_decrypt_bf2(inst)) { - inst->mode_serialize = PSA_MODE_36; - inst->decrypted = 0x50; - return; - } - - /* All paths failed */ - inst->bf_attempted = 1; - inst->decrypted = 0x00; -} - /* Fast path (no BF) — used in feed callback */ static void psa_decrypt_fast(SubGhzProtocolDecoderPSA* inst) { if(psa_direct_xor_decrypt(inst)) { @@ -1199,8 +972,6 @@ void subghz_protocol_decoder_psa2_get_string(void* context, FuriString* output) furi_assert(context); SubGhzProtocolDecoderPSA* inst = context; - uint16_t key2_val = (uint16_t)(inst->key2_low & 0xFFFF); - if(inst->decrypted == 0x50 && inst->decrypted_type != 0) { subghz_custom_btn_set_original(inst->generic.btn == 0 ? 0xFF : inst->generic.btn); subghz_custom_btn_set_max(4); @@ -1209,42 +980,30 @@ void subghz_protocol_decoder_psa2_get_string(void* context, FuriString* output) if(inst->decrypted_type == PSA_MODE_23) { furi_string_printf(output, "%s %dbit\r\n" - "Key1:%08lX%08lX\r\n" - "Key2:%04X\r\n" - "Ser:%06lX\r\n" - "Btn:[%s] Cnt:%04lX\r\n" - "Type:%02X CRC:%02X\r\n" - "Sd:%06lX", + "Key:0x%08lX%08lX\r\n" + "SN:0x%lX Btn:%X\r\n" + "CRC:%02X Cnt:%04lX", inst->base.protocol->name, 128, inst->key1_high, inst->key1_low, - key2_val, inst->generic.serial, - psa_button_name(display_btn), inst->generic.cnt, - inst->decrypted_type, inst->decrypted_crc, - inst->decrypted_seed); + inst->generic.serial, display_btn, + inst->decrypted_crc, inst->generic.cnt); } else { furi_string_printf(output, "%s %dbit\r\n" - "Key1:%08lX%08lX\r\n" - "Key2:%04X\r\n" - "Ser:%06lX\r\n" - "Btn:[%s] Cnt:%08lX\r\n" - "Type:%02X CRC:%04X\r\n" - "Sd:%06lX", + "Key:0x%08lX%08lX\r\n" + "SN:0x%lX Btn:%X\r\n" + "CRC:%04X Cnt:%08lX", inst->base.protocol->name, 128, inst->key1_high, inst->key1_low, - key2_val, inst->generic.serial, - psa_button_name(display_btn), inst->generic.cnt, - inst->decrypted_type, inst->decrypted_crc, - inst->decrypted_seed); + inst->generic.serial, display_btn, + inst->decrypted_crc, inst->generic.cnt); } } else { furi_string_printf(output, "%s %dbit\r\n" - "Key1:%08lX%08lX\r\n" - "Key2:%04X", + "Key:0x%08lX%08lX", inst->base.protocol->name, 128, - inst->key1_high, inst->key1_low, - key2_val); + inst->key1_high, inst->key1_low); } } diff --git a/lib/subghz/protocols/renault_v0.c b/lib/subghz/protocols/renault_v0.c index b1a3f609..b56f3caf 100644 --- a/lib/subghz/protocols/renault_v0.c +++ b/lib/subghz/protocols/renault_v0.c @@ -198,7 +198,6 @@ static bool renault_v0_button_valid_generic(uint8_t button); static bool renault_v0_preamble_bits_valid(uint8_t preamble_bits); static uint8_t renault_v0_default_preamble_bits(RenaultV0TypeId type_id); static bool renault_v0_type_preamble_bits_valid(RenaultV0TypeId type_id, uint8_t preamble_bits); -static const char* renault_v0_get_button_name(RenaultV0TypeId type_id, uint8_t button); static void renault_v0_parse_fields(uint64_t data, uint32_t* serial, uint8_t* button, uint8_t* counter); static void renault_v0_build_key( uint32_t serial, @@ -422,28 +421,6 @@ static bool renault_v0_type_preamble_bits_valid(RenaultV0TypeId type_id, uint8_t return preamble_bits == renault_v0_default_preamble_bits(type_id); } -static const char* renault_v0_get_button_name(RenaultV0TypeId type_id, uint8_t button) { - if(type_id == RenaultV0Type13) { - switch(button) { - case 0x06: - return "Lock"; - case 0x0A: - return "Unlock"; - default: - return "??"; - } - } - - const uint8_t low_nibble = button & 0x0FU; - if((low_nibble >= 0x04U) && (low_nibble <= 0x07U)) { - return "Lock"; - } - if((low_nibble >= 0x08U) && (low_nibble <= 0x0BU)) { - return "Unlock"; - } - return "??"; -} - static void renault_v0_parse_fields(uint64_t data, uint32_t* serial, uint8_t* button, uint8_t* counter) { if(serial) { *serial = (uint32_t)(data >> 40U); @@ -1349,23 +1326,16 @@ void subghz_protocol_decoder_renault_v0_get_string(void* context, FuriString* ou furi_string_cat_printf( output, "%s %dbit\r\n" - "Key:%016llX\r\n" - "Key2:%05lX\r\n" - "Sn:%06lX\r\n" - "Btn:%01X [%s]\r\n" - "Cnt:%02lX\r\n" - "C1:[%s] C2:[%s] IC:[%s]", + "Key:0x%016llX\r\n" + "SN:0x%lX Btn:%X\r\n" + "CRC:%s Cnt:%02lX", instance->generic.protocol_name, instance->packet_bit_count, instance->generic.data, - instance->key2, instance->generic.serial, instance->generic.btn, - renault_v0_get_button_name(instance->type_id, instance->generic.btn), - instance->generic.cnt, - instance->check_c1 ? "ERR" : "OK", - instance->check_c2 ? "ERR" : "OK", - instance->check_ic ? "MISS" : "MATCH"); + (instance->check_c1 || instance->check_c2) ? "ERR" : "OK", + instance->generic.cnt); } bool renault_v0_flipper_is_rolling(FlipperFormat* flipper_format) { diff --git a/lib/subghz/protocols/revers_rb2.c b/lib/subghz/protocols/revers_rb2.c index af063051..e4260dcf 100644 --- a/lib/subghz/protocols/revers_rb2.c +++ b/lib/subghz/protocols/revers_rb2.c @@ -400,9 +400,9 @@ void subghz_protocol_decoder_revers_rb2_get_string(void* context, FuriString* ou furi_string_cat_printf( output, - "%s %db\r\n" - "Key:%lX%08lX\r\n" - "Sn:0x%08lX \r\n", + "%s %dbit\r\n" + "Key:0x%lX%08lX\r\n" + "SN:0x%lX", instance->generic.protocol_name, instance->generic.data_count_bit, (uint32_t)(instance->generic.data >> 32), diff --git a/lib/subghz/protocols/roger.c b/lib/subghz/protocols/roger.c index 35d80788..003c685c 100644 --- a/lib/subghz/protocols/roger.c +++ b/lib/subghz/protocols/roger.c @@ -445,15 +445,12 @@ void subghz_protocol_decoder_roger_get_string(void* context, FuriString* output) furi_string_cat_printf( output, - "%s %db\r\n" - "Key: 0x%07lX\r\n" - "Serial: 0x%04lX\r\n" - "End: 0x%02lX\r\n" - "Btn: %01X", + "%s %dbit\r\n" + "Key:0x%07lX\r\n" + "SN:0x%lX Btn:%X", instance->generic.protocol_name, instance->generic.data_count_bit, (uint32_t)(instance->generic.data & 0xFFFFFFF), instance->generic.serial, - (uint32_t)(instance->generic.data & 0xFF), instance->generic.btn); } diff --git a/lib/subghz/protocols/scher_khan.c b/lib/subghz/protocols/scher_khan.c index 2e7e67d2..1b67b730 100644 --- a/lib/subghz/protocols/scher_khan.c +++ b/lib/subghz/protocols/scher_khan.c @@ -125,24 +125,6 @@ static void scher_khan_pro_encrypt( } } -static const char* scher_khan_btn_name(uint8_t btn) { - switch(btn) { - case 0x1: return "Lock"; - case 0x2: return "Unlock"; - case 0x3: return "Lock+Unlock"; - case 0x4: return "Trunk"; - case 0x5: return "Lock+Trunk"; - case 0x6: return "Unlock+Trunk"; - case 0x7: return "Lk+Ul+Tr"; - case 0x8: return "Start"; - case 0x9: return "Lock+Start"; - case 0xA: return "Unlock+Start"; - case 0xC: return "Trunk+Start"; - case 0xF: return "All/Panic"; - default: return "?"; - } -} - static uint8_t scher_khan_btn_to_custom(uint8_t btn) { switch(btn) { case 0x1: return SUBGHZ_CUSTOM_BTN_UP; @@ -1043,15 +1025,13 @@ void subghz_protocol_decoder_scher_khan_get_string(void* context, FuriString* ou output, "%s %dbit\r\n" "Key:0x%lX%08lX\r\n" - "Sn:%07lX Btn:[%s]\r\n" - "Cntr:%04lX\r\n" - "Pt: %s\r\n", + "SN:0x%lX Btn:%X\r\n" + "Cnt:%04lX", instance->generic.protocol_name, instance->generic.data_count_bit, (uint32_t)(instance->generic.data >> 32), (uint32_t)instance->generic.data, instance->generic.serial, - scher_khan_btn_name(scher_khan_get_btn_code(instance->generic.btn)), - instance->generic.cnt, - instance->protocol_name); + instance->generic.btn, + instance->generic.cnt); } diff --git a/lib/subghz/protocols/secplus_v1.c b/lib/subghz/protocols/secplus_v1.c index 9b2d7791..89035b55 100644 --- a/lib/subghz/protocols/secplus_v1.c +++ b/lib/subghz/protocols/secplus_v1.c @@ -577,9 +577,7 @@ void subghz_protocol_decoder_secplus_v1_get_string(void* context, FuriString* ou instance->generic.cnt = instance->generic.data & 0xFFFFFFFF; instance->generic.btn = fixed % 3; - uint8_t id0 = (fixed / 3) % 3; uint8_t id1 = (fixed / 9) % 3; - uint16_t pin = 0; // push protocol data to global variable subghz_block_generic_global.cnt_is_available = true; @@ -591,69 +589,25 @@ void subghz_protocol_decoder_secplus_v1_get_string(void* context, FuriString* ou subghz_block_generic_global.btn_length_bit = 2; // + if(id1 == 0) { + // (fixed // 3**3) % (3**7) 3^3=27 3^73=72187 + instance->generic.serial = (fixed / 27) % 2187; + } else { + //id = fixed / 27; + instance->generic.serial = fixed / 27; + } + furi_string_cat_printf( output, - "%s %db\r\n" - "Key:%lX%08lX\r\n" - "id1:%d id0:%d", + "%s %dbit\r\n" + "Key:0x%lX%08lX\r\n" + "SN:0x%lX Btn:%X\r\n" + "Cnt:%08lX", instance->generic.protocol_name, instance->generic.data_count_bit, (uint32_t)(instance->generic.data >> 32), (uint32_t)instance->generic.data, - id1, - id0); - - if(id1 == 0) { - // (fixed // 3**3) % (3**7) 3^3=27 3^73=72187 - - instance->generic.serial = (fixed / 27) % 2187; - // pin = (fixed // 3**10) % (3**9) 3^10=59049 3^9=19683 - pin = (fixed / 59049) % 19683; - - if(pin <= 9999) { - furi_string_cat_printf(output, " pin:%d", pin); - } else if(pin <= 11029) { - furi_string_cat_printf(output, " pin:enter"); - } - - int pin_suffix = 0; - // pin_suffix = (fixed // 3**19) % 3 3^19=1162261467 - pin_suffix = (fixed / 1162261467) % 3; - - if(pin_suffix == 1) { - furi_string_cat_printf(output, " #\r\n"); - } else if(pin_suffix == 2) { - furi_string_cat_printf(output, " *\r\n"); - } else { - furi_string_cat_printf(output, "\r\n"); - } - - furi_string_cat_printf( - output, - "Sn:0x%08lX\r\n" - "Cnt:%08lX " - "SwID:0x%X\r\n", - instance->generic.serial, - instance->generic.cnt, - instance->generic.btn); - } else { - //id = fixed / 27; - instance->generic.serial = fixed / 27; - if(instance->generic.btn == 1) { - furi_string_cat_printf(output, " Btn:left\r\n"); - } else if(instance->generic.btn == 0) { - furi_string_cat_printf(output, " Btn:middle\r\n"); - } else if(instance->generic.btn == 2) { //-V547 - furi_string_cat_printf(output, " Btn:right\r\n"); - } - - furi_string_cat_printf( - output, - "Sn:0x%08lX\r\n" - "Cnt:%08lX " - "SwID:0x%X\r\n", - instance->generic.serial, - instance->generic.cnt, - instance->generic.btn); - } + instance->generic.serial, + instance->generic.btn, + instance->generic.cnt); } diff --git a/lib/subghz/protocols/secplus_v2.c b/lib/subghz/protocols/secplus_v2.c index cab5d575..157feaa9 100644 --- a/lib/subghz/protocols/secplus_v2.c +++ b/lib/subghz/protocols/secplus_v2.c @@ -977,16 +977,12 @@ void subghz_protocol_decoder_secplus_v2_get_string(void* context, FuriString* ou furi_string_cat_printf( output, - "%s %db\r\n" - "Pk1:0x%lX%08lX\r\n" - "Pk2:0x%lX%08lX\r\n" - "Sn:0x%08lX Btn:0x%01X\r\n" - "Cnt:%07lX\r\n", - + "%s %dbit\r\n" + "Key:0x%lX%08lX\r\n" + "SN:0x%lX Btn:%X\r\n" + "Cnt:%07lX", instance->generic.protocol_name, instance->generic.data_count_bit, - (uint32_t)(instance->secplus_packet_1 >> 32), - (uint32_t)instance->secplus_packet_1, (uint32_t)(instance->generic.data >> 32), (uint32_t)instance->generic.data, instance->generic.serial, diff --git a/lib/subghz/protocols/sheriff_cfm.c b/lib/subghz/protocols/sheriff_cfm.c index 27d0530a..46a535da 100644 --- a/lib/subghz/protocols/sheriff_cfm.c +++ b/lib/subghz/protocols/sheriff_cfm.c @@ -44,14 +44,6 @@ typedef enum { SheriffCfmModelCount = 2, } SheriffCfmModel; -static const char* cfm_model_name(SheriffCfmModel model) { - switch(model) { - case SheriffCfmModelZX750: return "ZX-750"; - case SheriffCfmModelZX930: return "ZX-930"; - default: return "?"; - } -} - static void cfm_decrypt_transform(uint8_t* hop, SheriffCfmModel model) { uint8_t temp; switch(model) { @@ -100,16 +92,6 @@ static void cfm_encrypt_transform(uint8_t* hop, SheriffCfmModel model) { } } -static const char* cfm_btn_name(uint8_t btn) { - switch(btn) { - case 0x10: return "Lock"; - case 0x20: return "Unlock"; - case 0x40: return "Trunk"; - case 0x80: return "Panic"; - default: return "?"; - } -} - static uint8_t cfm_btn_to_custom(uint8_t btn) { switch(btn) { case 0x10: return SUBGHZ_CUSTOM_BTN_UP; @@ -646,14 +628,13 @@ void subghz_protocol_decoder_sheriff_cfm_get_string(void* context, FuriString* o output, "%s %dbit\r\n" "Key:0x%lX%08lX\r\n" - "Sn:%08lX Btn:[%s]\r\n" - "Cnt:%04lX Model:%s\r\n", + "SN:0x%lX Btn:%X\r\n" + "Cnt:%04lX", instance->generic.protocol_name, instance->generic.data_count_bit, (uint32_t)(instance->generic.data >> 32), (uint32_t)instance->generic.data, instance->generic.serial, - cfm_btn_name(selected_btn), - (uint32_t)instance->generic.cnt, - cfm_model_name(instance->model)); + selected_btn, + (uint32_t)instance->generic.cnt); } diff --git a/lib/subghz/protocols/smc5326.c b/lib/subghz/protocols/smc5326.c index 7e4fd269..aa370ced 100644 --- a/lib/subghz/protocols/smc5326.c +++ b/lib/subghz/protocols/smc5326.c @@ -359,33 +359,15 @@ SubGhzProtocolStatus return ret; } -static void subghz_protocol_smc5326_get_event_serialize(uint8_t event, FuriString* output) { - furi_string_cat_printf( - output, - "%s%s%s%s\r\n", - (((event >> 6) & 0x3) == 0x3 ? "B1 " : ""), - (((event >> 4) & 0x3) == 0x3 ? "B2 " : ""), - (((event >> 2) & 0x3) == 0x3 ? "B3 " : ""), - (((event >> 0) & 0x3) == 0x3 ? "B4 " : "")); -} - void subghz_protocol_decoder_smc5326_get_string(void* context, FuriString* output) { furi_assert(context); SubGhzProtocolDecoderSMC5326* instance = context; - uint32_t data = (uint32_t)((instance->generic.data >> 9) & 0xFFFF); furi_string_cat_printf( output, "%s %ubit\r\n" - "Key:%07lX Te:%luus\r\n" - " +: " DIP_PATTERN "\r\n" - " o: " DIP_PATTERN " ", + "Key:0x%07lX", instance->generic.protocol_name, instance->generic.data_count_bit, - (uint32_t)(instance->generic.data & 0x1FFFFFF), - instance->te, - SHOW_DIP_P(data, DIP_P), - SHOW_DIP_P(data, DIP_O)); - subghz_protocol_smc5326_get_event_serialize(instance->generic.data >> 1, output); - furi_string_cat_printf(output, " -: " DIP_PATTERN "\r\n", SHOW_DIP_P(data, DIP_N)); + (uint32_t)(instance->generic.data & 0x1FFFFFF)); } diff --git a/lib/subghz/protocols/somfy_keytis.c b/lib/subghz/protocols/somfy_keytis.c index 55d82fc4..431a749c 100644 --- a/lib/subghz/protocols/somfy_keytis.c +++ b/lib/subghz/protocols/somfy_keytis.c @@ -755,27 +755,6 @@ static void subghz_protocol_somfy_keytis_check_remote_controller(SubGhzBlockGene * Get button name. * @param btn Button number, 4 bit */ -static const char* subghz_protocol_somfy_keytis_get_name_button(uint8_t btn) { - const char* name_btn[0x10] = { - "Unknown", - "0x01", - "0x02", - "Prog", - "Key_1", - "0x05", - "0x06", - "0x07", - "0x08", - "0x09", - "0x0A", - "0x0B", - "0x0C", - "0x0D", - "0x0E", - "0x0F"}; - return btn <= 0xf ? name_btn[btn] : name_btn[0]; -} - uint8_t subghz_protocol_decoder_somfy_keytis_get_hash_data(void* context) { furi_assert(context); SubGhzProtocolDecoderSomfyKeytis* instance = context; @@ -850,19 +829,15 @@ void subghz_protocol_decoder_somfy_keytis_get_string(void* context, FuriString* furi_string_cat_printf( output, - "%s %db\r\n" - "%lX%08lX%06lX\r\n" - "Sn:0x%06lX \r\n" - "Cnt:%04lX\r\n" - "Btn:%X - %s\r\n", - + "%s %dbit\r\n" + "Key:0x%lX%08lX\r\n" + "SN:0x%lX Btn:%X\r\n" + "Cnt:%04lX", instance->generic.protocol_name, instance->generic.data_count_bit, (uint32_t)(instance->generic.data >> 32), (uint32_t)instance->generic.data, - instance->press_duration_counter, instance->generic.serial, - instance->generic.cnt, instance->generic.btn, - subghz_protocol_somfy_keytis_get_name_button(instance->generic.btn)); + instance->generic.cnt); } diff --git a/lib/subghz/protocols/somfy_telis.c b/lib/subghz/protocols/somfy_telis.c index c0b26c94..8c2f04aa 100644 --- a/lib/subghz/protocols/somfy_telis.c +++ b/lib/subghz/protocols/somfy_telis.c @@ -636,27 +636,6 @@ static void subghz_protocol_somfy_telis_check_remote_controller(SubGhzBlockGener * Get button name. * @param btn Button number, 4 bit */ -static const char* subghz_protocol_somfy_telis_get_name_button(uint8_t btn) { - const char* name_btn[16] = { - "Unknown", - "My", - "Up", - "My+Up", - "Down", - "My+Down", - "Up+Down", - "0x07", - "Prog", - "Sun+Flag", - "Flag", - "0x0B", - "0x0C", - "0x0D", - "0x0E", - "0x0F"}; - return btn <= 0xf ? name_btn[btn] : name_btn[0]; -} - uint8_t subghz_protocol_decoder_somfy_telis_get_hash_data(void* context) { furi_assert(context); SubGhzProtocolDecoderSomfyTelis* instance = context; @@ -769,18 +748,15 @@ void subghz_protocol_decoder_somfy_telis_get_string(void* context, FuriString* o furi_string_cat_printf( output, - "%s %db\r\n" + "%s %dbit\r\n" "Key:0x%lX%08lX\r\n" - "Sn:0x%06lX \r\n" - "Cnt:%04lX\r\n" - "Btn:%X - %s\r\n", - + "SN:0x%lX Btn:%X\r\n" + "Cnt:%04lX", instance->generic.protocol_name, instance->generic.data_count_bit, (uint32_t)(instance->generic.data >> 32), (uint32_t)instance->generic.data, instance->generic.serial, - instance->generic.cnt, instance->generic.btn, - subghz_protocol_somfy_telis_get_name_button(instance->generic.btn)); + instance->generic.cnt); } diff --git a/lib/subghz/protocols/star_line.c b/lib/subghz/protocols/star_line.c index 41d28167..c0067686 100644 --- a/lib/subghz/protocols/star_line.c +++ b/lib/subghz/protocols/star_line.c @@ -6,22 +6,6 @@ #define TAG "SubGhzProtocolStarLine" -static const char* star_line_btn_name(uint8_t btn) { - switch(btn) { - case 0x01: return "Lock"; - case 0x02: return "Unlock"; - case 0x03: return "Trunk"; - case 0x04: return "Panic"; - case 0x21: return "Lock"; - case 0x22: return "Unlock"; - case 0x23: return "Trunk"; - case 0x24: return "Start"; - case 0x25: return "Stop"; - case 0x26: return "Extra"; - default: return "Unknown"; - } -} - static uint8_t star_line_btn_to_custom(uint8_t btn) { switch(btn) { case 0x01: @@ -1092,11 +1076,6 @@ void subghz_protocol_decoder_star_line_get_string(void* context, FuriString* out uint32_t code_found_hi = instance->generic.data >> 32; uint32_t code_found_lo = instance->generic.data & 0x00000000ffffffff; - uint64_t code_found_reverse = subghz_protocol_blocks_reverse_key( - instance->generic.data, instance->generic.data_count_bit); - uint32_t code_found_reverse_hi = code_found_reverse >> 32; - uint32_t code_found_reverse_lo = code_found_reverse & 0x00000000ffffffff; - uint8_t display_btn; uint8_t custom = subghz_custom_btn_get(); if(custom == SUBGHZ_CUSTOM_BTN_OK) { @@ -1105,40 +1084,17 @@ void subghz_protocol_decoder_star_line_get_string(void* context, FuriString* out display_btn = star_line_custom_to_btn(custom, instance->generic.btn); } - bool is_twage = (instance->generic.btn & 0x20) != 0; - - if(is_twage) { - furi_string_cat_printf( - output, - "%s %dbit\r\n" - "Key:%08lX%08lX\r\n" - "Fix:0x%08lX\r\n" - "Hop:0x%08lX\r\n" - "Btn:[%s] Cnt:%04lX\r\n", - instance->generic.protocol_name, - instance->generic.data_count_bit, - code_found_hi, - code_found_lo, - code_found_reverse_hi, - code_found_reverse_lo, - star_line_btn_name(display_btn), - instance->generic.cnt); - } else { - // Classic: only 4 buttons - furi_string_cat_printf( - output, - "%s %dbit\r\n" - "Key:%08lX%08lX\r\n" - "Fix:0x%08lX\r\n" - "Hop:0x%08lX\r\n" - "Btn:[%s] Cnt:%04lX\r\n", - instance->generic.protocol_name, - instance->generic.data_count_bit, - code_found_hi, - code_found_lo, - code_found_reverse_hi, - code_found_reverse_lo, - star_line_btn_name(display_btn), - instance->generic.cnt); - } + furi_string_cat_printf( + output, + "%s %dbit\r\n" + "Key:0x%08lX%08lX\r\n" + "SN:0x%lX Btn:%X\r\n" + "Cnt:%04lX", + instance->generic.protocol_name, + instance->generic.data_count_bit, + code_found_hi, + code_found_lo, + instance->generic.serial, + display_btn, + instance->generic.cnt); } diff --git a/lib/subghz/protocols/subaru.c b/lib/subghz/protocols/subaru.c index bd334465..9aa46df5 100644 --- a/lib/subghz/protocols/subaru.c +++ b/lib/subghz/protocols/subaru.c @@ -108,17 +108,6 @@ static uint8_t subaru_btn_to_custom(uint8_t btn_code) { } } -static const char* subaru_get_button_name(uint8_t btn) { - switch(btn) { - case 0x01: return "Lock"; - case 0x02: return "Unlock"; - case 0x03: return "Trunk"; - case 0x04: return "Panic"; - case 0x08: return "0x08"; - default: return "??"; - } -} - static void subaru_decode_count(const uint8_t* KB, uint16_t* count) { uint8_t lo = 0; if((KB[4] & 0x40) == 0) lo |= 0x01; @@ -473,17 +462,16 @@ void subghz_protocol_decoder_subaru_get_string(void* context, FuriString* output furi_string_cat_printf( output, "%s %dbit\r\n" - "Key:%08lX%08lX\r\n" - "Sn:%06lX Cnt:%04X\r\n" - "Btn:%X [%s]", + "Key:0x%08lX%08lX\r\n" + "SN:0x%lX Btn:%X\r\n" + "Cnt:%04X", instance->generic.protocol_name, instance->generic.data_count_bit, key_hi, key_lo, instance->serial, - instance->count, instance->button, - subaru_get_button_name(instance->button)); + instance->count); } void* subghz_protocol_encoder_subaru_alloc(SubGhzEnvironment* environment) { diff --git a/lib/subghz/protocols/telcoma_edge.c b/lib/subghz/protocols/telcoma_edge.c index 803fe7d6..02ac2761 100644 --- a/lib/subghz/protocols/telcoma_edge.c +++ b/lib/subghz/protocols/telcoma_edge.c @@ -182,10 +182,10 @@ void subghz_protocol_decoder_telcoma_edge_get_string(void* context, FuriString* uint8_t channel = payload & 0x07; furi_string_cat_printf( output, - "Telcoma/Cardin\nEDGE %db\r\n" + "%s %dbit\r\n" "Key:0x%08lX\r\n" - "Serial:0x%05lX\r\n" - "Ch:0x%01X\r\n", + "SN:0x%lX Btn:%X", + instance->generic.protocol_name, instance->generic.data_count_bit, (unsigned long)data, (unsigned long)serial, diff --git a/lib/subghz/protocols/toyota.c b/lib/subghz/protocols/toyota.c index bd52bdb1..4c68ba6b 100644 --- a/lib/subghz/protocols/toyota.c +++ b/lib/subghz/protocols/toyota.c @@ -247,26 +247,6 @@ static uint32_t toyota_extract( * Name helpers * ---------------------------------------------------------------- */ -static const char* toyota_button_name(uint8_t btn, uint8_t variant) { - if(variant == 1) { - switch(btn & 0x0F) { - case TOYOTA_B_BTN_LOCK: return "Lock"; - case TOYOTA_B_BTN_UNLOCK: return "Unlock"; - case 0x0F: return "Lock+Unlock"; - case 0x04: return "Trunk"; - default: return "Unknown"; - } - } - switch(btn & 0x0F) { - case TOYOTA_A_BTN_LOCK: return "Lock"; - case TOYOTA_A_BTN_UNLOCK: return "Unlock"; - case 0x09: return "Lock+Unlock"; - case 0x02: return "Trunk"; - case 0x04: return "Aux"; - default: return "Unknown"; - } -} - static const char* toyota_model_name(uint8_t variant) { return (variant == 1) ? "Tundra" : "Corolla"; } @@ -715,7 +695,6 @@ void subghz_protocol_decoder_toyota_get_string(void* context, FuriString* output furi_assert(context); SubGhzProtocolDecoderToyota* inst = context; - uint32_t hop = (uint32_t)(inst->generic.data >> 32); uint32_t serial = (uint32_t)((inst->generic.data >> 4) & 0x0FFFFFFF); uint8_t button = (uint8_t)(inst->generic.data & 0x0F); uint8_t var = (inst->generic.cnt != 0) ? 1 : 0; @@ -723,13 +702,12 @@ void subghz_protocol_decoder_toyota_get_string(void* context, FuriString* output furi_string_cat_printf( output, "%s %dbit\r\n" - "Hop: %08lX\r\n" - "Sn: %07lX\r\n" - "Btn: %X [%s]", + "Key:0x%lX%08lX\r\n" + "SN:0x%lX Btn:%X", toyota_model_name(var), inst->generic.data_count_bit, - (unsigned long)hop, + (uint32_t)(inst->generic.data >> 32), + (uint32_t)inst->generic.data, (unsigned long)serial, - button, - toyota_button_name(button, var)); + button); } diff --git a/lib/subghz/protocols/treadmill37.c b/lib/subghz/protocols/treadmill37.c index ddb8ba02..6a540d9e 100644 --- a/lib/subghz/protocols/treadmill37.c +++ b/lib/subghz/protocols/treadmill37.c @@ -330,9 +330,6 @@ void subghz_protocol_decoder_treadmill37_get_string(void* context, FuriString* o subghz_protocol_treadmill37_check_remote_controller(&instance->generic); - uint64_t code_found_reverse = subghz_protocol_blocks_reverse_key( - instance->generic.data, instance->generic.data_count_bit); - // for future use // // push protocol data to global variable // subghz_block_generic_global.btn_is_available = false; @@ -342,15 +339,12 @@ void subghz_protocol_decoder_treadmill37_get_string(void* context, FuriString* o furi_string_cat_printf( output, - "%s %db\r\n" - "Key: 0x%08llX\r\n" - "Yek: 0x%08llX\r\n" - "Serial: 0x%06lX\r\n" - "Btn: %04lX", + "%s %dbit\r\n" + "Key:0x%08llX\r\n" + "SN:0x%lX Btn:%lX", instance->generic.protocol_name, instance->generic.data_count_bit, (uint64_t)(instance->generic.data & 0xFFFFFFFFFF), - (code_found_reverse & 0xFFFFFFFFFF), instance->generic.serial, instance->generic.cnt); } diff --git a/lib/subghz/protocols/vag.c b/lib/subghz/protocols/vag.c index 1e022345..618961ff 100644 --- a/lib/subghz/protocols/vag.c +++ b/lib/subghz/protocols/vag.c @@ -80,25 +80,6 @@ static struct aut64_key* protocol_vag_get_key(uint8_t index) { static const uint32_t vag_tea_key_schedule[] = {0x0B46502D, 0x5E253718, 0x2BF93A19, 0x622C1206}; -static const char* vag_button_name(uint8_t btn) { - switch(btn) { - case 0x1: - return "Unlock"; - case 0x2: - return "Lock"; - case 0x4: - return "Boot"; - case 0x10: - return "Unlock"; - case 0x20: - return "Lock"; - case 0x40: - return "Boot"; - default: - return "Unkn"; - } -} - static uint8_t vag_custom_to_btn(uint8_t custom, uint8_t original_btn) { switch(custom) { case 1: return 0x20; @@ -1210,7 +1191,6 @@ void subghz_protocol_decoder_vag_get_string(void* context, FuriString* output) { } uint64_t key1 = ((uint64_t)instance->key1_high << 32) | instance->key1_low; - uint16_t key2 = (uint16_t)(instance->key2_low & 0xFFFF); uint8_t type_byte = (uint8_t)(instance->key1_high >> 24); const char* vehicle_name; @@ -1242,36 +1222,27 @@ void subghz_protocol_decoder_vag_get_string(void* context, FuriString* output) { // the encoder to trigger windows-down/windows-up on real vehicles. furi_string_cat_printf( output, - "%s %db\r\n" - "Key1:%08lX%08lX\r\n" - "Key2:%04X\r\n" - "KeyIdx:%d\r\n" - "Sn:%08lX\r\n" - "Cnt:%06lX\r\n" - "Btn:[%s]\r\n" - "Flags:0x%X", + "%s %dbit\r\n" + "Key:0x%08lX%08lX\r\n" + "SN:0x%lX Btn:%X\r\n" + "Cnt:%06lX", vehicle_name, instance->data_count_bit, (unsigned long)(key1 >> 32), (unsigned long)(key1 & 0xFFFFFFFF), - key2, - instance->key_idx, (unsigned long)instance->serial, - (unsigned long)instance->cnt, - vag_button_name(instance->btn), - (unsigned int)instance->btn_flags); + (unsigned int)instance->btn, + (unsigned long)instance->cnt); } else { furi_string_cat_printf( output, - "%s %db\r\n" - "Key1:%08lX%08lX\r\n" - "Key2:%04X\r\n" + "%s %dbit\r\n" + "Key:0x%08lX%08lX\r\n" "(corrupted)", vehicle_name, instance->data_count_bit, (unsigned long)(key1 >> 32), - (unsigned long)(key1 & 0xFFFFFFFF), - key2); + (unsigned long)(key1 & 0xFFFFFFFF)); } }