mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-08-05 05:04:27 -04:00

* Update README.md
Actually valid complete ali h4m link
* Fake brightness reimplementation (#2444)
* Fake brightness reimplementation
* indentation
* added call to the function which is caching the display settings values
* use cached values instead of pmem
* app manager (#2442)
* fix unset autostart
* clean up - add comments to prevent misleading
* move the app to external and with necessary changes
* replace autostart app
* Add + - buttons in Encoder dial settings (#2447)
* M10 additional parser (#2448)
* Remember previous capture settings (#2450)
* Renamed parameters in rx_capture.ini file (#2452)
* Rename settings in file to match screen
* Renamed variables for hopefully better clarity
* Navigation buttons (#2458)
* regenerate bitmap data
* pagination in submenu
* using little font so we are not eating menu buttons
* docker improvements (#2455)
* Update README.md
New metal case link
* The gerber files of the portapack H4 (#2463)
* Create README.txt
* Update README.txt
* Add files via upload
The gerber files of the portapack h4.
* delete
* Upload the gerber files for H4
* Update README.md (#2456)
Added a link to Lab401.com as a purchase option for EU customers.
(Lab401 was added as the EU exclusive distributor for the H4M - https://opensourcesdrlab.com/pages/distributors)
* Update README.md
* rename bitmaps into bmp
* disabling button on main menu, change labels and add 'icons' (#2466)
* disabling button on main menu, change labels and add 'icons'
* fix reverse order of buttons
---------
Co-authored-by: gullradriel <gullradriel@no-mail.com>
* fix for empty text prompt crash (#2468)
* added discord server information (#2471)
* Add the feature to decide rotate direction of encoder (#2472)
* Update README.md
Lab401 link with our redirection
* Fix encoder setting p.mem issue (#2475)
* Update README.md
Discord badge was broken, switching to shields.io
* Add fast flash script for sdcard switch hardware (#2480)
* fix cmake_minimum_required to 3.16 (#2499)
* fix fallthrough warning (#2497)
* Flipper tx: use file_path, example file (#2496)
* added subghz_dir
* use subghz_dir from file_path
* example file
* Externalize antenna calc and wav view (#2498)
* externalize antenna calc and wav view
* Added a tool to check if all the pictures in graphics are used in internal apps
* APRS: add frequency settings for Brazil (#2494)
* Add frequency settings for Brazil, named 'BR' that tunes to 145.570 MHz.
* Also added: Japan: 144.640 MHz (JAP), Thailand: 144.900 MHz (THA), Philippines: 144.740 MHz (PHI)
* Reordered list by increasing frequency
Co-authored-by: gullradriel <3157857+gullradriel@users.noreply.github.com>
* Added different modulations in signal generator (#2492)
* Added DSB, AM 100% mod index and AM 50% mod index. Changed UI.
* put back app in 'Utilities' (#2500)
Co-authored-by: gullradriel <gullradriel@no-mail.com>
* fix baseband (#2501)
* externalize wipe sdcard (#2502)
* Removing vim swap files (#2503)
* Removing vim swap files
* Added vim swap file to .gitignore
* Add modal to turn off screen when charging is detected (#2514)
* Moved country-specific FREQMAN files to the separate repository set up for it. (#2517)
* fix docker build warnings in dockerfile-nogit (#2518)
* Add new app "hopper" app. (#2482)
* make both jammer and hopper exist
* add example hopper payload
* example files
* swap scanner and recon app location
* Add widget preview tool (#2520)
* PoC
* opt
* opt
* Playlist editor (#2506)
* make both exist
* format
* fix focusing issue
* add example hopper payload
* fix compiler err
* clean up
* correct linker script addr
* lint
* PoC
* unknown: write_line issue
* clean up
* merge
* fix read line
* remove debug code
* fix english
* support new file
* support enter delay
* fix crash
* remove debug code
* some final tune
* Support Bug Key AKA Auto Key for OOK Editor app (#2523)
* _
* some final tune
* textual
* rename following gull's suggestion
* add cursor to font viewer app (#2528)
* Allow disable/enable waveform in Audio app to remove decoding problem on some frequencies
* Added different modulations in signal generator
* Added DSB, AM 100% mod index and AM 50% mod index.
* Changed UI.
* Added pulsed CW
* Adding Wefax demodulation mode inside Audio App (#2539)
* Adding_new_WFAX_GUI_mode_Audio_App
* Wefax_APT_demodulation_structure
* Solving REC Apt signal.wav from WFAX
* clang format issues
* correcting comments
* Breakout - The Portapack remake game rises from the pirate's lair (#2541)
* Breakout - The Portapack remake game rises from the pirate's lair
* Fixes
* Added a signature
* Trivial textual change about missing SD content (#2542)
* _
* _
* waveform fix 3 and trivial change (#2540)
* Moved games to new game menu (#2544)
* Moved games to new game menu
* There's enough games to have a menu now and I plan to make more. Having them in "Utilities" made no sense.
* Wefax warning fix modulation fix (#2543)
* changed order of modulations, changed case to avoid capture
* added missing AMAudioFMApt mode to dump pmem
* reorder demod, adding missing ones, fix warnings
* removed uneeded 'previous_modulation', renamed WFAX to AMFM to match other places
* removing uneeded 'previous_modulation' uneeded check in change_modulation
* move capture at the end so AMAUdioFMApt is matching the other arrays for position 4
* added AMFM to Recon Level and Scanner
* clang + more details in some comments
---------
Co-authored-by: gullradriel <gullradriel@no-mail.com>
* Snake (#2549)
* Create the Shopping Cart Lock app
Will demonstrate tomorrow. Don't merge until I do 😁
* Fixes for HTotoo's comments 😎
* Improved audio the best I can.
If nobody has any ideas to further improve high frequencies of the audio, the hardware may not be capable. I still need to check with line-out to better speaker to make sure it's not just the speaker, but it shouldn't be.
* Compared against baseband_api.cpp - matched some things better but still playback seems to be missing higher fq sounds
* renamed wav files to a more specific / less generic name
* indentation + using variables instead of litteral names for wav files to use
* indentation
* Made a Snake game - enjoy
* Code formatting. I always forget.
* move to keep sort order
* Update external.ld
Sorry I should have also asked if there was any reason that address ranges 0xADDA0000--0xADDD0000 were skipped in external.ld. I assumed there wasn't so I changed it to be consecutive using the same 0x10000 step as the other modules. If there is any reason to skip them then we should add a comment to note it. Of course these are all just temporary address values used for linking and get overwritten by a kludgy "search & replace" during the build process.
Resolves enhancement request #764
---------
Co-authored-by: gullradriel <gullradriel@no-mail.com>
Co-authored-by: Mark Thompson <129641948+NotherNgineer@users.noreply.github.com>
* Nested Debug menu into Utilities menu to tidy Home screen (#2551)
* rename rand pwd app (#2552)
* _
* remove wip code that forgot to add in old branch
* Moved speaker 1px to the right to match muted icon variant. (#2554)
* Stopwatch external app (#2553)
* updated bitmaps for speaker icon (#2555)
* updated bitmaps for speaker icon
* removed opera cake icon that was added by mistake
* adding missing Game menu source png
* cyan for Game menu
* regenerated icons
* Breakout icon change (#2556)
- Changed Breakout icon
- Changed Tetris icon color to green
* Snake icon change (#2557)
* Remove deprecated QR Code code (#2558)
* Setting for faster Button Repeat delays (#2559)
* Setting for faster Button Repeat delays
* Tweak fast delay times
* Tweak delay times
* Added description line and tweaked delay again
* OokBrute app opt (#2561)
* zooming_spectrum_AMFM_mode (#2565)
* Update README.md
Fixing opesourcesdrlab link
* Update README.md
Other link broken
* WeFax rx ext app (#2566)
* wf3
* Ookbrute (#2354)
* Revert "Ookbrute (#2354)"
This reverts commit abb8143eec
.
* fix
* test edition
* re enable ble
* re enable ert
* steal amfm stuff
* something happens
* save bmp on start btn
* kinda works
* exit crash fixed
* redline, remove some hardcoded
* removed cpu killer red line, and some fixes
* simplify #1
* seems ok. time to improve
* added hidden freq offset to receiver model, so wefax can be set to the "correct" freq without users needs to substract 300 hz
* badly implemented sync detection, and disabled it.
* fix for fix
* fixes
* fix offset to real life off
* no line on freq enter
* fixes
* Doom - Mayhem Edition (#2570)
* Doom - Mini Mayhem version
* Update ui_doom.cpp
* Update ui_doom.cpp
* Update ui_doom.cpp
* Update ui_doom.cpp
* Update ui_doom.cpp
* Update ui_doom.cpp
* Update ui_doom.cpp
* Update ui_doom.cpp
* Doom - Mayhem Edition
Made the Doom - Mayhem Edition game. Some little bugs but good enough for nightly.
* Code formatting. Forgot like always.
* give more initial ammo until i put ammo around the maze to collect
* Update Doom main.cpp for better icon (#2575)
* fix external app address list (#2573)
* Add WEFAX freqman file (#2567)
* Add WEFAX freqman file
* fix bad escaped spaces and unicode characters
* Add icon for the doom game (#2574)
* Add icon for the doom game
* Add b/w .png to convert as doom icon
* Added wefax offset to audio app too. (#2572)
* added wefax offset to audio app too.
* moved from head to cpp
* Put ticker class and pp_colors in hpp file in namespace and remove helper files (#2577)
* stopwatch opt (#2578)
* stopwatch opt
* comments
* format
* fxi ms display when user tune display level
* issue template fine tune (#2579)
* Combined cpp files, stuffed helper files in hpp, updates start and game over screens (#2583)
* Combine cpp, move helpers to hpp (#2584)
* naming space (#2585)
* Tetris: Combined cpp files. Helper files into hpp. Dark mode. Encoder on. (#2587)
* Adding_Waterfall_ZOOM_x2_in_AM_modes_Audio_App (#2586)
* adding zoom_factor to app settings
* separated zoom_factor settings for AM and AMFM
* fix order so zoom factor is also applied correctly on modulation change
* fix zoom not applied when changing bandwidth
* temporary disable the Scanner so we are not breaking the nightly. Until we are choosing to finally remove it or find a better solution
---------
Co-authored-by: gullradriel <3157857+gullradriel@users.noreply.github.com>
Co-authored-by: gullradriel <gullradriel@no-mail.com>
* Fixed the I Tetromino rotation using SRS (Super Rotation System) (#2588)
* Externalize dump pmem (#2590)
* initial commit
* clang
* memory icon
* text output and exit button, FOCUS OVERRIDE TO AVOID COMPILATION ERROR
* modem and data_structure_version accessor
---------
Co-authored-by: gullradriel <gullradriel@no-mail.com>
* remove dead code (#2593)
* remove not yet enabled screening app (#2594)
* move default splash into sdcard (#2595)
* move bmps to sdcard
* remove unrelated files
* gitignore
* credit
* format
* Externalize scanner (#2589)
* externalize scanner
* NFM as main baseband as it's the biggest used one
* fix modulation bug introduced with AMFM
* Externalize level (#2596)
* removing ability to focus on RSSI bars and to launch level app, until a solution to launch external apps from internal ones is given
* externalize Level app
* Remove unneeded AMFM support in those apps (#2597)
* Create CODE_OF_CONDUCT.md
* Create pull_request_template.md
* Create SECURITY.md
* Create CONTRIBUTING.md (#2598)
* Force 433.92 and remove metadata check (#2599)
* Force 433.92 and remove metadata check: we already know the frequency for all files so don't need a million metadata files to match.
* Variable fixes and move to header
* Added more Wefax stations (#2600)
* Delete sdcard/FREQMAN/WEFAX.TXT
Replace with 2 files
* Add more WeFax frequencies
* Update comments
* Oops wrong folder
* Oops wrong folder
* Change comments
* Remove RF TX and use PATX baseband for audio --> speaker out only (#2601)
* Force 433.92 and remove metadata check
We already know the frequency for all files so don't need a million metadata files to match.
* Remove RF TX. Improve PATX baseband.
* code formatting of course
* Issue template again (#2602)
* test1
* test2
* add tap tempo to metronomic app (#2605)
* _
* format
* fix new tree in Arch
* solving_Audio_App_AM_GUI_Problem_issue_2604 (#2609)
* make the ptext_prompt func can define which keyboard to enter (#2608)
* _
* format
* use define
* prevent long life var for audio app - AM (#2610)
* static vars so no external linkage is possible
* persistent settings and no more global living variables
---------
Co-authored-by: gullradriel <gullradriel@no-mail.com>
* theme fix again (#2611)
* theme fix again
* _
* user can disable battery change hint (#2612)
* theme fix again
* _
* _
* GFX EQ App (#2607)
* Make the beginnings of rf3d
* Name change...
* Add mood button
* Remove forced amp settings and add persistent user settings
* Fix options bar layout and SettingsManager
* Make the background paint to black again after opening fq modal
* fix audio/mod/settings and cleaned unneeded parts
* Mapped bars to audio spectrum
* Improved frequency response... still needs work i think
* add on_freqchg to be able to answer to serial frequency change command
* Made calculations for 14 bars to fit screen and little adjustments
* Visual improvements
Co-authored-by: gullradriel
* Improved make_bitmap tool (#2615)
* Enhance Graphic Equalizer Visualization with Improved Frequency Bands and Response (#2614)
* Custom waterfall colors (#2617)
* Custom waterfall gradient
* Installing a custom waterfall gradient via fileman
* default file for user friendly swap
Co-authored-by: gullradriel <gullradriel@no-mail.com>
* Delete dead code in ble_rx_app.cpp (#2620)
Duplicate include on line 24 removed.
* Fix default waterfall file (#2621)
* correct default settings from file
* correct colors names
* fix comments (#2622)
* Touch on waterfall to set cursor pos (#2624)
* init
* fix typo that found by Copilot
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Adding 8.33KHz spacing (#2628)
* Adding 8.33KHz spacing
* remove extern options_db_t freqman_steps which is now brought by ui_receiver.hpp
* use freqman db steps instead of static array
Co-authored-by: gullradriel <gullradriel@no-mail.com>
* Added menu group for transceivers (#2623)
* Added menu group for transceivers
* Reorder apps icons
* Support IPS screen & brightness set for IPS screen (#2629)
* _
* format
* format
* format
* Fix bug that created by PR "Added menu group for transceivers" (#2630)
* spectrum cursor opt again (#2634)
* spectrum cursor opt
* fmt
* remove blink
* remove End event
* cleanup
* Update README.md
Links were dead for opensourcesdrlab
* Fix for #2538 (#2635)
* Fix for #2538
Fix for #2538
Added on_bandwidth_changed Callback to ui_transmitter.hpp
Modified the field_bw.on_change lambda in the TransmitterView constructor to trigger the on_bandwidth_changed callback
Connected the Callback in ui_siggen.cpp
I am not a C++ programmer so this change was proposed by Gemini AI.
I have built and tested the App and it works as expected and I don't think the change will have any unexpected side effects.
* Fix clang issues
Fix clang issues
* Update ui_transmitter.cpp
typo
* Revised change
The proposed change mirrors the way a change to the frequency (on_edit_frequency) is triggered in ui_siggen by the tx_view.
The bw parameter is not passed because it is stored in _setting in the tx_view and will be read by update_config.
A change to the bw is not checked against auto_update to keep its behaviour consistent with a change to the gain, amplitude or frequency.
* Make changes to the channel_bandwidth dynamic whist playing
Behaviour of channel bandwidth is now consistent with frequency, amp and gain.
* comment edit
* revert hackrf submodule checkpoint to the repo
* comment
---------
Co-authored-by: zxkmm <zxkmm@hotmail.com>
* Adding_WFM_AM_mode_to_Audio_App (#2644)
* Adding_WFM_AM_mode_to_Audio_App
* more precise values for cos and sin theta, fix sen_theta to sin_theta
* fix sen_theta to sin_theta
* going back to WFM as main baseband in main.cpp as NFM is now making the apps crashing. Looks like last additions to WFM made it bigger. (#2646)
* remove dead code (#2647)
* Update ui_tetris.cpp (#2650)
Start "I" tetromino a bit higher and block rotate if it will cause out of bounds collision.
* Noaa apt decoder (#2648)
* Explicit_naming_wefax_NOAA_and_small_addition (#2651)
* slightly improved ads-b receiver module (#2649)
* slightly improved ads-b receiver module:
* fix Heading, Speed and Vrate decoders
* decode more ModeS messages
* log all ModeS messages (except DF11)
* fix formatting (clang-style); advice on data alignment taken into account
* ADS-B module: convert Indicated AirSpeed to True AirSpeed if altitute is known
* ADS-B rx module: replacing floating point with integer arithmetic
* adding 10Hz and 50Hz to freqman_steps (#2652)
* Improve_RF_sensitivity_NOAA_signal (#2654)
* Upload the PCB file of PortaPack H4 and update the schematic file (#2657)
* Create README.txt
* Update README.txt
* Add files via upload
The gerber files of the portapack h4.
* delete
* Upload the gerber files for H4
* Create README.txt
This is the V1.0 version PCB file of PortaPack H4.
* Upload the pcb file for H4
* Update README.txt
* Update LCD_TF_Schematic.pdf
* Jammer app add modes (#2659)
* Add new jammer modes
Overview
This PR enhances the PortaPack Jammer app by introducing eight new signal types, ported from my Flipper Zero RF Jammer app (https://github.com/RocketGod-git/flipper-zero-rf-jammer). These modes expand the app's capability to disrupt a wide range of RF communication protocols, from analog radios to modern digital systems. The implementation preserves the original app structure, resolves namespace conflicts, and ensures compatibility with the Mayhem firmware.
New Modes
The following modes have been added to the options_type in ui_jammer.hpp, with corresponding signal generation in proc_jammer.cpp:
Noise: Generates broadband white noise to interfere with analog and digital signals (e.g., Wi-Fi, Bluetooth, key fobs). Highly effective for overwhelming receivers across a frequency range.
Sine: Produces a continuous, unmodulated sine wave to jam narrowband receivers, ideal for analog FM/AM radios or telemetry systems.
Square: Emits a harmonic-rich square wave, disrupting digital protocols (e.g., OOK, ASK) and systems sensitive to sharp transitions, such as remote keyless entry.
Sawtooth (Experimental): Generates a sawtooth wave with a unique harmonic profile, useful for testing interference against PWM-based or niche analog systems.
Triangle (Experimental): Creates a triangle wave with minimal harmonics, suitable for exploratory jamming of narrowband systems or receiver linearity testing.
Chirp: Outputs a rapid frequency-sweeping chirp signal, effective against frequency-hopping and spread-spectrum systems (e.g., some Wi-Fi, Bluetooth, or military radios).
Gauss: Generates Gaussian noise to mimic natural interference, targeting digital systems like GPS or data links by degrading signal-to-noise ratios.
Brute (Experimental): Transmits a constant maximum-amplitude signal to saturate simple receiver front-ends, useful for brute-force jamming of basic analog devices.
* Add new jammer modes
Overview
This PR enhances the PortaPack Jammer app by introducing eight new signal types, ported from my Flipper Zero RF Jammer app (https://github.com/RocketGod-git/flipper-zero-rf-jammer). These modes expand the app's capability to disrupt a wide range of RF communication protocols, from analog radios to modern digital systems. The implementation preserves the original app structure, resolves namespace conflicts, and ensures compatibility with the Mayhem firmware.
New Modes
The following modes have been added to the options_type in ui_jammer.hpp, with corresponding signal generation in proc_jammer.cpp:
Noise: Generates broadband white noise to interfere with analog and digital signals (e.g., Wi-Fi, Bluetooth, key fobs). Highly effective for overwhelming receivers across a frequency range.
Sine: Produces a continuous, unmodulated sine wave to jam narrowband receivers, ideal for analog FM/AM radios or telemetry systems.
Square: Emits a harmonic-rich square wave, disrupting digital protocols (e.g., OOK, ASK) and systems sensitive to sharp transitions, such as remote keyless entry.
Sawtooth (Experimental): Generates a sawtooth wave with a unique harmonic profile, useful for testing interference against PWM-based or niche analog systems.
Triangle (Experimental): Creates a triangle wave with minimal harmonics, suitable for exploratory jamming of narrowband systems or receiver linearity testing.
Chirp: Outputs a rapid frequency-sweeping chirp signal, effective against frequency-hopping and spread-spectrum systems (e.g., some Wi-Fi, Bluetooth, or military radios).
Gauss: Generates Gaussian noise to mimic natural interference, targeting digital systems like GPS or data links by degrading signal-to-noise ratios.
Brute (Experimental): Transmits a constant maximum-amplitude signal to saturate simple receiver front-ends, useful for brute-force jamming of basic analog devices.
* refactor the serial log logic of BLE Rx (#2660)
* Prepare for display orientation part 1 (#2661)
* fix png part
* screen max width fixes (#2663)
* max width fixes
* format
* Audio to right (#2664)
* r.align
* Storing_selected_NOAA_filter_in_settings_file (#2665)
* Storing_selected_NOAA_filter_in_settings_file
* format_issues
* wfm_filters_GUI_name_std (#2668)
* getres cmd (#2671)
* ui new coord system examples and macros (#2672)
* Detector RX ext app (#2673)
* Jammer improvements (#2674)
* Add new jammer modes
Overview:
This PR enhances the PortaPack Jammer app by introducing eight new signal types, ported from my Flipper Zero RF Jammer app (https://github.com/RocketGod-git/flipper-zero-rf-jammer). These modes expand the app's capability to disrupt a wide range of RF communication protocols, from analog radios to modern digital systems. The implementation preserves the original app structure, resolves namespace conflicts, and ensures compatibility with the Mayhem firmware.
New Modes
The following modes have been added to the options_type in ui_jammer.hpp, with corresponding signal generation in proc_jammer.cpp:
Noise: Generates broadband white noise to interfere with analog and digital signals (e.g., Wi-Fi, Bluetooth, key fobs). Highly effective for overwhelming receivers across a frequency range.
Sine: Produces a continuous, unmodulated sine wave to jam narrowband receivers, ideal for analog FM/AM radios or telemetry systems.
Square: Emits a harmonic-rich square wave, disrupting digital protocols (e.g., OOK, ASK) and systems sensitive to sharp transitions, such as remote keyless entry.
Sawtooth (Experimental): Generates a sawtooth wave with a unique harmonic profile, useful for testing interference against PWM-based or niche analog systems.
Triangle (Experimental): Creates a triangle wave with minimal harmonics, suitable for exploratory jamming of narrowband systems or receiver linearity testing.
Chirp: Outputs a rapid frequency-sweeping chirp signal, effective against frequency-hopping and spread-spectrum systems (e.g., some Wi-Fi, Bluetooth, or military radios).
Gauss: Generates Gaussian noise to mimic natural interference, targeting digital systems like GPS or data links by degrading signal-to-noise ratios.
Brute (Experimental): Transmits a constant maximum-amplitude signal to saturate simple receiver front-ends, useful for brute-force jamming of basic analog devices.
* Fixed and made brutal.
This PR introduces user-focused improvements to the Jammer App in the HackRF PortaPack Mayhem Firmware, enhancing usability and flexibility. The changes address specific user requirements for a more intuitive default configuration, continuous waveform support, and dynamic setting adjustments during transmission.
* jammer fix (#2676)
* jammer fix
* Adding_BPF_selection_to_the_NOAA_APT_signal (#2675)
* Adding_BPF_selection_to_the_NOAA_APT_signal
* comments, spell mistake .
* trivial apps folder movement (#2677)
* Clean_LCD_beat_in_NOAA_Rx_App (#2678)
* Added ability to enter custom tone values in Morse app (#2679)
* Added ability to enter custom tone values in Morse app
Added the ability to type in a custom tone value in the morse TX app (issue#2582)
*Click on the tone field to open a keyboard for entering in a desired value between 100hz - 9999hz.
*Maintains original step value of 20 when scrolling the rotary wheel.
* Update ui_morse.cpp
Replaced std::to_string with to_string_dec_uint
* Moved tone_input_buffer init to in-class
* removed some std stuff only used here (#2681)
* 80mhz jammer range (#2682)
Looks great 😎🤘🚀
* Radio app improvements (#2680)
* Rename looking glass preset for clarity and consistency (#2686)
* Gfx widget and Radio (#2685)
* widgetize
* gfx and Radio improvement
* format + handle not wfm visual states
* wf or gf
* Externalize widget (#2688)
* Add all jammer modes in hopper app (#2691)
Added all modes that jammer app supports in hopper app.
* Super secret dont look (#2690)
* Add new jammer modes
Overview
This PR enhances the PortaPack Jammer app by introducing eight new signal types, ported from my Flipper Zero RF Jammer app (https://github.com/RocketGod-git/flipper-zero-rf-jammer). These modes expand the app's capability to disrupt a wide range of RF communication protocols, from analog radios to modern digital systems. The implementation preserves the original app structure, resolves namespace conflicts, and ensures compatibility with the Mayhem firmware.
New Modes
The following modes have been added to the options_type in ui_jammer.hpp, with corresponding signal generation in proc_jammer.cpp:
Noise: Generates broadband white noise to interfere with analog and digital signals (e.g., Wi-Fi, Bluetooth, key fobs). Highly effective for overwhelming receivers across a frequency range.
Sine: Produces a continuous, unmodulated sine wave to jam narrowband receivers, ideal for analog FM/AM radios or telemetry systems.
Square: Emits a harmonic-rich square wave, disrupting digital protocols (e.g., OOK, ASK) and systems sensitive to sharp transitions, such as remote keyless entry.
Sawtooth (Experimental): Generates a sawtooth wave with a unique harmonic profile, useful for testing interference against PWM-based or niche analog systems.
Triangle (Experimental): Creates a triangle wave with minimal harmonics, suitable for exploratory jamming of narrowband systems or receiver linearity testing.
Chirp: Outputs a rapid frequency-sweeping chirp signal, effective against frequency-hopping and spread-spectrum systems (e.g., some Wi-Fi, Bluetooth, or military radios).
Gauss: Generates Gaussian noise to mimic natural interference, targeting digital systems like GPS or data links by degrading signal-to-noise ratios.
Brute (Experimental): Transmits a constant maximum-amplitude signal to saturate simple receiver front-ends, useful for brute-force jamming of basic analog devices.
* Super secret
* You gotta get (Get) that (That) dirt off your shoulder
* Add 1ms hop option to hopper app + 0ms (freeze UI) (#2692)
* add dark theme (#2695)
* Made the Dino Game (#2697)
* Add vendor name in bluetooth rx app (#2696)
* add macaddress db, add vendor name in bluetooth rx app
* show "missing macaddress.db" instead of unknown if db not found
* bluetooth rx list with colors based on mac vendor
* bug fix
* Modified Text Editor to handle long presses. (#2698)
* Improved FPV_ANALOG.txt FREQMAN file (#2700)
* Improved FPV_ANALOG.txt FREQMAN file
Removed unused or super rare analog fpv bands: U, O, H, D
Added 1.2GHz -1.3GHz channels sometimes used for long range analog fpv
* Corrected and updated the labels to be more consistent.
Corrected the labels to be more consistent.
I also somehow messed up the correct channels because 1.3GHz FPV is not fully standardized, but these channels seem to be the most common.
It should be all correct now.
Example transmitters using those channels:
https://greenchip.com.ua/0-0-1615-2.html
https://flymod.net/en/item/walksnail_vtx_9ch
https://pl.aliexpress.com/item/1005006505365351.html
* Filemanager: go to parent directory keep track of the right selected … (#2702)
* Filemanager: go to parent directory keep track of the right selected item and page number
* review: avoid unnecessary copies in get_extension
* ADSB database update (tools, db) (#2701)
* enhance make_airlines_db tool
* enhance make_icao24_db tool
* update airlinescode (.txt, .db), aircraftdatabase/icao24 (.csv, .db)
* Made the Space Invaders game. Argh matey! (#2709)
* Made the Space Invaders game. Argh matey!
* Format code, sigh.
* Made the Blackjack game (#2712)
* Made the Blackjack game
* Format Blackjack main.cpp
* Changed spade to diamond for dark mode visibility
* Format code
* Update app icons for Space Invaders and Dino Game (#2713)
* BLE Rx Improvements (#2710)
* Work to allow for unique beacon parsing functions.
* Fix Copyright
* Update firmware/application/apps/ble_rx_app.cpp
* Update firmware/baseband/proc_btlerx.cpp
* PR suggestions.
* Fix String.
* Refactor
* Added 3d printed cases for the H4M (#2715)
* Battleship (#2720)
* Made the Battleship 2P 2PP game - FSK is wip
* Using POCSAG
* Adding simple FSK Rx Processor. Can be used with New Apps. (#2716)
* Work to allow for unique beacon parsing functions.
* Fixing pull.
* Changes.
* Formatting.
* Fix Copyright
* Update firmware/application/apps/ble_rx_app.cpp
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Update firmware/baseband/proc_btlerx.cpp
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* PR suggestions.
* Fix String.
* FSK Rx Improvements. Works for my custom protocol.
* Fix buffer size.
* Refactor
* Formatting.
* Formatting.
* Fixing compiling, and BLE Rx UI/Performance.
* More improvements.
* Fixing stuck state.
* More stuck parsing fix.
* Combining PR changes.
* Improvements from previous PR.
* Fix dbM calculation relative to device RSSI.
* Formatting.
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: TJ <tj.baginski@cognosos.com>
* Add blue bar to subghzd+weather (#2724)
* AIS map improv (#2725)
* AIS map improv
* format code mismatch with vc
* Add radio settings, new app icon, and other UI improvements (#2732)
* update submodule (#2734)
Co-authored-by: gullradriel <gullradriel@no-mail.com>
* update version (#2735)
Co-authored-by: gullradriel <gullradriel@no-mail.com>
---------
Co-authored-by: Erwin Ried <1091420+eried@users.noreply.github.com>
Co-authored-by: hackrfstuff <leszczyleszczy@icloud.com>
Co-authored-by: sommermorgentraum <24917424+zxkmm@users.noreply.github.com>
Co-authored-by: Totoo <ttotoo@gmail.com>
Co-authored-by: Mark Thompson <129641948+NotherNgineer@users.noreply.github.com>
Co-authored-by: E.T. <tamas@eisenberger.hu>
Co-authored-by: OpenSourceSDRLab <opensourcesdr@outlook.com>
Co-authored-by: quantum-x <simon.yorkston@gmail.com>
Co-authored-by: gullradriel <gullradriel@no-mail.com>
Co-authored-by: Lucas C. Villa Real <lucasvr@users.noreply.github.com>
Co-authored-by: Davide Rovelli <103165301+daviderud@users.noreply.github.com>
Co-authored-by: Gaurav Chaturvedi <oddtazz@users.noreply.github.com>
Co-authored-by: RocketGod <57732082+RocketGod-git@users.noreply.github.com>
Co-authored-by: Lerold <github@lerold.slmail.me>
Co-authored-by: Brumi-2021 <86470699+Brumi-2021@users.noreply.github.com>
Co-authored-by: dark-juju <2839275+dark-juju@users.noreply.github.com>
Co-authored-by: Benjamin Møller <37707273+LupusE@users.noreply.github.com>
Co-authored-by: Oleg Belousov <belousov.oleg@gmail.com>
Co-authored-by: haruk <104354987+exe-noisy@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Luca <61653175+iu2frl@users.noreply.github.com>
Co-authored-by: Richard <richard.toy@gmail.com>
Co-authored-by: zxkmm <zxkmm@hotmail.com>
Co-authored-by: horrordash <45861453+horrordash@users.noreply.github.com>
Co-authored-by: Alien <2142224+mythic-alien@users.noreply.github.com>
Co-authored-by: Petro Danylevskyi <petro@danylevskyi.com>
Co-authored-by: Tommaso Ventafridda <33782489+tomventa@users.noreply.github.com>
Co-authored-by: Netro <146584182+iNetro@users.noreply.github.com>
Co-authored-by: plomek <86431917+plomek@users.noreply.github.com>
Co-authored-by: TJ <tj.baginski@cognosos.com>
490 lines
19 KiB
C++
490 lines
19 KiB
C++
/*
|
|
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
|
* Copyright (C) 2017 Furrtek
|
|
* Early 2023 joyel24 added meteomodem M20 support
|
|
*
|
|
* This file is part of PortaPack.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
* any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; see the file COPYING. If not, write to
|
|
* the Free Software Foundation, Inc., 51 Franklin Street,
|
|
* Boston, MA 02110-1301, USA.
|
|
*/
|
|
|
|
#include "sonde_packet.hpp"
|
|
#include "string_format.hpp"
|
|
#include <cstring>
|
|
// #include <complex>
|
|
|
|
namespace sonde {
|
|
|
|
static uint8_t calibytes[51 * 16]; // need these vars to survive
|
|
static uint8_t calfrchk[51]; // so subframes are preserved while populated
|
|
|
|
// Defines for Vaisala RS41, from https://github.com/rs1729/RS/blob/master/rs41/rs41sg.c
|
|
#define MASK_LEN 64
|
|
|
|
// Following values include the 4 bytes less shift, consumed in detecting the header on proc_sonde
|
|
#define block_status 0x35 // 0x039 // 40 bytes
|
|
#define block_gpspos 0x10E // 0x112 // 21 bytes
|
|
#define block_meas 0x61 // 0x65 // 42 bytes
|
|
#define pos_FrameNb 0x37 // 0x03B // 2 byte
|
|
#define pos_SondeID 0x39 // 0x03D // 8 byte
|
|
#define pos_Voltage 0x041 // 0x045 // 3 bytes (but first one is the important one) voltage x 10 ie: 26 = 2.6v
|
|
#define pos_CalData 0x04E // 0x052 // 1 byte, counter 0x00..0x32
|
|
#define pos_temp 0x063 // 0x067 // 3 bytes (uint24_t)
|
|
#define pos_GPSecefX 0x110 // 0x114 // 4 byte
|
|
#define pos_GPSecefY 0x114 // 0x118 // 4 byte (not actually used since Y and Z are following X, and grabbed in that same loop)
|
|
#define pos_GPSecefZ 0x118 // 0x11C // 4 byte (same as Y)
|
|
|
|
#define PI 3.1415926535897932384626433832795 // 3.1416 //(3.1415926535897932384626433832795)
|
|
|
|
Packet::Packet(
|
|
const baseband::Packet& packet,
|
|
const Type type)
|
|
: packet_{packet},
|
|
decoder_{packet_},
|
|
reader_bi_m{decoder_},
|
|
type_{type} {
|
|
if (type_ == Type::Meteomodem_unknown) {
|
|
// Right now we're just sure that the sync is from a Meteomodem sonde, differentiate between models now
|
|
const uint32_t id_byte = reader_bi_m.read(0 * 8, 16);
|
|
|
|
if (id_byte == 0x649F)
|
|
type_ = Type::Meteomodem_M10;
|
|
else if (id_byte == 0x648F)
|
|
type_ = Type::Meteomodem_M2K2;
|
|
else if (id_byte == 0x4520) // https://raw.githubusercontent.com/projecthorus/radiosonde_auto_rx/master/demod/mod/m20mod.c
|
|
type_ = Type::Meteomodem_M20;
|
|
}
|
|
}
|
|
|
|
size_t Packet::length() const {
|
|
return decoder_.symbols_count();
|
|
}
|
|
|
|
Timestamp Packet::received_at() const {
|
|
return packet_.timestamp();
|
|
}
|
|
|
|
Packet::Type Packet::type() const {
|
|
return type_;
|
|
}
|
|
|
|
// euquiq here:
|
|
// RS41SG 320 bits header, 320bytes frame (or more if it is an "extended frame")
|
|
// The raw data is xor-scrambled with the values in the 64 bytes vaisala_mask (see.hpp)
|
|
// from 0x008 to 0x037 (48 bytes reed-solomon error correction data)
|
|
|
|
uint8_t Packet::vaisala_descramble(const uint32_t pos) const { // vaisala_descramble(const uint32_t pos) const {
|
|
// packet_[i]; its a bit; packet_.size the total (should be 2560 bits)
|
|
uint8_t value = 0;
|
|
for (uint8_t i = 0; i < 8; i++)
|
|
value = (value << 1) | packet_[(pos * 8) + (7 - i)]; // get the byte from the bits collection
|
|
|
|
// packetReader reader { packet_ }; //This works just as above.
|
|
// value = reader.read(pos * 8,8);
|
|
// shift pos because first 4 bytes are consumed by proc_sonde in finding the vaisala signature
|
|
uint32_t mask_pos = pos + 4;
|
|
value = value ^ vaisala_mask[mask_pos % MASK_LEN]; // descramble with the xor pseudorandom table
|
|
return value;
|
|
};
|
|
|
|
GPS_data Packet::get_GPS_data() const {
|
|
GPS_data result;
|
|
if ((type_ == Type::Meteomodem_M10) || (type_ == Type::Meteomodem_M2K2)) {
|
|
result.alt = (reader_bi_m.read(22 * 8, 32) / 1000) - 48;
|
|
result.lat = reader_bi_m.read(14 * 8, 32) / ((1ULL << 32) / 360.0);
|
|
result.lon = reader_bi_m.read(18 * 8, 32) / ((1ULL << 32) / 360.0);
|
|
} else if (type_ == Type::Meteomodem_M20) {
|
|
result.alt = reader_bi_m.read(8 * 8, 24) / 100.0; // <|
|
|
result.lat = reader_bi_m.read(28 * 8, 32) / 1000000.0; // <| Inspired by https://raw.githubusercontent.com/projecthorus/radiosonde_auto_rx/master/demod/mod/m20mod.c
|
|
result.lon = reader_bi_m.read(32 * 8, 32) / 1000000.0; // <|
|
|
} else if (type_ == Type::Vaisala_RS41_SG) {
|
|
uint8_t XYZ_bytes[4];
|
|
int32_t XYZ; // 32bit
|
|
double_t X[3];
|
|
for (int32_t k = 0; k < 3; k++) { // Get X,Y,Z ECEF position from GPS
|
|
for (int32_t i = 0; i < 4; i++) // each one is 4 bytes (32 bits)
|
|
XYZ_bytes[i] = vaisala_descramble(pos_GPSecefX + (4 * k) + i);
|
|
memcpy(&XYZ, XYZ_bytes, 4);
|
|
X[k] = XYZ / 100.0;
|
|
}
|
|
|
|
double_t a = 6378137.0;
|
|
double_t b = 6356752.31424518;
|
|
double_t e = sqrt((a * a - b * b) / (a * a));
|
|
double_t ee = sqrt((a * a - b * b) / (b * b));
|
|
|
|
double_t lam = atan2(X[1], X[0]);
|
|
double_t p = sqrt(X[0] * X[0] + X[1] * X[1]);
|
|
double_t t = atan2(X[2] * a, p * b);
|
|
double_t phi = atan2(X[2] + ee * ee * b * sin(t) * sin(t) * sin(t),
|
|
p - e * e * a * cos(t) * cos(t) * cos(t));
|
|
|
|
double_t R = a / sqrt(1 - e * e * sin(phi) * sin(phi));
|
|
|
|
result.alt = p / cos(phi) - R;
|
|
result.lat = phi * 180 / PI;
|
|
result.lon = lam * 180 / PI;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
uint32_t Packet::battery_voltage() const {
|
|
if (type_ == Type::Meteomodem_M10)
|
|
return (reader_bi_m.read(69 * 8, 8) + (reader_bi_m.read(70 * 8, 8) << 8)) * 1000 / 150;
|
|
else if (type_ == Type::Meteomodem_M20) {
|
|
return 0; // NOT SUPPPORTED YET
|
|
} else if (type_ == Type::Meteomodem_M2K2)
|
|
return reader_bi_m.read(69 * 8, 8) * 66; // Actually 65.8
|
|
else if (type_ == Type::Vaisala_RS41_SG) {
|
|
uint32_t voltage = vaisala_descramble(pos_Voltage) * 100; // byte 69 = voltage * 10 (check if this value needs to be multiplied)
|
|
return voltage;
|
|
} else {
|
|
return 0; // Unknown
|
|
}
|
|
}
|
|
|
|
uint32_t Packet::frame() const {
|
|
if (type_ == Type::Vaisala_RS41_SG) {
|
|
uint32_t frame_number = vaisala_descramble(pos_FrameNb) | (vaisala_descramble(pos_FrameNb + 1) << 8);
|
|
return frame_number;
|
|
} else {
|
|
return 0; // Unknown
|
|
}
|
|
}
|
|
|
|
temp_humid Packet::get_temp_humid() const {
|
|
temp_humid result;
|
|
result.humid = 0;
|
|
result.temp = 0;
|
|
|
|
if (type_ == Type::Meteomodem_M10) {
|
|
// https://github.com/projecthorus/radiosonde_auto_rx/blob/master/demod/mod/m10mod.c
|
|
// temp:
|
|
uint16_t ADC_Ti_raw = (reader_bi_m.read(0x49 * 8, 8) << 8) | reader_bi_m.read(0x48 * 8, 8) << 8; // int.temp.diode, ref: 4095->1.5V
|
|
if (ADC_Ti_raw != 0) {
|
|
// internal
|
|
float vti, ti;
|
|
// INCH1A (temp.diode), slau144
|
|
vti = ADC_Ti_raw / 4095.0 * 1.5; // V_REF+ = 1.5V, no calibration
|
|
ti = (vti - 0.986) / 0.00355; // 0.986/0.00355=277.75, 1.5/4095/0.00355=0.1032
|
|
result.temp = ti;
|
|
}
|
|
// NTC - Thermistor Shibaura PB5 - 41E
|
|
float p0 = 1.07303516e-03,
|
|
p1 = 2.41296733e-04,
|
|
p2 = 2.26744154e-06,
|
|
p3 = 6.52855181e-08;
|
|
// T/K = 1/( p0 + p1*ln(R) + p2*ln(R)^2 + p3*ln(R)^3 )
|
|
|
|
// range/scale 0, 1, 2: // M10-pcb
|
|
float Rs_T[3] = {12.1e3, 36.5e3, 475.0e3}; // bias/series
|
|
float Rp[3] = {1e20, 330.0e3, 2000.0e3}; // parallel, Rp[0]=inf
|
|
|
|
uint8_t scT; // {0,1,2}, range/scale voltage divider
|
|
uint16_t ADC_RT; // ADC12 P6.7(A7) , adr_0377h,adr_0376h
|
|
// uint16_t Tcal[2]; // adr_1000h[scT*4]
|
|
|
|
float adc_max = 4095.0; // ADC12
|
|
float x, R;
|
|
float T = 0; // T/Kelvin
|
|
|
|
scT = reader_bi_m.read(0x3E * 8, 8); // adr_0455h
|
|
ADC_RT = (reader_bi_m.read(0x40 * 8, 8) << 8) | reader_bi_m.read(0x3F * 8, 8);
|
|
if (ADC_RT != 0) {
|
|
ADC_RT -= 0xA000;
|
|
// Tcal[0] = (reader_bi_m.read(0x42 * 8, 8) << 8) | reader_bi_m.read(0x41 * 8, 8);
|
|
// Tcal[1] = (reader_bi_m.read(0x44 * 8, 8) << 8) | reader_bi_m.read(0x43 * 8, 8);
|
|
|
|
x = (adc_max - ADC_RT) / ADC_RT; // (Vcc-Vout)/Vout
|
|
if (scT < 3)
|
|
R = Rs_T[scT] / (x - Rs_T[scT] / Rp[scT]);
|
|
else
|
|
R = -1;
|
|
|
|
if (R > 0) T = 1 / (p0 + p1 * log(R) + p2 * log(R) * log(R) + p3 * log(R) * log(R) * log(R));
|
|
result.temp = T - 273.15;
|
|
}
|
|
|
|
// humidity:
|
|
// get count rh:
|
|
float TBCCR1 = (reader_bi_m.read(0x35 * 8, 8) | (reader_bi_m.read(0x36 * 8, 8) << 8) | (reader_bi_m.read(0x37 * 8, 8) << 16)) / 1000.0;
|
|
// get count 55:
|
|
float TBCREF = (reader_bi_m.read(0x32 * 8, 8) | (reader_bi_m.read(0x33 * 8, 8) << 8) | (reader_bi_m.read(0x34 * 8, 8) << 16)) / 1000.0;
|
|
if (TBCREF != 0) {
|
|
float cRHc55 = TBCCR1 / TBCREF; //;get_count_RH(gpx) / get_count_55(gpx); // CalRef 55%RH , T=20C ?
|
|
// get_Tntc2: --unused.
|
|
// float Rs = 22.1e3; // P5.6=Vcc
|
|
// float R25 = 2.2e3;
|
|
// float b = 3650.0; // B/Kelvin
|
|
// float T25 = 25.0 + 273.15; // T0=25C, R0=R25=5k
|
|
// -> Steinhart-Hart coefficients (polyfit):
|
|
|
|
// cRHc55_RH:
|
|
// float TH = get_Tntc2(gpx); --unused
|
|
float rh = (cRHc55 - 0.8955) / 0.002; // UPSI linear transfer function
|
|
// temperature compensation
|
|
float T0 = 0.0, T1 = -30.0; // T/C
|
|
if (result.temp < T0) rh += T0 - result.temp / 5.5; // approx/empirical
|
|
if (result.temp < T1) rh *= 1.0 + (T1 - result.temp) / 75.0; // approx/empirical
|
|
if (rh < 0.0) rh = 0.0;
|
|
if (rh > 100.0) rh = 100.0;
|
|
result.humid = rh;
|
|
}
|
|
}
|
|
|
|
if (type_ == Type::Vaisala_RS41_SG && crc_ok_RS41()) // Only process if packet is healthy
|
|
{
|
|
// memset(calfrchk, 0, 51); // is this necessary ? only if the sondeID changes (new sonde)
|
|
// original code from https://github.com/rs1729/RS/blob/master/rs41/rs41ptu.c
|
|
float Rf1, // ref-resistor f1 (750 Ohm)
|
|
Rf2, // ref-resistor f2 (1100 Ohm)
|
|
co1[3], // { -243.911 , 0.187654 , 8.2e-06 }
|
|
calT1[3], // calibration T1
|
|
co2[3], // { -243.911 , 0.187654 , 8.2e-06 }
|
|
calT2[3], // calibration T2-Hum
|
|
calH[2]; // calibration Hum
|
|
|
|
uint32_t meas[12], i;
|
|
|
|
//-------------- get_CalData
|
|
|
|
//-------------- populate calibytes (from getFrameConf)
|
|
|
|
uint8_t calfr = vaisala_descramble(pos_CalData); // get subframe #slot
|
|
|
|
for (i = 0; i < 16; i++) // Load subrfame calibration page (16 bytes) into #slot
|
|
calibytes[calfr * 16 + i] = vaisala_descramble(pos_CalData + 1 + i); // pos = pos_CalData + 1 + i ; vaisala_descramble(pos)
|
|
|
|
calfrchk[calfr] = 1; // flag this #slot as populated
|
|
|
|
memcpy(&Rf1, calibytes + 61, 4); // 0x03*0x10+13
|
|
memcpy(&Rf2, calibytes + 65, 4); // 0x04*0x10+ 1
|
|
|
|
memcpy(co1 + 0, calibytes + 77, 4); // 0x04*0x10+13
|
|
memcpy(co1 + 1, calibytes + 81, 4); // 0x05*0x10+ 1
|
|
memcpy(co1 + 2, calibytes + 85, 4); // 0x05*0x10+ 5
|
|
|
|
memcpy(calT1 + 0, calibytes + 89, 4); // 0x05*0x10+ 9
|
|
memcpy(calT1 + 1, calibytes + 93, 4); // 0x05*0x10+13
|
|
memcpy(calT1 + 2, calibytes + 97, 4); // 0x06*0x10+ 1
|
|
|
|
memcpy(calH + 0, calibytes + 117, 4); // 0x07*0x10+ 5
|
|
memcpy(calH + 1, calibytes + 121, 4); // 0x07*0x10+ 9
|
|
|
|
memcpy(co2 + 0, calibytes + 293, 4); // 0x12*0x10+ 5
|
|
memcpy(co2 + 1, calibytes + 297, 4); // 0x12*0x10+ 9
|
|
memcpy(co2 + 2, calibytes + 301, 4); // 0x12*0x10+13
|
|
|
|
memcpy(calT2 + 0, calibytes + 305, 4); // 0x13*0x10+ 1
|
|
memcpy(calT2 + 1, calibytes + 309, 4); // 0x13*0x10+ 5
|
|
memcpy(calT2 + 2, calibytes + 313, 4); // 0x13*0x10+ 9
|
|
//---------------------------------------
|
|
for (i = 0; i < 12; i++)
|
|
meas[i] = vaisala_descramble(pos_temp + (3 * i)) |
|
|
(vaisala_descramble(pos_temp + (3 * i) + 1) << 8) |
|
|
(vaisala_descramble(pos_temp + (3 * i) + 2) << 16);
|
|
|
|
//----Check if necessary calibytes are already present for calculation
|
|
|
|
if (calfrchk[0x03] && calfrchk[0x04] && calfrchk[0x04] && calfrchk[0x05] && calfrchk[0x05] && calfrchk[0x06]) // Calibites OK for Temperature
|
|
{
|
|
//----------get_Tc------------------------
|
|
float* p = co1;
|
|
float* c = calT1;
|
|
float g = (float)(meas[2] - meas[1]) / (Rf2 - Rf1), // gain
|
|
Rb = (meas[1] * Rf2 - meas[2] * Rf1) / (float)(meas[2] - meas[1]), // ofs
|
|
Rc = meas[0] / g - Rb,
|
|
R = Rc * c[0],
|
|
T = (p[0] + p[1] * R + p[2] * R * R + c[1]) * (1.0 + c[2]);
|
|
result.temp = T;
|
|
}
|
|
|
|
if (calfrchk[0x07]) {
|
|
//----------get_RH------------------------
|
|
float a0 = 7.5; // empirical
|
|
float a1 = 350.0 / calH[0]; // empirical
|
|
float fh = (meas[3] - meas[4]) / (float)(meas[5] - meas[4]);
|
|
float rh = 100.0 * (a1 * fh - a0);
|
|
float T0 = 0.0, T1 = -25.0; // T/C
|
|
rh += T0 - result.temp / 5.5; // empir. temperature compensation
|
|
if (result.temp < T1)
|
|
rh *= 1.0 + (T1 - result.temp) / 90.0; // empir. temperature compensation
|
|
if (rh < 0.0)
|
|
rh = 0.0;
|
|
if (rh > 100.0)
|
|
rh = 100.0;
|
|
if (result.temp < -273.0)
|
|
rh = -1.0;
|
|
result.humid = rh;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
std::string Packet::type_string() const {
|
|
switch (type_) {
|
|
case Type::Unknown:
|
|
return "Unknown";
|
|
case Type::Meteomodem_unknown:
|
|
return "Meteomodem ???";
|
|
case Type::Meteomodem_M10:
|
|
return "Meteomodem M10";
|
|
case Type::Meteomodem_M20:
|
|
return "Meteomodem M20";
|
|
case Type::Meteomodem_M2K2:
|
|
return "Meteomodem M2K2";
|
|
case Type::Vaisala_RS41_SG:
|
|
return "Vaisala RS41-SG";
|
|
default:
|
|
return "? 0x" + symbols_formatted().data.substr(0, 6);
|
|
}
|
|
}
|
|
|
|
std::string Packet::serial_number() const {
|
|
if (type_ == Type::Meteomodem_M10) {
|
|
// See https://github.com/rs1729/RS/blob/master/m10/m10x.c line 606
|
|
// Starting at byte #93: 00000000 11111111 22222222 33333333 44444444
|
|
// CCCC AAAABBBB
|
|
// 44444444 33333333
|
|
// DDDEEEEE EEEEEEEE
|
|
|
|
return to_string_hex(reader_bi_m.read(93 * 8 + 16, 4), 1) +
|
|
to_string_dec_uint(reader_bi_m.read(93 * 8 + 20, 4), 2, '0') + " " +
|
|
to_string_hex(reader_bi_m.read(93 * 8 + 4, 4), 1) + " " +
|
|
to_string_dec_uint(reader_bi_m.read(93 * 8 + 24, 3), 1) +
|
|
to_string_dec_uint(reader_bi_m.read(93 * 8 + 27, 13), 4, '0');
|
|
} else if (type_ == Type::Vaisala_RS41_SG) {
|
|
std::string serial_id = "";
|
|
uint8_t achar;
|
|
for (uint8_t i = 0; i < 8; i++) { // euquiq: Serial ID is 8 bytes long, each byte a char
|
|
achar = vaisala_descramble(pos_SondeID + i);
|
|
if (achar < 32 || achar > 126)
|
|
return "?"; // Maybe there are ids with less than 8 bytes and this is not OK.
|
|
serial_id += (char)achar;
|
|
}
|
|
return serial_id;
|
|
} else {
|
|
return "?";
|
|
}
|
|
}
|
|
|
|
FormattedSymbols Packet::symbols_formatted() const {
|
|
if (type_ == Type::Vaisala_RS41_SG) { // Euquiq: now we distinguish different types
|
|
uint32_t bytes = packet_.size() / 8; // Need the byte amount, which if full, it SHOULD be 320 size() should return 2560
|
|
std::string hex_data;
|
|
std::string hex_error;
|
|
hex_data.reserve(bytes * 2); // 2 hexa chars per byte
|
|
hex_error.reserve(1);
|
|
for (uint32_t i = 0; i < bytes; i++) // log will show the packet starting on the last 4 bytes from signature 93DF1A60
|
|
hex_data += to_string_hex(vaisala_descramble(i), 2);
|
|
return {hex_data, hex_error};
|
|
} else {
|
|
return format_symbols(decoder_);
|
|
}
|
|
}
|
|
|
|
bool Packet::crc_ok() const {
|
|
switch (type_) {
|
|
case Type::Meteomodem_M10:
|
|
return crc_ok_M10();
|
|
case Type::Vaisala_RS41_SG:
|
|
return crc_ok_RS41();
|
|
default:
|
|
return true; // euquiq: it was false, but if no crc routine, then no way to check
|
|
}
|
|
}
|
|
|
|
// each data block has a 2 byte header, data, and 2 byte tail:
|
|
// 1st byte: block ID
|
|
// 2nd byte: data length (without header or tail)
|
|
// <data>
|
|
// 2 bytes CRC16 over the data.
|
|
bool Packet::crc_ok_RS41() const // check CRC for the data blocks we need
|
|
{
|
|
if (!crc16rs41(block_status))
|
|
return false;
|
|
|
|
if (!crc16rs41(block_gpspos))
|
|
return false;
|
|
|
|
if (!crc16rs41(block_meas))
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
// Checks CRC16 on a RS41 field:
|
|
bool Packet::crc16rs41(uint32_t field_start) const {
|
|
int crc16poly = 0x1021;
|
|
int rem = 0xFFFF, b, j;
|
|
int xbyte;
|
|
uint32_t pos = field_start + 1;
|
|
uint8_t length = vaisala_descramble(pos);
|
|
|
|
if (pos + length + 2 > packet_.size() / 8)
|
|
return false; // Out of packet!
|
|
|
|
for (b = 0; b < length; b++) {
|
|
pos++;
|
|
xbyte = vaisala_descramble(pos);
|
|
rem = rem ^ (xbyte << 8);
|
|
for (j = 0; j < 8; j++) {
|
|
if (rem & 0x8000) {
|
|
rem = (rem << 1) ^ crc16poly;
|
|
} else {
|
|
rem = (rem << 1);
|
|
}
|
|
rem &= 0xFFFF;
|
|
}
|
|
}
|
|
// Check calculated CRC against packet's one
|
|
pos++;
|
|
int crcok = vaisala_descramble(pos) | (vaisala_descramble(pos + 1) << 8);
|
|
if (crcok != rem)
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
bool Packet::crc_ok_M10() const {
|
|
uint16_t cs{0};
|
|
uint32_t c0, c1, t, t6, t7, s, b;
|
|
|
|
for (size_t i = 0; i < packet_.size(); i++) {
|
|
b = packet_[i];
|
|
c1 = cs & 0xFF;
|
|
|
|
// B
|
|
b = (b >> 1) | ((b & 1) << 7);
|
|
b ^= (b >> 2) & 0xFF;
|
|
|
|
// A1
|
|
t6 = (cs & 1) ^ ((cs >> 2) & 1) ^ ((cs >> 4) & 1);
|
|
t7 = ((cs >> 1) & 1) ^ ((cs >> 3) & 1) ^ ((cs >> 5) & 1);
|
|
t = (cs & 0x3F) | (t6 << 6) | (t7 << 7);
|
|
|
|
// A2
|
|
s = (cs >> 7) & 0xFF;
|
|
s ^= (s >> 2) & 0xFF;
|
|
|
|
c0 = b ^ t ^ s;
|
|
|
|
cs = ((c1 << 8) | c0) & 0xFFFF;
|
|
}
|
|
|
|
return ((cs & 0xFFFF) == ((packet_[0x63] << 8) | (packet_[0x63 + 1])));
|
|
}
|
|
|
|
} /* namespace sonde */
|