Kaynağa Gözat

Add nrf24scan from https://github.com/xMasterX/all-the-plugins

git-subtree-dir: nrf24scan
git-subtree-mainline: 1514a65bf4336c1d7413afb6be881bf01414c473
git-subtree-split: d6d2d8736f97dbb419b0250b884cb885ccc88c1e
Willy-JL 2 yıl önce
ebeveyn
işleme
b24f7a6504

+ 1 - 0
nrf24scan/.gitsubtree

@@ -0,0 +1 @@
+https://github.com/xMasterX/all-the-plugins dev non_catalog_apps/nrf24scan

+ 7 - 0
nrf24scan/Distr/nrf24scan/addr-CO2mini.txt

@@ -0,0 +1,7 @@
+Rate: 1
+Ch: 122
+ESB: 1
+DPL: 0
+CRC: 2
+Payload: 4
+P0: C8C8C1

+ 7 - 0
nrf24scan/Distr/nrf24scan/addr-WCO1.txt

@@ -0,0 +1,7 @@
+Rate: 1
+Ch: 120
+ESB: 1
+DPL: 1
+CRC: 2
+Payload: 4
+P0: C8C8E5

+ 11 - 0
nrf24scan/Distr/nrf24scan/addresses.txt

@@ -0,0 +1,11 @@
+Rate: 1
+Ch: 2
+ESB: 1
+DPL: 0
+CRC: 2
+Payload: 4
+P0: C8C8C0
+P1: C8C8C1
+P2: C2
+P3: C3
+P4: E5

+ 5 - 0
nrf24scan/Distr/nrf24scan/sniff.txt

@@ -0,0 +1,5 @@
+SNIFF
+ESB: 1
+CRC: 2
+P0: 00AA
+P1: 0055

BIN
nrf24scan/Gerber_PCB_Flipper Zero nRF24 board mini_v1_0.zip


BIN
nrf24scan/Gerber_PCB_Flipper Zero nRF24 board_v1_0.zip


+ 674 - 0
nrf24scan/LICENSE

@@ -0,0 +1,674 @@
+                    GNU GENERAL PUBLIC LICENSE
+                       Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+  The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works.  By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.  We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors.  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+  To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights.  Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received.  You must make sure that they, too, receive
+or can get the source code.  And you must show them these terms so they
+know their rights.
+
+  Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+  For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software.  For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+  Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so.  This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software.  The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable.  Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products.  If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+  Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary.  To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                       TERMS AND CONDITIONS
+
+  0. Definitions.
+
+  "This License" refers to version 3 of the GNU General Public License.
+
+  "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+  "The Program" refers to any copyrightable work licensed under this
+License.  Each licensee is addressed as "you".  "Licensees" and
+"recipients" may be individuals or organizations.
+
+  To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy.  The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+  A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+  To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy.  Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+  To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies.  Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+  An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License.  If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+  1. Source Code.
+
+  The "source code" for a work means the preferred form of the work
+for making modifications to it.  "Object code" means any non-source
+form of a work.
+
+  A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+  The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form.  A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+  The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities.  However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work.  For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+  The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+  The Corresponding Source for a work in source code form is that
+same work.
+
+  2. Basic Permissions.
+
+  All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met.  This License explicitly affirms your unlimited
+permission to run the unmodified Program.  The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work.  This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+  You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force.  You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright.  Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+  Conveying under any other circumstances is permitted solely under
+the conditions stated below.  Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+  No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+  When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+  4. Conveying Verbatim Copies.
+
+  You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+  You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+  5. Conveying Modified Source Versions.
+
+  You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+    a) The work must carry prominent notices stating that you modified
+    it, and giving a relevant date.
+
+    b) The work must carry prominent notices stating that it is
+    released under this License and any conditions added under section
+    7.  This requirement modifies the requirement in section 4 to
+    "keep intact all notices".
+
+    c) You must license the entire work, as a whole, under this
+    License to anyone who comes into possession of a copy.  This
+    License will therefore apply, along with any applicable section 7
+    additional terms, to the whole of the work, and all its parts,
+    regardless of how they are packaged.  This License gives no
+    permission to license the work in any other way, but it does not
+    invalidate such permission if you have separately received it.
+
+    d) If the work has interactive user interfaces, each must display
+    Appropriate Legal Notices; however, if the Program has interactive
+    interfaces that do not display Appropriate Legal Notices, your
+    work need not make them do so.
+
+  A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit.  Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+  6. Conveying Non-Source Forms.
+
+  You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+    a) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by the
+    Corresponding Source fixed on a durable physical medium
+    customarily used for software interchange.
+
+    b) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by a
+    written offer, valid for at least three years and valid for as
+    long as you offer spare parts or customer support for that product
+    model, to give anyone who possesses the object code either (1) a
+    copy of the Corresponding Source for all the software in the
+    product that is covered by this License, on a durable physical
+    medium customarily used for software interchange, for a price no
+    more than your reasonable cost of physically performing this
+    conveying of source, or (2) access to copy the
+    Corresponding Source from a network server at no charge.
+
+    c) Convey individual copies of the object code with a copy of the
+    written offer to provide the Corresponding Source.  This
+    alternative is allowed only occasionally and noncommercially, and
+    only if you received the object code with such an offer, in accord
+    with subsection 6b.
+
+    d) Convey the object code by offering access from a designated
+    place (gratis or for a charge), and offer equivalent access to the
+    Corresponding Source in the same way through the same place at no
+    further charge.  You need not require recipients to copy the
+    Corresponding Source along with the object code.  If the place to
+    copy the object code is a network server, the Corresponding Source
+    may be on a different server (operated by you or a third party)
+    that supports equivalent copying facilities, provided you maintain
+    clear directions next to the object code saying where to find the
+    Corresponding Source.  Regardless of what server hosts the
+    Corresponding Source, you remain obligated to ensure that it is
+    available for as long as needed to satisfy these requirements.
+
+    e) Convey the object code using peer-to-peer transmission, provided
+    you inform other peers where the object code and Corresponding
+    Source of the work are being offered to the general public at no
+    charge under subsection 6d.
+
+  A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+  A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling.  In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage.  For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product.  A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+  "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source.  The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+  If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information.  But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+  The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed.  Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+  Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+  7. Additional Terms.
+
+  "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law.  If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+  When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it.  (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.)  You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+  Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+    a) Disclaiming warranty or limiting liability differently from the
+    terms of sections 15 and 16 of this License; or
+
+    b) Requiring preservation of specified reasonable legal notices or
+    author attributions in that material or in the Appropriate Legal
+    Notices displayed by works containing it; or
+
+    c) Prohibiting misrepresentation of the origin of that material, or
+    requiring that modified versions of such material be marked in
+    reasonable ways as different from the original version; or
+
+    d) Limiting the use for publicity purposes of names of licensors or
+    authors of the material; or
+
+    e) Declining to grant rights under trademark law for use of some
+    trade names, trademarks, or service marks; or
+
+    f) Requiring indemnification of licensors and authors of that
+    material by anyone who conveys the material (or modified versions of
+    it) with contractual assumptions of liability to the recipient, for
+    any liability that these contractual assumptions directly impose on
+    those licensors and authors.
+
+  All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10.  If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term.  If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+  If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+  Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+  8. Termination.
+
+  You may not propagate or modify a covered work except as expressly
+provided under this License.  Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+  However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+  Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+  Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License.  If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+  9. Acceptance Not Required for Having Copies.
+
+  You are not required to accept this License in order to receive or
+run a copy of the Program.  Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance.  However,
+nothing other than this License grants you permission to propagate or
+modify any covered work.  These actions infringe copyright if you do
+not accept this License.  Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+  10. Automatic Licensing of Downstream Recipients.
+
+  Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License.  You are not responsible
+for enforcing compliance by third parties with this License.
+
+  An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations.  If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+  You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License.  For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+  11. Patents.
+
+  A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based.  The
+work thus licensed is called the contributor's "contributor version".
+
+  A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version.  For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+  Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+  In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement).  To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+  If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients.  "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+  If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+  A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License.  You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+  Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+  12. No Surrender of Others' Freedom.
+
+  If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all.  For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+  13. Use with the GNU Affero General Public License.
+
+  Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work.  The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+  14. Revised Versions of this License.
+
+  The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+  Each version is given a distinguishing version number.  If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation.  If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+  If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+  Later license versions may give you additional or different
+permissions.  However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+  15. Disclaimer of Warranty.
+
+  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. Limitation of Liability.
+
+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+  17. Interpretation of Sections 15 and 16.
+
+  If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    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 3 of the License, 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.  If not, see <https://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+  If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+    <program>  Copyright (C) <year>  <name of author>
+    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+  You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<https://www.gnu.org/licenses/>.
+
+  The GNU General Public License does not permit incorporating your program
+into proprietary programs.  If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.  But first, please read
+<https://www.gnu.org/licenses/why-not-lgpl.html>.

+ 125 - 0
nrf24scan/README.md

@@ -0,0 +1,125 @@
+#  NRF24 scanner with logging and resend ability for Flipper Zero
+
+An [NRF24](https://www.sparkfun.com/datasheets/Components/SMD/nRF24L01Pluss_Preliminary_Product_Specification_v1_0.pdf) driver for the [Flipper Zero](https://flipperzero.one/) device. The NRF24 is a popular line of 2.4GHz radio transceivers from Nordic Semiconductors.<br>
+NRF24L01+ Enhanced ShockBurst packet decoder example using Python: [nrf24_packet_decoder.py](https://raw.githubusercontent.com/vad7/nrf24scan/master/nrf24_packet_decoder.py)<br>
+<br>
+Flipper Zero FAP file: [Nrf24_Scanner.fap](https://raw.githubusercontent.com/vad7/nrf24scan/master/Nrf24_Scanner.fap)
+<br><br>
+___________________________________________________________________________
+<br>
+<b>Приложение для Flipper Zero, читающее эфир на радиомодулях nRF24L01.</b><br>
+Выбор пукта меню - стрелки вверх/вниз, стрелки влево/вправо либо изменют настройки либо управляют видом списка, кнопка ОК либо выбирает режим (короткое нажатие), либо выполняет дополнительное действие (длительное нажатие).<br><br>
+<img src="https://raw.githubusercontent.com/vad7/nrf24scan/master/Screenshot-1.png"><br>
+По умолчанию при запуске включается режим поиска (sniff) - ищутся все валидные пакеты с корректным заголовком и CRC.<br>
+Размер CRC и тип пакета (Enhanced ShockBurst или нет) задается. CRC может быть или 1 или 2 байта.<br>
+Так как пакеты читаются в RAW формате, то длина полезной нагрузки не может быть больше 23 байт, пакеты с большей длинной не будут пойманы.<br>
+В настройках задается минимальный размер нагрузки (payload)<br>
+После принятия, пакет сдвигается побитно и валидируется. Побитный сдвиг сильно увеличивает вероятность отлова пакета, но так же увеличивается количество мусорных пакетов.<br>
+Количество уникальных адресов запоминается (просмотр - стрелка вниз в режиме просмотра адресов)<br>
+После поиска можно переключиться в режим сканирования по найденным адресам или сканировать адрес конкретного пакета или группы адресов с различным LSB в адресе<br>
+<br>
+<img src="https://raw.githubusercontent.com/vad7/nrf24scan/master/Screenshot-6.png">
+<br>
+Адреса, которые попались дважды и более раз отображаются списком:<br>
+<img src="https://raw.githubusercontent.com/vad7/nrf24scan/master/Screenshot-7.png">
+<br><br>
+Изменение режима sniff/scan - стрелками на пункте Scan.<br><br>
+Режим сканирования (scan) - просто чтение пакетов по заданным в настройках мак адресам и виду пакета - ESB/DPL.<br>
+На начальном экране в режиме чтения можно загрузить файл настроек (по умолчанию загружается settings.txt из папки nrf24_scanner на SD карте).<br>
+В файле настройке задаются адреса (максимум 6) в шестнадцатеричном виде (старший байт - первый), длина адреса вычисляется по P0.<br>
+Остальные настройки можно поменять интерактивно<br>
+Настройки сохраняются длительным нажатием на ОК.<br><br>
+<b>Описание настроек:</b><br>
+Ch - номер канала.<br>
+Rate - скорость передачи данных<br>
+Next Ch time - через сколько секунд будет увеличен номер канала<br>
+Log - выбор режима авто сохраннения в файлы log-xx.txt. Yes - сохранять в новый файл при заполнении буфера в 99 записей, Append - добавлять в последний файл, Clear - только очистка буфера<br><br>
+В пунктах Ch, Rate, Next при нажатии OK меняются параметры связи:<br>
+ESB - Enhanced ShockBurst (включена автоотправка подтверждения получения пакета, работающий приемник тоже попытается это сделать, возможны коллизии)<br>
+DPL - Динамический пакет<br>
+CRC1/2 - Размер CRC в байтах<br>
+Payload - размер пакета в байтах<br>
+<br>
+<b>Просмотр принятых пакетов</b><br><br>
+<img src="https://raw.githubusercontent.com/vad7/nrf24scan/master/Screenshot-2.png">
+<br>
+В пункте "Start scan/sniff" можно выбрать стрелками сканировать и смотреть или просто смотреть (view).<br>
+Если в файле настройки было несколько адресов, то первая цифра - номер канала (pipe) от 0 до 5.<br>
+Стрелки - перемещение по списку и горизонтальное скролирование<br>
+Долгий OK - отправка пакета<br>
+OK - вход в режим просмотра адресов и включения декодирования заголовка ESB пакета и CRC.<br>
+При декодировании заголовка (PCF) - первые 2 цифры - длина пакета в hex или 33, если длина пакета фиксирована<br>
+3-я цифра - PID (2bit) << 1 +  флаг NO_ACK<br>
+Если включен режим декодирования CRC, то по всему пакету ищется подходящая CRC и подчеркивается в списке, а так же вместо ":" выводится "=" после номера записи в буфере<br>
+<br>
+<img src="https://raw.githubusercontent.com/vad7/nrf24scan/master/Screenshot-3.png">
+<br>
+<img src="https://raw.githubusercontent.com/vad7/nrf24scan/master/Screenshot-4.png">
+<br>
+<img src="https://raw.githubusercontent.com/vad7/nrf24scan/master/Screenshot-5.png">
+<br>
+<br>
+Схема подключения модуля nRF24l01:<br>
+Big board:<br>
+<img src="https://raw.githubusercontent.com/vad7/nrf24scan/master/scheme.png">
+Gerber for full board (https://raw.githubusercontent.com/vad7/nrf24scan/master/Gerber_PCB_Flipper%20Zero%20nRF24%20board_v1_0.zip)<br>
+Easyeda source (https://oshwlab.com/vad7/flipper-zero-nrf24-board).
+<br><br>
+Mini board:<br>
+<img src="https://raw.githubusercontent.com/vad7/nRF24-Batch/main/Pics/NRF24_mini_3D.png">
+<br>
+<img src="https://raw.githubusercontent.com/vad7/nrf24scan/master/scheme2.png">
+<br>
+Gerber for mini board with 5V - 3.3V converter LM1117-3.3 (https://raw.githubusercontent.com/vad7/nrf24scan/master/Gerber_PCB_Flipper%20Zero%20nRF24%20board%20mini_v1_0.zip)<br>
+Easyeda source (https://oshwlab.com/vad7/flipper-zero-nrf24-board_copy).
+<br>
+<br>
+_________________________________________________________________________________
+<br>
+<br>
+Settings file (default addr.txt) format:<br>
+
+Rate: 0/1/2 - rate in Mbps (=0.25/1/2)<br>
+Ch: 0..125 - default channel          <br>
+ESB: 0/1 (1 - Enhanced ShockBurst)    <br>
+DPL: 0/1 (1 - Dynamic Payload Length) <br>
+CRC: 0/1/2 (CRC length)<br>
+Payload: 1..32 (bytes)                <br>
+P0: address pipe #0 in hex (max 5 bytes, LSB last)<br>
+P1: address pipe #1 in hex (max 5 bytes, LSB last)<br>
+P2: address pipe #2, LSB in hex (1 byte)   <br>
+P3: address pipe #3, LSB in hex (1 byte)   <br>
+P4: address pipe #4, LSB in hex (1 byte)   <br>
+P5: address pipe #5, LSB in hex (1 byte)   <br>
+captured data in raw format, first byte = address # 0..5, Payload len if DPL<br>
+... up to MAX_LOG_RECORDS-1<br>
+<br>
+In the list of the received:<br>
+Press OK - send the packet,<br>
+Long press OK - view addresses.<br>
+<br>
+Decode the Packet Control Field and check CRC (long press OK in the list and then press '<' / '>').<br>
+ESB (Enhanced Shockburst) option must be turned off.
+Press '>' to decode CRC.<br>
+1 - pipe #<br>
+2 - Payload length (for valide packet must be 1..20 or 33 hex)<br>
+3 - PID (2 bit) + NO_ACK (1 bit)<br>
+<br>
+<br>
+<br>
+## PinOut from from NoComp/Frog
+<img src="https://media.discordapp.net/attachments/937479784726949900/994495234618687509/unknown.png?width=567&height=634">
+
+# NRF24 pinout by UberGuidoZ
+2/A7 on FZ goes to MOSI/6 on nrf24l01<br>
+3/A6 on FZ goes to MISO/7 on nrf24l01<br>
+4/A4 on FZ goes to CSN/4 on nrf24l01<br>
+5/B3 on FZ goes to SCK/5 on nrf24l01<br>
+6/B2 on FZ goes to CE/3 on nrf24l01<br>
+8/GND on FZ goes to GND/1 on nrf24l01<br>
+9/3V3 on FZ goes to VCC/2 on nrf24l01<br>
+IRQ/8 is left disconnected on nrf24l01
+![NRF_Pins](https://user-images.githubusercontent.com/57457139/178093717-39effd5c-ebe2-4253-b13c-70517d7902f9.png)
+If the nRF module is acting a bit flakey, try adding a capacitor to the vcc/gnd lines! I've not tried the Plus model so it may have a bigger need for a cap. Otherwise, I haven't had any major issues. Anything from a 3.3 uF to 10 uF should do. (Watch your positive/negative placement! Negative to ground.) I learned if you wanna get fancy, include a 0.1 uF cap in parallel. The 3.3 uF to 10 uF will respond to slow freq changes while the 0.1 uF will respond to the high freq switching spikes that the larger one cannot. That said, a single 10 uF will likely suffice for the Mousejack attack. ¯\\\_(ツ)_/¯
+![NRF_Capacitor](https://user-images.githubusercontent.com/57457139/178169959-d030f9a6-d2ac-46af-af8b-470ff092c8a7.jpg)
+

BIN
nrf24scan/Screenshot-1.png


BIN
nrf24scan/Screenshot-2.png


BIN
nrf24scan/Screenshot-3.png


BIN
nrf24scan/Screenshot-4.png


BIN
nrf24scan/Screenshot-5.png


BIN
nrf24scan/Screenshot-6.png


BIN
nrf24scan/Screenshot-7.png


+ 20 - 0
nrf24scan/application.fam

@@ -0,0 +1,20 @@
+App(
+    appid="nrf24_scanner",
+    name="[NRF24] Scanner",
+    apptype=FlipperAppType.EXTERNAL,
+    entry_point="nrf24scan_app",
+    cdefines=["APP_NRF24SCAN"],
+    requires=["gui"],
+    stack_size=2 * 1024,
+    order=60,
+    fap_icon="nrf24scan_10px.png",
+    fap_category="GPIO",
+    fap_private_libs=[
+        Lib(
+            name="nrf24",
+            sources=[
+                "nrf24.c",
+            ],
+        ),
+    ],
+)

+ 533 - 0
nrf24scan/lib/nrf24/nrf24.c

@@ -0,0 +1,533 @@
+// Modified by vad7, 25.11.2022
+//
+#include "nrf24.h"
+#include <furi.h>
+#include <furi_hal.h>
+#include <furi_hal_resources.h>
+#include <assert.h>
+#include <string.h>
+
+void nrf24_init() {
+    furi_hal_spi_bus_handle_init(nrf24_HANDLE);
+    furi_hal_spi_acquire(nrf24_HANDLE);
+    furi_hal_gpio_init(nrf24_CE_PIN, GpioModeOutputPushPull, GpioPullUp, GpioSpeedVeryHigh);
+    furi_hal_gpio_write(nrf24_CE_PIN, false);
+}
+
+void nrf24_deinit() {
+    furi_hal_spi_release(nrf24_HANDLE);
+    furi_hal_spi_bus_handle_deinit(nrf24_HANDLE);
+    furi_hal_gpio_write(nrf24_CE_PIN, false);
+    furi_hal_gpio_init(nrf24_CE_PIN, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
+}
+
+void nrf24_spi_trx(
+    FuriHalSpiBusHandle* handle,
+    uint8_t* tx,
+    uint8_t* rx,
+    uint8_t size,
+    uint32_t timeout) {
+    UNUSED(timeout);
+    furi_hal_gpio_write(handle->cs, false);
+    furi_hal_spi_bus_trx(handle, tx, rx, size, nrf24_TIMEOUT);
+    furi_hal_gpio_write(handle->cs, true);
+}
+
+uint8_t nrf24_write_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t data) {
+    uint8_t tx[2] = {W_REGISTER | (REGISTER_MASK & reg), data};
+    uint8_t rx[2] = {0};
+    nrf24_spi_trx(handle, tx, rx, 2, nrf24_TIMEOUT);
+    //FURI_LOG_D("NRF_WR", " #%02X=%02X", reg, data);
+    return rx[0];
+}
+
+uint8_t nrf24_write_buf_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t* data, uint8_t size) {
+    uint8_t tx[size + 1];
+    uint8_t rx[size + 1];
+    memset(rx, 0, size + 1);
+    tx[0] = W_REGISTER | (REGISTER_MASK & reg);
+    memcpy(&tx[1], data, size);
+    nrf24_spi_trx(handle, tx, rx, size + 1, nrf24_TIMEOUT);
+    //FURI_LOG_D("NRF_WR", " #%02X(%02X)=0x%02X%02X%02X%02X%02X", reg, size, data[0], data[1], data[2], data[3], data[4] );
+    return rx[0];
+}
+
+uint8_t nrf24_read_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t* data, uint8_t size) {
+    uint8_t tx[size + 1];
+    uint8_t rx[size + 1];
+    memset(rx, 0, size + 1);
+    tx[0] = R_REGISTER | (REGISTER_MASK & reg);
+    memset(&tx[1], 0, size);
+    nrf24_spi_trx(handle, tx, rx, size + 1, nrf24_TIMEOUT);
+    memcpy(data, &rx[1], size);
+    return rx[0];
+}
+
+uint8_t nrf24_flush_rx(FuriHalSpiBusHandle* handle) {
+    uint8_t tx[] = {FLUSH_RX};
+    uint8_t rx[] = {0};
+    nrf24_spi_trx(handle, tx, rx, 1, nrf24_TIMEOUT);
+    return rx[0];
+}
+
+uint8_t nrf24_flush_tx(FuriHalSpiBusHandle* handle) {
+    uint8_t tx[] = {FLUSH_TX};
+    uint8_t rx[] = {0};
+    nrf24_spi_trx(handle, tx, rx, 1, nrf24_TIMEOUT);
+    return rx[0];
+}
+
+uint8_t nrf24_get_maclen(FuriHalSpiBusHandle* handle) {
+    uint8_t maclen;
+    nrf24_read_reg(handle, REG_SETUP_AW, &maclen, 1);
+    maclen &= 3;
+    return maclen + 2;
+}
+
+uint8_t nrf24_set_maclen(FuriHalSpiBusHandle* handle, uint8_t maclen) {
+    assert(maclen > 1 && maclen < 6);
+    uint8_t status = 0;
+    status = nrf24_write_reg(handle, REG_SETUP_AW, maclen - 2);
+    return status;
+}
+
+uint8_t nrf24_status(FuriHalSpiBusHandle* handle) {
+    uint8_t status;
+    uint8_t tx[] = {R_REGISTER | (REGISTER_MASK & REG_STATUS)};
+    nrf24_spi_trx(handle, tx, &status, 1, nrf24_TIMEOUT);
+    return status;
+}
+
+uint32_t nrf24_get_rate(FuriHalSpiBusHandle* handle) {
+    uint8_t setup = 0;
+    uint32_t rate = 0;
+    nrf24_read_reg(handle, REG_RF_SETUP, &setup, 1);
+    setup &= 0x28;
+    if(setup == 0x20)
+        rate = 250000; // 250kbps
+    else if(setup == 0x08)
+        rate = 2000000; // 2Mbps
+    else if(setup == 0x00)
+        rate = 1000000; // 1Mbps
+
+    return rate;
+}
+
+uint8_t nrf24_set_rate(FuriHalSpiBusHandle* handle, uint32_t rate) {
+    uint8_t r6 = 0;
+    uint8_t status = 0;
+    if(!rate) rate = 2000000;
+
+    nrf24_read_reg(handle, REG_RF_SETUP, &r6, 1); // RF_SETUP register
+    r6 = r6 & (~0x28); // Clear rate fields.
+    if(rate == 2000000)
+        r6 = r6 | 0x08;
+    else if(rate == 1000000)
+        r6 = r6;
+    else if(rate == 250000)
+        r6 = r6 | 0x20;
+
+    status = nrf24_write_reg(handle, REG_RF_SETUP, r6); // Write new rate.
+    return status;
+}
+
+uint8_t nrf24_get_chan(FuriHalSpiBusHandle* handle) {
+    uint8_t channel = 0;
+    nrf24_read_reg(handle, REG_RF_CH, &channel, 1);
+    return channel;
+}
+
+uint8_t nrf24_set_chan(FuriHalSpiBusHandle* handle, uint8_t chan) {
+    uint8_t status;
+    status = nrf24_write_reg(handle, REG_RF_CH, chan);
+    return status;
+}
+
+uint8_t nrf24_get_src_mac(FuriHalSpiBusHandle* handle, uint8_t* mac) {
+    uint8_t size = 0;
+    uint8_t status = 0;
+    size = nrf24_get_maclen(handle);
+    status = nrf24_read_reg(handle, REG_RX_ADDR_P0, mac, size);
+    return status;
+}
+
+uint8_t nrf24_set_src_mac(FuriHalSpiBusHandle* handle, uint8_t* mac, uint8_t size) {
+    uint8_t status = 0;
+    uint8_t clearmac[] = {0, 0, 0, 0, 0};
+    nrf24_set_maclen(handle, size);
+    nrf24_write_buf_reg(handle, REG_RX_ADDR_P0, clearmac, 5);
+    status = nrf24_write_buf_reg(handle, REG_RX_ADDR_P0, mac, size);
+    return status;
+}
+
+uint8_t nrf24_get_dst_mac(FuriHalSpiBusHandle* handle, uint8_t* mac) {
+    uint8_t size = 0;
+    uint8_t status = 0;
+    size = nrf24_get_maclen(handle);
+    status = nrf24_read_reg(handle, REG_TX_ADDR, mac, size);
+    return status;
+}
+
+uint8_t nrf24_set_dst_mac(FuriHalSpiBusHandle* handle, uint8_t* mac, uint8_t size) {
+    uint8_t status = 0;
+    uint8_t clearmac[] = {0, 0, 0, 0, 0};
+    nrf24_set_maclen(handle, size);
+    nrf24_write_buf_reg(handle, REG_TX_ADDR, clearmac, 5);
+    status = nrf24_write_buf_reg(handle, REG_TX_ADDR, mac, size);
+    return status;
+}
+
+uint8_t nrf24_get_packetlen(FuriHalSpiBusHandle* handle, uint8_t pipe) {
+    uint8_t len = 0;
+    if(pipe > 5) pipe = 0;
+    nrf24_read_reg(handle, RX_PW_P0 + pipe, &len, 1);
+    return len;
+}
+
+uint8_t nrf24_set_packetlen(FuriHalSpiBusHandle* handle, uint8_t len) {
+    uint8_t status = 0;
+    status = nrf24_write_reg(handle, RX_PW_P0, len);
+    return status;
+}
+
+uint8_t nrf24_rxpacket(FuriHalSpiBusHandle* handle, uint8_t* packet, uint8_t* ret_packetsize, uint8_t packet_size) {
+    uint8_t status = 0;
+    uint8_t tx_cmd[33] = {0}; // 32 max payload size + 1 for command
+    uint8_t tmp_packet[33] = {0};
+
+    status = nrf24_status(handle);
+    if(!(status & RX_DR)) {
+        tx_cmd[0] = R_REGISTER | (REGISTER_MASK & REG_FIFO_STATUS);
+        nrf24_spi_trx(handle, tx_cmd, tmp_packet, 2, nrf24_TIMEOUT);
+        if((tmp_packet[1] & 1) == 0) status |= RX_DR; // packet in FIFO buffer
+    }
+    if(status & RX_DR) {
+        if(packet_size == 1)
+            packet_size = nrf24_get_packetlen(handle, (status >> 1) & 7);
+        else if(packet_size == 0){
+            tx_cmd[0] = R_RX_PL_WID; tx_cmd[1] = 0;
+            nrf24_spi_trx(handle, tx_cmd, tmp_packet, 2, nrf24_TIMEOUT);
+            packet_size = tmp_packet[1];
+        }
+        if(packet_size > 32 || packet_size == 0) packet_size = 32;
+        tx_cmd[0] = R_RX_PAYLOAD; tx_cmd[1] = 0;
+        nrf24_spi_trx(handle, tx_cmd, tmp_packet, packet_size + 1, nrf24_TIMEOUT);
+        memcpy(packet, &tmp_packet[1], packet_size);
+        nrf24_write_reg(handle, REG_STATUS, RX_DR); // clear RX_DR
+    } else if(status & (TX_DS | MAX_RT)) { // MAX_RT, TX_DS
+        nrf24_write_reg(handle, REG_STATUS, (TX_DS | MAX_RT)); // clear RX_DR, MAX_RT.
+    }
+
+    *ret_packetsize = packet_size;
+    return status;
+}
+
+// Return 0 when error
+uint8_t nrf24_txpacket(FuriHalSpiBusHandle* handle, uint8_t* payload, uint8_t size, bool ack) {
+    uint8_t status = 0;
+    uint8_t tx[size + 1];
+    uint8_t rx[size + 1];
+    memset(tx, 0, size + 1);
+    memset(rx, 0, size + 1);
+
+    if(!ack)
+        tx[0] = W_TX_PAYLOAD_NOACK;
+    else
+        tx[0] = W_TX_PAYLOAD;
+
+    memcpy(&tx[1], payload, size);
+    nrf24_spi_trx(handle, tx, rx, size + 1, nrf24_TIMEOUT);
+    nrf24_set_tx_mode(handle);
+
+    uint32_t start_time = furi_get_tick();
+    while(!(status & (TX_DS | MAX_RT)) && furi_get_tick() - start_time < 2000UL) status = nrf24_status(handle);
+
+    if(status & MAX_RT) nrf24_flush_tx(handle);
+
+    nrf24_set_idle(handle);
+    nrf24_write_reg(handle, REG_STATUS, TX_DS | MAX_RT);
+    return status & TX_DS;
+}
+
+uint8_t nrf24_power_up(FuriHalSpiBusHandle* handle) {
+    uint8_t status = 0;
+    uint8_t cfg = 0;
+    nrf24_read_reg(handle, REG_CONFIG, &cfg, 1);
+    cfg = cfg | 2;
+    status = nrf24_write_reg(handle, REG_CONFIG, cfg);
+    furi_delay_ms(1000);
+    return status;
+}
+
+uint8_t nrf24_set_idle(FuriHalSpiBusHandle* handle) {
+    uint8_t status = 0;
+    uint8_t cfg = 0;
+    nrf24_read_reg(handle, REG_CONFIG, &cfg, 1);
+    cfg &= 0xfc; // clear bottom two bits to power down the radio
+    status = nrf24_write_reg(handle, REG_CONFIG, cfg);
+    //nr204_write_reg(handle, REG_EN_RXADDR, 0x0);
+    furi_hal_gpio_write(nrf24_CE_PIN, false);
+    return status;
+}
+
+uint8_t nrf24_set_rx_mode(FuriHalSpiBusHandle* handle) {
+    uint8_t status = 0;
+    uint8_t cfg = 0;
+    //status = nrf24_write_reg(handle, REG_CONFIG, 0x0F); // enable 2-byte CRC, PWR_UP, and PRIM_RX
+    nrf24_read_reg(handle, REG_CONFIG, &cfg, 1);
+    cfg |= 0x03; // PWR_UP, and PRIM_RX
+    status = nrf24_write_reg(handle, REG_CONFIG, cfg);
+    //nr204_write_reg(REG_EN_RXADDR, 0x03) // Set RX Pipe 0 and 1
+    furi_hal_gpio_write(nrf24_CE_PIN, true);
+    furi_delay_ms(2);
+    return status;
+}
+
+uint8_t nrf24_set_tx_mode(FuriHalSpiBusHandle* handle) {
+    uint8_t status = 0;
+    uint8_t cfg = 0;
+    furi_hal_gpio_write(nrf24_CE_PIN, false);
+    nrf24_write_reg(handle, REG_STATUS, 0x30);
+    //status = nrf24_write_reg(handle, REG_CONFIG, 0x0E); // enable 2-byte CRC, PWR_UP
+    nrf24_read_reg(handle, REG_CONFIG, &cfg, 1);
+    cfg &= 0xfe; // disable PRIM_RX
+    cfg |= 0x02; // PWR_UP
+    status = nrf24_write_reg(handle, REG_CONFIG, cfg);
+    furi_hal_gpio_write(nrf24_CE_PIN, true);
+    furi_delay_ms(2);
+    return status;
+}
+
+void nrf24_configure(
+    FuriHalSpiBusHandle* handle,
+    uint8_t rate,
+    uint8_t* srcmac,
+    uint8_t* dstmac,
+    uint8_t maclen,
+    uint8_t channel,
+    bool noack,
+    bool disable_aa) {
+    assert(channel <= 125);
+    assert(rate == 1 || rate == 2);
+    if(rate == 2)
+        rate = 8; // 2Mbps
+    else
+        rate = 0; // 1Mbps
+
+    nrf24_write_reg(handle, REG_CONFIG, 0x00); // Stop nRF
+    nrf24_set_idle(handle);
+    nrf24_write_reg(handle, REG_STATUS, 0x70); // clear interrupts
+    if(disable_aa)
+        nrf24_write_reg(handle, REG_EN_AA, 0x00); // Disable Shockburst
+    else
+        nrf24_write_reg(handle, REG_EN_AA, 0x1F); // Enable Shockburst
+
+    nrf24_write_reg(handle, REG_DYNPD, 0x3F); // enable dynamic payload length on all pipes
+    if(noack)
+        nrf24_write_reg(handle, REG_FEATURE, 0x05); // disable payload-with-ack, enable noack
+    else {
+        nrf24_write_reg(handle, REG_CONFIG, 0x0C); // 2 byte CRC
+        nrf24_write_reg(handle, REG_FEATURE, 0x07); // enable dyn payload and ack
+        nrf24_write_reg(
+            handle, REG_SETUP_RETR, 0x1f); // 15 retries for AA, 500us auto retransmit delay
+    }
+
+    nrf24_set_idle(handle);
+    nrf24_flush_rx(handle);
+    nrf24_flush_tx(handle);
+
+    if(maclen) nrf24_set_maclen(handle, maclen);
+    if(srcmac) nrf24_set_src_mac(handle, srcmac, maclen);
+    if(dstmac) nrf24_set_dst_mac(handle, dstmac, maclen);
+
+    nrf24_write_reg(handle, REG_RF_CH, channel);
+    nrf24_write_reg(handle, REG_RF_SETUP, rate);
+    furi_delay_ms(200);
+}
+
+void nrf24_init_promisc_mode(FuriHalSpiBusHandle* handle, uint8_t channel, uint8_t rate) {
+    //uint8_t preamble[] = {0x55, 0x00}; // little endian
+    uint8_t preamble[] = {0xAA, 0x00}; // little endian
+    //uint8_t preamble[] = {0x00, 0x55}; // little endian
+    //uint8_t preamble[] = {0x00, 0xAA}; // little endian
+    nrf24_write_reg(handle, REG_CONFIG, 0x00); // Stop nRF
+    nrf24_write_reg(handle, REG_STATUS, 0x70); // clear interrupts
+    nrf24_write_reg(handle, REG_DYNPD, 0x0); // disable shockburst
+    nrf24_write_reg(handle, REG_EN_AA, 0x00); // Disable Shockburst
+    nrf24_write_reg(handle, REG_FEATURE, 0x05); // disable payload-with-ack, enable noack
+    nrf24_set_maclen(handle, 2); // shortest address
+    nrf24_set_src_mac(handle, preamble, 2); // set src mac to preamble bits to catch everything
+    nrf24_set_packetlen(handle, 32); // set max packet length
+    nrf24_set_idle(handle);
+    nrf24_flush_rx(handle);
+    nrf24_flush_tx(handle);
+    nrf24_write_reg(handle, REG_RF_CH, channel);
+    nrf24_write_reg(handle, REG_RF_SETUP, rate);
+
+    // prime for RX, no checksum
+    nrf24_write_reg(handle, REG_CONFIG, 0x03); // PWR_UP and PRIM_RX, disable AA and CRC
+    furi_hal_gpio_write(nrf24_CE_PIN, true);
+    furi_delay_ms(100);
+}
+
+void hexlify(uint8_t* in, uint8_t size, char* out) {
+    memset(out, 0, size * 2);
+    for(int i = 0; i < size; i++)
+        snprintf(out + strlen(out), sizeof(out + strlen(out)), "%02X", in[i]);
+}
+
+uint64_t bytes_to_int64(uint8_t* bytes, uint8_t size, bool bigendian) {
+    uint64_t ret = 0;
+    for(int i = 0; i < size; i++)
+        if(bigendian)
+            ret |= bytes[i] << ((size - 1 - i) * 8);
+        else
+            ret |= bytes[i] << (i * 8);
+
+    return ret;
+}
+
+void int64_to_bytes(uint64_t val, uint8_t* out, bool bigendian) {
+    for(int i = 0; i < 8; i++) {
+        if(bigendian)
+            out[i] = (val >> ((7 - i) * 8)) & 0xff;
+        else
+            out[i] = (val >> (i * 8)) & 0xff;
+    }
+}
+
+uint32_t bytes_to_int32(uint8_t* bytes, bool bigendian) {
+    uint32_t ret = 0;
+    for(int i = 0; i < 4; i++)
+        if(bigendian)
+            ret |= bytes[i] << ((3 - i) * 8);
+        else
+            ret |= bytes[i] << (i * 8);
+
+    return ret;
+}
+
+void int32_to_bytes(uint32_t val, uint8_t* out, bool bigendian) {
+    for(int i = 0; i < 4; i++) {
+        if(bigendian)
+            out[i] = (val >> ((3 - i) * 8)) & 0xff;
+        else
+            out[i] = (val >> (i * 8)) & 0xff;
+    }
+}
+
+uint64_t bytes_to_int16(uint8_t* bytes, bool bigendian) {
+    uint16_t ret = 0;
+    for(int i = 0; i < 2; i++)
+        if(bigendian)
+            ret |= bytes[i] << ((1 - i) * 8);
+        else
+            ret |= bytes[i] << (i * 8);
+
+    return ret;
+}
+
+void int16_to_bytes(uint16_t val, uint8_t* out, bool bigendian) {
+    for(int i = 0; i < 2; i++) {
+        if(bigendian)
+            out[i] = (val >> ((1 - i) * 8)) & 0xff;
+        else
+            out[i] = (val >> (i * 8)) & 0xff;
+    }
+}
+
+// handle iffyness with preamble processing sometimes being a bit (literally) off
+void alt_address_old(uint8_t* packet, uint8_t* altaddr) {
+    uint8_t macmess_hi_b[4];
+    uint8_t macmess_lo_b[2];
+    uint32_t macmess_hi;
+    uint16_t macmess_lo;
+    uint8_t preserved;
+
+    // get first 6 bytes into 32-bit and 16-bit variables
+    memcpy(macmess_hi_b, packet, 4);
+    memcpy(macmess_lo_b, packet + 4, 2);
+
+    macmess_hi = bytes_to_int32(macmess_hi_b, true);
+
+    //preserve least 7 bits from hi that will be shifted down to lo
+    preserved = macmess_hi & 0x7f;
+    macmess_hi >>= 7;
+
+    macmess_lo = bytes_to_int16(macmess_lo_b, true);
+    macmess_lo >>= 7;
+    macmess_lo = (preserved << 9) | macmess_lo;
+    int32_to_bytes(macmess_hi, macmess_hi_b, true);
+    int16_to_bytes(macmess_lo, macmess_lo_b, true);
+    memcpy(altaddr, &macmess_hi_b[1], 3);
+    memcpy(altaddr + 3, macmess_lo_b, 2);
+}
+
+bool validate_address(uint8_t* addr) {
+    uint8_t bad[][3] = {{0x55, 0x55}, {0xAA, 0xAA}, {0x00, 0x00}, {0xFF, 0xFF}};
+    for(int i = 0; i < 4; i++)
+        for(int j = 0; j < 2; j++)
+            if(!memcmp(addr + j * 2, bad[i], 2)) return false;
+
+    return true;
+}
+
+bool nrf24_sniff_address(FuriHalSpiBusHandle* handle, uint8_t maclen, uint8_t* address) {
+    bool found = false;
+    uint8_t packet[32] = {0};
+    uint8_t packetsize;
+    //char printit[65];
+    uint8_t status = 0;
+    status = nrf24_rxpacket(handle, packet, &packetsize, true);
+    if(status & 0x40) {
+        if(validate_address(packet)) {
+            for(int i = 0; i < maclen; i++) address[i] = packet[maclen - 1 - i];
+
+            /*
+            alt_address(packet, packet);
+
+            for(i = 0; i < maclen; i++)
+                address[i + 5] = packet[maclen - 1 - i];
+            */
+
+            //memcpy(address, packet, maclen);
+            //hexlify(packet, packetsize, printit);
+            found = true;
+        }
+    }
+
+    return found;
+}
+
+uint8_t nrf24_find_channel(
+    FuriHalSpiBusHandle* handle,
+    uint8_t* srcmac,
+    uint8_t* dstmac,
+    uint8_t maclen,
+    uint8_t rate,
+    uint8_t min_channel,
+    uint8_t max_channel,
+    bool autoinit) {
+    uint8_t ping_packet[] = {0x0f, 0x0f, 0x0f, 0x0f}; // this can be anything, we just need an ack
+    uint8_t ch = max_channel + 1; // means fail
+    nrf24_configure(handle, rate, srcmac, dstmac, maclen, 2, false, false);
+    for(ch = min_channel; ch <= max_channel + 1; ch++) {
+        nrf24_write_reg(handle, REG_RF_CH, ch);
+        if(nrf24_txpacket(handle, ping_packet, 4, true)) break;
+    }
+
+    if(autoinit) {
+        FURI_LOG_D("nrf24", "initializing radio for channel %d", ch);
+        nrf24_configure(handle, rate, srcmac, dstmac, maclen, ch, false, false);
+        return ch;
+    }
+
+    return ch;
+}
+
+uint8_t nrf24_set_mac(uint8_t mac_addr, uint8_t *mac, uint8_t mlen)
+{
+    uint8_t addr[5];
+	for(int i = 0; i < mlen; i++) addr[i] = mac[mlen - i - 1];
+	return nrf24_write_buf_reg(nrf24_HANDLE, mac_addr, addr, mlen);
+}

+ 381 - 0
nrf24scan/lib/nrf24/nrf24.h

@@ -0,0 +1,381 @@
+#pragma once
+#include <stdbool.h>
+#include <stdint.h>
+#include <furi_hal_spi.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define R_REGISTER 0x00
+#define W_REGISTER 0x20
+#define REGISTER_MASK 0x1F
+#define ACTIVATE 0x50
+#define R_RX_PL_WID 0x60
+#define R_RX_PAYLOAD 0x61
+#define W_TX_PAYLOAD 0xA0
+#define W_TX_PAYLOAD_NOACK 0xB0
+#define W_ACK_PAYLOAD 0xA8
+#define FLUSH_TX 0xE1
+#define FLUSH_RX 0xE2
+#define REUSE_TX_PL 0xE3
+#define RF24_NOP 0xFF
+
+#define REG_CONFIG 0x00
+#define REG_EN_AA 0x01
+#define REG_EN_RXADDR 0x02
+#define REG_SETUP_AW 0x03
+#define REG_SETUP_RETR 0x04
+#define REG_DYNPD 0x1C
+#define REG_FEATURE 0x1D
+#define REG_RF_SETUP 0x06
+#define REG_STATUS 0x07
+#define REG_RX_ADDR_P0 0x0A
+#define REG_RX_ADDR_P1 0x0B
+#define REG_RX_ADDR_P2 0x0C
+#define REG_RX_ADDR_P3 0x0D
+#define REG_RX_ADDR_P4 0x0E
+#define REG_RX_ADDR_P5 0x0F
+#define REG_RF_CH 0x05
+#define REG_TX_ADDR 0x10
+#define REG_FIFO_STATUS 0x17
+
+#define RX_PW_P0 0x11
+#define RX_PW_P1 0x12
+#define RX_PW_P2 0x13
+#define RX_PW_P3 0x14
+#define RX_PW_P4 0x15
+#define RX_PW_P5 0x16
+#define RX_DR    0x40
+#define TX_DS    0x20
+#define MAX_RT   0x10
+
+#define nrf24_TIMEOUT 500
+#define nrf24_CE_PIN &gpio_ext_pb2
+#define nrf24_HANDLE &furi_hal_spi_bus_handle_external
+
+/* Low level API */
+
+/** Write device register
+ *
+ * @param      handle  - pointer to FuriHalSpiHandle
+ * @param      reg     - register
+ * @param      data    - data to write
+ *
+ * @return     device status
+ */
+uint8_t nrf24_write_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t data);
+
+/** Write buffer to device register
+ *
+ * @param      handle  - pointer to FuriHalSpiHandle
+ * @param      reg     - register
+ * @param      data    - data to write
+ * @param      size    - size of data to write
+ *
+ * @return     device status
+ */
+uint8_t nrf24_write_buf_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t* data, uint8_t size);
+
+/** Read device register
+ *
+ * @param      handle  - pointer to FuriHalSpiHandle
+ * @param      reg     - register
+ * @param[out] data    - pointer to data
+ *
+ * @return     device status
+ */
+uint8_t nrf24_read_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t* data, uint8_t size);
+
+/** Power up the radio for operation
+ * 
+ * @param      handle  - pointer to FuriHalSpiHandle
+ * 
+ * @return     device status
+ */
+uint8_t nrf24_power_up(FuriHalSpiBusHandle* handle);
+
+/** Power down the radio
+ * 
+ * @param      handle  - pointer to FuriHalSpiHandle
+ * 
+ * @return     device status
+ */
+uint8_t nrf24_set_idle(FuriHalSpiBusHandle* handle);
+
+/** Sets the radio to RX mode
+ *
+ * @param      handle  - pointer to FuriHalSpiHandle
+ * 
+ * @return     device status
+ */
+uint8_t nrf24_set_rx_mode(FuriHalSpiBusHandle* handle);
+
+/** Sets the radio to TX mode
+ *
+ * @param      handle  - pointer to FuriHalSpiHandle
+ * 
+ * @return     device status
+ */
+uint8_t nrf24_set_tx_mode(FuriHalSpiBusHandle* handle);
+
+/*=============================================================================================================*/
+
+/* High level API */
+
+/** Must call this before using any other nrf24 API
+ * 
+ */
+void nrf24_init();
+
+/** Must call this when we end using nrf24 device
+ * 
+ */
+void nrf24_deinit();
+
+/** Send flush rx command
+ *
+ * @param      handle  - pointer to FuriHalSpiHandle
+ *
+ * @return     device status
+ */
+uint8_t nrf24_flush_rx(FuriHalSpiBusHandle* handle);
+
+/** Send flush tx command
+ *
+ * @param      handle  - pointer to FuriHalSpiHandle
+ *
+ * @return     device status
+ */
+uint8_t nrf24_flush_tx(FuriHalSpiBusHandle* handle);
+
+/** Gets the RX packet length in data pipe 0
+ * 
+ * @param      handle  - pointer to FuriHalSpiHandle
+ *             pipe - pipe index (0..5)
+ * @return     packet length in data pipe 0
+ */
+uint8_t nrf24_get_packetlen(FuriHalSpiBusHandle* handle, uint8_t pipe);
+
+/** Sets the RX packet length in data pipe 0
+ * 
+ * @param      handle  - pointer to FuriHalSpiHandle
+ * @param      len - length to set
+ * 
+ * @return     device status
+ */
+uint8_t nrf24_set_packetlen(FuriHalSpiBusHandle* handle, uint8_t len);
+
+/** Gets configured length of MAC address
+ *
+ * @param      handle  - pointer to FuriHalSpiHandle
+ * 
+ * @return     MAC address length
+ */
+uint8_t nrf24_get_maclen(FuriHalSpiBusHandle* handle);
+
+/** Sets configured length of MAC address
+ *
+ * @param      handle  - pointer to FuriHalSpiHandle
+ * @param      maclen - length to set MAC address to, must be greater than 1 and less than 6
+ * 
+ * @return     MAC address length
+ */
+uint8_t nrf24_set_maclen(FuriHalSpiBusHandle* handle, uint8_t maclen);
+
+/** Gets the current status flags from the STATUS register
+ * 
+ * @param      handle  - pointer to FuriHalSpiHandle
+ * 
+ * @return     status flags
+ */
+uint8_t nrf24_status(FuriHalSpiBusHandle* handle);
+
+/** Gets the current transfer rate
+ * 
+ * @param      handle  - pointer to FuriHalSpiHandle
+ * 
+ * @return     transfer rate in bps
+ */
+uint32_t nrf24_get_rate(FuriHalSpiBusHandle* handle);
+
+/** Sets the transfer rate
+ *
+ * @param      handle  - pointer to FuriHalSpiHandle
+ * @param      rate - the transfer rate in bps
+ * 
+ * @return     device status
+ */
+uint8_t nrf24_set_rate(FuriHalSpiBusHandle* handle, uint32_t rate);
+
+/** Gets the current channel
+ * In nrf24, the channel number is multiplied times 1MHz and added to 2400MHz to get the frequency
+ * 
+ * @param      handle  - pointer to FuriHalSpiHandle
+ * 
+ * @return     channel
+ */
+uint8_t nrf24_get_chan(FuriHalSpiBusHandle* handle);
+
+/** Sets the channel
+ *
+ * @param      handle  - pointer to FuriHalSpiHandle
+ * @param      frequency - the frequency in hertz
+ * 
+ * @return     device status
+ */
+uint8_t nrf24_set_chan(FuriHalSpiBusHandle* handle, uint8_t chan);
+
+/** Gets the source mac address
+ *
+ * @param      handle  - pointer to FuriHalSpiHandle
+ * @param[out] mac - the source mac address
+ * 
+ * @return     device status
+ */
+uint8_t nrf24_get_src_mac(FuriHalSpiBusHandle* handle, uint8_t* mac);
+
+/** Sets the source mac address
+ *
+ * @param      handle  - pointer to FuriHalSpiHandle
+ * @param      mac - the mac address to set
+ * @param      size - the size of the mac address (2 to 5)
+ * 
+ * @return     device status
+ */
+uint8_t nrf24_set_src_mac(FuriHalSpiBusHandle* handle, uint8_t* mac, uint8_t size);
+
+/** Gets the dest mac address
+ *
+ * @param      handle  - pointer to FuriHalSpiHandle
+ * @param[out] mac - the source mac address
+ * 
+ * @return     device status
+ */
+uint8_t nrf24_get_dst_mac(FuriHalSpiBusHandle* handle, uint8_t* mac);
+
+/** Sets the dest mac address
+ *
+ * @param      handle  - pointer to FuriHalSpiHandle
+ * @param      mac - the mac address to set
+ * @param      size - the size of the mac address (2 to 5)
+ * 
+ * @return     device status
+ */
+uint8_t nrf24_set_dst_mac(FuriHalSpiBusHandle* handle, uint8_t* mac, uint8_t size);
+
+/** Reads RX packet
+ *
+ * @param      handle  - pointer to FuriHalSpiHandle
+ * @param[out] packet - the packet contents
+ * @param[out] ret_packetsize - size of the received packet
+ * @param      packet_size: >1 - size, 1 - packet length is determined by RX_PW_P0 register, 0 - it is determined by dynamic payload length command
+ * 
+ * @return     device status
+ */
+uint8_t
+    nrf24_rxpacket(FuriHalSpiBusHandle* handle, uint8_t* packet, uint8_t* ret_packetsize, uint8_t packet_size_flag);
+
+/** Sends TX packet
+ *
+ * @param      handle  - pointer to FuriHalSpiHandle
+ * @param      packet - the packet contents
+ * @param      size - packet size
+ * @param      ack - boolean to determine whether an ACK is required for the packet or not
+ * 
+ * @return     device status
+ */
+uint8_t nrf24_txpacket(FuriHalSpiBusHandle* handle, uint8_t* payload, uint8_t size, bool ack);
+
+/** Configure the radio
+ * This is not comprehensive, but covers a lot of the common configuration options that may be changed
+ * @param      handle  - pointer to FuriHalSpiHandle
+ * @param      rate - transfer rate in Mbps (1 or 2)
+ * @param      srcmac - source mac address
+ * @param      dstmac - destination mac address
+ * @param      maclen - length of mac address
+ * @param      channel - channel to tune to
+ * @param      noack - if true, disable auto-acknowledge
+ * @param      disable_aa - if true, disable ShockBurst
+ * 
+ */
+void nrf24_configure(
+    FuriHalSpiBusHandle* handle,
+    uint8_t rate,
+    uint8_t* srcmac,
+    uint8_t* dstmac,
+    uint8_t maclen,
+    uint8_t channel,
+    bool noack,
+    bool disable_aa);
+
+// Set mac address (MSB first), Return: Status
+uint8_t  nrf24_set_mac(uint8_t mac_addr, uint8_t *mac, uint8_t mlen);
+
+/** Configures the radio for "promiscuous mode" and primes it for rx
+ * This is not an actual mode of the nrf24, but this function exploits a few bugs in the chip that allows it to act as if it were.
+ * See http://travisgoodspeed.blogspot.com/2011/02/promiscuity-is-nrf24l01s-duty.html for details.
+ * @param      handle  - pointer to FuriHalSpiHandle
+ * @param      channel - channel to tune to
+ * @param      rate - transfer rate in Mbps (1 or 2) 
+ */
+void nrf24_init_promisc_mode(FuriHalSpiBusHandle* handle, uint8_t channel, uint8_t rate);
+
+/** Listens for a packet and returns first possible address sniffed
+ * Call this only after calling nrf24_init_promisc_mode
+ * @param      handle  - pointer to FuriHalSpiHandle
+ * @param      maclen - length of target mac address
+ * @param[out] addresses - sniffed address
+ * 
+ * @return     success
+ */
+bool nrf24_sniff_address(FuriHalSpiBusHandle* handle, uint8_t maclen, uint8_t* address);
+
+/** Sends ping packet on each channel for designated tx mac looking for ack
+ * 
+ * @param      handle  - pointer to FuriHalSpiHandle
+ * @param      srcmac - source address
+ * @param      dstmac - destination address
+ * @param      maclen - length of address
+ * @param      rate - transfer rate in Mbps (1 or 2) 
+ * @param      min_channel - channel to start with
+ * @param      max_channel - channel to end at
+ * @param      autoinit - if true, automatically configure radio for this channel
+ * 
+ * @return     channel that the address is listening on, if this value is above the max_channel param, it failed
+ */
+uint8_t nrf24_find_channel(
+    FuriHalSpiBusHandle* handle,
+    uint8_t* srcmac,
+    uint8_t* dstmac,
+    uint8_t maclen,
+    uint8_t rate,
+    uint8_t min_channel,
+    uint8_t max_channel,
+    bool autoinit);
+
+/** Converts 64 bit value into uint8_t array
+ * @param      val  - 64-bit integer
+ * @param[out] out - bytes out
+ * @param      bigendian - if true, convert as big endian, otherwise little endian
+ */
+void int64_to_bytes(uint64_t val, uint8_t* out, bool bigendian);
+
+/** Converts 32 bit value into uint8_t array
+ * @param      val  - 32-bit integer
+ * @param[out] out - bytes out
+ * @param      bigendian - if true, convert as big endian, otherwise little endian
+ */
+void int32_to_bytes(uint32_t val, uint8_t* out, bool bigendian);
+
+/** Converts uint8_t array into 32 bit value
+ * @param      bytes  - uint8_t array
+ * @param      bigendian - if true, convert as big endian, otherwise little endian
+ * 
+ * @return     32-bit value
+ */
+uint32_t bytes_to_int32(uint8_t* bytes, bool bigendian);
+
+#ifdef __cplusplus
+}
+#endif

+ 131 - 0
nrf24scan/nrf24_packet_decoder.py

@@ -0,0 +1,131 @@
+#
+# NRF24L01+ Enhanced ShockBurst packets decoder
+#
+payload_len_default = 4
+packets = \
+(
+  '10101010 11101110 00000011 00001000 00001011 01000111 000100 10 0 10101010 10101010 10101010 10101010 00011101',
+  '10101010 11001000 11001000 11000011 110011 10 0 00001011 00000011 00000101 00000000 0010001100100000',
+  '10101010 11001000 11001000 11000100 000100 11 1 00001011 00000011 00000101 00000000 0010010011100010',
+  '10101010 11001000 11001000 11000100  00001011 00000011 00000101 00000010 1000010101000010',
+  '10101010 11001000 11001000 11000000 110011 10 0 11110101 00000010 00000011 00000000 0000111001000000',
+  '01010101 01000000 01101000 00010101 000000 00 0 0100100000100000',
+#  '01010101 01000010 11100100 10100110 01010101 01000100 110011 00 0 10010101 10110011 01100100 10101100 10101011 01010010 01111100 01001010 1100110100110001',
+
+)
+
+def bin2hex(x):
+    def bin2hex_helper(r):
+        while r:
+            yield r[0:2].upper()
+            r = r[2:]
+    if len(x) == 0: return
+    fmt = "{0:0" + str(int(len(x) / 8 * 2)) + "X}"
+    hex_data = fmt.format(int(x, 2))
+    return list(bin2hex_helper(hex_data))
+
+def bin2hexlong(b):
+    b = b.replace(" ", "")
+    out = "";
+    n = 8
+    for i in range(0, len(b), n): 
+        b2 = b[i:i+n]
+        out = out + "{0:02X}".format(int(b2.ljust(8, '0'),2))
+    return out
+
+
+def split_packet(packet, parts):
+    """Split a string of 1s and 0s into multiple substrings as specified by parts.
+    Example: "111000011000", (3, 4, 2) -> ["111", "0000", "11", "000"]
+    :param packet: String of 1s and 0s
+    :param parts: Tuple of length of substrings
+    :return: list of substrings
+    """
+    out = []
+    packet = packet.replace(' ', '')
+    for part_length in parts:
+        out.append(packet[0:part_length])
+        packet = packet[part_length:]
+    out.append(packet)
+    return out
+
+
+def parse_packet(packet, address_length, ESB):
+    """Split a packet into its fields and return them as tuple."""
+    if ESB:
+         preamble, address, payload_length, pid, no_ack, rest = split_packet(packet=packet, parts=(8, 8 * address_length, 6, 2, 1))
+         payload, crc = split_packet(packet=rest, parts=((payload_len_default if int(payload_length, 2) > 32 else int(payload_length, 2)) * 8,))
+    else:
+         preamble, address, rest = split_packet(packet=packet, parts=(8, 8 * address_length))
+         crc = packet.rsplit(' ', 1)[1]
+         payload = rest[0:len(rest) - len(crc)]
+         payload_length = pid = no_ack = ''
+
+    assert preamble in ('10101010', '01010101')
+    assert len(crc) in (8, 16)
+
+    return preamble, address, payload_length, pid, no_ack, payload, crc
+
+
+def crc(bits, size=8):
+    """Calculate the crc value for the polynomial initialized with 0xFF/0xFFFF)
+    :param size: 8 or 16 bit crc
+    :param bits: String of 1s and 0s
+    :return:
+    :polynomial: 1 byte CRC - standard is 0x107 = 0b100000111 = x^8+x^2+x^1+1, result the same for 0x07
+    :polynomial: 2 byte CRC - standard is 0x11021 = X^16+X^12+X^5+1, result the same for 0x1021
+    """
+    if size == 8:
+      polynomial = 0x107
+      crc = 0xFF
+    else:
+      polynomial = 0x11021
+      crc = 0xFFFF
+    max_crc_value = (1 << size) - 1  # e.g. 0xFF for mode 8bit-crc
+    for bit in bits:
+        bit = int(bit, 2)
+        crc <<= 1
+        if (crc >> size) ^ bit:  # top most lfsr bit xor current data bit
+            crc ^= polynomial
+        crc &= max_crc_value  # trim the crc to reject carry over bits
+#        print('{:X}'.format(crc))
+    return crc
+
+
+if __name__ == '__main__':
+    for packet in packets:
+        fld = packet.split(' ');
+        address_length = -1
+        ESB = True
+        for f in fld:
+            if len(f) == 6 : break
+            if len(f) == 0 :
+                ESB = False 
+                break
+            address_length += 1
+        preamble, address, payload_length, pid, no_ack, payload, crc_received = \
+            parse_packet(packet=packet, address_length=address_length, ESB=ESB)
+        crc_size = len(crc_received)
+        crc_received = '0x' + '{:X}'.format(int(crc_received, 2))
+        print(f"Packet: {packet}")
+        print('\n'.join((
+			f'Hex: {bin2hexlong(packet)}',
+            'Preamble: 0x%X' % int(preamble,2),
+            f'Address: {address_length} bytes - {bin2hex(address)}')))
+        if ESB:
+             print('\n'.join((
+                 f'Payload length in packet: {int(payload_length, 2)}, used: {(payload_len_default if int(payload_length, 2) > 32 else int(payload_length, 2))}',
+                 f'Payload: {bin2hex(payload)}',
+                 f'Pid: {int(pid, 2)}',
+                 f'No_ack: {int(no_ack, 2) == 1}')))
+        else:
+             print(f'Not Enhanced ShockBurst packet, payload length: {int(len(payload) / 8)}')
+             print(f'Payload: {bin2hex(payload)}')
+        print(f'CRC{crc_size}: {crc_received}')
+        crc_calculated = '0x' + '{:X}'.format(crc(address + payload_length + pid + no_ack + payload, size=crc_size))
+        if crc_received == crc_calculated:
+            print('CRC is valid!')
+        else:
+            print(f'CRC mismatch! Calculated CRC is {crc_calculated}.')
+        print('-------------')
+

+ 1661 - 0
nrf24scan/nrf24scan.c

@@ -0,0 +1,1661 @@
+//
+// Written by vad7, 20.11.2022.
+//
+#include "nrf24scan.h"
+
+#include <furi.h>
+#include <furi_hal.h>
+#include <gui/gui.h>
+#include <dialogs/dialogs.h>
+#include <input/input.h>
+#include <stdlib.h>
+#include <dolphin/dolphin.h>
+#include <nrf24.h>
+#include <u8g2.h>
+
+#define TAG "nrf24scan"
+#define VERSION "2.2"
+#define MAX_CHANNEL 125
+#define MAX_ADDR 6
+
+#define SCAN_APP_PATH_FOLDER "/ext/nrf24scan"
+#define SETTINGS_FILENAME "addresses.txt" // Settings file format (1 parameter per line):
+// SNIFF - if present then sniff mode
+// Rate: 0/1/2 - rate in Mbps (=0.25/1/2)
+// Ch: 0..125 - default channel
+// ESB: 0/1 (1 - Enhanced ShockBurst)
+// DPL: 0/1 (1 - Dynamic Payload Length)
+// CRC: 0/1/2 (CRC length)
+// Payload: 1..32 (bytes)
+// P0: address P0 in hex (5 byte, LSB last)
+// P1: address P1 in hex (5 byte, LSB last)
+// P2: address P2, LSB in hex (1 byte)
+// P3: address P3, LSB in hex (1 byte)
+// P4: address P4, LSB in hex (1 byte)
+// P5: address P5, LSB in hex (1 byte)
+// captured data:
+//		first byte = { RAW packet flag (0x80/0x00) } + { channel number }
+//		second byte = { Payload len 5 bits, 0 = 32 } + {{ RAW packet: ESB flag 0x04/0x00 + address size-2 if RAW packet } or { pipe #(0..5) }},
+// ... up to MAX_LOG_RECORDS-1
+#define SNIFF_FILENAME "sniff.txt" // settings for sniff mode
+#define LOG_FILENAME "log"
+#define LOG_FILEEXT ".txt"
+#define MAX_LOG_RECORDS 200
+#define MAX_FOUND_RECORDS 70
+#define LOG_REC_SIZE 34 // max packet size
+#define VIEW_LOG_MAX_X 22
+#define VIEW_LOG_WIDTH_B 10 // bytes
+
+const char SettingsFld_Rate[] = "Rate:";
+const char SettingsFld_Ch[] = "Ch:";
+const char SettingsFld_ESB[] = "ESB:";
+const char SettingsFld_DPL[] = "DPL:";
+const char SettingsFld_CRC[] = "CRC:";
+const char SettingsFld_Payload[] = "Payload:";
+const char SettingsFld_Sniff[] = "SNIFF";
+char SettingsFld_Addr = 'P';
+
+Nrf24Scan* APP;
+uint8_t what_doing = 0; // 0 - setup, 1 - view log, 2 - view addresses
+uint8_t what_to_do =
+    1; // 0 - view, 1 - view & sniff, 2 - view & read, 3 - view & read selected addr
+uint8_t save_settings = 0;
+char screen_buf[64];
+char addr_file_name[32];
+uint8_t NRF_rate = 2; // 0 - 250Kbps, 1 - 1Mbps, 2 - 2Mbps
+uint8_t NRF_channel = 0; // 0..125
+uint8_t NRF_ESB = 1; // 0 - ShockBurst, 1 - Enhanced ShockBurst
+uint8_t NRF_DPL = 0; // 1 - Dynamic Payload Length
+uint8_t NRF_CRC = 2; // 1 - No, 1 - CRC 1byte, 2 - CRC 2byte
+uint8_t NRF_Payload = 32; // Payload len in bytes or Minimum payload in sniff mode, 0..32
+uint8_t NRF_Payload_sniff_min = 0;
+uint8_t NRF_AA_OFF = 0; // Disable Auto Acknowledgement
+bool NRF_ERROR = 0;
+bool NRF_BOARD_POWER_5V = false;
+
+struct ADDRS {
+    uint8_t addr_P0[5]; // MSB first
+    uint8_t addr_P1[5]; // MSB first
+    uint8_t addr_P2; // LSB only, MSB bytes equal addr_P1
+    uint8_t addr_P3; // LSB only, MSB bytes equal addr_P1
+    uint8_t addr_P4; // LSB only, MSB bytes equal addr_P1
+    uint8_t addr_P5; // LSB only, MSB bytes equal addr_P1
+    uint8_t addr_len; // 2..5
+    uint8_t addr_count;
+};
+
+struct ADDRS addrs;
+struct ADDRS addrs_sniff;
+bool sniff_loaded = 0;
+int16_t found_total;
+int16_t view_found;
+
+int8_t log_to_file = 0; // 0 - no, 1 - yes(new), 2 - append, -1 - only clear
+uint16_t log_arr_idx;
+uint16_t view_log_arr_idx = 0;
+uint16_t view_log_arr_x = 0;
+bool save_to_new_log = true;
+uint16_t last_packet_send = -1;
+uint8_t last_packet_send_st = 0;
+int16_t find_channel_period = 0; // sec
+uint8_t menu_selected = 0;
+uint32_t start_time;
+uint8_t view_log_decode_PCF =
+    0; // view log: 1 - decode packet control field (9b) when ESB off. After pipe # (hex): <Payload len 6b><PID_2b+NO_ACK_1b>
+uint8_t view_log_decode_CRC = 0; // CRC bytes - 1/2, 0 - none
+
+#define menu_selected_max 5
+enum {
+    Menu_open_file = 0,
+    Menu_enter_channel,
+    Menu_enter_rate,
+    Menu_enter_scan_period,
+    Menu_log,
+    Menu_ok
+};
+
+//#define MIN(a, b)  ((a<b)?a:b)
+
+static uint8_t GetHexVal(char hex) {
+    return (uint8_t)hex - ((uint8_t)hex < 58 ? 48 : ((uint8_t)hex < 97 ? 55 : 87));
+}
+
+// Return num bytes in array
+static uint8_t ConvertHexToArray(char* hex, uint8_t* array, uint8_t maxlen) {
+    uint8_t len = 0;
+    while(maxlen) {
+        uint8_t ch = *hex++;
+        if(ch == 0) break;
+        if(ch < '0') continue;
+        *array++ = (GetHexVal(ch) << 4) + GetHexVal(*hex++);
+        len++;
+        maxlen--;
+    }
+    return len;
+}
+
+static void add_to_str_hex_bytes(char* out, char* arr, int bytes) {
+    if(bytes <= 0) return;
+    out += strlen(out);
+    do {
+        snprintf(out, 3, "%02X", *arr++);
+        out += 2;
+    } while(--bytes);
+}
+
+static void add_to_furi_str_hex_bytes(FuriString* str, char* arr, int bytes) {
+    if(!bytes) return;
+    do {
+        furi_string_cat_printf(str, "%02X", *arr++);
+    } while(--bytes);
+}
+
+static void add_to_str_hex_bytes_shift_9b(char* out, char* arr, int bytes) {
+    if(bytes <= 0) return;
+    out += strlen(out);
+    arr++; // +8b
+    do {
+        snprintf(out, 4, "%02X", ((uint8_t)(*arr << 1)) | (*(arr + 1) >> 7));
+        arr++;
+        out += 2;
+    } while(--bytes);
+}
+
+void clear_log() {
+    log_arr_idx = 0;
+    view_log_arr_idx = 0;
+    last_packet_send = -1;
+    found_total = 0;
+    view_found = -1;
+}
+
+void write_to_log_file(Storage* storage, bool f_settings) {
+    if(log_arr_idx == 0 && !f_settings) return;
+    Stream* file_stream = file_stream_alloc(storage);
+    FuriString* str = furi_string_alloc();
+    furi_string_set(str, SCAN_APP_PATH_FOLDER);
+    furi_string_cat(str, "/");
+    bool fl;
+    if(f_settings) {
+        furi_string_cat(str, SETTINGS_FILENAME);
+        fl = file_stream_open(
+            file_stream, furi_string_get_cstr(str), FSAM_READ_WRITE, FSOM_CREATE_ALWAYS);
+        if(!fl) file_stream_close(file_stream);
+    } else {
+        furi_string_cat(str, LOG_FILENAME);
+        furi_string_cat(str, LOG_FILEEXT);
+        if(save_to_new_log) {
+            int cnt = 1;
+            do {
+                fl = file_stream_open(
+                    file_stream, furi_string_get_cstr(str), FSAM_READ_WRITE, FSOM_CREATE_NEW);
+                if(fl) break;
+                file_stream_close(file_stream);
+                furi_string_set(str, SCAN_APP_PATH_FOLDER);
+                furi_string_cat(str, "/");
+                furi_string_cat(str, LOG_FILENAME);
+                furi_string_cat_printf(str, "-%02d", cnt);
+                furi_string_cat(str, LOG_FILEEXT);
+            } while(++cnt < 100);
+            if(!fl) {
+                FURI_LOG_E(TAG, "Failed to create new log file");
+                notification_message(APP->notification, &sequence_blink_red_100);
+            }
+        } else {
+            fl = file_stream_open(
+                file_stream, furi_string_get_cstr(str), FSAM_READ_WRITE, FSOM_OPEN_APPEND);
+            if(fl) {
+                if(stream_size(file_stream) == 0) save_to_new_log = true;
+            } else
+                file_stream_close(file_stream);
+        }
+    }
+    if(fl) {
+        FURI_LOG_D(TAG, "Save to %s", furi_string_get_cstr(str));
+        if(save_to_new_log || f_settings) {
+            if(what_to_do == 1)
+                furi_string_printf(str, "%s\n", SettingsFld_Sniff);
+            else
+                furi_string_reset(str);
+            furi_string_cat_printf(
+                str,
+                "%s %d\n%s %d\n%s %d\n",
+                SettingsFld_Rate,
+                NRF_rate,
+                SettingsFld_Ch,
+                NRF_channel,
+                SettingsFld_ESB,
+                NRF_ESB);
+            furi_string_cat_printf(
+                str,
+                "%s %d\n%s %d\n%s %d\n",
+                SettingsFld_DPL,
+                NRF_DPL,
+                SettingsFld_CRC,
+                NRF_CRC,
+                SettingsFld_Payload,
+                what_to_do == 1 ? NRF_Payload_sniff_min : NRF_Payload);
+            if(addrs.addr_count > 0) {
+                furi_string_cat_printf(str, "P0: ");
+                add_to_furi_str_hex_bytes(str, (char*)addrs.addr_P0, addrs.addr_len);
+                furi_string_cat(str, "\n");
+            }
+            if(addrs.addr_count > 1) {
+                furi_string_cat_printf(str, "P1: ");
+                add_to_furi_str_hex_bytes(str, (char*)addrs.addr_P1, addrs.addr_len);
+                furi_string_cat(str, "\n");
+            }
+            if(addrs.addr_count > 2) {
+                furi_string_cat_printf(str, "P2: ");
+                furi_string_cat_printf(str, "%02X\n", addrs.addr_P2);
+            }
+            if(addrs.addr_count > 3) {
+                furi_string_cat_printf(str, "P3: ");
+                furi_string_cat_printf(str, "%02X\n", addrs.addr_P3);
+            }
+            if(addrs.addr_count > 4) {
+                furi_string_cat_printf(str, "P4: ");
+                furi_string_cat_printf(str, "%02X\n", addrs.addr_P4);
+            }
+            if(addrs.addr_count > 5) {
+                furi_string_cat_printf(str, "P5: ");
+                furi_string_cat_printf(str, "%02X\n", addrs.addr_P5);
+            }
+            if(!(fl = stream_write_string(file_stream, str) == furi_string_size(str))) {
+                FURI_LOG_E(TAG, "Failed to write header to file!");
+                notification_message(APP->notification, &sequence_blink_red_100);
+            }
+        }
+        if(fl) {
+            if(f_settings) {
+                save_settings = 0;
+                if(strcmp(addr_file_name, "NONE") == 0) strcpy(addr_file_name, SETTINGS_FILENAME);
+            } else {
+                int i = 0;
+                for(; i < log_arr_idx; i++) {
+                    furi_string_reset(str);
+                    uint8_t* ptr = APP->log_arr + i * LOG_REC_SIZE;
+                    int len;
+                    if(ptr[0] & 0x80) { // RAW
+                        len = (ptr[1] & 0b11) + 2 + ((ptr[1] & 0b100) ? 2 : 0) + (ptr[1] >> 3) +
+                              2; // addr + PCF? + payload + crcmax
+                    } else {
+                        len = (ptr[1] >> 3);
+                        if(len == 0) len = 32;
+                    }
+                    //if(len < NRF_Payload) len = NRF_Payload;
+                    add_to_furi_str_hex_bytes(str, (char*)ptr, len + 2);
+                    furi_string_cat(str, "\n");
+                    if(stream_write_string(file_stream, str) != furi_string_size(str)) {
+                        FURI_LOG_E(TAG, "Failed to write to file!");
+                        break;
+                    }
+                }
+                if(i == log_arr_idx) {
+                    notification_message(APP->notification, &sequence_blink_yellow_100);
+                    FURI_LOG_D(TAG, "File saved");
+                }
+                save_to_new_log = false;
+            }
+        }
+        file_stream_close(file_stream);
+    } else {
+        FURI_LOG_E(TAG, "Failed to open file %s", furi_string_get_cstr(str));
+        notification_message(APP->notification, &sequence_blink_red_100);
+    }
+    stream_free(file_stream);
+    furi_string_free(str);
+}
+
+static bool select_settings_file(Stream* stream) {
+    DialogsApp* dialogs = furi_record_open("dialogs");
+    bool result = false;
+    FuriString* path;
+    path = furi_string_alloc();
+    furi_string_set(path, SCAN_APP_PATH_FOLDER);
+
+    DialogsFileBrowserOptions browser_options;
+    dialog_file_browser_set_basic_options(&browser_options, ".txt", NULL);
+    browser_options.hide_ext = false;
+
+    bool ret = dialog_file_browser_show(dialogs, path, path, &browser_options);
+
+    furi_record_close("dialogs");
+    if(ret) {
+        if(!file_stream_open(stream, furi_string_get_cstr(path), FSAM_READ, FSOM_OPEN_EXISTING)) {
+            FURI_LOG_D(TAG, "Cannot open file \"%s\"", furi_string_get_cstr(path));
+            file_stream_close(stream);
+        } else {
+            FURI_LOG_D(TAG, "Open file \"%s\"", furi_string_get_cstr(path));
+            strncpy(
+                addr_file_name,
+                furi_string_get_cstr(path) + sizeof(SCAN_APP_PATH_FOLDER),
+                sizeof(addr_file_name));
+            result = true;
+        }
+    }
+    furi_string_free(path);
+    return result;
+}
+
+// 0 - success, otherwise an error
+static uint8_t load_settings_file(Stream* file_stream) {
+    size_t file_size = 0;
+    char* file_buf;
+    uint8_t err = 5;
+    file_size = stream_size(file_stream);
+    if(file_size == (size_t)0) {
+        FURI_LOG_D(TAG, "load failed. file_size: %d", file_size);
+        return 1;
+    }
+    file_size = MIN(file_size, (size_t)LOG_REC_SIZE * MAX_LOG_RECORDS * 2 + 100);
+    file_buf = malloc(file_size + 1);
+    if(file_buf == NULL) {
+        FURI_LOG_D(TAG, "Memory low, need: %d", file_size);
+        return 2;
+    }
+    memset(file_buf, 0, file_size + 1);
+    if(stream_read(file_stream, (uint8_t*)file_buf, file_size) == file_size) {
+        FURI_LOG_D(TAG, "Loading settings file");
+        char* line_ptr = file_buf;
+        int16_t line_num = 0;
+        what_to_do = 2;
+        sniff_loaded = 0;
+        bool log_loaded = false;
+        while(line_ptr && (size_t)(line_ptr - file_buf) < file_size) {
+            char* end_ptr = strstr((char*)line_ptr, "\n");
+            if(end_ptr == NULL)
+                end_ptr = file_buf + file_size;
+            else
+                *end_ptr = '\0';
+            int line_len = end_ptr - line_ptr;
+            if(*line_ptr == '\r' || line_len == 0) {
+                line_ptr = end_ptr + 1;
+                continue;
+            }
+            if(*(end_ptr - 1) < '0') {
+                *(end_ptr - 1) = '\0';
+                line_len--;
+            }
+            //FURI_LOG_D(TAG, " L#%d: [%d]%s", line_num, line_len, line_ptr);
+            if(strncmp(line_ptr, SettingsFld_Rate, sizeof(SettingsFld_Rate) - 1) == 0) {
+                NRF_rate = atoi(line_ptr + sizeof(SettingsFld_Rate));
+            } else if(strncmp(line_ptr, SettingsFld_Ch, sizeof(SettingsFld_Ch) - 1) == 0) {
+                NRF_channel = atoi(line_ptr + sizeof(SettingsFld_Ch));
+            } else if(strncmp(line_ptr, SettingsFld_ESB, sizeof(SettingsFld_ESB) - 1) == 0) {
+                NRF_ESB = atoi(line_ptr + sizeof(SettingsFld_ESB));
+            } else if(strncmp(line_ptr, SettingsFld_DPL, sizeof(SettingsFld_DPL) - 1) == 0) {
+                NRF_DPL = atoi(line_ptr + sizeof(SettingsFld_DPL));
+            } else if(strncmp(line_ptr, SettingsFld_CRC, sizeof(SettingsFld_CRC) - 1) == 0) {
+                NRF_CRC = atoi(line_ptr + sizeof(SettingsFld_CRC));
+                if(what_to_do == 1) view_log_decode_CRC = NRF_CRC;
+            } else if(strncmp(line_ptr, SettingsFld_Payload, sizeof(SettingsFld_Payload) - 1) == 0) {
+                uint8_t pld = atoi(line_ptr + sizeof(SettingsFld_Payload));
+                if(pld > 32) pld = 32;
+                if(sniff_loaded) {
+                    NRF_Payload_sniff_min = pld;
+                } else {
+                    if(pld == 0) pld = 32;
+                    NRF_Payload = pld;
+                }
+            } else if(strncmp(line_ptr, SettingsFld_Sniff, sizeof(SettingsFld_Sniff) - 1) == 0) {
+                what_to_do = 1;
+                sniff_loaded = 1;
+            } else if(*line_ptr == SettingsFld_Addr) {
+                char a = *(++line_ptr);
+                struct ADDRS* adr = sniff_loaded ? &addrs_sniff : &addrs;
+                line_ptr += 3;
+                switch(a) {
+                case '0':
+                    memset(adr, 0, sizeof(addrs));
+                    adr->addr_len =
+                        ConvertHexToArray(line_ptr, adr->addr_P0, sniff_loaded ? 3 : 5);
+                    if(adr->addr_len >= 2) err = 0;
+                    break;
+                case '1':
+                    ConvertHexToArray(line_ptr, adr->addr_P1, what_to_do == 1 ? 3 : 5);
+                    break;
+                case '2':
+                    ConvertHexToArray(line_ptr, &adr->addr_P2, 1);
+                    break;
+                case '3':
+                    ConvertHexToArray(line_ptr, &adr->addr_P3, 1);
+                    break;
+                case '4':
+                    ConvertHexToArray(line_ptr, &adr->addr_P4, 1);
+                    break;
+                case '5':
+                    ConvertHexToArray(line_ptr, &adr->addr_P5, 1);
+                    break;
+                default:
+                    a = 0;
+                    break;
+                }
+                if(err == 0 && a) adr->addr_count = a - '0' + 1;
+            } else if(line_len >= 3 * 2) { // data
+                if(!log_loaded) {
+                    log_loaded = true;
+                    clear_log();
+                    what_to_do = 0;
+                }
+                if(log_arr_idx < MAX_LOG_RECORDS - 1) {
+                    if(ConvertHexToArray(
+                           line_ptr, APP->log_arr + log_arr_idx * LOG_REC_SIZE, LOG_REC_SIZE) > 0)
+                        err = 0;
+                    log_arr_idx++;
+                }
+            }
+            line_ptr = end_ptr + 1;
+            line_num++;
+        }
+    } else {
+        FURI_LOG_D(TAG, "load failed. file size: %d", file_size);
+        err = 4;
+    }
+    free(file_buf);
+    return err;
+}
+
+static void input_callback(InputEvent* input_event, FuriMessageQueue* event_queue) {
+    furi_assert(event_queue);
+    PluginEvent event = {.type = EventTypeKey, .input = *input_event};
+    furi_message_queue_put(event_queue, &event, FuriWaitForever);
+}
+
+void check_add_addr(uint8_t* pkt) {
+    if(addrs.addr_count > 0 && memcmp(addrs.addr_P0, pkt, addrs.addr_len) == 0) return;
+    if(addrs.addr_count > 1 && memcmp(addrs.addr_P1, pkt, addrs.addr_len - 1) == 0) {
+        if(addrs.addr_P1[addrs.addr_len - 1] == pkt[addrs.addr_len - 1]) return;
+        if(addrs.addr_count > 2 && addrs.addr_P2 == pkt[addrs.addr_len - 1]) return;
+        if(addrs.addr_count > 3 && addrs.addr_P3 == pkt[addrs.addr_len - 1]) return;
+        if(addrs.addr_count > 4 && addrs.addr_P4 == pkt[addrs.addr_len - 1]) return;
+        if(addrs.addr_count > 5 && addrs.addr_P5 == pkt[addrs.addr_len - 1]) return;
+    }
+    if(addrs.addr_count == 1)
+        memcpy(addrs.addr_P1, pkt, addrs.addr_len);
+    else if(addrs.addr_count == 2)
+        addrs.addr_P2 = pkt[addrs.addr_len - 1];
+    else if(addrs.addr_count == 3)
+        addrs.addr_P3 = pkt[addrs.addr_len - 1];
+    else if(addrs.addr_count == 4)
+        addrs.addr_P4 = pkt[addrs.addr_len - 1];
+    else if(addrs.addr_count == 5)
+        addrs.addr_P5 = pkt[addrs.addr_len - 1];
+    addrs.addr_count++;
+}
+
+static void prepare_nrf24(bool fsend_packet) {
+    nrf24_write_reg(nrf24_HANDLE, REG_STATUS, 0x70); // clear interrupts
+    nrf24_write_reg(
+        nrf24_HANDLE,
+        REG_RF_SETUP,
+        (NRF_rate == 0 ? 0b00100000 :
+         NRF_rate == 1 ? 0 :
+                         0b00001000) |
+            0b111); // +TX high power
+    uint8_t erx_addr = (1 << 0); // Enable RX_P0
+    struct ADDRS* adr = what_to_do == 1 ? &addrs_sniff : &addrs;
+    if(!fsend_packet) {
+        uint8_t payload = NRF_Payload;
+        uint8_t* rec = APP->log_arr + view_log_arr_idx * LOG_REC_SIZE;
+        uint8_t addr_size = (*(rec + 1) & 0b11) + 2;
+        bool setup_from_log = false;
+        if(what_to_do >= 2) {
+            if(log_arr_idx && (*rec & 0x80)) {
+                setup_from_log = true;
+                memcpy(addrs.addr_P0, rec + 2, addr_size);
+                addrs.addr_count = 1;
+                addrs.addr_len = addr_size;
+                payload = *(rec + 1) >> 3;
+                if(what_to_do == 2) {
+                    uint8_t* p = APP->log_arr + 2;
+                    int16_t i = 0;
+                    for(i = 0; i < log_arr_idx; i++, p += LOG_REC_SIZE) {
+                        if((*(p - 2) & 0x80) && (*(p - 1) & 0b11) + 2 == addr_size &&
+                           rec + 2 != p) {
+                            if(memcmp(p, addrs.addr_P0, addr_size - 1) == 0) {
+                                check_add_addr(p);
+                                if(addrs.addr_count >= 6) break;
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        if(what_to_do == 1) { // SNIFF
+            payload = 32;
+            nrf24_write_reg(nrf24_HANDLE, REG_CONFIG, 0x70); // Mask all interrupts
+            nrf24_write_reg(nrf24_HANDLE, REG_SETUP_RETR, 0); // Automatic Retransmission
+            nrf24_write_reg(nrf24_HANDLE, REG_EN_AA, 0); // Auto acknowledgement
+            nrf24_write_reg(
+                nrf24_HANDLE,
+                REG_FEATURE,
+                0); // Enables the W_TX_PAYLOAD_NOACK command, Disable Payload with ACK, set Dynamic Payload
+            // EN_DYN_ACK(0x01)  for W_TX_PAYLOAD_NOACK cmd broke AA on some fake nRF24l01+ modules
+        } else if(setup_from_log) { // Scan
+            nrf24_write_reg(
+                nrf24_HANDLE,
+                REG_CONFIG,
+                0x70 | ((NRF_CRC == 1 ? 0b1000 :
+                         NRF_CRC == 2 ? 0b1100 :
+                                        0))); // Mask all interrupts
+            nrf24_write_reg(nrf24_HANDLE, REG_RF_CH, *rec & 0x7F);
+            nrf24_write_reg(
+                nrf24_HANDLE,
+                REG_FEATURE,
+                *(rec + 2 + addr_size) >> 2 != 0x33 ?
+                    4 :
+                    0); // Enables the W_TX_PAYLOAD_NOACK command, Disable Payload with ACK, set Dynamic Payload
+            if(*(rec + 1) & 0b100) { // ESB
+                nrf24_write_reg(nrf24_HANDLE, REG_SETUP_RETR, 0x01); // Automatic Retransmission
+                nrf24_write_reg(nrf24_HANDLE, REG_EN_AA, 0x3F); // Auto acknowledgement
+            } else {
+                nrf24_write_reg(nrf24_HANDLE, REG_SETUP_RETR, 0); // Automatic Retransmission
+                nrf24_write_reg(nrf24_HANDLE, REG_EN_AA, 0); // Auto acknowledgement
+            }
+        } else {
+            nrf24_write_reg(
+                nrf24_HANDLE,
+                REG_CONFIG,
+                0x70 | ((NRF_CRC == 1 ? 0b1000 :
+                         NRF_CRC == 2 ? 0b1100 :
+                                        0))); // Mask all interrupts
+            nrf24_write_reg(
+                nrf24_HANDLE, REG_SETUP_RETR, NRF_ESB ? 0x01 : 0); // Automatic Retransmission
+            nrf24_write_reg(
+                nrf24_HANDLE,
+                REG_EN_AA,
+                NRF_AA_OFF || !NRF_ESB ? 0 : 0x3F); // Auto acknowledgement
+            nrf24_write_reg(
+                nrf24_HANDLE,
+                REG_FEATURE,
+                NRF_DPL ?
+                    4 :
+                    0); // Enables the W_TX_PAYLOAD_NOACK command, Disable Payload with ACK, set Dynamic Payload
+            nrf24_write_reg(
+                nrf24_HANDLE, REG_DYNPD, NRF_DPL ? 0x3F : 0); // Enable dynamic payload reg
+            nrf24_write_reg(nrf24_HANDLE, REG_RF_CH, NRF_channel);
+        }
+        if(adr->addr_count == 0) return;
+        nrf24_write_reg(nrf24_HANDLE, RX_PW_P0, payload);
+        nrf24_set_maclen(nrf24_HANDLE, adr->addr_len);
+        nrf24_set_mac(REG_RX_ADDR_P0, adr->addr_P0, adr->addr_len);
+        uint8_t tmp[5] = {0};
+        nrf24_read_reg(nrf24_HANDLE, REG_RX_ADDR_P0, tmp, adr->addr_len);
+        for(uint8_t i = 0; i < adr->addr_len / 2; i++) {
+            uint8_t tb = tmp[i];
+            tmp[i] = tmp[adr->addr_len - i - 1];
+            tmp[adr->addr_len - i - 1] = tb;
+        }
+        NRF_ERROR = memcmp(adr->addr_P0, tmp, adr->addr_len) != 0;
+        FURI_LOG_D(TAG, "Payload: %d", payload);
+        nrf24_write_reg(nrf24_HANDLE, RX_PW_P0, payload);
+        if(adr->addr_count > 1) {
+            nrf24_set_mac(REG_RX_ADDR_P1, adr->addr_P1, adr->addr_len);
+            nrf24_write_reg(nrf24_HANDLE, RX_PW_P1, payload);
+            erx_addr |= (1 << 1); // Enable RX_P1
+        } else
+            nrf24_write_reg(nrf24_HANDLE, RX_PW_P1, 0);
+        if(adr->addr_count > 2) {
+            nrf24_write_buf_reg(nrf24_HANDLE, REG_RX_ADDR_P2, &adr->addr_P2, 1);
+            nrf24_write_reg(nrf24_HANDLE, RX_PW_P2, payload);
+            erx_addr |= (1 << 2); // Enable RX_P2
+        } else
+            nrf24_write_reg(nrf24_HANDLE, RX_PW_P2, 0);
+        if(adr->addr_count > 3) {
+            nrf24_write_buf_reg(nrf24_HANDLE, REG_RX_ADDR_P3, &adr->addr_P3, 1);
+            nrf24_write_reg(nrf24_HANDLE, RX_PW_P3, payload);
+            erx_addr |= (1 << 3); // Enable RX_P3
+        } else
+            nrf24_write_reg(nrf24_HANDLE, RX_PW_P3, 0);
+        if(adr->addr_count > 4) {
+            nrf24_write_buf_reg(nrf24_HANDLE, REG_RX_ADDR_P4, &adr->addr_P4, 1);
+            nrf24_write_reg(nrf24_HANDLE, RX_PW_P4, payload);
+            erx_addr |= (1 << 4); // Enable RX_P4
+        } else
+            nrf24_write_reg(nrf24_HANDLE, RX_PW_P4, 0);
+        if(adr->addr_count > 5) {
+            nrf24_write_buf_reg(nrf24_HANDLE, REG_RX_ADDR_P5, &adr->addr_P5, 1);
+            nrf24_write_reg(nrf24_HANDLE, RX_PW_P5, payload);
+            erx_addr |= (1 << 5); // Enable RX_P5
+        } else
+            nrf24_write_reg(nrf24_HANDLE, RX_PW_P5, 0);
+        nrf24_write_reg(nrf24_HANDLE, REG_EN_RXADDR, erx_addr);
+    }
+    nrf24_flush_rx(nrf24_HANDLE);
+    nrf24_flush_tx(nrf24_HANDLE);
+    nrf24_set_idle(nrf24_HANDLE);
+}
+
+void correct_NRF_Payload_sniff_min() {
+    uint8_t pld = 32 - 3 - (NRF_ESB ? 2 : 0) - NRF_CRC + (addrs_sniff.addr_len - 2);
+    if(NRF_Payload_sniff_min > pld) NRF_Payload_sniff_min = pld;
+}
+
+static void start_scanning() {
+    FURI_LOG_D(TAG, "Start proc-%d: Ch=%d Rate=%d", what_to_do, NRF_channel, NRF_rate);
+    if(what_to_do == 1) { // SNIFF
+        correct_NRF_Payload_sniff_min();
+        view_log_decode_CRC = NRF_CRC;
+    } else if(sniff_loaded) { // Switch from sniff to scan/view
+        // to do...
+    }
+    prepare_nrf24(false);
+    if(NRF_ERROR) {
+        FURI_LOG_E(TAG, "NRF R/W ERROR!");
+        return;
+    }
+    nrf24_set_rx_mode(nrf24_HANDLE);
+    start_time = furi_get_tick();
+}
+
+// start bitnum = 7
+uint32_t calc_crc(uint32_t crc, uint8_t* ptr, uint8_t bitnum, uint16_t bits) {
+    //uint8_t bitnum = 7;
+    uint32_t crc_high, polynom;
+    if(view_log_decode_CRC == 2) {
+        crc_high = (1 << 16);
+        polynom = 0x1021; // X^16+X^12+X^5+1 => 0x11021 & 0xFFFF = 0x1021
+    } else {
+        crc_high = (1 << 8);
+        polynom = 0x07; // x^8+x^2+x^1+1 => 0x107 & 0xFF = 0x07
+    }
+    while(bits--) {
+        crc <<= 1;
+        if(((crc & crc_high) != 0) ^ ((*ptr >> bitnum) & 1)) crc ^= polynom;
+        if(bitnum == 0) {
+            ptr++;
+            bitnum = 7;
+        } else
+            bitnum--;
+    }
+    return crc & (view_log_decode_CRC == 2 ? 0xFFFF : 0xFF);
+}
+
+// shifted 1 bit right
+uint32_t get_shifted_crc(uint8_t* pcrc) {
+    uint32_t crc = ((*pcrc << 1) & 0xFF) | (*(pcrc + 1) >> 7);
+    if(view_log_decode_CRC == 2) {
+        crc = (crc << 8) | ((*(pcrc + 1) << 1) & 0xFF) | (*(pcrc + 2) >> 7);
+    }
+    return crc;
+}
+
+bool check_packet(uint8_t* pkt, uint16_t size) {
+    if(size < 3 || size > 32) return false;
+    uint8_t b = *pkt;
+    if(b == 0x55 || b == 0xAA || b == 0x00 || b == 0xFF)
+        return false; // skip pkt when address begin with
+    uint32_t prevcrc = 0xFFFFFFFF;
+    bool found = false;
+    uint8_t addr_size = 3;
+    for(; addr_size <= 5; addr_size++) {
+        if(NRF_ESB) {
+            uint8_t _payload = *(pkt + addr_size) >> 2;
+            if((_payload > size - addr_size - 2 - view_log_decode_CRC && _payload != 0x33))
+                continue;
+            uint8_t* p = pkt + addr_size;
+            if(prevcrc == 0xFFFFFFFF) {
+                prevcrc = calc_crc(
+                    view_log_decode_CRC == 2 ? 0xFFFF : 0xFF,
+                    pkt,
+                    7,
+                    3 * 8); // crc for smallest addr
+            }
+            uint32_t crc;
+            if(addr_size > 3)
+                crc = calc_crc(prevcrc, p - (addr_size - 3), 7, 8 * (addr_size - 3));
+            else
+                crc = prevcrc;
+            if(_payload != 0x33) { // DPL
+                crc = calc_crc(crc, p, 7, 9 + _payload * 8);
+                if(crc == get_shifted_crc(p + _payload + 1)) {
+                    *(pkt - 1) = ((_payload & 0x1F) << 3) + 0b100 + (addr_size - 2);
+                    FURI_LOG_D(
+                        TAG, "VALID CRC %X: dpl: %d, addr: %d", (uint16_t)crc, _payload, addr_size);
+                    found = true;
+                    break;
+                }
+            } else {
+                crc = calc_crc(crc, p++, 7, 9); // PCF
+                if(crc == get_shifted_crc(p)) {
+                    _payload = 0;
+                    found = true;
+                } else {
+                    for(uint8_t i = 1; i < size - addr_size - view_log_decode_CRC; i++) {
+                        crc = calc_crc(crc, p++, 6, 8);
+                        if(crc == get_shifted_crc(p)) {
+                            _payload = i;
+                            found = true;
+                            break;
+                        }
+                    }
+                }
+                if(found) {
+                    *(pkt - 1) = ((_payload & 0x1F) << 3) + 0b100 + (addr_size - 2);
+                    FURI_LOG_D(
+                        TAG, "VALID CRC %X: pl: %d, addr: %d", (uint16_t)crc, _payload, addr_size);
+                    break;
+                }
+            }
+        } else {
+            uint8_t* p;
+            if(addr_size == 3) {
+                prevcrc = calc_crc(
+                    view_log_decode_CRC == 2 ? 0xFFFF : 0xFF,
+                    pkt,
+                    7,
+                    3 * 8); // crc for smallest addr
+                p = pkt + addr_size;
+            } else {
+                p = pkt + addr_size - 1;
+                prevcrc = calc_crc(prevcrc, p++, 7, 8);
+            }
+            uint32_t crc = prevcrc;
+            if((view_log_decode_CRC == 1 && crc == *p) ||
+               (view_log_decode_CRC == 2 && crc == (uint32_t)((*p << 8) | *(p + 1)))) {
+                *(pkt - 1) = ((0 & 0x1F) << 3) + 0b000 + (addr_size - 2);
+                FURI_LOG_D(TAG, "VALID CRC %X: pl: %d, addr: %d", (uint16_t)crc, 0, addr_size);
+                found = true;
+                break;
+            }
+            for(uint8_t i = 1; i <= size - addr_size - view_log_decode_CRC; i++) {
+                crc = calc_crc(crc, p++, 7, 8);
+                if((view_log_decode_CRC == 1 && crc == *p) ||
+                   (view_log_decode_CRC == 2 && crc == (uint32_t)((*p << 8) | *(p + 1)))) {
+                    *(pkt - 1) = ((i & 0x1F) << 3) + 0b000 + (addr_size - 2);
+                    FURI_LOG_D(TAG, "VALID CRC %X: pl: %d, addr: %d", (uint16_t)crc, i, addr_size);
+                    found = true;
+                    break;
+                }
+            }
+            if(found) break;
+        }
+    }
+    if(found) {
+        if(furi_log_get_level() == FuriLogLevelDebug) {
+            char dbuf[65];
+            dbuf[0] = 0;
+            add_to_str_hex_bytes(dbuf, (char*)pkt, size);
+            FURI_LOG_D(TAG, "PKT%02X: %s (%d)", *(pkt - 1), dbuf, size);
+        }
+        int16_t i = 0;
+        for(; i < found_total; i++) {
+            if(APP->found[i].addr_size != addr_size) continue;
+            if(memcmp(APP->found[i].addr, pkt, addr_size) == 0) break;
+        }
+        if(i != found_total) { // found
+            APP->found[i].total++;
+        } else {
+            uint8_t* p = APP->log_arr + 2;
+            for(i = 0; i < log_arr_idx; i++, p += LOG_REC_SIZE) {
+                if((*(p - 2) & 0x80) && (*(p - 1) & 0b11) + 2 == addr_size && pkt != p) {
+                    if(memcmp(p, pkt, addr_size) == 0) break;
+                }
+            }
+            if(i != log_arr_idx && found_total < MAX_FOUND_RECORDS) { // found -> 2
+                memset(&APP->found[found_total], 0, sizeof(struct FOUND));
+                memcpy(APP->found[found_total].addr, pkt, addr_size);
+                APP->found[found_total].addr_size = addr_size;
+                APP->found[found_total].total = 2;
+                if(found_total == 0) view_found = 0;
+                found_total++;
+            }
+        }
+    }
+
+    return found;
+}
+
+bool nrf24_read_newpacket() {
+    if(APP->log_arr == NULL) return false;
+    bool found = false;
+    uint8_t packetsize;
+    uint8_t* ptr = APP->log_arr + log_arr_idx * LOG_REC_SIZE;
+    uint8_t st;
+    /* test pkts	
+	static int iii = 0;
+    char ppp[][65] = { 	"54A545109411544BAAE50110A3282512A9A1152A565B22AAA48AB751A5",
+						"C8C8C0CE7A81018007202FFFFC", 
+						"EAEC8C8C2CE3C0101006FB737A",
+						"BEBFFFEC8C8C1CC00542AF7CFF7DBEAFE3397FEAFEF1DDFA4AEF7FDBB7CDEABC",
+						"FEAAAABEAAFEAAC8C8C28E1C810080490ABAF7FEEB76B7FDFEF7DFFB47FB97FE",
+						"A8AAC8C8C1CE20163DF7DFFD00",
+						"AFFEEFEC8C8C2CE4001010062F037F9BFFDF1DAD5EDBEF55DD9AB535FCB67F55",
+						"AC8C8C1CE5F8102000D503D7ABF",
+						"EE03080B4712555555550E80",
+						"C8C8C41385818280127100",
+						"AAC8C8C3CE05818280119000"
+						"AC8C8C413858182801271000",
+						"AAC8C8C40B0305028542"
+					};
+	if(iii < 13) {
+		ConvertHexToArray(ppp[iii], ptr + 2, 32);
+		st = RX_DR;
+		packetsize = 32;
+		iii++;
+	} else
+//*/
+    st = nrf24_rxpacket(
+        nrf24_HANDLE,
+        ptr + 2 + (what_to_do == 1 ? addrs_sniff.addr_len - 2 : 0),
+        &packetsize,
+        what_to_do == 1 ? 32 : !NRF_DPL);
+    if(st & RX_DR) {
+        st = (st >> 1) & 7; // pipe #
+        if(what_to_do == 1) { // SNIFF
+            *ptr++ = NRF_channel | 0x80;
+            *ptr++ = st; // pipe #
+            if(addrs_sniff.addr_len > 2) {
+                *ptr = st == 0 ? addrs_sniff.addr_P0[2] :
+                       st == 1 ? addrs_sniff.addr_P1[2] :
+                       st == 2 ? addrs_sniff.addr_P2 :
+                       st == 3 ? addrs_sniff.addr_P3 :
+                       st == 4 ? addrs_sniff.addr_P4 :
+                                 addrs_sniff.addr_P5;
+            }
+            if(!check_packet(ptr, packetsize)) {
+                if(addrs_sniff.addr_len > 2) return false; // skip if mac MSB added to preamble
+                uint8_t shifted = 0;
+                uint8_t shift_max = (32 - 3 - NRF_Payload_sniff_min - NRF_CRC) * 8 - 1;
+                while(shifted++ <
+                      shift_max) { // Shift packet left by one bit if minimum payload fits
+                    uint8_t i = 0;
+                    for(; i < packetsize - 1; i++) ptr[i] = (ptr[i] << 1) | (ptr[i + 1] >> 7);
+                    ptr[i] <<= 1;
+                    if(check_packet(ptr, packetsize - (shifted >> 3) - 1)) goto x_valid;
+                }
+                return false;
+            }
+        } else {
+            *ptr++ = NRF_channel;
+            *ptr++ = ((packetsize & 0x1F) << 3) | st; // payload size + pipe #
+        }
+    x_valid:
+        if(packetsize < 32) memset(ptr + packetsize, 0, 32 - packetsize);
+        if(log_arr_idx < MAX_LOG_RECORDS - 1) {
+            log_arr_idx++;
+        } else {
+            if(log_to_file == 1 || log_to_file == 2) {
+                write_to_log_file(APP->storage, false);
+                clear_log();
+            } else {
+                memmove(APP->log_arr, APP->log_arr + LOG_REC_SIZE, log_arr_idx * LOG_REC_SIZE);
+            }
+        }
+        FURI_LOG_D(TAG, "Found packet #%d pipe %d", log_arr_idx, st);
+        notification_message(APP->notification, &sequence_blink_white_100);
+        found = true;
+    }
+    return found;
+}
+
+bool nrf24_send_packet() {
+    if(log_arr_idx == 0) return false;
+    prepare_nrf24(!what_to_do);
+    uint8_t* ptr = APP->log_arr + view_log_arr_idx * LOG_REC_SIZE;
+    nrf24_write_reg(nrf24_HANDLE, REG_RF_CH, *ptr & 0x7F);
+    if(*ptr & 0x80) { // RAW packet
+        //uint8_t pktinfo = *(ptr + 1);
+        //nrf24_set_maclen(nrf24_HANDLE, (pktinfo & 0b11) + 2);
+        //if(pktinfo & 0b100) { // ESB
+        nrf24_write_reg(nrf24_HANDLE, REG_SETUP_RETR, 0); // No Automatic Retransmission
+        nrf24_write_reg(nrf24_HANDLE, REG_EN_AA, 0); // No Auto acknowledgement
+        //}
+        //uint8_t alen = (*(ptr + 2) & 0b11) + 2;
+        uint8_t adr[2];
+        adr[0] = ptr[2];
+        adr[1] = ptr[3];
+        nrf24_set_maclen(nrf24_HANDLE, 2);
+        nrf24_set_mac(REG_RX_ADDR_P0, adr, 2);
+        nrf24_set_mac(REG_TX_ADDR, adr, 2);
+        last_packet_send_st = nrf24_txpacket(nrf24_HANDLE, ptr + 2 + 2, 32 - 2, true);
+    } else {
+        nrf24_write_reg(
+            nrf24_HANDLE, REG_SETUP_RETR, NRF_ESB ? 0x11 : 0); // Automatic Retransmission
+        nrf24_write_reg(
+            nrf24_HANDLE, REG_EN_AA, NRF_AA_OFF || !NRF_ESB ? 0 : 0x3F); // Auto acknowledgement
+        uint8_t* adr;
+        uint8_t a = *(ptr + 1) & 0b111;
+        if(a < 2) {
+            if(a == 0)
+                adr = addrs.addr_P0;
+            else
+                adr = addrs.addr_P1;
+            nrf24_set_mac(REG_RX_ADDR_P0, adr, addrs.addr_len);
+            nrf24_set_mac(REG_TX_ADDR, adr, addrs.addr_len);
+        } else {
+            uint8_t buf[5];
+            memcpy(buf, addrs.addr_P1, addrs.addr_len - 1);
+            buf[addrs.addr_len - 1] = a == 2 ? addrs.addr_P2 :
+                                      a == 3 ? addrs.addr_P3 :
+                                      a == 4 ? addrs.addr_P4 :
+                                               addrs.addr_P5;
+            nrf24_set_mac(REG_RX_ADDR_P0, buf, addrs.addr_len);
+            nrf24_set_mac(REG_TX_ADDR, buf, addrs.addr_len);
+        }
+        a = *(ptr + 1) >> 3;
+        if(a == 0) a = 32;
+        nrf24_write_reg(
+            nrf24_HANDLE,
+            REG_CONFIG,
+            0x70 | ((NRF_CRC == 1 ? 0b1000 :
+                     NRF_CRC == 2 ? 0b1100 :
+                                    0))); // Mask all interrupts
+        nrf24_write_reg(nrf24_HANDLE, REG_DYNPD, NRF_DPL ? 0x3F : 0); // Enable dynamic payload reg
+        last_packet_send_st = nrf24_txpacket(nrf24_HANDLE, ptr + 2, a, true);
+    }
+    last_packet_send = view_log_arr_idx;
+    notification_message(
+        APP->notification,
+        last_packet_send_st ? &sequence_blink_blue_100 : &sequence_blink_red_100);
+    if(what_to_do) start_scanning();
+    return last_packet_send_st;
+}
+
+static void render_callback(Canvas* const canvas, void* ctx) {
+    const PluginState* plugin_state = ctx;
+    if(plugin_state == NULL) return;
+    if(furi_mutex_acquire(plugin_state->mutex, 25) != FuriStatusOk) return;
+    //canvas_draw_frame(canvas, 0, 0, 128, 64); // border around the edge of the screen
+    if(what_doing == 0) {
+        canvas_set_font(canvas, FontSecondary); // 8x10 font, 6 lines
+        if(save_settings)
+            snprintf(
+                screen_buf, sizeof(screen_buf), "Save: %s", SETTINGS_FILENAME); // menu_selected = 0
+        else
+            snprintf(screen_buf, sizeof(screen_buf), "Load: %s", addr_file_name);
+        canvas_draw_str(canvas, 10, 10, screen_buf);
+        snprintf(screen_buf, sizeof(screen_buf), "Ch: %d", NRF_channel); // menu_selected = 1
+        canvas_draw_str(canvas, 10, 20, screen_buf);
+        if(NRF_ESB) {
+            strcpy(screen_buf, "ESB");
+            if(NRF_DPL) strcat(screen_buf, " DPL");
+            canvas_draw_str(canvas, 78, 20, screen_buf);
+        }
+        if(NRF_AA_OFF) {
+            canvas_draw_str(canvas, 61, 20, "AA");
+            canvas_draw_line(canvas, 60, 21, 72, 12);
+        }
+        snprintf(
+            screen_buf,
+            sizeof(screen_buf),
+            "Rate: %sbps",
+            NRF_rate == 2 ? "2M" :
+            NRF_rate == 1 ? "1M" :
+                            "250K"); // menu_selected = 2
+        canvas_draw_str(canvas, 10, 30, screen_buf);
+        if(what_to_do == 1)
+            snprintf(screen_buf, sizeof(screen_buf), "Min Payl: %d", NRF_Payload_sniff_min);
+        else if(what_to_do >= 2) {
+            uint8_t* p = APP->log_arr + view_log_arr_idx * LOG_REC_SIZE;
+            snprintf(
+                screen_buf,
+                sizeof(screen_buf),
+                "Payload: %d",
+                log_arr_idx && (*p & 0x80) ? *(p + 1) >> 3 : NRF_Payload);
+        } else
+            snprintf(screen_buf, sizeof(screen_buf), "Payload: %d", NRF_Payload);
+        canvas_draw_str(canvas, 78, 30, screen_buf);
+        strcpy(screen_buf, "Next Ch time: "); // menu_selected = 3
+        if(find_channel_period == 0)
+            strcat(screen_buf, "off");
+        else
+            snprintf(
+                screen_buf + strlen(screen_buf), sizeof(screen_buf), "%d s", find_channel_period);
+        canvas_draw_str(canvas, 10, 40, screen_buf);
+        if(NRF_CRC == 1)
+            canvas_draw_str(canvas, 99, 40, "CRC1");
+        else if(NRF_CRC == 2)
+            canvas_draw_str(canvas, 99, 40, "CRC2");
+        snprintf(
+            screen_buf,
+            sizeof(screen_buf),
+            "Log: %s",
+            log_to_file == 0 ? "No" :
+            log_to_file == 1 ? "Yes" :
+            log_to_file == 2 ? "Append" :
+                               "Clear"); // menu_selected = 4
+        canvas_draw_str(canvas, 10, 50, screen_buf);
+        if(what_to_do) { // menu_selected = 5
+            if(NRF_ERROR)
+                snprintf(screen_buf, sizeof(screen_buf), "nRF24L01+ r/w ERROR!");
+            else {
+                if(what_to_do == 1)
+                    snprintf(screen_buf, sizeof(screen_buf), "Start sniff");
+                else {
+                    uint8_t* p = APP->log_arr + view_log_arr_idx * LOG_REC_SIZE;
+                    if(log_arr_idx && (*p & 0x80)) { // +RAW
+                        snprintf(screen_buf, sizeof(screen_buf), "Start read: ");
+                        add_to_str_hex_bytes(screen_buf, (char*)p + 2, (*(p + 1) & 0b11) + 2);
+                        if(what_to_do == 2) strcpy(screen_buf + strlen(screen_buf) - 2, "* ");
+                    } else
+                        snprintf(
+                            screen_buf,
+                            sizeof(screen_buf),
+                            "Start scan (pipes: %d)",
+                            addrs.addr_count);
+                }
+            }
+        } else
+            snprintf(screen_buf, sizeof(screen_buf), "View log (pipes: %d)", addrs.addr_count);
+        canvas_draw_str(canvas, 10, 60, screen_buf);
+        canvas_draw_str(canvas, 0, menu_selected * 10 + 10, ">");
+    } else if(what_doing == 1) {
+        canvas_set_font(canvas, FontBatteryPercent); // 5x7 font, 9 lines
+        bool ch2 = false;
+        screen_buf[0] = '\0';
+        if(view_log_arr_x == 0) {
+            strcat(screen_buf, "  ");
+            ch2 = true;
+        } else {
+            snprintf(screen_buf, sizeof(screen_buf), "<%d", view_log_arr_x);
+            if(view_log_arr_x < VIEW_LOG_MAX_X) ch2 = true;
+        }
+        snprintf(
+            screen_buf + strlen(screen_buf),
+            sizeof(screen_buf),
+            " %s ch: %d - %d.",
+            what_to_do == 1 ? "Sniff" :
+            what_to_do == 0 ? "View" :
+                              "Read",
+            NRF_channel,
+            log_arr_idx);
+        canvas_draw_str(canvas, 0, 7, screen_buf);
+        if(ch2) canvas_draw_str(canvas, 121, 7, ">");
+        if(log_arr_idx) {
+            if(view_log_arr_idx >= log_arr_idx) view_log_arr_idx = log_arr_idx - 1;
+            uint16_t page = view_log_arr_idx & ~7;
+            for(uint8_t i = 0; i < 8 && page + i < log_arr_idx; i++) {
+                screen_buf[0] = (view_log_arr_idx & 7) != i          ? ' ' :
+                                last_packet_send != view_log_arr_idx ? '>' :
+                                last_packet_send_st                  ? '*' :
+                                                                       '!';
+                screen_buf[1] = '\0';
+                uint8_t* ptr = APP->log_arr + (page + i) * LOG_REC_SIZE;
+                uint8_t channel = *ptr++;
+                uint8_t* crcptr = NULL;
+                uint8_t pre = 0;
+                int count = 0;
+                if(channel & 0x80) { // RAW packet: nn:>{.address..}-xxxxxxxx
+                    uint8_t pktinfo = *ptr++;
+                    bool _PCF = pktinfo & 0b100;
+                    uint8_t plen = count = (pktinfo >> 3);
+                    uint8_t adrsize = (pktinfo & 0b11) + 2;
+                    plen += adrsize;
+                    count += view_log_decode_CRC;
+                    if(view_log_arr_x > 0) count -= view_log_arr_x - 1;
+                    uint8_t max_width = VIEW_LOG_WIDTH_B;
+                    if(view_log_arr_x == 0) max_width -= 5;
+                    if(count > max_width) count = max_width;
+                    if(count > 0) {
+                        uint8_t* pcrc = ptr;
+                        uint32_t crc;
+                        crc = view_log_decode_CRC == 2 ? 0xFFFF : 0xFF;
+                        crc = calc_crc(crc, pcrc, 7, (_PCF ? 9 : 0) + plen * 8);
+                        pcrc += plen;
+                        if(_PCF) { //ESB
+                            pcrc++;
+                            if(crc == get_shifted_crc(pcrc)) crcptr = pcrc;
+                        } else {
+                            if((view_log_decode_CRC == 1 && crc == *pcrc) ||
+                               (view_log_decode_CRC == 2 &&
+                                crc == (uint32_t)((*pcrc << 8) | *(pcrc + 1)))) {
+                                crcptr = pcrc;
+                            }
+                        }
+                        if(view_log_arr_x == 0) {
+                            add_to_str_hex_bytes(screen_buf, (char*)ptr, adrsize);
+                            for(int8_t j = 5 - adrsize; j > 0; j--) strcat(screen_buf, "  ");
+                            strcat(screen_buf, "-");
+                            pre += 5 * 2 + 1;
+                        } else {
+                            ptr += view_log_arr_x - 1;
+                        }
+                        ptr += adrsize;
+                        if(_PCF)
+                            add_to_str_hex_bytes_shift_9b(screen_buf, (char*)ptr++, count);
+                        else
+                            add_to_str_hex_bytes(screen_buf, (char*)ptr, count);
+                    }
+                } else {
+                    uint8_t dpl = *ptr++;
+                    uint8_t pipe = dpl & 0b111;
+                    dpl >>= 3;
+                    if(dpl == 0) dpl = 32;
+                    count = dpl - view_log_arr_x;
+                    if(view_log_decode_PCF) count--;
+                    uint8_t max_width = VIEW_LOG_WIDTH_B;
+                    if(view_log_arr_x == 0) {
+                        if(addrs.addr_count > 1) max_width--;
+                        if(view_log_decode_PCF) max_width -= 2;
+                    }
+                    if(count > max_width) count = max_width;
+                    if(count > 0) {
+                        if(view_log_decode_CRC) {
+                            static uint16_t prev_addr_CRC;
+                            static int8_t prev_pipe = -1;
+                            uint8_t* pcrc = ptr;
+                            uint32_t crc;
+                            if(prev_pipe == pipe) {
+                                crc = prev_addr_CRC;
+                            } else {
+                                crc = view_log_decode_CRC == 2 ? 0xFFFF : 0xFF;
+                                if(pipe <= 1) {
+                                    crc = calc_crc(
+                                        crc,
+                                        pipe == 0 ? addrs.addr_P0 : addrs.addr_P1,
+                                        7,
+                                        addrs.addr_len * 8);
+                                } else {
+                                    crc =
+                                        calc_crc(crc, addrs.addr_P1, 7, (addrs.addr_len - 1) * 8);
+                                    crc = calc_crc(
+                                        crc,
+                                        pipe == 2 ? &addrs.addr_P2 :
+                                        pipe == 3 ? &addrs.addr_P3 :
+                                        pipe == 4 ? &addrs.addr_P4 :
+                                                    &addrs.addr_P5,
+                                        7,
+                                        8);
+                                }
+                                prev_addr_CRC = crc;
+                                prev_pipe = pipe;
+                            }
+                            if(view_log_decode_PCF) {
+                                crc = calc_crc(crc, pcrc++, 7, 9);
+                                if(crc == get_shifted_crc(pcrc)) crcptr = pcrc;
+                                if(crcptr == NULL) {
+                                    for(int8_t j = 0; j < (int8_t)dpl - view_log_decode_CRC - 1;
+                                        j++) {
+                                        crc = calc_crc(crc, pcrc++, 6, 8);
+                                        if(crc == get_shifted_crc(pcrc)) {
+                                            crcptr = pcrc;
+                                            break;
+                                        }
+                                    }
+                                }
+                            } else {
+                                for(int8_t j = 0; j < (int8_t)dpl - view_log_decode_CRC; j++) {
+                                    crc = calc_crc(crc, pcrc++, 7, 8);
+                                    if((view_log_decode_CRC == 1 && crc == *pcrc) ||
+                                       (view_log_decode_CRC == 2 &&
+                                        crc == (uint32_t)((*pcrc << 8) | *(pcrc + 1)))) {
+                                        crcptr = pcrc;
+                                        break;
+                                    }
+                                }
+                            }
+                        }
+                    }
+                    ptr += view_log_arr_x;
+                    if(max_width < VIEW_LOG_WIDTH_B) {
+                        pre += snprintf(screen_buf + 1, 10, "%X-", pipe);
+                        if(view_log_decode_PCF) {
+                            pre += snprintf(
+                                screen_buf + strlen(screen_buf),
+                                10,
+                                "%02X%01X-",
+                                *ptr >> 2,
+                                ((*ptr & 3) << 1) | (*(ptr + 1) >> 7));
+                        }
+                    }
+                    if(view_log_decode_PCF)
+                        add_to_str_hex_bytes_shift_9b(screen_buf, (char*)ptr++, count);
+                    else
+                        add_to_str_hex_bytes(screen_buf, (char*)ptr, count);
+                }
+                uint16_t y = 14 + i * 7;
+                canvas_draw_str(canvas, 3 * 5, y, screen_buf);
+                uint16_t x = page + i + 1;
+                if(x > 99) {
+                    snprintf(screen_buf, 16, "%d", x);
+                    canvas_draw_str(canvas, 1, y, screen_buf + 1);
+                    canvas_draw_frame(canvas, 0, y - 2, 1, 2);
+                    x = 2;
+                } else {
+                    x = snprintf(screen_buf, 16, "%d", x);
+                    canvas_draw_str(canvas, 0, y, screen_buf);
+                }
+                if(crcptr) { // 5x7 font, 9 lines
+                    canvas_draw_str(canvas, x * 5, y, "=");
+                    int n = crcptr - (uint8_t*)ptr;
+                    if(n > -view_log_decode_CRC && n < count) {
+                        int len;
+                        x = (4 + pre) * 5;
+                        if(n < 0) {
+                            len = view_log_decode_CRC + n;
+                            n = 0;
+                        } else {
+                            len = MIN(view_log_decode_CRC, count - n);
+                            x += n * 2 * 5;
+                            canvas_draw_line(canvas, x - 1, y, x - 1, y - 1);
+                        }
+                        canvas_draw_line(canvas, x - 1, y, n = x + len * 2 * 5 - 1, y);
+                        canvas_draw_line(canvas, n, y, n, y - 1);
+                    }
+                } else
+                    canvas_draw_str(canvas, x * 5, y, ":");
+            }
+        }
+    } else {
+        canvas_set_font(canvas, FontBatteryPercent); // 5x7 font, 9 lines
+        if(view_found >= 0) {
+            snprintf(screen_buf, 50, "Found > 1: %d", found_total);
+            canvas_draw_str(canvas, 0, 1 * 7, screen_buf);
+            int16_t idx = view_found * 7;
+            for(uint8_t i = 0; i < 7; i++, idx++) {
+                if(idx >= found_total) break;
+                snprintf(screen_buf, 16, "%d. ", idx + 1);
+                add_to_str_hex_bytes(
+                    screen_buf, (char*)APP->found[idx].addr, APP->found[idx].addr_size);
+                if(APP->found[idx].addr_size == 3)
+                    strcat(screen_buf, "    ");
+                else if(APP->found[idx].addr_size == 4)
+                    strcat(screen_buf, "  ");
+                snprintf(screen_buf + strlen(screen_buf), 16, " - %d", APP->found[idx].total);
+                canvas_draw_str(canvas, 0, (2 + i) * 7, screen_buf);
+            }
+        } else {
+            struct ADDRS* a;
+            if(what_to_do == 1) {
+                a = &addrs_sniff;
+                canvas_draw_str(canvas, 0, 1 * 7, "Sniff prefix:");
+            } else {
+                a = &addrs;
+                canvas_draw_str(canvas, 0, 1 * 7, "Addresses:");
+            }
+            if(a->addr_count > 0) {
+                snprintf(screen_buf, sizeof(screen_buf), "P0: ");
+                add_to_str_hex_bytes(screen_buf, (char*)a->addr_P0, a->addr_len);
+                canvas_draw_str(canvas, 0, 2 * 7, screen_buf);
+            }
+            if(a->addr_count > 1) {
+                snprintf(screen_buf, sizeof(screen_buf), "P1: ");
+                add_to_str_hex_bytes(screen_buf, (char*)a->addr_P1, a->addr_len);
+                canvas_draw_str(canvas, 0, 3 * 7, screen_buf);
+            }
+            if(a->addr_count > 2) {
+                canvas_draw_str(canvas, 0, 4 * 7, "P2: ");
+                snprintf(screen_buf, sizeof(screen_buf), "%02X", a->addr_P2);
+                canvas_draw_str(canvas, (4 + (a->addr_len - 1) * 2) * 5, 4 * 7, screen_buf);
+            }
+            if(a->addr_count > 3) {
+                canvas_draw_str(canvas, 0, 5 * 7, "P3: ");
+                snprintf(screen_buf, sizeof(screen_buf), "%02X", a->addr_P3);
+                canvas_draw_str(canvas, (4 + (a->addr_len - 1) * 2) * 5, 5 * 7, screen_buf);
+            }
+            if(a->addr_count > 4) {
+                canvas_draw_str(canvas, 0, 6 * 7, "P4: ");
+                snprintf(screen_buf, sizeof(screen_buf), "%02X", a->addr_P4);
+                canvas_draw_str(canvas, (4 + (a->addr_len - 1) * 2) * 5, 6 * 7, screen_buf);
+            }
+            if(a->addr_count > 5) {
+                canvas_draw_str(canvas, 0, 7 * 7, "P5: ");
+                snprintf(screen_buf, sizeof(screen_buf), "%02X", a->addr_P5);
+                canvas_draw_str(canvas, (4 + (a->addr_len - 1) * 2) * 5, 7 * 7, screen_buf);
+            }
+        }
+        if(log_arr_idx) {
+            uint8_t* ptr = APP->log_arr + view_log_arr_idx * LOG_REC_SIZE;
+            uint8_t pktinfo = *(ptr + 1);
+            snprintf(screen_buf, 32, ">Ch: %d L: %d", *ptr & 0x7F, pktinfo >> 3);
+            if(*ptr & 0x80) {
+                strcat(screen_buf, " RAW");
+                if(pktinfo & 0b100) {
+                    snprintf(
+                        screen_buf + strlen(screen_buf),
+                        16,
+                        " ESB %s",
+                        *(ptr + 2 + (pktinfo & 0b11) + 2) >> 2 != 0x33 ? "DPL" : "");
+                }
+            }
+            canvas_draw_str(canvas, 0, 8 * 7, screen_buf);
+        }
+        screen_buf[0] = 'v';
+        strcpy(screen_buf + 1, VERSION);
+        canvas_draw_str(canvas, 105, 7, screen_buf);
+        if(view_log_decode_PCF || view_log_decode_CRC) {
+            strcpy(screen_buf, "Decode: ");
+            if(view_log_decode_PCF) strcat(screen_buf, "ESB ");
+            if(view_log_decode_CRC == 1)
+                strcat(screen_buf, "CRC1");
+            else if(view_log_decode_CRC == 2)
+                strcat(screen_buf, "CRC2");
+            canvas_draw_str(canvas, 0, 64, screen_buf);
+        }
+    }
+    furi_mutex_release(plugin_state->mutex);
+}
+
+int32_t nrf24scan_app(void* p) {
+    UNUSED(p);
+    APP = malloc(sizeof(Nrf24Scan));
+    APP->event_queue = furi_message_queue_alloc(8, sizeof(PluginEvent));
+    PluginState* plugin_state = malloc(sizeof(PluginState));
+    plugin_state->mutex = furi_mutex_alloc(FuriMutexTypeNormal);
+    if(!plugin_state->mutex) {
+        furi_message_queue_free(APP->event_queue);
+        FURI_LOG_E(TAG, "cannot create mutex");
+        free(plugin_state);
+        return 255;
+    }
+    APP->log_arr = malloc(LOG_REC_SIZE * MAX_LOG_RECORDS);
+    if(APP->log_arr == NULL) {
+        FURI_LOG_E(TAG, "Not enouch memory: %d", LOG_REC_SIZE * MAX_LOG_RECORDS);
+        strcpy(addr_file_name, "MEMORY LOW!");
+    }
+    clear_log();
+    APP->found = malloc(sizeof(struct FOUND) * MAX_FOUND_RECORDS);
+    if(APP->found == NULL) {
+        FURI_LOG_E(TAG, "Not enouch memory: %d", sizeof(struct FOUND) * MAX_FOUND_RECORDS);
+        strcpy(addr_file_name, "MEMORY LOW!!");
+    }
+
+    memset((uint8_t*)&addrs, 0, sizeof(addrs));
+    memset((uint8_t*)&addrs_sniff, 0, sizeof(addrs_sniff));
+    if(!furi_hal_power_is_otg_enabled()) {
+        furi_hal_power_enable_otg();
+        NRF_BOARD_POWER_5V = true;
+        furi_delay_ms(100);
+    }
+    nrf24_init();
+
+    // Set system callbacks
+    APP->view_port = view_port_alloc();
+    view_port_draw_callback_set(APP->view_port, render_callback, plugin_state);
+    view_port_input_callback_set(APP->view_port, input_callback, APP->event_queue);
+
+    // Open GUI and register view_port
+    APP->gui = furi_record_open(RECORD_GUI);
+    gui_add_view_port(APP->gui, APP->view_port, GuiLayerFullscreen);
+    APP->notification = furi_record_open(RECORD_NOTIFICATION);
+    APP->storage = furi_record_open(RECORD_STORAGE);
+    storage_common_mkdir(APP->storage, SCAN_APP_PATH_FOLDER);
+    Stream* file_stream = file_stream_alloc(APP->storage);
+    FuriString* path = furi_string_alloc();
+    furi_string_set(path, SCAN_APP_PATH_FOLDER);
+    furi_string_cat(path, "/");
+    furi_string_cat(path, SNIFF_FILENAME);
+    if(file_stream_open(file_stream, furi_string_get_cstr(path), FSAM_READ, FSOM_OPEN_EXISTING)) {
+        uint8_t err = load_settings_file(file_stream);
+        if(!err)
+            strncpy(
+                addr_file_name,
+                furi_string_get_cstr(path) + sizeof(SCAN_APP_PATH_FOLDER),
+                sizeof(addr_file_name));
+        else
+            snprintf(addr_file_name, sizeof(addr_file_name), "LOAD ERROR#%d", err);
+    } else {
+        strcpy(addr_file_name, "NONE");
+        if(what_to_do == 1) {
+            addrs.addr_P0[0] = 0;
+            addrs.addr_P0[1] = 0x55;
+            addrs.addr_len = 2;
+            addrs.addr_count = 1;
+            view_log_decode_CRC = NRF_CRC = 2;
+            NRF_Payload_sniff_min = 0; // Min
+        }
+    }
+    file_stream_close(file_stream);
+    stream_free(file_stream);
+    furi_string_free(path);
+
+    PluginEvent event;
+    for(bool processing = true; processing;) {
+        FuriStatus event_status = furi_message_queue_get(APP->event_queue, &event, 100);
+        furi_mutex_acquire(plugin_state->mutex, FuriWaitForever);
+
+        if(event_status == FuriStatusOk) {
+            // press events
+            if(event.type == EventTypeKey) {
+                //FURI_LOG_D(TAG, "Key: %d Type: %d Sec: %u", event.input.key, event.input.type, event.input.sequence);
+                switch(event.input.key) {
+                case InputKeyUp:
+                    if(event.input.type == InputTypeShort || event.input.type == InputTypeRepeat) {
+                        if(what_doing == 0) {
+                            if(menu_selected > 0)
+                                menu_selected--;
+                            else
+                                menu_selected = menu_selected_max;
+                        } else if(what_doing == 1) {
+                            view_log_arr_idx -= event.input.type == InputTypeRepeat ? 10 : 1;
+                            if(view_log_arr_idx >= log_arr_idx) view_log_arr_idx = 0;
+                        } else if(what_doing == 2) {
+                            if(view_found > -1) view_found--;
+                        }
+                    }
+                    break;
+                case InputKeyDown:
+                    if(event.input.type == InputTypeShort || event.input.type == InputTypeRepeat) {
+                        if(what_doing == 0) {
+                            if(menu_selected < menu_selected_max)
+                                menu_selected++;
+                            else
+                                menu_selected = 0;
+                        } else if(what_doing == 1) {
+                            if(log_arr_idx == 0)
+                                view_log_arr_idx = 0;
+                            else {
+                                view_log_arr_idx += event.input.type == InputTypeRepeat ? 10 : 1;
+                                if(view_log_arr_idx >= log_arr_idx)
+                                    view_log_arr_idx = log_arr_idx - 1;
+                            }
+                        } else if(what_doing == 2) {
+                            if(view_found < found_total / 7) view_found++;
+                        }
+                    }
+                    break;
+                case InputKeyLeft:
+                    if(event.input.type == InputTypeShort || event.input.type == InputTypeRepeat) {
+                        if(what_doing == 0) {
+                            switch(menu_selected) {
+                            case Menu_enter_channel:
+                                NRF_channel -= event.input.type == InputTypeRepeat ? 10 : 1;
+                                if(NRF_channel > MAX_CHANNEL) NRF_channel = MAX_CHANNEL;
+                                break;
+                            case Menu_enter_rate:
+                                if(what_to_do == 1) { // SNIFF
+                                    NRF_Payload_sniff_min -=
+                                        event.input.type == InputTypeRepeat ? 10 : 1;
+                                    correct_NRF_Payload_sniff_min();
+                                } else {
+                                    NRF_Payload -= event.input.type == InputTypeRepeat ? 10 : 1;
+                                    if(NRF_Payload > 32) NRF_Payload = 0;
+                                }
+                                break;
+                            case Menu_enter_scan_period:
+                                find_channel_period -= event.input.type == InputTypeRepeat ? 10 :
+                                                                                             1;
+                                if(find_channel_period < 0) find_channel_period = 0;
+                                break;
+                            case Menu_log:
+                                if(--log_to_file < -1) log_to_file = 2;
+                                break;
+                            case Menu_ok:
+                                if(--what_to_do > 3) what_to_do = 3;
+                                break;
+                            }
+                        } else if(what_doing == 1) {
+                            if(view_log_arr_x > 0) view_log_arr_x--;
+                        } else if(what_doing == 2) {
+                            //if(NRF_ESB == 0)
+                            view_log_decode_PCF ^= 1;
+                        }
+                    }
+                    break;
+                case InputKeyRight:
+                    if(event.input.type == InputTypeShort || event.input.type == InputTypeRepeat) {
+                        if(what_doing == 0) {
+                            switch(menu_selected) {
+                            case Menu_open_file:
+                                save_settings ^= 1;
+                                break;
+                            case Menu_enter_channel:
+                                NRF_channel += event.input.type == InputTypeRepeat ? 10 : 1;
+                                if(NRF_channel > MAX_CHANNEL) NRF_channel = 0;
+                                break;
+                            case Menu_enter_rate:
+                                if(what_to_do == 1) { // SNIFF
+                                    NRF_Payload_sniff_min +=
+                                        event.input.type == InputTypeRepeat ? 10 : 1;
+                                    correct_NRF_Payload_sniff_min();
+                                } else {
+                                    NRF_Payload += event.input.type == InputTypeRepeat ? 10 : 1;
+                                    if(NRF_Payload > 32) NRF_Payload = 32;
+                                }
+                                break;
+                            case Menu_enter_scan_period:
+                                find_channel_period += event.input.type == InputTypeRepeat ? 10 :
+                                                                                             1;
+                                break;
+                            case Menu_log:
+                                if(++log_to_file > 2) log_to_file = -1;
+                                break;
+                            case Menu_ok:
+                                if(++what_to_do > 3) what_to_do = 0;
+                                break;
+                            }
+                        } else if(what_doing == 1) {
+                            if(view_log_arr_x < VIEW_LOG_MAX_X) view_log_arr_x++;
+                        } else if(what_doing == 2) {
+                            if(++view_log_decode_CRC > 2) view_log_decode_CRC = 0;
+                        }
+                    }
+                    break;
+                case InputKeyOk:
+                    if(event.input.type == InputTypeShort) {
+                        if(what_doing == 0) {
+                            switch(menu_selected) {
+                            case Menu_open_file:
+                                if(save_settings) {
+                                    write_to_log_file(APP->storage, true);
+                                } else {
+                                    file_stream = file_stream_alloc(APP->storage);
+                                    if(select_settings_file(file_stream)) {
+                                        uint8_t err = load_settings_file(file_stream);
+                                        if(!err)
+                                            save_to_new_log = true;
+                                        else
+                                            snprintf(
+                                                addr_file_name,
+                                                sizeof(addr_file_name),
+                                                "LOAD ERROR#%d",
+                                                err);
+                                        file_stream_close(file_stream);
+                                        menu_selected = Menu_ok;
+                                    }
+                                    stream_free(file_stream);
+                                }
+                                break;
+                            case Menu_enter_channel:
+                                if(what_to_do == 1) {
+                                    if(NRF_ESB)
+                                        NRF_DPL = NRF_ESB = 0;
+                                    else
+                                        NRF_ESB = 1;
+                                } else {
+                                    if(NRF_ESB) {
+                                        if(NRF_DPL)
+                                            NRF_DPL = NRF_ESB = 0;
+                                        else
+                                            NRF_DPL = 1;
+                                    } else
+                                        NRF_ESB = 1;
+                                }
+                                break;
+                            case Menu_enter_rate:
+                                NRF_rate++;
+                                if(NRF_rate > 2) NRF_rate = 0;
+                                break;
+                            case Menu_enter_scan_period:
+                                if(++NRF_CRC > 2) NRF_CRC = what_to_do == 1 ? 1 : 0;
+                                break;
+                            case Menu_ok:
+                                if(what_to_do) {
+                                    if((addrs.addr_count ||
+                                        (what_to_do >= 2 && log_arr_idx &&
+                                         *(APP->log_arr + view_log_arr_idx * LOG_REC_SIZE) &
+                                             0x80)) ||
+                                       what_to_do == 1) {
+                                        if(log_to_file == -1) {
+                                            log_to_file = 0;
+                                            clear_log();
+                                            save_to_new_log = true;
+                                        } else if(log_to_file == 1)
+                                            save_to_new_log = true;
+                                        start_scanning();
+                                        if(!NRF_ERROR) what_doing = 1;
+                                    }
+                                } else
+                                    what_doing = 1;
+                                break;
+                            }
+                        } else if(what_doing == 1) {
+                            what_doing = 2;
+                        } else if(what_doing == 2) {
+                            what_doing = 1;
+                        }
+                    } else if(event.input.type == InputTypeLong) {
+                        if(what_doing == 0) {
+                            if(menu_selected == Menu_enter_channel) {
+                                NRF_AA_OFF ^= 1;
+                            } else if(menu_selected == Menu_log) { // Log
+                                if(log_arr_idx && (log_to_file == 1 || log_to_file == 2)) {
+                                    write_to_log_file(APP->storage, false);
+                                    clear_log();
+                                }
+                            }
+                        } else if(what_doing == 1 || what_doing == 2) {
+                            nrf24_send_packet();
+                        }
+                    }
+                    break;
+                case InputKeyBack:
+                    if(event.input.type == InputTypeLong)
+                        processing = false;
+                    else if(event.input.type == InputTypeShort) {
+                        if(what_doing) what_doing--;
+                        if(what_doing == 0) {
+                            nrf24_set_idle(nrf24_HANDLE);
+                        }
+                    }
+                    break;
+                default:
+                    break;
+                }
+            }
+        }
+        if(what_doing && what_to_do) {
+            nrf24_read_newpacket();
+            if(find_channel_period &&
+               furi_get_tick() - start_time >= (uint32_t)find_channel_period * 1000UL) {
+                if(++NRF_channel > MAX_CHANNEL) NRF_channel = 0;
+                start_scanning();
+            }
+        }
+
+        furi_mutex_release(plugin_state->mutex);
+        view_port_update(APP->view_port);
+    }
+    nrf24_set_idle(nrf24_HANDLE);
+    if(log_arr_idx && (log_to_file == 1 || log_to_file == 2)) {
+        write_to_log_file(APP->storage, false);
+    }
+    nrf24_deinit();
+    if(NRF_BOARD_POWER_5V) furi_hal_power_disable_otg();
+
+    view_port_enabled_set(APP->view_port, false);
+    gui_remove_view_port(APP->gui, APP->view_port);
+    furi_record_close(RECORD_GUI);
+    furi_record_close(RECORD_NOTIFICATION);
+    furi_record_close(RECORD_STORAGE);
+    view_port_free(APP->view_port);
+    furi_message_queue_free(APP->event_queue);
+    if(APP->log_arr) free(APP->log_arr);
+    if(APP->found) free(APP->found);
+    furi_mutex_free(plugin_state->mutex);
+    free(plugin_state);
+    free(APP);
+    return 0;
+}

+ 39 - 0
nrf24scan/nrf24scan.h

@@ -0,0 +1,39 @@
+#pragma once
+
+#include <gui/gui.h>
+#include <gui/view.h>
+#include <gui/view_dispatcher.h>
+#include <gui/modules/submenu.h>
+#include <gui/modules/dialog_ex.h>
+#include <toolbox/stream/file_stream.h>
+#include <notification/notification_messages.h>
+
+typedef enum {
+    EventTypeTick,
+    EventTypeKey,
+} EventType;
+
+typedef struct {
+    EventType type;
+    InputEvent input;
+} PluginEvent;
+
+typedef struct {
+    FuriMutex* mutex;
+} PluginState;
+
+struct FOUND {
+    uint8_t addr_size;
+    uint8_t addr[5];
+    uint16_t total;
+};
+
+typedef struct {
+    Gui* gui;
+    FuriMessageQueue* event_queue;
+    ViewPort* view_port;
+    Storage* storage;
+    NotificationApp* notification;
+    uint8_t* log_arr;
+    struct FOUND* found;
+} Nrf24Scan;

BIN
nrf24scan/nrf24scan_10px.png


BIN
nrf24scan/scheme.png


BIN
nrf24scan/scheme2.png