Finish NNNet app shell, updates, and docs
This commit is contained in:
502
LICENSE
Normal file
502
LICENSE
Normal file
@@ -0,0 +1,502 @@
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
26
README.md
26
README.md
@@ -1,4 +1,4 @@
|
||||
# School BLE Mesh Messenger
|
||||
# NNNet
|
||||
|
||||
Проект для школьного офлайн-месседжера на базе **BLE P2P mesh-сети**.
|
||||
|
||||
@@ -8,6 +8,14 @@
|
||||
- работа в условиях отсутствия Wi-Fi/мобильной сети;
|
||||
- безопасное взаимодействие с базовой модерацией.
|
||||
|
||||
## Текущее состояние
|
||||
- BLE discovery + advertising работают.
|
||||
- Реализован минимальный GATT transport для обмена mesh-пакетами.
|
||||
- Есть foreground service, Room-хранилище, ACK/retry очередь и базовый Telegram-подобный UI.
|
||||
- Реализованы список чатов, окно диалога, вкладка настроек, ручная проверка обновлений и опциональная автопроверка через `version.json`.
|
||||
- При выключенном Bluetooth приложение запрашивает его включение перед запуском mesh.
|
||||
- Публикация APK и сайта автоматизирована через `Makefile`.
|
||||
|
||||
## Стек
|
||||
- Android приложение: **Kotlin**
|
||||
- Сборка: **Gradle** + `Gradle Wrapper`
|
||||
@@ -34,12 +42,12 @@
|
||||
|
||||
3. **Messaging Layer**
|
||||
- личные сообщения;
|
||||
- групповые чаты (класс/учителя);
|
||||
- список чатов и окно диалога;
|
||||
- статусы доставки (queued/sent/relayed/delivered).
|
||||
|
||||
4. **Data Layer**
|
||||
- локальное хранилище (Room);
|
||||
- кэш пользователей, чатов, сообщений, ключей.
|
||||
- история сообщений и очередь исходящей доставки.
|
||||
|
||||
5. **Security Layer**
|
||||
- идентификация пользователя;
|
||||
@@ -66,12 +74,13 @@
|
||||
- [x] Описать формат сетевого пакета (черновой JSON codec + модель пакета).
|
||||
- [x] Реализовать базовый BLE bootstrap (scanner + advertiser + runtime permissions).
|
||||
- [x] Реализовать минимальный GATT-обмен между BLE-узлами.
|
||||
- [ ] Реализовать очередь отправки + ретраи + ACK timeout.
|
||||
- [x] Реализовать очередь отправки + ретраи + ACK timeout.
|
||||
- [x] Добавить защиту от дубликатов по `messageId` (in-memory cache, базово).
|
||||
- [x] Реализовать mesh-forwarding с ограничением TTL (routing action layer, базово).
|
||||
- [ ] Добавить UI для списка чатов и окна сообщений.
|
||||
- [ ] Подключить Room и миграции схемы.
|
||||
- [x] Добавить список чатов и базовый UI окна сообщений.
|
||||
- [x] Подключить Room и базовую схему хранения.
|
||||
- [x] Добавить логирование сети и debug-экран маршрутов.
|
||||
- [x] Добавить ручную проверку обновлений и опциональную автопроверку клиента.
|
||||
- [ ] Реализовать базовую регистрацию пользователя (локальный профиль).
|
||||
- [ ] Добавить шифрование полезной нагрузки сообщений.
|
||||
- [ ] Написать инструментальные тесты BLE-обмена.
|
||||
@@ -91,5 +100,8 @@
|
||||
- `make publish` — увеличить версию, собрать APK, опубликовать клиент и перезагрузить `nginx`.
|
||||
- `make server-start|server-stop|server-restart|server-status|server-rebuild` — управление `nginx`.
|
||||
|
||||
## Лицензия
|
||||
Проект использует лицензию `GPL-3.0`. См. [LICENSE](/home/dom4k/nnnet/LICENSE).
|
||||
|
||||
## Ближайший следующий шаг
|
||||
Добавить очередь отправки, ACK timeout/retry и локальное хранение сообщений через Room.
|
||||
Добавить профили пользователей, шифрование payload и инструментальные тесты BLE-обмена между несколькими устройствами.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
plugins {
|
||||
id("com.android.application")
|
||||
id("org.jetbrains.kotlin.android")
|
||||
id("org.jetbrains.kotlin.kapt")
|
||||
}
|
||||
|
||||
android {
|
||||
@@ -41,4 +42,9 @@ dependencies {
|
||||
implementation("androidx.appcompat:appcompat:1.7.0")
|
||||
implementation("com.google.android.material:material:1.12.0")
|
||||
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
|
||||
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.3")
|
||||
implementation("androidx.room:room-runtime:2.6.1")
|
||||
implementation("androidx.room:room-ktx:2.6.1")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.1")
|
||||
kapt("androidx.room:room-compiler:2.6.1")
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CONNECTED_DEVICE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
|
||||
@@ -1,28 +1,73 @@
|
||||
package com.schoolmesh.messenger
|
||||
|
||||
import android.Manifest
|
||||
import android.bluetooth.BluetoothAdapter
|
||||
import android.bluetooth.BluetoothManager
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.widget.ArrayAdapter
|
||||
import android.widget.Button
|
||||
import android.widget.EditText
|
||||
import android.widget.ListView
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.google.android.material.switchmaterial.SwitchMaterial
|
||||
import com.schoolmesh.messenger.data.ChatSummary
|
||||
import com.schoolmesh.messenger.data.MeshDatabase
|
||||
import com.schoolmesh.messenger.data.MeshRepository
|
||||
import com.schoolmesh.messenger.mesh.MeshForegroundService
|
||||
import com.schoolmesh.messenger.mesh.MeshServiceContract
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.json.JSONObject
|
||||
import java.net.HttpURLConnection
|
||||
import java.net.URL
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.ArrayDeque
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
private lateinit var repository: MeshRepository
|
||||
private lateinit var statusText: TextView
|
||||
private lateinit var peersText: TextView
|
||||
private lateinit var logsText: TextView
|
||||
private lateinit var activeChatTitle: TextView
|
||||
private lateinit var targetInput: EditText
|
||||
private lateinit var messageInput: EditText
|
||||
private lateinit var chatListView: ListView
|
||||
private lateinit var messageListView: ListView
|
||||
private lateinit var chatsScreen: android.view.View
|
||||
private lateinit var settingsScreen: android.view.View
|
||||
private lateinit var autoUpdateSwitch: SwitchMaterial
|
||||
|
||||
private val peers = linkedSetOf<String>()
|
||||
private val logs = ArrayDeque<String>()
|
||||
private val chatSummaries = mutableListOf<ChatSummary>()
|
||||
private val chatItems = mutableListOf<String>()
|
||||
private val messageItems = mutableListOf<String>()
|
||||
|
||||
private lateinit var chatAdapter: ArrayAdapter<String>
|
||||
private lateinit var messageAdapter: ArrayAdapter<String>
|
||||
|
||||
private var activePeerId: String? = null
|
||||
private var pendingSend: PendingSend? = null
|
||||
private var pendingStartRequested = false
|
||||
|
||||
private val prefs by lazy {
|
||||
getSharedPreferences("nnnet_settings", Context.MODE_PRIVATE)
|
||||
}
|
||||
|
||||
private val meshEventReceiver = object : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context?, intent: Intent?) {
|
||||
@@ -34,6 +79,10 @@ class MainActivity : AppCompatActivity() {
|
||||
MeshServiceContract.EVENT_STATUS -> updateStatus(value)
|
||||
MeshServiceContract.EVENT_PEER -> addPeer(value)
|
||||
MeshServiceContract.EVENT_LOG -> appendLog(value)
|
||||
MeshServiceContract.EVENT_MESSAGES_CHANGED -> {
|
||||
refreshChats()
|
||||
refreshMessages()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,11 +92,23 @@ class MainActivity : AppCompatActivity() {
|
||||
) { result ->
|
||||
val allGranted = result.values.all { it }
|
||||
if (allGranted) {
|
||||
startMesh()
|
||||
ensureBluetoothEnabledAndContinue()
|
||||
} else {
|
||||
updateStatus("Нет BLE-разрешений")
|
||||
appendLog("Permissions denied by user")
|
||||
Toast.makeText(this, "Разрешения отклонены", Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(this, "Permissions denied", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
|
||||
private val enableBluetoothLauncher = registerForActivityResult(
|
||||
ActivityResultContracts.StartActivityForResult()
|
||||
) {
|
||||
if (bluetoothAdapter()?.isEnabled == true) {
|
||||
continueAfterBluetoothReady()
|
||||
} else {
|
||||
updateStatus("Bluetooth is disabled")
|
||||
appendLog("Bluetooth enable request denied")
|
||||
Toast.makeText(this, "Bluetooth is required", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,26 +116,72 @@ class MainActivity : AppCompatActivity() {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
|
||||
val database = MeshDatabase.getInstance(applicationContext)
|
||||
repository = MeshRepository(database.messageDao(), database.outboundQueueDao())
|
||||
|
||||
statusText = findViewById(R.id.statusText)
|
||||
peersText = findViewById(R.id.peersText)
|
||||
logsText = findViewById(R.id.logsText)
|
||||
activeChatTitle = findViewById(R.id.activeChatTitle)
|
||||
targetInput = findViewById(R.id.targetInput)
|
||||
messageInput = findViewById(R.id.messageInput)
|
||||
chatListView = findViewById(R.id.chatListView)
|
||||
messageListView = findViewById(R.id.messageListView)
|
||||
chatsScreen = findViewById(R.id.chatsScreen)
|
||||
settingsScreen = findViewById(R.id.settingsScreen)
|
||||
autoUpdateSwitch = findViewById(R.id.autoUpdateSwitch)
|
||||
|
||||
chatAdapter = ArrayAdapter(this, android.R.layout.simple_list_item_1, chatItems)
|
||||
messageAdapter = ArrayAdapter(this, android.R.layout.simple_list_item_1, messageItems)
|
||||
chatListView.adapter = chatAdapter
|
||||
messageListView.adapter = messageAdapter
|
||||
|
||||
findViewById<Button>(R.id.btnTabChats).setOnClickListener { showChats() }
|
||||
findViewById<Button>(R.id.btnTabSettings).setOnClickListener { showSettings() }
|
||||
findViewById<Button>(R.id.btnStartMesh).setOnClickListener {
|
||||
ensurePermissionsAndStart()
|
||||
pendingStartRequested = true
|
||||
ensurePermissionsAndMaybeStart()
|
||||
}
|
||||
findViewById<Button>(R.id.btnStopMesh).setOnClickListener {
|
||||
MeshForegroundService.stop(this)
|
||||
updateStatus("Mesh остановлен")
|
||||
updateStatus("Mesh stopped")
|
||||
appendLog("Mesh service stop requested")
|
||||
}
|
||||
findViewById<Button>(R.id.btnSendMessage).setOnClickListener {
|
||||
enqueueMessageFromUi()
|
||||
}
|
||||
findViewById<Button>(R.id.btnCheckUpdates).setOnClickListener {
|
||||
checkForUpdates(manual = true)
|
||||
}
|
||||
|
||||
chatListView.setOnItemClickListener { _, _, position, _ ->
|
||||
val chat = chatSummaries[position]
|
||||
activePeerId = chat.peerId
|
||||
targetInput.setText(chat.peerId)
|
||||
activeChatTitle.text = chat.peerId
|
||||
refreshMessages()
|
||||
}
|
||||
|
||||
autoUpdateSwitch.isChecked = prefs.getBoolean(KEY_AUTO_UPDATE, false)
|
||||
autoUpdateSwitch.setOnCheckedChangeListener { _, isChecked ->
|
||||
prefs.edit().putBoolean(KEY_AUTO_UPDATE, isChecked).apply()
|
||||
appendLog("Auto update set to $isChecked")
|
||||
}
|
||||
|
||||
renderPeers()
|
||||
renderLogs()
|
||||
refreshChats()
|
||||
refreshMessages()
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
registerMeshReceiver()
|
||||
refreshChats()
|
||||
refreshMessages()
|
||||
if (autoUpdateSwitch.isChecked) {
|
||||
checkForUpdates(manual = false)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
@@ -82,6 +189,16 @@ class MainActivity : AppCompatActivity() {
|
||||
super.onStop()
|
||||
}
|
||||
|
||||
private fun showChats() {
|
||||
chatsScreen.visibility = android.view.View.VISIBLE
|
||||
settingsScreen.visibility = android.view.View.GONE
|
||||
}
|
||||
|
||||
private fun showSettings() {
|
||||
chatsScreen.visibility = android.view.View.GONE
|
||||
settingsScreen.visibility = android.view.View.VISIBLE
|
||||
}
|
||||
|
||||
private fun registerMeshReceiver() {
|
||||
val filter = IntentFilter(MeshServiceContract.ACTION_EVENT)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
@@ -92,17 +209,63 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun ensurePermissionsAndStart() {
|
||||
private fun enqueueMessageFromUi() {
|
||||
val targetId = targetInput.text.toString().trim()
|
||||
val body = messageInput.text.toString().trim()
|
||||
if (targetId.isEmpty() || body.isEmpty()) {
|
||||
Toast.makeText(this, "Target and message are required", Toast.LENGTH_SHORT).show()
|
||||
return
|
||||
}
|
||||
|
||||
pendingSend = PendingSend(targetId, body)
|
||||
pendingStartRequested = true
|
||||
ensurePermissionsAndMaybeStart()
|
||||
appendLog("Message queued for $targetId")
|
||||
messageInput.text?.clear()
|
||||
}
|
||||
|
||||
private fun ensurePermissionsAndMaybeStart() {
|
||||
val missing = requiredPermissions().filter { permission ->
|
||||
ContextCompat.checkSelfPermission(this, permission) != android.content.pm.PackageManager.PERMISSION_GRANTED
|
||||
}
|
||||
if (missing.isEmpty()) {
|
||||
startMesh()
|
||||
ensureBluetoothEnabledAndContinue()
|
||||
} else {
|
||||
permissionLauncher.launch(missing.toTypedArray())
|
||||
}
|
||||
}
|
||||
|
||||
private fun ensureBluetoothEnabledAndContinue() {
|
||||
val adapter = bluetoothAdapter()
|
||||
if (adapter == null) {
|
||||
updateStatus("Bluetooth adapter unavailable")
|
||||
appendLog("Bluetooth adapter unavailable")
|
||||
return
|
||||
}
|
||||
if (adapter.isEnabled) {
|
||||
continueAfterBluetoothReady()
|
||||
} else {
|
||||
val enableIntent = Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE)
|
||||
enableBluetoothLauncher.launch(enableIntent)
|
||||
}
|
||||
}
|
||||
|
||||
private fun continueAfterBluetoothReady() {
|
||||
if (pendingStartRequested) {
|
||||
startMesh()
|
||||
pendingStartRequested = false
|
||||
}
|
||||
pendingSend?.let {
|
||||
activePeerId = it.targetId
|
||||
targetInput.setText(it.targetId)
|
||||
activeChatTitle.text = it.targetId
|
||||
MeshForegroundService.sendMessage(this, it.targetId, it.body)
|
||||
pendingSend = null
|
||||
}
|
||||
refreshChats()
|
||||
refreshMessages()
|
||||
}
|
||||
|
||||
private fun requiredPermissions(): List<String> {
|
||||
val permissions = mutableListOf<String>()
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
@@ -120,9 +283,151 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
private fun startMesh() {
|
||||
MeshForegroundService.start(this)
|
||||
updateStatus("Запуск foreground service")
|
||||
updateStatus("Foreground service starting")
|
||||
appendLog("Mesh service start requested")
|
||||
Toast.makeText(this, "Mesh запускается", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
private fun bluetoothAdapter(): BluetoothAdapter? {
|
||||
val manager = getSystemService(BluetoothManager::class.java)
|
||||
return manager?.adapter
|
||||
}
|
||||
|
||||
private fun refreshChats() {
|
||||
lifecycleScope.launch {
|
||||
val chats = repository.chatSummaries()
|
||||
chatSummaries.clear()
|
||||
chatSummaries.addAll(chats)
|
||||
chatItems.clear()
|
||||
chatItems.addAll(
|
||||
chats.map { chat ->
|
||||
val time = timestampFormatter.format(Date(chat.lastTimestamp))
|
||||
"${chat.peerId}\n${chat.lastBody}\n$time · ${chat.lastStatus}"
|
||||
}
|
||||
)
|
||||
chatAdapter.notifyDataSetChanged()
|
||||
if (activePeerId == null && chats.isNotEmpty()) {
|
||||
activePeerId = chats.first().peerId
|
||||
targetInput.setText(activePeerId)
|
||||
activeChatTitle.text = activePeerId
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun refreshMessages() {
|
||||
val peerId = activePeerId ?: targetInput.text.toString().trim()
|
||||
if (peerId.isEmpty()) {
|
||||
messageItems.clear()
|
||||
messageItems.add("Select a chat or enter a peer id")
|
||||
messageAdapter.notifyDataSetChanged()
|
||||
return
|
||||
}
|
||||
|
||||
lifecycleScope.launch {
|
||||
val messages = repository.messagesForPeer(peerId)
|
||||
messageItems.clear()
|
||||
if (messages.isEmpty()) {
|
||||
messageItems.add("No messages with $peerId yet")
|
||||
} else {
|
||||
messageItems.addAll(
|
||||
messages
|
||||
.asReversed()
|
||||
.map { message ->
|
||||
val time = timestampFormatter.format(Date(message.createdAt))
|
||||
val bubble = if (message.direction == MeshRepository.DIRECTION_OUTGOING) "You" else message.senderId
|
||||
"[$time] $bubble\n${message.body}\n${message.status}"
|
||||
}
|
||||
)
|
||||
}
|
||||
messageAdapter.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkForUpdates(manual: Boolean) {
|
||||
lifecycleScope.launch {
|
||||
val updateInfo = withContext(Dispatchers.IO) {
|
||||
runCatching {
|
||||
val connection = URL(UPDATE_METADATA_URL).openConnection() as HttpURLConnection
|
||||
connection.connectTimeout = 5_000
|
||||
connection.readTimeout = 5_000
|
||||
connection.inputStream.bufferedReader().use { reader ->
|
||||
val json = JSONObject(reader.readText())
|
||||
UpdateInfo(
|
||||
versionCode = json.getInt("versionCode"),
|
||||
versionName = json.getString("versionName"),
|
||||
apkPath = json.getString("apkPath"),
|
||||
releaseNotesTitle = json.optString("releaseNotesTitle", "Что нового"),
|
||||
releaseNotesPath = json.optString("releaseNotesPath", "")
|
||||
)
|
||||
}
|
||||
}.getOrNull()
|
||||
}
|
||||
|
||||
if (updateInfo == null) {
|
||||
if (manual) {
|
||||
Toast.makeText(this@MainActivity, "Failed to check updates", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
appendLog("Update check failed")
|
||||
return@launch
|
||||
}
|
||||
|
||||
if (updateInfo.versionCode > currentVersionCode()) {
|
||||
appendLog("Update found: ${updateInfo.versionName}")
|
||||
showUpdateDialog(updateInfo)
|
||||
} else if (manual) {
|
||||
Toast.makeText(this@MainActivity, "You already have the latest version", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showUpdateDialog(updateInfo: UpdateInfo) {
|
||||
lifecycleScope.launch {
|
||||
val releaseNotes = withContext(Dispatchers.IO) {
|
||||
fetchReleaseNotes(updateInfo.releaseNotesPath)
|
||||
}
|
||||
|
||||
AlertDialog.Builder(this@MainActivity)
|
||||
.setTitle(updateInfo.releaseNotesTitle)
|
||||
.setMessage(
|
||||
buildString {
|
||||
append("Version ${updateInfo.versionName} is available.")
|
||||
if (!releaseNotes.isNullOrBlank()) {
|
||||
append("\n\n")
|
||||
append(releaseNotes.trim())
|
||||
}
|
||||
}
|
||||
)
|
||||
.setPositiveButton("Open download") { _, _ ->
|
||||
val url = if (updateInfo.apkPath.startsWith("http")) {
|
||||
updateInfo.apkPath
|
||||
} else {
|
||||
"$UPDATE_BASE_URL/${updateInfo.apkPath.trimStart('/')}"
|
||||
}
|
||||
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url)))
|
||||
}
|
||||
.setNegativeButton("Later", null)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
|
||||
private fun fetchReleaseNotes(path: String): String? {
|
||||
if (path.isBlank()) return null
|
||||
val url = if (path.startsWith("http")) path else "$UPDATE_BASE_URL/${path.trimStart('/')}"
|
||||
return runCatching {
|
||||
val connection = URL(url).openConnection() as HttpURLConnection
|
||||
connection.connectTimeout = 5_000
|
||||
connection.readTimeout = 5_000
|
||||
connection.inputStream.bufferedReader().use { it.readText() }
|
||||
}.getOrNull()
|
||||
}
|
||||
|
||||
private fun currentVersionCode(): Int {
|
||||
val packageInfo = packageManager.getPackageInfo(packageName, 0)
|
||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
packageInfo.longVersionCode.toInt()
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
packageInfo.versionCode
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateStatus(text: String) {
|
||||
@@ -145,21 +450,38 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
private fun renderPeers() {
|
||||
peersText.text = if (peers.isEmpty()) {
|
||||
"Узлы не найдены"
|
||||
"Nearby peers will appear here"
|
||||
} else {
|
||||
peers.joinToString(separator = "\n")
|
||||
"Peers online: ${peers.joinToString(separator = ", ")}"
|
||||
}
|
||||
}
|
||||
|
||||
private fun renderLogs() {
|
||||
logsText.text = if (logs.isEmpty()) {
|
||||
"Лог пуст"
|
||||
"Log is empty"
|
||||
} else {
|
||||
logs.joinToString(separator = "\n")
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val MAX_LOG_ENTRIES = 20
|
||||
private const val KEY_AUTO_UPDATE = "auto_update"
|
||||
private const val MAX_LOG_ENTRIES = 30
|
||||
private const val UPDATE_BASE_URL = "https://net.nnn-team.pro"
|
||||
private const val UPDATE_METADATA_URL = "$UPDATE_BASE_URL/assets/meta/version.json"
|
||||
private val timestampFormatter = SimpleDateFormat("HH:mm", Locale.US)
|
||||
}
|
||||
|
||||
private data class PendingSend(
|
||||
val targetId: String,
|
||||
val body: String
|
||||
)
|
||||
|
||||
private data class UpdateInfo(
|
||||
val versionCode: Int,
|
||||
val versionName: String,
|
||||
val apkPath: String,
|
||||
val releaseNotesTitle: String,
|
||||
val releaseNotesPath: String
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.schoolmesh.messenger.data
|
||||
|
||||
data class ChatSummary(
|
||||
val peerId: String,
|
||||
val lastBody: String,
|
||||
val lastStatus: String,
|
||||
val lastTimestamp: Long,
|
||||
val unreadCount: Int
|
||||
)
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.schoolmesh.messenger.data
|
||||
|
||||
import android.content.Context
|
||||
import androidx.room.Database
|
||||
import androidx.room.Room
|
||||
import androidx.room.RoomDatabase
|
||||
|
||||
@Database(
|
||||
entities = [MessageEntity::class, OutboundQueueEntity::class],
|
||||
version = 1,
|
||||
exportSchema = false
|
||||
)
|
||||
abstract class MeshDatabase : RoomDatabase() {
|
||||
abstract fun messageDao(): MessageDao
|
||||
abstract fun outboundQueueDao(): OutboundQueueDao
|
||||
|
||||
companion object {
|
||||
@Volatile
|
||||
private var instance: MeshDatabase? = null
|
||||
|
||||
fun getInstance(context: Context): MeshDatabase {
|
||||
return instance ?: synchronized(this) {
|
||||
instance ?: Room.databaseBuilder(
|
||||
context.applicationContext,
|
||||
MeshDatabase::class.java,
|
||||
"mesh.db"
|
||||
).build().also { instance = it }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.schoolmesh.messenger.data
|
||||
|
||||
import com.schoolmesh.messenger.mesh.MeshPacket
|
||||
import com.schoolmesh.messenger.mesh.PacketType
|
||||
import java.util.UUID
|
||||
|
||||
class MeshRepository(
|
||||
private val messageDao: MessageDao,
|
||||
private val queueDao: OutboundQueueDao
|
||||
) {
|
||||
suspend fun enqueueOutgoingMessage(
|
||||
senderId: String,
|
||||
targetId: String,
|
||||
body: String,
|
||||
now: Long = System.currentTimeMillis()
|
||||
): String {
|
||||
val messageId = UUID.randomUUID().toString()
|
||||
messageDao.upsert(
|
||||
MessageEntity(
|
||||
messageId = messageId,
|
||||
senderId = senderId,
|
||||
targetId = targetId,
|
||||
body = body,
|
||||
packetType = PacketType.MESSAGE.name,
|
||||
direction = DIRECTION_OUTGOING,
|
||||
status = STATUS_QUEUED,
|
||||
createdAt = now,
|
||||
updatedAt = now
|
||||
)
|
||||
)
|
||||
queueDao.upsert(
|
||||
OutboundQueueEntity(
|
||||
messageId = messageId,
|
||||
targetId = targetId,
|
||||
body = body,
|
||||
nextAttemptAt = now,
|
||||
attemptCount = 0,
|
||||
maxAttempts = DEFAULT_MAX_ATTEMPTS,
|
||||
createdAt = now
|
||||
)
|
||||
)
|
||||
return messageId
|
||||
}
|
||||
|
||||
suspend fun recordIncomingMessage(packet: MeshPacket, now: Long = System.currentTimeMillis()) {
|
||||
if (messageDao.findById(packet.messageId) != null) return
|
||||
messageDao.upsert(
|
||||
MessageEntity(
|
||||
messageId = packet.messageId,
|
||||
senderId = packet.senderId,
|
||||
targetId = packet.targetId,
|
||||
body = packet.payload,
|
||||
packetType = packet.type.name,
|
||||
direction = DIRECTION_INCOMING,
|
||||
status = STATUS_DELIVERED,
|
||||
createdAt = packet.timestamp,
|
||||
updatedAt = now,
|
||||
ackedAt = now
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun markAckDelivered(originalMessageId: String, now: Long = System.currentTimeMillis()) {
|
||||
messageDao.updateStatus(originalMessageId, STATUS_DELIVERED, now, now)
|
||||
queueDao.delete(originalMessageId)
|
||||
}
|
||||
|
||||
suspend fun markSendAttempt(
|
||||
messageId: String,
|
||||
attemptCount: Int,
|
||||
nextAttemptAt: Long,
|
||||
error: String? = null,
|
||||
now: Long = System.currentTimeMillis()
|
||||
) {
|
||||
messageDao.updateStatus(messageId, STATUS_SENT, now, null)
|
||||
queueDao.updateAttempt(messageId, nextAttemptAt, attemptCount, error)
|
||||
}
|
||||
|
||||
suspend fun markFailed(messageId: String, error: String, now: Long = System.currentTimeMillis()) {
|
||||
messageDao.updateStatus(messageId, STATUS_FAILED, now, null)
|
||||
queueDao.delete(messageId)
|
||||
}
|
||||
|
||||
suspend fun readyQueue(now: Long = System.currentTimeMillis(), limit: Int = 20): List<OutboundQueueEntity> {
|
||||
return queueDao.readyToSend(now, limit)
|
||||
}
|
||||
|
||||
suspend fun recentMessages(limit: Int = 50): List<MessageEntity> {
|
||||
return messageDao.recentMessages(limit)
|
||||
}
|
||||
|
||||
suspend fun chatSummaries(): List<ChatSummary> {
|
||||
return messageDao.chatSummaries()
|
||||
}
|
||||
|
||||
suspend fun messagesForPeer(peerId: String, limit: Int = 100): List<MessageEntity> {
|
||||
return messageDao.messagesForPeer(peerId, limit)
|
||||
}
|
||||
|
||||
suspend fun queuedCount(): Int = queueDao.count()
|
||||
|
||||
companion object {
|
||||
const val STATUS_QUEUED = "queued"
|
||||
const val STATUS_SENT = "sent"
|
||||
const val STATUS_DELIVERED = "delivered"
|
||||
const val STATUS_FAILED = "failed"
|
||||
|
||||
const val DIRECTION_INCOMING = "incoming"
|
||||
const val DIRECTION_OUTGOING = "outgoing"
|
||||
|
||||
private const val DEFAULT_MAX_ATTEMPTS = 5
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.schoolmesh.messenger.data
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Insert
|
||||
import androidx.room.OnConflictStrategy
|
||||
import androidx.room.Query
|
||||
|
||||
@Dao
|
||||
interface MessageDao {
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
suspend fun upsert(message: MessageEntity)
|
||||
|
||||
@Query("SELECT * FROM messages ORDER BY createdAt DESC LIMIT :limit")
|
||||
suspend fun recentMessages(limit: Int): List<MessageEntity>
|
||||
|
||||
@Query("SELECT * FROM messages WHERE messageId = :messageId LIMIT 1")
|
||||
suspend fun findById(messageId: String): MessageEntity?
|
||||
|
||||
@Query(
|
||||
"""
|
||||
SELECT * FROM messages
|
||||
WHERE senderId = :peerId OR targetId = :peerId
|
||||
ORDER BY createdAt DESC
|
||||
LIMIT :limit
|
||||
"""
|
||||
)
|
||||
suspend fun messagesForPeer(peerId: String, limit: Int): List<MessageEntity>
|
||||
|
||||
@Query(
|
||||
"""
|
||||
SELECT
|
||||
CASE
|
||||
WHEN direction = 'incoming' THEN senderId
|
||||
ELSE targetId
|
||||
END AS peerId,
|
||||
body AS lastBody,
|
||||
status AS lastStatus,
|
||||
createdAt AS lastTimestamp,
|
||||
0 AS unreadCount
|
||||
FROM messages
|
||||
WHERE createdAt IN (
|
||||
SELECT MAX(createdAt)
|
||||
FROM messages
|
||||
GROUP BY CASE
|
||||
WHEN direction = 'incoming' THEN senderId
|
||||
ELSE targetId
|
||||
END
|
||||
)
|
||||
ORDER BY createdAt DESC
|
||||
"""
|
||||
)
|
||||
suspend fun chatSummaries(): List<ChatSummary>
|
||||
|
||||
@Query(
|
||||
"""
|
||||
UPDATE messages
|
||||
SET status = :status, updatedAt = :updatedAt, ackedAt = :ackedAt
|
||||
WHERE messageId = :messageId
|
||||
"""
|
||||
)
|
||||
suspend fun updateStatus(messageId: String, status: String, updatedAt: Long, ackedAt: Long?)
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.schoolmesh.messenger.data
|
||||
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
|
||||
@Entity(tableName = "messages")
|
||||
data class MessageEntity(
|
||||
@PrimaryKey val messageId: String,
|
||||
val senderId: String,
|
||||
val targetId: String,
|
||||
val body: String,
|
||||
val packetType: String,
|
||||
val direction: String,
|
||||
val status: String,
|
||||
val createdAt: Long,
|
||||
val updatedAt: Long,
|
||||
val ackedAt: Long? = null
|
||||
)
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.schoolmesh.messenger.data
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Insert
|
||||
import androidx.room.OnConflictStrategy
|
||||
import androidx.room.Query
|
||||
|
||||
@Dao
|
||||
interface OutboundQueueDao {
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
suspend fun upsert(item: OutboundQueueEntity)
|
||||
|
||||
@Query(
|
||||
"""
|
||||
SELECT * FROM outbound_queue
|
||||
WHERE nextAttemptAt <= :now AND attemptCount < maxAttempts
|
||||
ORDER BY nextAttemptAt ASC
|
||||
LIMIT :limit
|
||||
"""
|
||||
)
|
||||
suspend fun readyToSend(now: Long, limit: Int): List<OutboundQueueEntity>
|
||||
|
||||
@Query("DELETE FROM outbound_queue WHERE messageId = :messageId")
|
||||
suspend fun delete(messageId: String)
|
||||
|
||||
@Query(
|
||||
"""
|
||||
UPDATE outbound_queue
|
||||
SET nextAttemptAt = :nextAttemptAt, attemptCount = :attemptCount, lastError = :lastError
|
||||
WHERE messageId = :messageId
|
||||
"""
|
||||
)
|
||||
suspend fun updateAttempt(messageId: String, nextAttemptAt: Long, attemptCount: Int, lastError: String?)
|
||||
|
||||
@Query("SELECT COUNT(*) FROM outbound_queue")
|
||||
suspend fun count(): Int
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.schoolmesh.messenger.data
|
||||
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
|
||||
@Entity(tableName = "outbound_queue")
|
||||
data class OutboundQueueEntity(
|
||||
@PrimaryKey val messageId: String,
|
||||
val targetId: String,
|
||||
val body: String,
|
||||
val nextAttemptAt: Long,
|
||||
val attemptCount: Int,
|
||||
val maxAttempts: Int,
|
||||
val createdAt: Long,
|
||||
val lastError: String? = null
|
||||
)
|
||||
@@ -21,6 +21,7 @@ import android.bluetooth.le.ScanCallback
|
||||
import android.bluetooth.le.ScanFilter
|
||||
import android.bluetooth.le.ScanResult
|
||||
import android.bluetooth.le.ScanSettings
|
||||
import android.bluetooth.BluetoothStatusCodes
|
||||
import android.content.Context
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Build
|
||||
@@ -35,6 +36,8 @@ class BleMeshManager(
|
||||
private val context: Context,
|
||||
private val onPeerDiscovered: (String) -> Unit = {},
|
||||
private val onStatusChanged: (String) -> Unit = {},
|
||||
private val onAckReceived: (String) -> Unit = {},
|
||||
private val onMessageReceived: (MeshPacket) -> Unit = {},
|
||||
private val onError: (String) -> Unit = {},
|
||||
private val onLog: (String) -> Unit = {},
|
||||
private val seenPacketCache: SeenPacketCache = SeenPacketCache()
|
||||
@@ -55,6 +58,9 @@ class BleMeshManager(
|
||||
bluetoothAdapter?.address ?: "android-${UUID.randomUUID()}"
|
||||
}
|
||||
|
||||
val nodeId: String
|
||||
get() = localNodeId
|
||||
|
||||
private val scanCallback = object : ScanCallback() {
|
||||
override fun onScanResult(callbackType: Int, result: ScanResult) {
|
||||
val device = result.device ?: return
|
||||
@@ -172,7 +178,7 @@ class BleMeshManager(
|
||||
}
|
||||
|
||||
return when (packet.type) {
|
||||
PacketType.ACK -> MeshAction.ConsumeAck(packet.messageId)
|
||||
PacketType.ACK -> MeshAction.ConsumeAck(packet.payload)
|
||||
PacketType.PRESENCE -> MeshAction.ConsumePresence(packet.senderId)
|
||||
PacketType.MESSAGE -> MeshAction.ProcessAndRelay(packet.decrementedTtl())
|
||||
}
|
||||
@@ -227,7 +233,10 @@ class BleMeshManager(
|
||||
when (val action = onPacketReceived(packet)) {
|
||||
MeshAction.DropDuplicate -> log("Duplicate packet dropped: ${packet.messageId}")
|
||||
MeshAction.DropExpired -> log("Expired packet dropped: ${packet.messageId}")
|
||||
is MeshAction.ConsumeAck -> log("ACK consumed: ${action.messageId}")
|
||||
is MeshAction.ConsumeAck -> {
|
||||
onAckReceived(action.messageId)
|
||||
log("ACK consumed: ${action.messageId}")
|
||||
}
|
||||
is MeshAction.ConsumePresence -> {
|
||||
onPeerDiscovered(action.senderId)
|
||||
onStatusChanged("Presence from ${action.senderId}")
|
||||
@@ -235,6 +244,7 @@ class BleMeshManager(
|
||||
}
|
||||
|
||||
is MeshAction.ProcessAndRelay -> {
|
||||
onMessageReceived(packet)
|
||||
onStatusChanged("Message from ${packet.senderId}")
|
||||
log("Relaying packet ${packet.messageId}")
|
||||
broadcastPacket(action.packetToRelay)
|
||||
@@ -340,31 +350,42 @@ class BleMeshManager(
|
||||
broadcastPacket(ack)
|
||||
}
|
||||
|
||||
private fun broadcastPacket(packet: MeshPacket) {
|
||||
private fun broadcastPacket(packet: MeshPacket): Boolean {
|
||||
var sent = false
|
||||
activeConnections.values.forEach { gatt ->
|
||||
writePacket(gatt, packet)
|
||||
sent = writePacket(gatt, packet) || sent
|
||||
}
|
||||
return sent
|
||||
}
|
||||
|
||||
fun sendPacket(packet: MeshPacket): Boolean {
|
||||
val directedGatt = activeConnections[packet.targetId]
|
||||
return if (directedGatt != null) {
|
||||
writePacket(directedGatt, packet)
|
||||
} else {
|
||||
broadcastPacket(packet)
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
private fun writePacket(gatt: BluetoothGatt, packet: MeshPacket) {
|
||||
private fun writePacket(gatt: BluetoothGatt, packet: MeshPacket): Boolean {
|
||||
val characteristic = gatt
|
||||
.getService(MESH_SERVICE_UUID)
|
||||
?.getCharacteristic(CHARACTERISTIC_PACKET_UUID)
|
||||
|
||||
if (characteristic == null) {
|
||||
log("Remote characteristic missing on ${gatt.device.address}")
|
||||
return
|
||||
return false
|
||||
}
|
||||
|
||||
val payload = MeshPacketCodec.encode(packet).toByteArray(StandardCharsets.UTF_8)
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
gatt.writeCharacteristic(
|
||||
characteristic,
|
||||
payload,
|
||||
BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT
|
||||
)
|
||||
) == BluetoothStatusCodes.SUCCESS
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
characteristic.writeType = BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT
|
||||
|
||||
@@ -10,23 +10,50 @@ import android.os.Build
|
||||
import android.os.IBinder
|
||||
import androidx.core.app.NotificationCompat
|
||||
import com.schoolmesh.messenger.R
|
||||
import com.schoolmesh.messenger.data.MeshDatabase
|
||||
import com.schoolmesh.messenger.data.MeshRepository
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.cancel
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class MeshForegroundService : Service() {
|
||||
private val serviceScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
||||
private lateinit var bleMeshManager: BleMeshManager
|
||||
private lateinit var repository: MeshRepository
|
||||
private lateinit var queueProcessor: MeshQueueProcessor
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
createNotificationChannel()
|
||||
val database = MeshDatabase.getInstance(applicationContext)
|
||||
repository = MeshRepository(database.messageDao(), database.outboundQueueDao())
|
||||
bleMeshManager = BleMeshManager(
|
||||
context = applicationContext,
|
||||
onPeerDiscovered = { address ->
|
||||
sendEvent(MeshServiceContract.EVENT_PEER, address)
|
||||
sendEvent(MeshServiceContract.EVENT_LOG, "Peer discovered: $address")
|
||||
queueProcessor.poke()
|
||||
},
|
||||
onStatusChanged = { status ->
|
||||
sendEvent(MeshServiceContract.EVENT_STATUS, status)
|
||||
updateNotification(status)
|
||||
},
|
||||
onAckReceived = { messageId ->
|
||||
serviceScope.launch {
|
||||
repository.markAckDelivered(messageId)
|
||||
sendEvent(MeshServiceContract.EVENT_LOG, "ACK delivered for $messageId")
|
||||
sendEvent(MeshServiceContract.EVENT_MESSAGES_CHANGED, messageId)
|
||||
}
|
||||
},
|
||||
onMessageReceived = { packet ->
|
||||
serviceScope.launch {
|
||||
repository.recordIncomingMessage(packet)
|
||||
sendEvent(MeshServiceContract.EVENT_LOG, "Message stored from ${packet.senderId}")
|
||||
sendEvent(MeshServiceContract.EVENT_MESSAGES_CHANGED, packet.messageId)
|
||||
}
|
||||
},
|
||||
onError = { message ->
|
||||
sendEvent(MeshServiceContract.EVENT_STATUS, "Ошибка: $message")
|
||||
sendEvent(MeshServiceContract.EVENT_LOG, "Error: $message")
|
||||
@@ -36,18 +63,27 @@ class MeshForegroundService : Service() {
|
||||
sendEvent(MeshServiceContract.EVENT_LOG, message)
|
||||
}
|
||||
)
|
||||
queueProcessor = MeshQueueProcessor(
|
||||
scope = serviceScope,
|
||||
repository = repository,
|
||||
meshManager = bleMeshManager,
|
||||
onLog = { message -> sendEvent(MeshServiceContract.EVENT_LOG, message) }
|
||||
)
|
||||
}
|
||||
|
||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||
when (intent?.action) {
|
||||
MeshServiceContract.ACTION_STOP -> stopMesh()
|
||||
MeshServiceContract.ACTION_SEND_MESSAGE -> enqueueMessage(intent)
|
||||
else -> startMesh()
|
||||
}
|
||||
return START_STICKY
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
queueProcessor.stop()
|
||||
bleMeshManager.stop()
|
||||
serviceScope.cancel()
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
@@ -56,14 +92,37 @@ class MeshForegroundService : Service() {
|
||||
private fun startMesh() {
|
||||
startForeground(NOTIFICATION_ID, buildNotification("Mesh запускается"))
|
||||
bleMeshManager.start()
|
||||
queueProcessor.start()
|
||||
queueProcessor.poke()
|
||||
}
|
||||
|
||||
private fun stopMesh() {
|
||||
queueProcessor.stop()
|
||||
bleMeshManager.stop()
|
||||
stopForeground(STOP_FOREGROUND_REMOVE)
|
||||
stopSelf()
|
||||
}
|
||||
|
||||
private fun enqueueMessage(intent: Intent) {
|
||||
val targetId = intent.getStringExtra(MeshServiceContract.EXTRA_TARGET_ID)?.trim().orEmpty()
|
||||
val messageBody = intent.getStringExtra(MeshServiceContract.EXTRA_MESSAGE_BODY)?.trim().orEmpty()
|
||||
if (targetId.isEmpty() || messageBody.isEmpty()) {
|
||||
sendEvent(MeshServiceContract.EVENT_LOG, "Cannot enqueue empty target/body")
|
||||
return
|
||||
}
|
||||
|
||||
serviceScope.launch {
|
||||
val messageId = repository.enqueueOutgoingMessage(
|
||||
senderId = bleMeshManager.nodeId,
|
||||
targetId = targetId,
|
||||
body = messageBody
|
||||
)
|
||||
sendEvent(MeshServiceContract.EVENT_LOG, "Message queued: $messageId")
|
||||
sendEvent(MeshServiceContract.EVENT_MESSAGES_CHANGED, messageId)
|
||||
queueProcessor.poke()
|
||||
}
|
||||
}
|
||||
|
||||
private fun buildNotification(contentText: String): Notification {
|
||||
return NotificationCompat.Builder(this, CHANNEL_ID)
|
||||
.setContentTitle(getString(R.string.notification_title))
|
||||
@@ -115,5 +174,14 @@ class MeshForegroundService : Service() {
|
||||
}
|
||||
context.startService(intent)
|
||||
}
|
||||
|
||||
fun sendMessage(context: Context, targetId: String, body: String) {
|
||||
val intent = Intent(context, MeshForegroundService::class.java).apply {
|
||||
action = MeshServiceContract.ACTION_SEND_MESSAGE
|
||||
putExtra(MeshServiceContract.EXTRA_TARGET_ID, targetId)
|
||||
putExtra(MeshServiceContract.EXTRA_MESSAGE_BODY, body)
|
||||
}
|
||||
context.startService(intent)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.schoolmesh.messenger.mesh
|
||||
|
||||
import com.schoolmesh.messenger.data.MeshRepository
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.isActive
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class MeshQueueProcessor(
|
||||
private val scope: CoroutineScope,
|
||||
private val repository: MeshRepository,
|
||||
private val meshManager: BleMeshManager,
|
||||
private val onLog: (String) -> Unit = {}
|
||||
) {
|
||||
private var loopJob: Job? = null
|
||||
|
||||
fun start() {
|
||||
if (loopJob?.isActive == true) return
|
||||
loopJob = scope.launch {
|
||||
while (isActive) {
|
||||
processReadyQueue()
|
||||
delay(POLL_INTERVAL_MS)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun stop() {
|
||||
loopJob?.cancel()
|
||||
loopJob = null
|
||||
}
|
||||
|
||||
fun poke() {
|
||||
scope.launch {
|
||||
processReadyQueue()
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun processReadyQueue() {
|
||||
val items = repository.readyQueue()
|
||||
items.forEach { item ->
|
||||
val sent = meshManager.sendPacket(
|
||||
MeshPacket(
|
||||
messageId = item.messageId,
|
||||
senderId = meshManager.nodeId,
|
||||
targetId = item.targetId,
|
||||
type = PacketType.MESSAGE,
|
||||
payload = item.body
|
||||
)
|
||||
)
|
||||
|
||||
if (sent) {
|
||||
val nextRetryAt = System.currentTimeMillis() + ACK_TIMEOUT_MS
|
||||
repository.markSendAttempt(
|
||||
messageId = item.messageId,
|
||||
attemptCount = item.attemptCount + 1,
|
||||
nextAttemptAt = nextRetryAt
|
||||
)
|
||||
onLog("Queued message ${item.messageId} sent, waiting for ACK")
|
||||
} else if (item.attemptCount + 1 >= item.maxAttempts) {
|
||||
repository.markFailed(item.messageId, "No reachable peers")
|
||||
onLog("Queued message ${item.messageId} failed after max attempts")
|
||||
} else {
|
||||
val nextRetryAt = System.currentTimeMillis() + RETRY_BACKOFF_MS
|
||||
repository.markSendAttempt(
|
||||
messageId = item.messageId,
|
||||
attemptCount = item.attemptCount + 1,
|
||||
nextAttemptAt = nextRetryAt,
|
||||
error = "No reachable peers"
|
||||
)
|
||||
onLog("Queued message ${item.messageId} rescheduled")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val POLL_INTERVAL_MS = 5_000L
|
||||
private const val ACK_TIMEOUT_MS = 8_000L
|
||||
private const val RETRY_BACKOFF_MS = 4_000L
|
||||
}
|
||||
}
|
||||
@@ -3,12 +3,16 @@ package com.schoolmesh.messenger.mesh
|
||||
object MeshServiceContract {
|
||||
const val ACTION_START = "com.schoolmesh.messenger.mesh.START"
|
||||
const val ACTION_STOP = "com.schoolmesh.messenger.mesh.STOP"
|
||||
const val ACTION_SEND_MESSAGE = "com.schoolmesh.messenger.mesh.SEND_MESSAGE"
|
||||
const val ACTION_EVENT = "com.schoolmesh.messenger.mesh.EVENT"
|
||||
|
||||
const val EXTRA_EVENT_TYPE = "event_type"
|
||||
const val EXTRA_EVENT_VALUE = "event_value"
|
||||
const val EXTRA_TARGET_ID = "target_id"
|
||||
const val EXTRA_MESSAGE_BODY = "message_body"
|
||||
|
||||
const val EVENT_STATUS = "status"
|
||||
const val EVENT_PEER = "peer"
|
||||
const val EVENT_LOG = "log"
|
||||
const val EVENT_MESSAGES_CHANGED = "messages_changed"
|
||||
}
|
||||
|
||||
@@ -1,90 +1,230 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#18222D"
|
||||
android:orientation="vertical"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="24dp">
|
||||
android:background="#233040"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingHorizontal="16dp"
|
||||
android:paddingVertical="14dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/titleText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="School Mesh Messenger"
|
||||
android:textAppearance="@style/TextAppearance.Material3.HeadlineMedium" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/subtitleText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="Debug-экран BLE mesh: foreground service, найденные узлы и журнал событий." />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnStartMesh"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Запустить mesh" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnStopMesh"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_weight="1"
|
||||
android:text="Остановить mesh" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/statusLabel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
android:text="Статус"
|
||||
android:text="NNNet"
|
||||
android:textColor="#F3F7FB"
|
||||
android:textSize="22sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/statusText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="#2F6EA5"
|
||||
android:paddingHorizontal="10dp"
|
||||
android:paddingVertical="6dp"
|
||||
android:text="Offline"
|
||||
android:textColor="#FFFFFF" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="Ожидание запуска" />
|
||||
android:background="#233040"
|
||||
android:orientation="horizontal"
|
||||
android:paddingHorizontal="12dp"
|
||||
android:paddingBottom="12dp">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnTabChats"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_weight="1"
|
||||
android:text="Chats" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnTabSettings"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Settings" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/chatsScreen"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/peersLabel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
android:text="Найденные узлы"
|
||||
android:background="#121A23"
|
||||
android:paddingHorizontal="16dp"
|
||||
android:paddingVertical="10dp"
|
||||
android:text="Chats"
|
||||
android:textColor="#8FA1B3"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<ListView
|
||||
android:id="@+id/chatListView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="180dp"
|
||||
android:background="#10161E"
|
||||
android:divider="#1A2531"
|
||||
android:dividerHeight="1dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="#1F2C39"
|
||||
android:orientation="vertical"
|
||||
android:padding="14dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/activeChatTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Select a chat"
|
||||
android:textColor="#F3F7FB"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/peersText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:background="#EAF3F7"
|
||||
android:layout_marginTop="4dp"
|
||||
android:text="Nearby peers will appear here"
|
||||
android:textColor="#8FA1B3" />
|
||||
</LinearLayout>
|
||||
|
||||
<ListView
|
||||
android:id="@+id/messageListView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:background="#0E1621"
|
||||
android:divider="@android:color/transparent"
|
||||
android:dividerHeight="8dp"
|
||||
android:padding="12dp"
|
||||
android:text="Узлы не найдены" />
|
||||
android:transcriptMode="alwaysScroll" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="#18222D"
|
||||
android:orientation="vertical"
|
||||
android:padding="12dp">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/targetInput"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="#233040"
|
||||
android:hint="Peer ID"
|
||||
android:padding="12dp"
|
||||
android:textColor="#F3F7FB"
|
||||
android:textColorHint="#8FA1B3" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/messageInput"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:background="#233040"
|
||||
android:hint="Write a message"
|
||||
android:minLines="2"
|
||||
android:padding="12dp"
|
||||
android:textColor="#F3F7FB"
|
||||
android:textColorHint="#8FA1B3" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnSendMessage"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="10dp"
|
||||
android:text="Send" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/settingsScreen"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:visibility="gone">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="16dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Settings"
|
||||
android:textColor="#F3F7FB"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<com.google.android.material.switchmaterial.SwitchMaterial
|
||||
android:id="@+id/autoUpdateSwitch"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:text="Enable auto update checks"
|
||||
android:textColor="#F3F7FB"
|
||||
app:useMaterialThemeColors="false" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnCheckUpdates"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="Check updates now" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnStartMesh"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="Start mesh" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnStopMesh"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="Stop mesh" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/logsLabel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
android:text="Журнал событий"
|
||||
android:text="Event log"
|
||||
android:textColor="#8FA1B3"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
@@ -94,8 +234,9 @@
|
||||
android:layout_marginTop="8dp"
|
||||
android:background="#101820"
|
||||
android:padding="12dp"
|
||||
android:text="Лог пуст"
|
||||
android:text="Log is empty"
|
||||
android:textColor="#EAF7F2"
|
||||
android:textIsSelectable="true" />
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
</LinearLayout>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<resources>
|
||||
<string name="app_name">School Mesh Messenger</string>
|
||||
<string name="notification_title">School Mesh Messenger</string>
|
||||
<string name="app_name">NNNet</string>
|
||||
<string name="notification_title">NNNet</string>
|
||||
<string name="notification_channel_name">Mesh status</string>
|
||||
</resources>
|
||||
|
||||
@@ -14,5 +14,5 @@ dependencyResolutionManagement {
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "SchoolMeshMessenger"
|
||||
rootProject.name = "NNNet"
|
||||
include(":app")
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
# Архитектура School Mesh Messenger
|
||||
# Архитектура NNNet
|
||||
|
||||
## Слои
|
||||
- BLE Transport: сканирование, реклама, соединения, обмен пакетами.
|
||||
- Mesh Layer: маршрутизация, TTL, дедупликация, ACK.
|
||||
- Messaging Layer: чаты, статусы доставки, история.
|
||||
- Messaging Layer: список чатов, диалог, статусы доставки, история.
|
||||
- Storage Layer: Room для локального хранения.
|
||||
- Delivery Layer: retry queue, ACK timeout, повторные отправки из фонового сервиса.
|
||||
- Update Layer: `version.json`, changelog и ручная/автоматическая проверка обновлений клиента.
|
||||
|
||||
## Сетевой пакет (черновик)
|
||||
```json
|
||||
@@ -20,6 +22,6 @@
|
||||
```
|
||||
|
||||
## Ближайшие шаги
|
||||
1. BLE discovery + advertising прототип.
|
||||
2. Relay между 2-3 устройствами.
|
||||
3. ACK/timeout/retry очередь.
|
||||
1. Укрепить transport: фрагментация крупных пакетов и более надёжный reconnect.
|
||||
2. Ввести шифрование payload и управление профилями пользователей.
|
||||
3. Добавить инструментальные BLE-тесты на нескольких устройствах и полевой прогон.
|
||||
|
||||
@@ -6,6 +6,7 @@ BUILD_FILE="$ROOT_DIR/android/app/build.gradle.kts"
|
||||
META_DIR="$ROOT_DIR/website/assets/meta"
|
||||
APK_FILE="$ROOT_DIR/website/downloads/app-debug.apk"
|
||||
OUTPUT_FILE="$META_DIR/version.json"
|
||||
RELEASE_NOTES_FILE="$ROOT_DIR/website/assets/meta/release-notes.txt"
|
||||
|
||||
mkdir -p "$META_DIR"
|
||||
|
||||
@@ -20,7 +21,9 @@ cat > "$OUTPUT_FILE" <<EOF
|
||||
"versionCode": $version_code,
|
||||
"buildDateUtc": "$build_date",
|
||||
"apkPath": "downloads/app-debug.apk",
|
||||
"apkSizeBytes": $apk_size
|
||||
"apkSizeBytes": $apk_size,
|
||||
"releaseNotesTitle": "Что нового",
|
||||
"releaseNotesPath": "assets/meta/release-notes.txt"
|
||||
}
|
||||
EOF
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
const versionBadge = document.getElementById('versionBadge');
|
||||
const versionSummary = document.getElementById('versionSummary');
|
||||
const downloadMeta = document.getElementById('downloadMeta');
|
||||
const releaseNotesSummary = document.getElementById('releaseNotesSummary');
|
||||
const releaseNotesText = document.getElementById('releaseNotesText');
|
||||
if (!btn) return;
|
||||
|
||||
btn.addEventListener('click', (event) => {
|
||||
@@ -12,7 +14,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
}
|
||||
});
|
||||
|
||||
fetch('assets/meta/version.json', { cache: 'no-store' })
|
||||
fetch('/assets/meta/version.json', { cache: 'no-store' })
|
||||
.then((response) => {
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP ${response.status}`);
|
||||
@@ -38,6 +40,29 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
if (meta.apkPath) {
|
||||
btn.setAttribute('href', meta.apkPath);
|
||||
}
|
||||
if (meta.releaseNotesTitle && releaseNotesSummary) {
|
||||
releaseNotesSummary.textContent = meta.releaseNotesTitle;
|
||||
}
|
||||
|
||||
if (meta.releaseNotesPath && releaseNotesText) {
|
||||
const notesPath = meta.releaseNotesPath.startsWith('/')
|
||||
? meta.releaseNotesPath
|
||||
: `/${meta.releaseNotesPath}`;
|
||||
|
||||
fetch(notesPath, { cache: 'no-store' })
|
||||
.then((response) => {
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP ${response.status}`);
|
||||
}
|
||||
return response.text();
|
||||
})
|
||||
.then((notes) => {
|
||||
releaseNotesText.innerHTML = notes.trim().replace(/\n/g, '<br>');
|
||||
})
|
||||
.catch(() => {
|
||||
releaseNotesText.textContent = 'Не удалось загрузить changelog.';
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
if (versionBadge) {
|
||||
|
||||
5
website/assets/meta/release-notes.txt
Normal file
5
website/assets/meta/release-notes.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
- Добавлено хранение сообщений и очереди отправки через Room.
|
||||
- Добавлен цикл доставки с ACK, retry и фоновой обработкой в mesh service.
|
||||
- Добавлен интерфейс в стиле мессенджера: список чатов, окно диалога и настройки.
|
||||
- Добавлен запрос на включение Bluetooth, если он выключен.
|
||||
- Добавлена ручная проверка обновлений и опциональная автопроверка в настройках.
|
||||
8
website/assets/meta/update.json
Normal file
8
website/assets/meta/update.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"versionName": "0.1.1",
|
||||
"versionCode": 2,
|
||||
"buildDateUtc": "2026-03-16T19:46:22Z",
|
||||
"apkPath": "downloads/app-debug.apk",
|
||||
"apkSizeBytes": 9110725,
|
||||
"releaseNotesPath": "assets/meta/release-notes.txt"
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>School Mesh Messenger</title>
|
||||
<title>NNNet</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet" />
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.css" rel="stylesheet" />
|
||||
<link href="assets/css/styles.css" rel="stylesheet" />
|
||||
@@ -13,10 +13,10 @@
|
||||
<div class="container">
|
||||
<div class="row align-items-center g-4">
|
||||
<div class="col-lg-8">
|
||||
<h1 class="display-5 fw-bold mb-3">School Mesh Messenger</h1>
|
||||
<h1 class="display-5 fw-bold mb-3">NNNet</h1>
|
||||
<p class="lead mb-4">Офлайн-мессенджер для школы на базе BLE mesh-сети: связь между учениками и учителями без интернета.</p>
|
||||
<div class="d-flex gap-2 flex-wrap">
|
||||
<a class="btn btn-light btn-lg" href="#download"><i class="bi bi-download me-2"></i>Скачать APK</a>
|
||||
<a class="btn btn-light btn-lg" href="downloads/app-debug.apk" download><i class="bi bi-download me-2"></i>Скачать APK</a>
|
||||
<a class="btn btn-outline-light btn-lg" href="#about"><i class="bi bi-diagram-3 me-2"></i>Как это работает</a>
|
||||
</div>
|
||||
</div>
|
||||
@@ -25,6 +25,10 @@
|
||||
<div class="small text-uppercase">Статус</div>
|
||||
<div id="versionBadge" class="h4 mb-2">Загрузка версии...</div>
|
||||
<p id="versionSummary" class="mb-0">Получаем информацию о последней сборке.</p>
|
||||
<details class="mt-3">
|
||||
<summary id="releaseNotesSummary">Что нового</summary>
|
||||
<p id="releaseNotesText" class="mb-0 mt-2">Описание обновления загружается...</p>
|
||||
</details>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -37,8 +41,8 @@
|
||||
<h2 class="mb-4">Что внутри</h2>
|
||||
<div class="row g-3">
|
||||
<div class="col-md-4"><div class="feature p-3 rounded-4"><i class="bi bi-broadcast-pin fs-2"></i><h5 class="mt-2">BLE Discovery</h5><p class="mb-0">Обнаружение ближайших узлов и обмен пакетами.</p></div></div>
|
||||
<div class="col-md-4"><div class="feature p-3 rounded-4"><i class="bi bi-share fs-2"></i><h5 class="mt-2">Mesh Relay</h5><p class="mb-0">Передача сообщений hop-by-hop с TTL и ACK.</p></div></div>
|
||||
<div class="col-md-4"><div class="feature p-3 rounded-4"><i class="bi bi-shield-lock fs-2"></i><h5 class="mt-2">Безопасность</h5><p class="mb-0">Базовое шифрование и защита от дубликатов.</p></div></div>
|
||||
<div class="col-md-4"><div class="feature p-3 rounded-4"><i class="bi bi-share fs-2"></i><h5 class="mt-2">Mesh Relay</h5><p class="mb-0">Передача сообщений hop-by-hop с TTL, ACK и retry queue.</p></div></div>
|
||||
<div class="col-md-4"><div class="feature p-3 rounded-4"><i class="bi bi-database fs-2"></i><h5 class="mt-2">Local Storage</h5><p class="mb-0">Room хранит историю сообщений и очередь исходящей доставки.</p></div></div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@@ -50,16 +54,17 @@
|
||||
<a id="downloadBtn" class="btn btn-success" href="downloads/app-debug.apk"><i class="bi bi-phone me-2"></i>Скачать APK</a>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</main>
|
||||
|
||||
<footer class="py-4">
|
||||
<div class="container d-flex justify-content-between flex-wrap gap-2">
|
||||
<span>© 2026 School Mesh Project</span>
|
||||
<span>Offline-first for schools</span>
|
||||
<span>© 2026 NNN Team</span>
|
||||
<a href="https://git.dom4k.pro/dom4k/NNNet" target="_blank" rel="noreferrer">git.dom4k.pro/dom4k/NNNet</a>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="assets/js/app.js"></script>
|
||||
<script src="assets/js/app.js?v=3"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user