更新
This commit is contained in:
parent
34081161e6
commit
6c41c45e3b
4
luci-app-modem/.gitattributes
vendored
Normal file
4
luci-app-modem/.gitattributes
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
#指定换行符
|
||||
/luasrc/** text eol=lf
|
||||
# /old/* text eol=lf
|
||||
/root/** text eol=lf
|
674
luci-app-modem/LICENSE
Normal file
674
luci-app-modem/LICENSE
Normal file
@ -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>.
|
40
luci-app-modem/Makefile
Normal file
40
luci-app-modem/Makefile
Normal file
@ -0,0 +1,40 @@
|
||||
# Copyright (C) 2020 Lienol <lawlienol@gmail.com>
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v3.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-modem
|
||||
LUCI_TITLE:=LuCI support for Modem
|
||||
LUCI_PKGARCH:=all
|
||||
PKG_VERSION:=20231207-1.0
|
||||
PKG_LICENSE:=GPLv3
|
||||
PKG_LINCESE_FILES:=LICENSE
|
||||
PKF_MAINTAINER:=siriling <siriling@qq.com>
|
||||
LUCI_DEPENDS:=+luci-compat +kmod-usb-net +kmod-usb-net-cdc-ether +kmod-usb-acm \
|
||||
+kmod-usb-net-qmi-wwan +kmod-usb-net-rndis +kmod-usb-serial-qualcomm \
|
||||
+kmod-usb-net-sierrawireless +kmod-usb-ohci +kmod-usb-serial \
|
||||
+kmod-usb-serial-option +kmod-usb-wdm \
|
||||
+kmod-usb2 +kmod-usb3 \
|
||||
+kmod-usb-net-cdc-mbim \
|
||||
+usbutils \
|
||||
+kmod-qmi_wwan_q \
|
||||
+kmod-pcie_mhi +pciutils \
|
||||
+quectel-CM-5G \
|
||||
+sms-tool +jp +grep\
|
||||
|
||||
define Package/luci-app-modem/conffiles
|
||||
/etc/config/modem
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/config
|
||||
# shown in make menuconfig <Help>
|
||||
help
|
||||
$(LUCI_TITLE)
|
||||
Version: $(PKG_VERSION)
|
||||
endef
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
14
luci-app-modem/README.md
Normal file
14
luci-app-modem/README.md
Normal file
@ -0,0 +1,14 @@
|
||||
# luci-app-modem
|
||||
|
||||
- 原项目地址:https://github.com/momokind/luci-app-hypermodem
|
||||
|
||||
## 说明
|
||||
|
||||
- 在原项目的基础上修改代码逻辑
|
||||
|
||||
- 添加USB和PCIe等依赖支持
|
||||
|
||||
- 添加多模块支持
|
||||
|
||||
- 支持USB和PCIE两种连接模式的5G模块用QMI模式进行IPv6拨号,然后下发给内网设备
|
||||
|
214
luci-app-modem/luasrc/controller/modem.lua
Normal file
214
luci-app-modem/luasrc/controller/modem.lua
Normal file
@ -0,0 +1,214 @@
|
||||
-- Copyright 2020 Lienol <lawlienol@gmail.com>
|
||||
module("luci.controller.modem", package.seeall)
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/modem") then
|
||||
return
|
||||
end
|
||||
entry({"admin", "network", "modem"}, alias("admin", "network", "modem", "index"), translate("Modem"), 100).dependent = true
|
||||
entry({"admin", "network", "modem", "index"},cbi("modem/index"),translate("Modem Config"),10).leaf = true
|
||||
entry({"admin", "network", "modem", "at_commands"},template("modem/at_commands"),translate("AT Commands"),20).leaf = true
|
||||
entry({"admin", "network", "modem", "config"}, cbi("modem/config")).leaf = true
|
||||
entry({"admin", "network", "modem", "modem_info"}, template("modem/modem_info"), translate("Modem Info"),30).leaf = true
|
||||
|
||||
--模块状态
|
||||
entry({"admin", "network", "modem", "get_csq"}, call("action_get_csq"))
|
||||
|
||||
--AT命令
|
||||
entry({"admin", "network", "modem", "status"}, call("act_status")).leaf = true
|
||||
entry({"admin", "network", "modem", "run_at"}, call("at"), nil).leaf = true
|
||||
entry({"admin", "network", "modem", "user_atc"}, call("useratc"), nil).leaf = true
|
||||
entry({"admin", "network", "modem", "at_port_select"}, call("modemSelect"), nil).leaf = true
|
||||
end
|
||||
|
||||
-- 模块列表状态函数
|
||||
function act_status()
|
||||
local e = {}
|
||||
e.index = luci.http.formvalue("index")
|
||||
e.status = luci.sys.call(string.format("busybox ps -w | grep -v 'grep' | grep '/var/etc/socat/%s' >/dev/null", luci.http.formvalue("id"))) == 0
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
||||
|
||||
-- 模块状态获取
|
||||
function action_get_csq()
|
||||
local file
|
||||
stat = "/tmp/modem_cell.file"
|
||||
file = io.open(stat, "r")
|
||||
local rv ={}
|
||||
|
||||
-- echo 'RM520N-GL'
|
||||
-- echo 'manufacturer'
|
||||
-- echo '1e0e:9001'
|
||||
-- echo $COPS #运营商
|
||||
-- echo '' #端口
|
||||
-- echo '' #温度
|
||||
-- echo '' #拨号模式
|
||||
rv["modem"] = file:read("*line")
|
||||
rv["manufacturer"] = file:read("*line")
|
||||
rv["modid"] = file:read("*line")
|
||||
rv["cops"] = file:read("*line")
|
||||
rv["port"] = file:read("*line")
|
||||
rv["tempur"] = file:read("*line")
|
||||
rv["proto"] = file:read("*line")
|
||||
rv["mode"] = file:read("*line")
|
||||
|
||||
|
||||
-- echo $IMEI #imei
|
||||
-- echo $IMSI #imsi
|
||||
-- echo $ICCID #iccid
|
||||
-- echo $phone #phone
|
||||
rv["imei"] = file:read("*line")
|
||||
rv["imsi"] = file:read("*line")
|
||||
rv["iccid"] =file:read("*line")
|
||||
rv["phone"] = file:read("*line")
|
||||
file:read("*line")
|
||||
|
||||
|
||||
-- echo $net_type
|
||||
-- echo $CSQ
|
||||
-- echo $CSQ_PER
|
||||
-- echo $CSQ_RSSI
|
||||
-- echo '' #参考信号接收质量 RSRQ ecio
|
||||
-- echo '' #参考信号接收质量 RSRQ ecio1
|
||||
-- echo '' #参考信号接收功率 RSRP rscp
|
||||
-- echo '' #参考信号接收功率 RSRP rscp1
|
||||
-- echo '' #信噪比 SINR rv["sinr"]
|
||||
-- echo '' #连接状态监控 rv["netmode"]
|
||||
rv["net_type"] = file:read("*line")
|
||||
rv["csq"] = file:read("*line")
|
||||
rv["per"] = file:read("*line")
|
||||
rv["rssi"] = file:read("*line")
|
||||
rv["ecio"] = file:read("*line")
|
||||
rv["ecio1"] = file:read("*line")
|
||||
rv["rscp"] = file:read("*line")
|
||||
rv["rscp1"] = file:read("*line")
|
||||
rv["sinr"] = file:read("*line")
|
||||
rv["netmode"] = file:read("*line")
|
||||
file:read("*line")
|
||||
|
||||
rssi = rv["rssi"]
|
||||
ecio = rv["ecio"]
|
||||
rscp = rv["rscp"]
|
||||
ecio1 = rv["ecio1"]
|
||||
rscp1 = rv["rscp1"]
|
||||
if ecio == nil then
|
||||
ecio = "-"
|
||||
end
|
||||
if ecio1 == nil then
|
||||
ecio1 = "-"
|
||||
end
|
||||
if rscp == nil then
|
||||
rscp = "-"
|
||||
end
|
||||
if rscp1 == nil then
|
||||
rscp1 = "-"
|
||||
end
|
||||
|
||||
if ecio ~= "-" then
|
||||
rv["ecio"] = ecio .. " dB"
|
||||
end
|
||||
if rscp ~= "-" then
|
||||
rv["rscp"] = rscp .. " dBm"
|
||||
end
|
||||
if ecio1 ~= " " then
|
||||
rv["ecio1"] = " (" .. ecio1 .. " dB)"
|
||||
end
|
||||
if rscp1 ~= " " then
|
||||
rv["rscp1"] = " (" .. rscp1 .. " dBm)"
|
||||
end
|
||||
|
||||
rv["mcc"] = file:read("*line")
|
||||
rv["mnc"] = file:read("*line")
|
||||
rv["rnc"] = file:read("*line")
|
||||
rv["rncn"] = file:read("*line")
|
||||
rv["lac"] = file:read("*line")
|
||||
rv["lacn"] = file:read("*line")
|
||||
rv["cid"] = file:read("*line")
|
||||
rv["cidn"] = file:read("*line")
|
||||
rv["lband"] = file:read("*line")
|
||||
rv["channel"] = file:read("*line")
|
||||
rv["pci"] = file:read("*line")
|
||||
|
||||
rv["date"] = file:read("*line")
|
||||
|
||||
-- rv["phonen"] = file:read("*line")
|
||||
--rv["host"] = "0"
|
||||
|
||||
-- rv["simerr"] = "0"
|
||||
|
||||
-- rv["down"] = file:read("*line")
|
||||
-- rv["up"] = file:read("*line")
|
||||
|
||||
-- rv["cell"] = file:read("*line")
|
||||
-- rv["modtype"] = file:read("*line")
|
||||
|
||||
-- rv["lat"] = "-"
|
||||
-- rv["long"] = "-"
|
||||
|
||||
rv["crate"] = translate("快速(每10秒更新一次)")
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(rv)
|
||||
end
|
||||
|
||||
-- at页面命令函数
|
||||
function at()
|
||||
local devv = tostring(uci:get("modem", "general", "atport"))
|
||||
|
||||
local at_code = http.formvalue("code")
|
||||
if at_code then
|
||||
local odpall = io.popen("sms_tool -d " .. devv .. " at " ..at_code:gsub("[$]", "\\\$"):gsub("\"", "\\\"").." 2>&1")
|
||||
local odp = odpall:read("*a")
|
||||
odpall:close()
|
||||
http.write(tostring(odp))
|
||||
else
|
||||
http.write_json(http.formvalue())
|
||||
end
|
||||
end
|
||||
|
||||
-- AT界面模块选择
|
||||
function modemSelect()
|
||||
|
||||
local at_ports={}
|
||||
local at={}
|
||||
local modem_number=uci:get('modem','global','modem_number')
|
||||
for i=0,modem_number do
|
||||
local at_port = uci:get('modem','modem'..i,'at_port')
|
||||
at_ports[#at_ports+1]=at_port
|
||||
-- table.insert(at_ports,at_port)
|
||||
end
|
||||
|
||||
-- 遍历查找AT串口
|
||||
-- uci:foreach("modem", "modem-device", function (modem_device)
|
||||
-- at_port = modem_device["at_port"]
|
||||
-- at_ports[#at_ports+1]=at_port
|
||||
-- end)
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(at_ports)
|
||||
end
|
||||
|
||||
-- 用户AT命令读取
|
||||
function uat(rv)
|
||||
local command_file = nixio.fs.access("/etc/config/atcmds.user") and
|
||||
io.popen("cat /etc/config/atcmds.user")
|
||||
|
||||
if command_file then
|
||||
for line in command_file:lines() do
|
||||
local i = line
|
||||
if i then
|
||||
rv[#rv + 1] = {
|
||||
atu = i
|
||||
}
|
||||
end
|
||||
end
|
||||
command_file:close()
|
||||
end
|
||||
end
|
||||
|
||||
-- 用户AT命令写入函数
|
||||
function useratc()
|
||||
local atu = { }
|
||||
uat(atu)
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(atu)
|
||||
end
|
116
luci-app-modem/luasrc/model/cbi/modem/config.lua
Normal file
116
luci-app-modem/luasrc/model/cbi/modem/config.lua
Normal file
@ -0,0 +1,116 @@
|
||||
local d = require "luci.dispatcher"
|
||||
local uci = require "luci.model.uci".cursor()
|
||||
|
||||
m = Map("modem", translate("Modem Config"))
|
||||
m.redirect = d.build_url("admin", "network", "modem")
|
||||
|
||||
s = m:section(NamedSection, arg[1], "config", "")
|
||||
s.addremove = false
|
||||
s.dynamic = false
|
||||
s:tab("general", translate("General Settings"))
|
||||
s:tab("advanced", translate("Advanced Settings"))
|
||||
|
||||
--------general--------
|
||||
|
||||
-- 是否启用
|
||||
enable = s:taboption("general", Flag, "enable", translate("Enable"))
|
||||
enable.default = "0"
|
||||
enable.rmempty = false
|
||||
|
||||
-- 备注
|
||||
remarks = s:taboption("general", Value, "remarks", translate("Remarks"))
|
||||
remarks.rmempty = true
|
||||
|
||||
-- 移动网络
|
||||
-- moblie_net = s:taboption("general", Value, "moblie_net", translate("Moblie Network"))
|
||||
moblie_net = s:taboption("general", ListValue, "moblie_net", translate("Moblie Network"))
|
||||
-- moblie_net.default = ""
|
||||
moblie_net.rmempty = false
|
||||
|
||||
-- 拨号模式
|
||||
-- mode = s:taboption("general", ListValue, "mode", translate("Mode"))
|
||||
-- mode.rmempty = false
|
||||
|
||||
-- 根据调制解调器节点获取模块名
|
||||
-- function getDeviceName(device_node)
|
||||
-- local deviceName
|
||||
-- uci:foreach("modem", "modem-device", function (modem_device)
|
||||
-- if device_node == modem_device["device_node"] then
|
||||
-- deviceName = modem_device["name"]
|
||||
-- end
|
||||
-- end)
|
||||
-- return string.upper(deviceName)
|
||||
-- end
|
||||
|
||||
-- 显示设备通用信息(网络,拨号模式)(有bug)
|
||||
function devicesGeneralInfo()
|
||||
local modem_number=uci:get('modem','global','modem_number')
|
||||
for i=0,modem_number do
|
||||
--获取模块名
|
||||
local deviceName = uci:get('modem','modem'..i,'name')
|
||||
if deviceName == nil then
|
||||
deviceName = "unknown"
|
||||
end
|
||||
--设置网络
|
||||
local net = uci:get('modem','modem'..i,'net')
|
||||
if net ~= nil then
|
||||
moblie_net:value(net,net.." ("..translate(deviceName:upper())..")")
|
||||
|
||||
--设置拨号模式
|
||||
local mode = s:taboption("general", ListValue, "mode", translate("Mode"))
|
||||
mode.rmempty = false
|
||||
|
||||
local modes = uci:get_list('modem','modem'..tostring(i),'modes')
|
||||
for i in ipairs(modes) do
|
||||
mode:value(modes[i],string.upper(modes[i]))
|
||||
end
|
||||
mode:depends("moblie_net", net)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
devicesGeneralInfo()
|
||||
|
||||
--------advanced--------
|
||||
|
||||
-- 拨号工具
|
||||
dial_tool = s:taboption("advanced", Value, "dial_tool", translate("Dial Tool"))
|
||||
dial_tool.rmempty = true
|
||||
dial_tool:value("", translate("Auto Choose"))
|
||||
dial_tool:value("quectel-CM", translate("quectel-CM"))
|
||||
|
||||
-- 网络类型
|
||||
pdp_type= s:taboption("advanced", ListValue, "pdp_type", translate("PDP Type"))
|
||||
pdp_type.default = "ipv4_ipv6"
|
||||
pdp_type.rmempty = false
|
||||
pdp_type:value("ipv4", translate("IPv4"))
|
||||
pdp_type:value("ipv6", translate("IPv6"))
|
||||
pdp_type:value("ipv4_ipv6", translate("IPv4/IPv6"))
|
||||
|
||||
-- 接入点
|
||||
apn = s:taboption("advanced", Value, "apn", translate("APN"))
|
||||
apn.default = ""
|
||||
apn.rmempty = true
|
||||
apn:value("", translate("Auto Choose"))
|
||||
apn:value("cmnet", translate("China Mobile"))
|
||||
apn:value("3gnet", translate("China Unicom"))
|
||||
apn:value("ctnet", translate("China Telecom"))
|
||||
apn:value("cbnet", translate("China Broadcast"))
|
||||
apn:value("5gscuiot", translate("Skytone"))
|
||||
|
||||
username = s:taboption("advanced", Value, "username", translate("PAP/CHAP Username"))
|
||||
username.rmempty = true
|
||||
|
||||
password = s:taboption("advanced", Value, "password", translate("PAP/CHAP Password"))
|
||||
password.rmempty = true
|
||||
|
||||
auth = s:taboption("advanced", Value, "auth", translate("Authentication Type"))
|
||||
auth.default = ""
|
||||
auth.rmempty = true
|
||||
auth:value("", translate("NONE"))
|
||||
auth:value("both", "PAP/CHAP (both)")
|
||||
auth:value("pap", "PAP")
|
||||
auth:value("chap", "CHAP")
|
||||
-- auth:value("none", "NONE")
|
||||
|
||||
return m
|
71
luci-app-modem/luasrc/model/cbi/modem/index.lua
Normal file
71
luci-app-modem/luasrc/model/cbi/modem/index.lua
Normal file
@ -0,0 +1,71 @@
|
||||
local d = require "luci.dispatcher"
|
||||
local e = luci.model.uci.cursor()
|
||||
|
||||
m = Map("modem")
|
||||
m.title = translate("Modem Config")
|
||||
m.description = translate("Configuration panel for Modem, Add and configure all modules on this page")
|
||||
|
||||
s = m:section(NamedSection, "global", "global")
|
||||
s.anonymous = true
|
||||
s.addremove = false
|
||||
|
||||
o = s:option(Flag, "enable", translate("Enable"))
|
||||
o.rmempty = false
|
||||
|
||||
s = m:section(TypedSection, "config", translate("Modem List"))
|
||||
s.anonymous = true
|
||||
s.addremove = true
|
||||
s.template = "cbi/tblsection"
|
||||
s.extedit = d.build_url("admin", "network", "modem", "config", "%s")
|
||||
|
||||
function s.create(e, t)
|
||||
local uuid = string.gsub(luci.sys.exec("echo -n $(cat /proc/sys/kernel/random/uuid)"), "-", "")
|
||||
t = uuid
|
||||
TypedSection.create(e, t)
|
||||
luci.http.redirect(e.extedit:format(t))
|
||||
end
|
||||
function s.remove(e, t)
|
||||
e.map.proceed = true
|
||||
e.map:del(t)
|
||||
luci.http.redirect(d.build_url("admin", "network", "modem"))
|
||||
end
|
||||
|
||||
o = s:option(Flag, "enable", translate("Enable"))
|
||||
o.width = "5%"
|
||||
o.rmempty = false
|
||||
|
||||
-- o = s:option(DummyValue, "status", translate("Status"))
|
||||
-- o.template = "modem/status"
|
||||
-- o.value = translate("Collecting data...")
|
||||
|
||||
o = s:option(DummyValue, "remarks", translate("Remarks"))
|
||||
|
||||
o = s:option(DummyValue, "moblie_net", translate("Moblie Network"))
|
||||
o.cfgvalue = function(t, n)
|
||||
-- 检测移动网络设备是否存在
|
||||
local moblie_net = (Value.cfgvalue(t, n) or "")
|
||||
local odpall = io.popen("ls /sys/class/net/ | grep -w "..moblie_net.." | wc -l")
|
||||
local odp = odpall:read("*a"):gsub("\n","")
|
||||
odpall:close()
|
||||
if odp ~= "0" then
|
||||
return moblie_net
|
||||
else
|
||||
return "The network device was not found"
|
||||
end
|
||||
end
|
||||
|
||||
o = s:option(DummyValue, "mode", translate("Mode"))
|
||||
o.cfgvalue = function(t, n)
|
||||
local mode = (Value.cfgvalue(t, n) or ""):upper()
|
||||
return mode
|
||||
end
|
||||
|
||||
o = s:option(DummyValue, "pdp_type", translate("PDP Type"))
|
||||
o.cfgvalue = function(t, n)
|
||||
local pdp_type = (Value.cfgvalue(t, n) or ""):gsub("_","/"):upper():gsub("V","v")
|
||||
return pdp_type
|
||||
end
|
||||
|
||||
-- m:append(Template("modem/list_status"))
|
||||
|
||||
return m
|
163
luci-app-modem/luasrc/view/modem/at_commands.htm
Normal file
163
luci-app-modem/luasrc/view/modem/at_commands.htm
Normal file
@ -0,0 +1,163 @@
|
||||
<%+header%>
|
||||
|
||||
<!--
|
||||
-- Copyright 2020-2021 Rafał Wabik (IceG) - From eko.one.pl forum
|
||||
-- Licensed to the GNU General Public License v3.0.
|
||||
-->
|
||||
|
||||
<h2 name="content"><%:AT Commands%></h2>
|
||||
<div class="cbi-map-descr"><%:Web UI for handling AT commands via sms_tool.%></div>
|
||||
<p></p>
|
||||
<h4><br/></h4>
|
||||
<div class="table" width="100%">
|
||||
|
||||
<div class="tr">
|
||||
<div class="td left" width="25%"><%:Modem Select%>:</div>
|
||||
|
||||
<div class="td left" style="width:50%;">
|
||||
<select name="at_port" id="at_port" onclick="copyFunction()"></select>
|
||||
</div>
|
||||
<div class="td left" style="width:50%;"></div>
|
||||
</div>
|
||||
|
||||
<div class="tr">
|
||||
<div class="td left" width="25%"><%:User AT Commands%>:</div>
|
||||
|
||||
<div class="td left" style="width:50%;">
|
||||
<select name="ussd" id="pl" onclick="copyFunction()"></select>
|
||||
</div>
|
||||
<div class="td left" style="width:50%;"></div>
|
||||
</div>
|
||||
|
||||
<div class="tr">
|
||||
<div class="td left" style="width:25%;"><%:Command to send%>:</div>
|
||||
|
||||
<div class="td left" ><input type="text" id="code" required size="20" ></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="table" width="100%">
|
||||
<div class="td left" style="width:25%;"><%:Reply%>:
|
||||
<p>
|
||||
<pre id="odp" style="visibility: hidden; width:75%;"></pre></div>
|
||||
|
||||
<div class="tr cbi-rowstyle-2">
|
||||
<div class="td right"><input type="button" style="margin-right: 26%"; id="sendcmd" class="btn cbi-button cbi-button-neutral" value="<%:Send Command%>" /></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
// 读取AT串口
|
||||
window.onload = function readATPort()
|
||||
{
|
||||
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "modem", "at_port_select")%>', null,
|
||||
function(x, json)
|
||||
{
|
||||
select = document.getElementById('at_port');
|
||||
var count = Object.keys(json).length;
|
||||
for(var d=0;d<=count;d++)
|
||||
{
|
||||
var opt = document.createElement('option');
|
||||
console.log("hello")
|
||||
console.log(json)
|
||||
var s = json[d].at_ports;
|
||||
// var fields = s.split(/;/);
|
||||
// var name = fields[0];
|
||||
// var port = fields[1];
|
||||
var name = s;
|
||||
var port = s;
|
||||
opt.text = name;
|
||||
opt.value = port.trim();
|
||||
opt.innerHTML = name;
|
||||
select.appendChild(opt);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
window.onload = function readUSER()
|
||||
{
|
||||
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "modem", "user_atc")%>', null,
|
||||
function(x, json)
|
||||
{
|
||||
select = document.getElementById('pl');
|
||||
var count = Object.keys(json).length;
|
||||
for(var d=0;d<=count;d++)
|
||||
{
|
||||
var opt = document.createElement('option');
|
||||
|
||||
var s = json[d].atu;
|
||||
var fields = s.split(/;/);
|
||||
var name = fields[0];
|
||||
var code = fields[1];
|
||||
opt.text = name;
|
||||
opt.value = code.trim();
|
||||
opt.innerHTML = name;
|
||||
select.appendChild(opt);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function copyFunction() {
|
||||
|
||||
var node = document.getElementById('odp');
|
||||
node.style.visibility = 'hidden';
|
||||
|
||||
var x = document.getElementById("pl").value;
|
||||
document.getElementById("code").value = x;
|
||||
document.getElementById("odp").innerHTML = "";
|
||||
}
|
||||
|
||||
|
||||
function postcmd(cmd) {
|
||||
(new XHR()).post("<%=luci.dispatcher.build_url("admin", "network", "modem", "run_at")%>", {"code":cmd}, function(x) {
|
||||
console.log(x.response)
|
||||
console.log(x)
|
||||
|
||||
var aStr = x.response;
|
||||
var myre = /^[\s\t]*(\r\n|\n|\r)/gm;
|
||||
var bStr = aStr.replace(myre,"");
|
||||
document.getElementById("odp").innerHTML = bStr;
|
||||
var el = document.getElementsByName("odp")[0];
|
||||
el.value.replace(/(\r\n|\n|\r)/gm, "");
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function (ev) {var button = document.getElementById("sendcmd");
|
||||
button.addEventListener("click", function () {
|
||||
|
||||
|
||||
var s = document.getElementById("code").value;
|
||||
if ( s.length == 0 )
|
||||
{
|
||||
document.getElementById("odp").innerHTML = "";
|
||||
alert("<%:Please enter a AT Command%>");
|
||||
return false;
|
||||
}
|
||||
|
||||
var cmd = document.getElementById("code");
|
||||
postcmd(cmd.value);
|
||||
cmd.value = "";
|
||||
|
||||
var node = document.getElementById('odp');
|
||||
if (node.style.visibility=='visible') {
|
||||
node.style.visibility = 'hidden';
|
||||
}
|
||||
else
|
||||
node.style.visibility = 'visible'
|
||||
|
||||
return true;
|
||||
});
|
||||
}, true);
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<%+footer%>
|
||||
|
19
luci-app-modem/luasrc/view/modem/list_status.htm
Normal file
19
luci-app-modem/luasrc/view/modem/list_status.htm
Normal file
@ -0,0 +1,19 @@
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
var _status = document.getElementsByClassName('_status');
|
||||
for(var i = 0; i < _status.length; i++) {
|
||||
var id = _status[i].parentElement.parentElement.parentElement.id;
|
||||
id = id.substr(id.lastIndexOf("-") + 1);
|
||||
XHR.poll(1,'<%=url([[admin]], [[network]], [[modem]], [[status]])%>', {
|
||||
index: i,
|
||||
id: id
|
||||
},
|
||||
function(x, result) {
|
||||
_status[result.index].setAttribute("style","font-weight:bold;");
|
||||
_status[result.index].setAttribute("color",result.status ? "green":"red");
|
||||
_status[result.index].innerHTML = (result.status ? '✓' : 'X');
|
||||
}
|
||||
);
|
||||
}
|
||||
//]]>
|
||||
</script>
|
296
luci-app-modem/luasrc/view/modem/modem_info.htm
Normal file
296
luci-app-modem/luasrc/view/modem/modem_info.htm
Normal file
@ -0,0 +1,296 @@
|
||||
<%+header%>
|
||||
<%
|
||||
local fs = require "nixio.fs"
|
||||
nosms = 1
|
||||
if not fs.stat("/etc/nosim") then
|
||||
nosms = 0
|
||||
end
|
||||
havegps = 0
|
||||
if fs.stat("/etc/havegps") then
|
||||
havegps = 1
|
||||
end
|
||||
%>
|
||||
<style>g {color:grey; font-size:75%; vertical-align: super;}</style>
|
||||
<script type="text/javascript" src="<%=resource%>/xhr.js?v=git-23.159.15540-7154b89"></script>
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
|
||||
modemtype=0;
|
||||
cell=0;
|
||||
portx="-";
|
||||
phonenx = "";
|
||||
hided = 0;
|
||||
|
||||
XHR.poll(2, '<%=luci.dispatcher.build_url("admin", "network", "modem", "get_csq")%>', null,
|
||||
function(x, rv)
|
||||
{
|
||||
document.getElementById('date').innerHTML=rv.date;
|
||||
|
||||
document.getElementById('csq').innerHTML=rv.csq;
|
||||
document.getElementById('per').innerHTML=rv.per;
|
||||
document.getElementById('rssi').innerHTML=rv.rssi;
|
||||
document.getElementById('modem').innerHTML=rv.modem;
|
||||
document.getElementById('cops').innerHTML=rv.cops;
|
||||
document.getElementById('net_type').innerHTML=rv.net_type;
|
||||
document.getElementById('lac').innerHTML=rv.lac;
|
||||
document.getElementById('cid').innerHTML=rv.cid;
|
||||
document.getElementById('lacn').innerHTML=rv.lacn;
|
||||
document.getElementById('cidn').innerHTML=rv.cidn;
|
||||
document.getElementById('mcc').innerHTML=rv.mcc;
|
||||
document.getElementById('mnc').innerHTML=rv.mnc;
|
||||
document.getElementById('rnc').innerHTML=rv.rnc;
|
||||
document.getElementById('rncn').innerHTML=rv.rncn;
|
||||
document.getElementById('down').innerHTML=rv.down;
|
||||
document.getElementById('up').innerHTML=rv.up;
|
||||
document.getElementById('ecio').innerHTML=rv.ecio;
|
||||
document.getElementById('rscp').innerHTML=rv.rscp;
|
||||
document.getElementById('ecio1').innerHTML=rv.ecio1;
|
||||
document.getElementById('rscp1').innerHTML=rv.rscp1;
|
||||
document.getElementById('manufacturer').innerHTML=rv.manufacturer;
|
||||
document.getElementById('chan').innerHTML=rv.channel;
|
||||
document.getElementById('lband').innerHTML=rv.lband;
|
||||
document.getElementById('conmon').innerHTML=rv.netmode;
|
||||
document.getElementById('tempur').innerHTML=rv.tempur;
|
||||
|
||||
document.getElementById('pci').innerHTML=rv.pci;
|
||||
document.getElementById('sinr').innerHTML=rv.sinr;
|
||||
|
||||
document.getElementById('imei').innerHTML=rv.imei;
|
||||
document.getElementById('imsi').innerHTML=rv.imsi;
|
||||
document.getElementById('iccid').innerHTML=rv.iccid;
|
||||
document.getElementById('phone').innerHTML=rv.phone;
|
||||
|
||||
|
||||
<% if havegps == 1 then %>
|
||||
document.getElementById('lat').innerHTML=rv.lat;
|
||||
document.getElementById('long').innerHTML=rv.long;
|
||||
<% end %>
|
||||
// document.getElementById('idvp').innerHTML=rv.modid;
|
||||
// document.getElementById('proto').innerHTML=rv.proto;
|
||||
// document.getElementById('port').innerHTML=rv.port;
|
||||
|
||||
// document.getElementById('crate').innerHTML=rv.crate;
|
||||
// if (phonenx == "")
|
||||
// {
|
||||
// document.getElementById('phone').value=rv.phone;
|
||||
// document.getElementById('phonen').value=rv.phonen;
|
||||
// phonenx = document.getElementById('phone').value;
|
||||
// document.getElementById("phone").disabled=false;
|
||||
// document.getElementById("phonen").disabled=false;
|
||||
// document.getElementById("pho").disabled=false;
|
||||
// }
|
||||
|
||||
// if (rv.phone == "-")
|
||||
// {
|
||||
// document.getElementById('phone').value="-";
|
||||
// document.getElementById('phonen').value="-";
|
||||
// document.getElementById("pho").disabled=true;
|
||||
// document.getElementById("phone").disabled=true;
|
||||
// document.getElementById("phonen").disabled=true;
|
||||
// phonenx = "";
|
||||
// }
|
||||
|
||||
// simerr = rv.simerr;
|
||||
// if (simerr == "0")
|
||||
// {
|
||||
// document.getElementById("simwarn").style.display="none";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// document.getElementById("simwarn").style.display="block";
|
||||
// document.getElementById("simsg").style.color = "red";
|
||||
// if (simerr == "1")
|
||||
// {
|
||||
// document.getElementById("simsg").innerHTML = "<%:SIM卡已锁定,个人资料中未输入SIM Pin!!%>";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (simerr == "2")
|
||||
// {
|
||||
// document.getElementById("simsg").innerHTML = "<%:解锁SIM卡的Pin不正确%>";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (simerr == "3")
|
||||
// {
|
||||
// document.getElementById("simsg").innerHTML = "<%:无效SIM卡%>";
|
||||
// } else
|
||||
// {
|
||||
// document.getElementById("simsg").innerHTML = "<%:SIM卡未锁定.错误的SIM卡%>";
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// reslt=rv.result
|
||||
|
||||
// portx=rv.port
|
||||
// if (portx == "-" )
|
||||
// {
|
||||
// document.getElementById('inc1').style.display="none";
|
||||
// document.getElementById('dec1').style.display="none";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// document.getElementById('inc1').style.display="block";
|
||||
// document.getElementById('dec1').style.display="block";
|
||||
// }
|
||||
|
||||
// host = rv.host;
|
||||
// if(host == "1")
|
||||
// {
|
||||
// document.getElementById("pho").disabled=true;
|
||||
// }
|
||||
}
|
||||
);
|
||||
|
||||
function clear_data()
|
||||
{
|
||||
document.getElementById('port').innerHTML="<%:Changing Port%>";
|
||||
document.getElementById('csq').innerHTML="-";
|
||||
document.getElementById('per').innerHTML="-";
|
||||
document.getElementById('rssi').innerHTML="-";
|
||||
document.getElementById('modem').innerHTML="-";
|
||||
document.getElementById('cops').innerHTML="-";
|
||||
document.getElementById('net_type').innerHTML="-";
|
||||
document.getElementById('lac').innerHTML="-";
|
||||
document.getElementById('cid').innerHTML="-";
|
||||
document.getElementById('lacn').innerHTML="-";
|
||||
document.getElementById('cidn').innerHTML="-";
|
||||
document.getElementById('mcc').innerHTML="-";
|
||||
document.getElementById('mnc').innerHTML="-";
|
||||
document.getElementById('rnc').innerHTML="-";
|
||||
document.getElementById('rncn').innerHTML="-";
|
||||
document.getElementById('down').innerHTML="-";
|
||||
document.getElementById('up').innerHTML="-";
|
||||
document.getElementById('ecio').innerHTML="-";
|
||||
document.getElementById('rscp').innerHTML="-";
|
||||
document.getElementById('ecio1').innerHTML="-";
|
||||
document.getElementById('rscp1').innerHTML="-";
|
||||
document.getElementById('netmode').innerHTML="-";
|
||||
document.getElementById('manufacturer').innerHTML=" ";
|
||||
document.getElementById('chan').innerHTML=" ";
|
||||
document.getElementById('conmon').innerHTML="-";
|
||||
document.getElementById('phone').value="-";
|
||||
|
||||
|
||||
document.getElementById('imei').innerHTML="-";
|
||||
document.getElementById('imsi').innerHTML="-";
|
||||
document.getElementById('iccid').innerHTML="-";
|
||||
document.getElementById('lband').innerHTML="-";
|
||||
document.getElementById('pci').innerHTML="-";
|
||||
<% if havegps == 1 then %>
|
||||
document.getElementById('lat').innerHTML="-";
|
||||
document.getElementById('long').innerHTML="-";
|
||||
<% end %>
|
||||
|
||||
// document.getElementById('idvp').innerHTML="-";
|
||||
// document.getElementById('phonen').value="-";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//]]></script>
|
||||
|
||||
|
||||
<div class="cbi-map" id="cbi-modem">
|
||||
<h2 name="content"><%:信号状态/模块信息%></h2>
|
||||
<div class="cbi-map-descr">请注意该插件所有功能并无适配所有5G模块,不用妄想冷门模块插上就能用(有能力者自行适配)
|
||||
</div>
|
||||
|
||||
<fieldset class="cbi-section" id="simwarn" style="display:none;">
|
||||
<legend><%:SIM警告%></legend>
|
||||
<table width="550" border="0">
|
||||
<tr>
|
||||
<td width="10%"></td>
|
||||
<td width="60%"><div align="left" id="simsg" style="font-size:1.875em"><strong></strong></div></td>
|
||||
<td width="30%"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
|
||||
|
||||
<fieldset class="cbi-section" id="cbi-mod">
|
||||
<legend><%:综合信息%></legend>
|
||||
<table width="100%" cellspacing="10">
|
||||
<tr><td width="20%"><%:模块 :%></td><td id="modem">-</td><td></td></tr>
|
||||
<tr><td width="20%"><%:制造商 :%></td><td id="manufacturer"></td><td></td></tr>
|
||||
<tr><td width="20%"><%:温度 : %></td><td id="tempur"></td><td></td></tr>
|
||||
<tr><td width="20%"><%:更新时间 : %></td><td id="date"></td><td></td></tr>
|
||||
<!-- <tr><td width="20%"><%:ID : %></td><td id="idvp"></td><td></td></tr>
|
||||
<tr><td width="20%"><%:端口 : %></td><td id="port"></td><td></td></tr>
|
||||
<tr><td width="20%"><%:协议 : %></td><td id="proto"></td><td></td></tr> -->
|
||||
</table>
|
||||
</fieldset>
|
||||
|
||||
<% if nosms == 0 then %>
|
||||
<% end %>
|
||||
|
||||
<fieldset class="cbi-section" id="cbi-msinfo">
|
||||
<legend><%:通信模块/SIM卡信息%></legend>
|
||||
<table width="100%" cellspacing="10">
|
||||
<tr><td width="20%"><%:运营商 : %></td><td id="cops"></td><td></td></tr>
|
||||
<tr><td width="20%"><%:IMEI :%></td><td id="imei"></td><td></td></tr>
|
||||
<tr><td width="20%"><%:IMSI : %></td><td id="imsi"></td><td></td></tr>
|
||||
<tr><td width="20%"><%:ICCID : %></td><td id="iccid"></td><td></td></tr>
|
||||
<tr><td width="20%"><%:SIM卡号码 : %></td><td id="phone"></td><td></td></tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
|
||||
|
||||
<fieldset class="cbi-section" id="cbi-sig">
|
||||
<legend><%:信号状态%></legend>
|
||||
<table width="100%" cellspacing="10">
|
||||
<tr><td width="20%"><%:蜂窝网络类型 :%></td><td id="net_type"></td><td></td></tr>
|
||||
<tr><td width="20%"><%:CSQ : %></td><td id="csq"></td><td></td></tr>
|
||||
<tr><td width="20%"><%:信号强度 : %></td><td id="per"></td><td></td></tr>
|
||||
<tr><td width="20%"><%:信号接收强度 RSSI : %></td><td id="rssi"></td><td></td></tr>
|
||||
<tr><td width="20%"><%:参考信号接收质量 RSRQ : %></td><td><ul><span id="ecio" class="r"></span><span id="ecio1" class="r"></span></ul></td><td></td></tr>
|
||||
<tr><td width="20%"><%:参考信号接收功率 RSRP : %></td><td><ul><span id="rscp" class="r"></span><span id="rscp1" class="r"></span></ul></td><td></td></tr>
|
||||
<tr><td width="20%"><%:信噪比 SINR : %></td><td id="sinr"></td><td></td></tr>
|
||||
<tr><td width="20%"><%:连接状态监控 : %></td><td id="conmon"></td><td></td></tr>
|
||||
|
||||
</table>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="cbi-section" id="cbi-sig">
|
||||
<legend><%:基站信息%></legend>
|
||||
<table width="100%" cellspacing="10">
|
||||
<tr><td width="20%"><%:MCC / MNC :%></td><td id="mcc"></td><td id="mnc"></td></tr>
|
||||
<tr><td width="20%"><%:eNB ID : %></td><td><ul><span id="rnc" class="r"></span><span id="rncn" class="r"></span></ul></td><td></td></tr>
|
||||
<tr><td width="20%"><%:TAC : %></td><td><ul><span id="lac" class="r"></span><span id="lacn" class="r"></span></ul></td><td></td></tr>
|
||||
<tr><td width="20%"><%:Cell ID : %></td><td><ul><span id="cid" class="r"></span><span id="cidn" class="r"></span></ul></td><td></td></tr>
|
||||
<tr><td width="20%"><%:频段 Band : %></td><td id="lband"></td><td></td></tr>
|
||||
<tr><td width="20%"><%:频点 Channel : %></td><td id="chan"></td><td></td></tr>
|
||||
<tr><td width="20%"><%:物理小区标识 PCI : %></td><td id="pci"></td><td></td></tr>
|
||||
<tr><td width="20%"><%:最大Qos级别 Maximum Qos : %></td><td><ul><span id="down" class="r"></span><span id="up" class="r"></span></ul></td><td></td></tr>
|
||||
|
||||
</table>
|
||||
</fieldset>
|
||||
|
||||
|
||||
<% if havegps == 1 then %>
|
||||
<fieldset class="cbi-section" id="cbi-gps">
|
||||
<legend><%:GPS 定位%></legend>
|
||||
<table width="550" border="0">
|
||||
<tr>
|
||||
<td width="30%"><div align="right"><%:纬度 :%></div></td>
|
||||
<td><ul id="lat"></ul></td>
|
||||
<td width="1%"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><div align="right"><%:经度 :%></div></td>
|
||||
<td><ul id="long"></ul></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
<% end %>
|
||||
|
||||
|
||||
</div>
|
||||
<%+footer%>
|
||||
|
3
luci-app-modem/luasrc/view/modem/status.htm
Normal file
3
luci-app-modem/luasrc/view/modem/status.htm
Normal file
@ -0,0 +1,3 @@
|
||||
<%+cbi/valueheader%>
|
||||
<font class="_status" hint="<%=self:cfgvalue(section)%>">--</font>
|
||||
<%+cbi/valuefooter%>
|
135
luci-app-modem/note/OpenWRT软件开发.md
Normal file
135
luci-app-modem/note/OpenWRT软件开发.md
Normal file
@ -0,0 +1,135 @@
|
||||
# OpenWRT软件开发
|
||||
|
||||
# 一、相关文档
|
||||
|
||||
UCI系统:https://openwrt.org/docs/guide-user/base-system/uci
|
||||
|
||||
OpenWRT命令解释器:https://openwrt.org/zh/docs/guide-user/base-system/user.beginner.cli
|
||||
|
||||
热插拔:https://openwrt.org/zh/docs/guide-user/base-system/hotplug
|
||||
|
||||
网络基础配置:https://openwrt.org/zh/docs/guide-user/base-system/basic-networking
|
||||
|
||||
Web界面相关
|
||||
|
||||
- 自定义主题:https://github.com/openwrt/luci/wiki/HowTo:-Create-Themes
|
||||
- 模块参考:https://github.com/openwrt/luci/wiki/Modules
|
||||
- 模板参考:https://github.com/openwrt/luci/wiki/Templates
|
||||
- 实例参考:https://blog.csdn.net/byb123/article/details/77921486/
|
||||
|
||||
# 二、网络配置
|
||||
|
||||
在任何网络配置更改(通过uci或其他方式)之后,你需要输入以下内容来重载网络配置:
|
||||
|
||||
```shell
|
||||
service network reload
|
||||
```
|
||||
|
||||
如果您安装的版本没有提供`service`命令,则可以使用:
|
||||
|
||||
```shell
|
||||
/etc/init.d/network reload
|
||||
```
|
||||
|
||||
# 三、拨号程序
|
||||
|
||||
拨号步骤
|
||||
|
||||
```shell
|
||||
run_dial()
|
||||
{
|
||||
local enabled
|
||||
config_get_bool enabled $1 enabled
|
||||
|
||||
if [ "$enabled" = "1" ]; then
|
||||
local apn
|
||||
local user
|
||||
local password
|
||||
local auth
|
||||
local ipv6
|
||||
local device
|
||||
|
||||
#获取配置
|
||||
config_get apn $1 apn
|
||||
config_get user $1 user
|
||||
config_get password $1 password
|
||||
config_get auth $1 auth
|
||||
config_get ipv6 $1 ipv6
|
||||
config_get device $1 device
|
||||
|
||||
devname="$(basename "$device")" #获取调制解调器,/dev/cdc-wdm0->cdc-wdm0
|
||||
devicepath="$(find /sys/class/ -name $devname)" #找到设备快捷路径,/sys/class/net/cdc-wdm0
|
||||
devpath="$(readlink -f $devicepath/device/)" #找出连接的物理设备路径,/sys/devices/.../
|
||||
ifname="$( ls "$devpath"/net )" #获取设备名,/sys/devices/.../net->cdc-wdm0
|
||||
|
||||
procd_open_instance #打开一个示例?
|
||||
procd_set_param command quectel-CM #设置参数?
|
||||
if [ "$ipv6" = 1 ]; then
|
||||
procd_append_param command -4 -6
|
||||
fi
|
||||
if [ "$apn" != "" ];then
|
||||
procd_append_param command -s $apn
|
||||
fi
|
||||
if [ "$user" != "" ]; then
|
||||
procd_append_param command $user
|
||||
fi
|
||||
if [ "$password" != "" ]; then
|
||||
procd_append_param command $password
|
||||
fi
|
||||
if [ "$auth" != "" ]; then
|
||||
procd_append_param command $auth
|
||||
fi
|
||||
if [ "$device" != "" ]; then
|
||||
procd_append_param command -i $ifname
|
||||
fi
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
|
||||
if [ -d /sys/class/net/rmnet_mhi0 ]; then
|
||||
pre_set rmnet_mhi0.1
|
||||
elif [ -d /sys/class/net/wwan0_1 ]; then
|
||||
pre_set wwan0_1
|
||||
elif [ -d /sys/class/net/wwan0.1 ]; then
|
||||
pre_set wwan0.1
|
||||
elif [ -d /sys/class/net/wwan0 ]; then
|
||||
pre_set wwan0
|
||||
fi
|
||||
fi
|
||||
|
||||
sleep 15
|
||||
}
|
||||
```
|
||||
|
||||
# 四、shell
|
||||
|
||||
获取设备物理路径
|
||||
|
||||
device_bus_path.sh
|
||||
|
||||
```shell
|
||||
#!/bin/sh
|
||||
|
||||
#获取物理设备地址
|
||||
local device_name="$(basename "$1")"
|
||||
local device_path="$(find /sys/class/ -name $device_name)"
|
||||
local device_physical_path="$(readlink -f $device_path/device/)"
|
||||
local device_bus_path=$(dirname "$device_physical_path")
|
||||
return $device_bus_path
|
||||
```
|
||||
|
||||
设置配置
|
||||
|
||||
setConfig.sh
|
||||
|
||||
```shell
|
||||
#!/bin/sh
|
||||
|
||||
#处理获取到的路径
|
||||
substr="${parentDir/\/sys\/devices\//}"
|
||||
echo $substr
|
||||
|
||||
#写入到配置中
|
||||
uci set modem.modem1.path="$substr"
|
||||
uci commit modem2
|
||||
```
|
||||
|
83
luci-app-modem/po/zh-cn/modem.po
Normal file
83
luci-app-modem/po/zh-cn/modem.po
Normal file
@ -0,0 +1,83 @@
|
||||
msgid "Base Setting"
|
||||
msgstr "基本设置"
|
||||
|
||||
msgid "Modem"
|
||||
msgstr "移动通信模组"
|
||||
|
||||
msgid "Modem Config"
|
||||
msgstr "模组配置"
|
||||
|
||||
msgid "Modem List"
|
||||
msgstr "模块列表"
|
||||
|
||||
msgid "Configuration panel for Modem, Add and configure all modules on this page"
|
||||
msgstr "通信模组服务配置界面,在此页面添加和配置所有模块"
|
||||
|
||||
msgid "AT Commands"
|
||||
msgstr "AT命令"
|
||||
|
||||
msgid "Modem Info"
|
||||
msgstr "模组信息"
|
||||
|
||||
msgid "General Settings"
|
||||
msgstr "通用配置"
|
||||
|
||||
msgid "Advanced Settings"
|
||||
msgstr "高级配置"
|
||||
|
||||
msgid "Remarks"
|
||||
msgstr "备注"
|
||||
|
||||
msgid "Moblie Network"
|
||||
msgstr "移动网络"
|
||||
|
||||
msgid "UNKNOWN"
|
||||
msgstr "未知"
|
||||
|
||||
msgid "The network device was not found"
|
||||
msgstr "移动网络"
|
||||
|
||||
msgid "Mode"
|
||||
msgstr "模式"
|
||||
|
||||
msgid "Dial Tool"
|
||||
msgstr "拨号工具"
|
||||
|
||||
msgid "Auto Choose"
|
||||
msgstr "自动选择"
|
||||
|
||||
msgid "quectel-CM"
|
||||
msgstr "移远模组拨号工具"
|
||||
|
||||
msgid "PDP Type"
|
||||
msgstr "网络类型"
|
||||
|
||||
msgid "APN"
|
||||
msgstr "接入点"
|
||||
|
||||
msgid "China Mobile"
|
||||
msgstr "中国移动"
|
||||
|
||||
msgid "China Unicom"
|
||||
msgstr "中国联通"
|
||||
|
||||
msgid "China Telecom"
|
||||
msgstr "中国电信"
|
||||
|
||||
msgid "China Broadcast"
|
||||
msgstr "中国广电"
|
||||
|
||||
msgid "Skytone"
|
||||
msgstr "天际通"
|
||||
|
||||
msgid "PAP/CHAP Username"
|
||||
msgstr "PAP/CHAP 用户名"
|
||||
|
||||
msgid "PAP/CHAP Password"
|
||||
msgstr "PAP/CHAP 密码"
|
||||
|
||||
msgid "Authentication Type"
|
||||
msgstr "认证类型"
|
||||
|
||||
msgid "NONE"
|
||||
msgstr "无"
|
38
luci-app-modem/root/etc/config/modem
Normal file
38
luci-app-modem/root/etc/config/modem
Normal file
@ -0,0 +1,38 @@
|
||||
|
||||
config global 'global'
|
||||
option enable '0'
|
||||
|
||||
config modem-device 'modem0'
|
||||
option device_node '/dev/mhi_QMI0'
|
||||
option data_interface 'pcie'
|
||||
option path '/sys/devices/pci0000:00/0000:00:08.0'
|
||||
option at_port '/dev/mhi_DUN'
|
||||
option name 'fm150-ae'
|
||||
option manufacturer 'fibocom'
|
||||
option net 'rmnet_mhi0'
|
||||
option net_interface 'rmnet_mhi0.1'
|
||||
list ports '/dev/mhi_BHI'
|
||||
list ports '/dev/mhi_DIAG'
|
||||
list ports '/dev/mhi_DUN'
|
||||
list ports '/dev/mhi_LOOPBACK'
|
||||
list modes 'qmi'
|
||||
|
||||
config modem-device 'modem1'
|
||||
option name 'rm500q-gl'
|
||||
option manufacturer 'quectel'
|
||||
option path 'pci0000:00/0000:00:07.0'
|
||||
option data_interface 'usb'
|
||||
option device_node '/dev/cdc_wdm0'
|
||||
list modes 'qmi'
|
||||
list modes 'gobinet'
|
||||
list modes 'ecm'
|
||||
list modes 'mbim'
|
||||
list modes 'rndis'
|
||||
list modes 'ncm'
|
||||
|
||||
config config 'e0b28f3e24554d52920bae39fe227d36'
|
||||
option enable '0'
|
||||
option remarks 'test'
|
||||
option moblie_net 'rmnet_mhi0'
|
||||
option mode 'qmi'
|
||||
option pdp_type 'ipv4_ipv6'
|
369
luci-app-modem/root/etc/init.d/modem
Normal file
369
luci-app-modem/root/etc/init.d/modem
Normal file
@ -0,0 +1,369 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2006-2014 OpenWrt.org
|
||||
|
||||
START=94
|
||||
STOP=13
|
||||
USE_PROCD=1
|
||||
|
||||
#设置拨号模式
|
||||
# $1:拨号模式
|
||||
set_mode()
|
||||
{
|
||||
#获取AT串口、制造商、模块名
|
||||
local at_port=$(uci -q get modem.modem$modem_no.at_port)
|
||||
local manufacturer=$(uci -q get modem.modem$modem_no.manufacturer)
|
||||
local name=$(uci -q get modem.modem$modem_no.name)
|
||||
|
||||
#分制造商设置不同的AT命令
|
||||
local command
|
||||
if [ "$manufacturer" = "quectel" ]; then
|
||||
local mode_num
|
||||
case $1 in
|
||||
"qmi") mode_num='0' ;;
|
||||
"gobinet") mode_num='0' ;;
|
||||
"ecm") mode_num='1' ;;
|
||||
"mbim") mode_num='2' ;;
|
||||
"rndis") mode_num='3' ;;
|
||||
"ncm") mode_num='5' ;;
|
||||
"*") mode_num='0' ;;
|
||||
esac
|
||||
|
||||
#查询当前拨号模式
|
||||
command='AT+QCFG="usbnet"'
|
||||
local at_result=$(sh /usr/share/modem/modem_at.sh $at_port $command)
|
||||
if [[ "$at_result" != *"$mode_num"* ]]; then
|
||||
#切换到指定的拨号模式
|
||||
case $1 in
|
||||
"qmi") command='AT+QCFG="usbnet",0' ;;
|
||||
"gobinet") command='AT+QCFG="usbnet",0' ;;
|
||||
"ecm") command='AT+QCFG="usbnet",1' ;;
|
||||
"mbim") command='AT+QCFG="usbnet",2' ;;
|
||||
"rndis") command='AT+QCFG="usbnet",3' ;;
|
||||
"ncm") command='AT+QCFG="usbnet",5' ;;
|
||||
"*") command='AT+QCFG="usbnet",0' ;;
|
||||
esac
|
||||
sh /usr/share/modem/modem_at.sh $at_port $command
|
||||
#移远切换模式后,还需要重启模块,待测试
|
||||
fi
|
||||
elif [ "$manufacturer" = "fibocom" ]; then
|
||||
if [ "$name" = "fm150-ae" ]; then
|
||||
local mode_num
|
||||
case $1 in
|
||||
"qmi") mode_num='32' ;;
|
||||
"gobinet") mode_num='32' ;;
|
||||
"ecm") mode_num='23' ;;
|
||||
"mbim") mode_num='29' ;;
|
||||
"rndis") mode_num='24' ;;
|
||||
"ncm") mode_num='23' ;;
|
||||
"*") mode_num='32' ;;
|
||||
esac
|
||||
|
||||
#查询当前拨号模式
|
||||
command='AT+GTUSBMODE?'
|
||||
local at_result=$(sh /usr/share/modem/modem_at.sh $at_port $command)
|
||||
if [[ "$at_result" != *"$mode_num"* ]]; then
|
||||
#切换到指定的拨号模式
|
||||
case $1 in
|
||||
"qmi") command='AT+GTUSBMODE=32' ;;
|
||||
"gobinet") command='AT+GTUSBMODE=32' ;;
|
||||
"ecm") command='AT+GTUSBMODE=23' ;;
|
||||
"mbim") command='AT+GTUSBMODE=29' ;;
|
||||
"rndis") command='AT+GTUSBMODE=24' ;;
|
||||
"ncm") command='AT+GTUSBMODE=23' ;;
|
||||
"*") command='AT+GTUSBMODE=32' ;;
|
||||
esac
|
||||
sh /usr/share/modem/modem_at.sh $at_port $command
|
||||
fi
|
||||
elif [ "$name" = "fm650" ]; then
|
||||
#待处理
|
||||
echo "fm650"
|
||||
fi
|
||||
else
|
||||
#没有匹配到制造商,需要手动切换模块的拨号模式
|
||||
echo "请手动切换模块的拨号模式"
|
||||
fi
|
||||
}
|
||||
|
||||
#设置防火墙
|
||||
set_firewall()
|
||||
{
|
||||
local num=`uci show firewall | grep "name='wan'" | wc -l`
|
||||
local wwan_num=`uci -q get firewall.@zone[$num].network | grep -w "$1" | wc -l`
|
||||
if [ "$wwan_num" = "0" ]; then
|
||||
uci add_list firewall.@zone[$num].network="$1"
|
||||
fi
|
||||
uci commit firewall
|
||||
}
|
||||
|
||||
#设置IPv4网络接口
|
||||
# $1:网络接口名称
|
||||
# $2:网络接口
|
||||
set_ipv4_interface()
|
||||
{
|
||||
[ "$(uci -q get network.$1.ifname)" != "$2" ] && {
|
||||
uci set network.$1='interface'
|
||||
uci set network.$1.ifname="$2"
|
||||
uci set network.$1.proto='dhcp'
|
||||
uci commit network
|
||||
|
||||
#加入WAN防火墙
|
||||
set_firewall $1
|
||||
|
||||
#启动网络接口
|
||||
ifup $1
|
||||
}
|
||||
}
|
||||
|
||||
#设置IPv6网络接口
|
||||
# $1:网络接口名称
|
||||
# $2:网络接口
|
||||
set_ipv6_interface()
|
||||
{
|
||||
if [ "$(uci -q get network.$1.ifname)" != "$2" ]; then
|
||||
uci set network.$1='interface'
|
||||
uci set network.$1.ifname="$2"
|
||||
uci set network.$1.proto='dhcpv6'
|
||||
uci set network.$1.extendprefix='1'
|
||||
uci commit network
|
||||
|
||||
#加入WAN防火墙
|
||||
set_firewall $1
|
||||
|
||||
#启动网络接口
|
||||
ifup $1
|
||||
else
|
||||
uci set network.$1.extendprefix='1'
|
||||
uci commit network
|
||||
fi
|
||||
}
|
||||
|
||||
#设置网络接口
|
||||
# $1:模块序号
|
||||
# $2:网络接口
|
||||
set_interface()
|
||||
{
|
||||
case $pdp_type in
|
||||
"ipv4") set_ipv4_interface wwan_5g_$1 $2 ;;
|
||||
"ipv6") set_ipv6_interface wwan6_5g_$1 $2 ;;
|
||||
"ipv4_ipv6")
|
||||
set_ipv4_interface wwan_5g_$1 $2
|
||||
set_ipv6_interface wwan6_5g_$1 $2
|
||||
;;
|
||||
"*")
|
||||
set_ipv4_interface wwan_5g_$1 $2
|
||||
set_ipv6_interface wwan6_5g_$1 $2
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
qmi()
|
||||
{
|
||||
#设置拨号模式
|
||||
set_mode qmi
|
||||
|
||||
#设置网络接口
|
||||
local net_interface=$(uci -q get modem.modem$modem_no.net_interface)
|
||||
set_interface $modem_no $net_interface
|
||||
|
||||
#拨号
|
||||
procd_open_instance
|
||||
|
||||
if [ "$dial_tool" = "quectel-CM" ]; then
|
||||
procd_set_param command quectel-CM
|
||||
elif [[ -z "$dial_tool" ]]; then
|
||||
procd_set_param command quectel-CM
|
||||
else
|
||||
procd_set_param command $dial_tool
|
||||
fi
|
||||
|
||||
case $pdp_type in
|
||||
"ipv4") procd_append_param command -4 ;;
|
||||
"ipv6") procd_append_param command -6 ;;
|
||||
"ipv4_ipv6") procd_append_param command -4 -6 ;;
|
||||
"*") procd_append_param command -4 -6 ;;
|
||||
esac
|
||||
|
||||
if [ "$apn" != "" ]; then
|
||||
procd_append_param command -s $apn
|
||||
fi
|
||||
if [ "$user" != "" ]; then
|
||||
procd_append_param command $user
|
||||
fi
|
||||
if [ "$password" != "" ]; then
|
||||
procd_append_param command $password
|
||||
fi
|
||||
if [ "$auth" != "" ]; then
|
||||
procd_append_param command $auth
|
||||
fi
|
||||
if [ "$moblie_net" != "" ]; then
|
||||
procd_append_param command -i $moblie_net
|
||||
fi
|
||||
procd_set_param respawn
|
||||
procd_set_param procd_pid /var/run/modem/modem$modem_no.pid
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
gobinet()
|
||||
{
|
||||
qmi
|
||||
}
|
||||
|
||||
ecm()
|
||||
{
|
||||
#设置拨号模式
|
||||
set_mode ecm
|
||||
|
||||
#获取网络接口、AT串口、制造商
|
||||
local net_interface=$(uci -q get modem.modem$modem_no.net_interface)
|
||||
local at_port=$(uci -q get modem.modem$modem_no.at_port)
|
||||
local manufacturer=$(uci -q get modem.modem$modem_no.manufacturer)
|
||||
#设置网络接口
|
||||
set_interface $modem_no $net_interface
|
||||
|
||||
#拨号
|
||||
procd_open_instance
|
||||
procd_set_param command sh /usr/share/modem/modem_at.sh $at_port
|
||||
if [ "$manufacturer" = "quectel" ]; then
|
||||
procd_append_param command 'ATI'
|
||||
elif [ "$manufacturer" = "fibocom" ]; then
|
||||
procd_append_param command 'AT+GTRNDIS=1,1'
|
||||
fi
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
mbim()
|
||||
{
|
||||
qmi
|
||||
}
|
||||
|
||||
rndis()
|
||||
{
|
||||
ecm
|
||||
#广和通的rndis和ecm不同,后续再测试
|
||||
}
|
||||
|
||||
ncm()
|
||||
{
|
||||
ecm
|
||||
}
|
||||
|
||||
#实例运行状态
|
||||
instance_status()
|
||||
{
|
||||
#获取modem的实例信息
|
||||
local response=$(ubus call service list '{"name": "modem"}')
|
||||
local instance_number=$(echo "$response" | jq -r '.modem.instances | length')
|
||||
for i in $(seq 1 $((instance_number))); do
|
||||
#获取运行状态和拨号命令
|
||||
local running_status=$(echo "$response" | jq -r '.modem.instances.$i.running')
|
||||
local command=$(echo "$response" | jq -r '.modem.instances.instance$i.command')
|
||||
if [ "$running_status" = "$true" ] && [[ "$command" = *"$moblie_net"* ]]; then
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
dial()
|
||||
{
|
||||
config_get enable $1 enable
|
||||
[ "$enable" = "0" ] && return 0
|
||||
|
||||
local remarks #备注
|
||||
local moblie_net #移动网络
|
||||
local mode #拨号模式
|
||||
local dial_tool #拨号工具
|
||||
local pdp_type #网络类型
|
||||
local apn
|
||||
local user
|
||||
local password
|
||||
local auth
|
||||
|
||||
config_get remarks $1 remarks
|
||||
config_get moblie_net $1 moblie_net
|
||||
config_get mode $1 mode
|
||||
config_get dial_tool $1 dial_tool
|
||||
config_get pdp_type $1 pdp_type
|
||||
config_get apn $1 apn
|
||||
config_get user $1 user
|
||||
config_get password $1 password
|
||||
config_get auth $1 auth
|
||||
|
||||
#查看移动网络是否已经有实例在运行
|
||||
instance_status
|
||||
[ $? = "1" ] && return 0
|
||||
|
||||
#获取模块序号
|
||||
local modem_number=$(uci -q get modem.@global[0].option.modem_number)
|
||||
for i in $(seq 0 $((modem_number-1))); do
|
||||
local net=$(uci -q get modem.modem$i.net)
|
||||
if [ "$net" = "$moblie_net" ]; then
|
||||
#模块序号
|
||||
modem_no=$i
|
||||
fi
|
||||
done
|
||||
|
||||
#根据不同的拨号模式拨号
|
||||
if [ "$mode" = "qmi" ]; then
|
||||
qmi
|
||||
elif [ "$mode" = "gobinet" ]; then
|
||||
gobinet #暂无,同qmi
|
||||
elif [ "$mode" = "ecm" ]; then
|
||||
ecm
|
||||
elif [ "$mode" = "mbim" ]; then
|
||||
mbim
|
||||
elif [ "$mode" = "rndis" ]; then
|
||||
rndis
|
||||
elif [ "$mode" = "ncm" ]; then
|
||||
ncm
|
||||
fi
|
||||
|
||||
# sleep 15
|
||||
}
|
||||
|
||||
stop_dial()
|
||||
{
|
||||
#停止所有拨号
|
||||
config_get enable $1 enable
|
||||
[ "$enable" = "0" ] && {
|
||||
killall quectel-CM >/dev/null 2>&1
|
||||
return 0
|
||||
}
|
||||
|
||||
#停止单个拨号
|
||||
local moblie_net #移动网络
|
||||
config_get moblie_net $1 moblie_net
|
||||
|
||||
#获取modem的实例信息
|
||||
local response=$(ubus call service list '{"name": "modem"}')
|
||||
local instance_number=$(echo "$response" | jq -r '.modem.instances | length')
|
||||
for i in $(seq 1 $((instance_number))); do
|
||||
#获取拨号命令
|
||||
local command=$(echo "$response" | jq -r '.modem.instances.instance$i.command')
|
||||
if [ "$command" = *"$moblie_net"* ]; then
|
||||
local pid=$(echo "$response" | jq -r '.modem.instances.$i.pid')
|
||||
kill $pid >/dev/null 2>&1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
service_triggers()
|
||||
{
|
||||
procd_add_reload_trigger "modem"
|
||||
}
|
||||
|
||||
start_service() {
|
||||
enable=$(uci -q get modem.@global[0].enable)
|
||||
if [ "$enable" = "0" ];then
|
||||
stop_service
|
||||
else
|
||||
config_load modem
|
||||
config_foreach dial "config"
|
||||
fi
|
||||
}
|
||||
|
||||
stop_service()
|
||||
{
|
||||
config_load modem
|
||||
config_foreach stop_dial "config"
|
||||
}
|
8
luci-app-modem/root/etc/init.d/modeminit
Normal file
8
luci-app-modem/root/etc/init.d/modeminit
Normal file
@ -0,0 +1,8 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=99
|
||||
|
||||
start() {
|
||||
# /bin/sh /usr/share/cpe/rssi &
|
||||
/bin/sh /usr/share/modem/modem_data &
|
||||
}
|
19
luci-app-modem/root/etc/uci-defaults/luci-app-modem
Normal file
19
luci-app-modem/root/etc/uci-defaults/luci-app-modem
Normal file
@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci -q get modem.global >/dev/null || uci -q batch <<-EOF >/dev/null
|
||||
set modem.global=global
|
||||
set modem.global.enable=1
|
||||
commit modem
|
||||
EOF
|
||||
|
||||
/etc/init.d/modem enable
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@modem[-1]
|
||||
add ucitrack modem
|
||||
set ucitrack.@modem[-1].init=modem
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
rm -rf /tmp/luci-*cache
|
||||
exit 0
|
281
luci-app-modem/root/usr/share/modem/fibocom.sh
Normal file
281
luci-app-modem/root/usr/share/modem/fibocom.sh
Normal file
@ -0,0 +1,281 @@
|
||||
#!/bin/sh
|
||||
|
||||
# fibocom获取基站信息
|
||||
Fibocom_Cellinfo()
|
||||
{
|
||||
#baseinfo.gcom
|
||||
OX=$( sh modem_at.sh $at_port "ATI")
|
||||
OX=$( sh modem_at.sh $at_port "AT+CGEQNEG=1")
|
||||
|
||||
#cellinfo0.gcom
|
||||
OX1=$( sh modem_at.sh $at_port "AT+COPS=3,0;+COPS?")
|
||||
OX2=$( sh modem_at.sh $at_port "AT+COPS=3,2;+COPS?")
|
||||
OX=$OX1" "$OX2
|
||||
|
||||
#cellinfo.gcom
|
||||
OY1=$( sh modem_at.sh $at_port "AT+CREG=2;+CREG?;+CREG=0")
|
||||
OY2=$( sh modem_at.sh $at_port "AT+CEREG=2;+CEREG?;+CEREG=0")
|
||||
OY3=$( sh modem_at.sh $at_port "AT+C5GREG=2;+C5GREG?;+C5GREG=0")
|
||||
OY=$OY1" "$OY2" "$OY3
|
||||
|
||||
|
||||
OXx=$OX
|
||||
OX=$(echo $OX | tr 'a-z' 'A-Z')
|
||||
OY=$(echo $OY | tr 'a-z' 'A-Z')
|
||||
OX=$OX" "$OY
|
||||
|
||||
#debug "$OX"
|
||||
#debug "$OY"
|
||||
|
||||
COPS="-"
|
||||
COPS_MCC="-"
|
||||
COPS_MNC="-"
|
||||
COPSX=$(echo $OXx | grep -o "+COPS: [01],0,.\+," | cut -d, -f3 | grep -o "[^\"]\+")
|
||||
|
||||
if [ "x$COPSX" != "x" ]; then
|
||||
COPS=$COPSX
|
||||
fi
|
||||
|
||||
COPSX=$(echo $OX | grep -o "+COPS: [01],2,.\+," | cut -d, -f3 | grep -o "[^\"]\+")
|
||||
|
||||
if [ "x$COPSX" != "x" ]; then
|
||||
COPS_MCC=${COPSX:0:3}
|
||||
COPS_MNC=${COPSX:3:3}
|
||||
if [ "$COPS" = "-" ]; then
|
||||
COPS=$(awk -F[\;] '/'$COPS'/ {print $2}' $ROOTER/signal/mccmnc.data)
|
||||
[ "x$COPS" = "x" ] && COPS="-"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$COPS" = "-" ]; then
|
||||
COPS=$(echo "$O" | awk -F[\"] '/^\+COPS: 0,0/ {print $2}')
|
||||
if [ "x$COPS" = "x" ]; then
|
||||
COPS="-"
|
||||
COPS_MCC="-"
|
||||
COPS_MNC="-"
|
||||
fi
|
||||
fi
|
||||
COPS_MNC=" "$COPS_MNC
|
||||
|
||||
OX=$(echo "${OX//[ \"]/}")
|
||||
CID=""
|
||||
CID5=""
|
||||
RAT=""
|
||||
REGV=$(echo "$OX" | grep -o "+C5GREG:2,[0-9],[A-F0-9]\{2,6\},[A-F0-9]\{5,10\},[0-9]\{1,2\}")
|
||||
if [ -n "$REGV" ]; then
|
||||
LAC5=$(echo "$REGV" | cut -d, -f3)
|
||||
LAC5=$LAC5" ($(printf "%d" 0x$LAC5))"
|
||||
CID5=$(echo "$REGV" | cut -d, -f4)
|
||||
CID5L=$(printf "%010X" 0x$CID5)
|
||||
RNC5=${CID5L:1:6}
|
||||
RNC5=$RNC5" ($(printf "%d" 0x$RNC5))"
|
||||
CID5=${CID5L:7:3}
|
||||
CID5="Short $(printf "%X" 0x$CID5) ($(printf "%d" 0x$CID5)), Long $(printf "%X" 0x$CID5L) ($(printf "%d" 0x$CID5L))"
|
||||
RAT=$(echo "$REGV" | cut -d, -f5)
|
||||
fi
|
||||
REGV=$(echo "$OX" | grep -o "+CEREG:2,[0-9],[A-F0-9]\{2,4\},[A-F0-9]\{5,8\}")
|
||||
REGFMT="3GPP"
|
||||
if [ -z "$REGV" ]; then
|
||||
REGV=$(echo "$OX" | grep -o "+CEREG:2,[0-9],[A-F0-9]\{2,4\},[A-F0-9]\{1,3\},[A-F0-9]\{5,8\}")
|
||||
REGFMT="SW"
|
||||
fi
|
||||
if [ -n "$REGV" ]; then
|
||||
LAC=$(echo "$REGV" | cut -d, -f3)
|
||||
LAC=$(printf "%04X" 0x$LAC)" ($(printf "%d" 0x$LAC))"
|
||||
if [ $REGFMT = "3GPP" ]; then
|
||||
CID=$(echo "$REGV" | cut -d, -f4)
|
||||
else
|
||||
CID=$(echo "$REGV" | cut -d, -f5)
|
||||
fi
|
||||
CIDL=$(printf "%08X" 0x$CID)
|
||||
RNC=${CIDL:1:5}
|
||||
RNC=$RNC" ($(printf "%d" 0x$RNC))"
|
||||
CID=${CIDL:6:2}
|
||||
CID="Short $(printf "%X" 0x$CID) ($(printf "%d" 0x$CID)), Long $(printf "%X" 0x$CIDL) ($(printf "%d" 0x$CIDL))"
|
||||
|
||||
else
|
||||
REGV=$(echo "$OX" | grep -o "+CREG:2,[0-9],[A-F0-9]\{2,4\},[A-F0-9]\{2,8\}")
|
||||
if [ -n "$REGV" ]; then
|
||||
LAC=$(echo "$REGV" | cut -d, -f3)
|
||||
CID=$(echo "$REGV" | cut -d, -f4)
|
||||
if [ ${#CID} -gt 4 ]; then
|
||||
LAC=$(printf "%04X" 0x$LAC)" ($(printf "%d" 0x$LAC))"
|
||||
CIDL=$(printf "%08X" 0x$CID)
|
||||
RNC=${CIDL:1:3}
|
||||
CID=${CIDL:4:4}
|
||||
CID="Short $(printf "%X" 0x$CID) ($(printf "%d" 0x$CID)), Long $(printf "%X" 0x$CIDL) ($(printf "%d" 0x$CIDL))"
|
||||
else
|
||||
LAC=""
|
||||
fi
|
||||
else
|
||||
LAC=""
|
||||
fi
|
||||
fi
|
||||
REGSTAT=$(echo "$REGV" | cut -d, -f2)
|
||||
if [ "$REGSTAT" == "5" -a "$COPS" != "-" ]; then
|
||||
COPS_MNC=$COPS_MNC" (Roaming)"
|
||||
fi
|
||||
if [ -n "$CID" -a -n "$CID5" ] && [ "$RAT" == "13" -o "$RAT" == "10" ]; then
|
||||
LAC="4G $LAC, 5G $LAC5"
|
||||
CID="4G $CID<br />5G $CID5"
|
||||
RNC="4G $RNC, 5G $RNC5"
|
||||
elif [ -n "$CID5" ]; then
|
||||
LAC=$LAC5
|
||||
CID=$CID5
|
||||
RNC=$RNC5
|
||||
fi
|
||||
if [ -z "$LAC" ]; then
|
||||
LAC="-"
|
||||
CID="-"
|
||||
RNC="-"
|
||||
fi
|
||||
}
|
||||
|
||||
Fibocom_SIMINFO()
|
||||
{
|
||||
debug "Fibocom_SIMINFO"
|
||||
|
||||
# 获取IMEI
|
||||
IMEI=$( sh modem_at.sh $at_port "AT+CGSN" | sed -n '2p' )
|
||||
# 获取IMSI
|
||||
IMSI=$( sh modem_at.sh $at_port "AT+CIMI" | sed -n '2p' )
|
||||
# 获取ICCID
|
||||
ICCID=$( sh modem_at.sh $at_port "AT+ICCID" | grep -o "+ICCID:[ ]*[-0-9]\+" | grep -o "[-0-9]\{1,4\}" )
|
||||
# 获取电话号码
|
||||
phone=$( sh modem_at.sh $at_port "AT+CNUM" | grep "+CNUM:" )
|
||||
}
|
||||
|
||||
#fibocom查找基站AT
|
||||
# $1:AT串口
|
||||
get_fibocom_data()
|
||||
{
|
||||
debug "get fibocom data"
|
||||
#设置AT串口
|
||||
at_port=$1
|
||||
|
||||
# All_CSQ
|
||||
|
||||
Fibocom_SIMINFO
|
||||
Fibocom_Cellinfo
|
||||
|
||||
#温度
|
||||
OX=$( sh modem_at.sh $at_port "AT+CPMUTEMP")
|
||||
TEMP=$(echo "$OX" | grep -o "+CPMUTEMP:[ ]*[-0-9]\+" | grep -o "[-0-9]\{1,4\}")
|
||||
if [ -n "$TEMP" ]; then
|
||||
TEMP=$(echo $TEMP)$(printf "\xc2\xb0")"C"
|
||||
fi
|
||||
|
||||
#基站信息
|
||||
OX=$( sh modem_at.sh $at_port "AT+CPSI?")
|
||||
rec=$(echo "$OX" | grep "+CPSI:")
|
||||
w=$(echo $rec |grep "NO SERVICE"| wc -l)
|
||||
if [ $w -ge 1 ];then
|
||||
debug "NO SERVICE"
|
||||
return
|
||||
fi
|
||||
w=$(echo $rec |grep "NR5G_"| wc -l)
|
||||
if [ $w -ge 1 ];then
|
||||
|
||||
w=$(echo $rec |grep "32768"| wc -l)
|
||||
if [ $w -ge 1 ];then
|
||||
debug "-32768"
|
||||
return
|
||||
fi
|
||||
|
||||
debug "$rec"
|
||||
rec1=${rec##*+CPSI:}
|
||||
#echo "$rec1"
|
||||
MODE="${rec1%%,*}" # MODE="NR5G"
|
||||
rect1=${rec1#*,}
|
||||
rect1s="${rect1%%,*}" #Online
|
||||
rect2=${rect1#*,}
|
||||
rect2s="${rect2%%,*}" #460-11
|
||||
rect3=${rect2#*,}
|
||||
rect3s="${rect3%%,*}" #0xCFA102
|
||||
rect4=${rect3#*,}
|
||||
rect4s="${rect4%%,*}" #55744245764
|
||||
rect5=${rect4#*,}
|
||||
rect5s="${rect5%%,*}" #196
|
||||
rect6=${rect5#*,}
|
||||
rect6s="${rect6%%,*}" #NR5G_BAND78
|
||||
rect7=${rect6#*,}
|
||||
rect7s="${rect7%%,*}" #627264
|
||||
rect8=${rect7#*,}
|
||||
rect8s="${rect8%%,*}" #-940
|
||||
rect9=${rect8#*,}
|
||||
rect9s="${rect9%%,*}" #-110
|
||||
# "${rec1##*,}" #最后一位
|
||||
rect10=${rect9#*,}
|
||||
rect10s="${rect10%%,*}" #最后一位
|
||||
PCI=$rect5s
|
||||
LBAND="n"$(echo $rect6s | cut -d, -f0 | grep -o "BAND[0-9]\{1,3\}" | grep -o "[0-9]\+")
|
||||
CHANNEL=$rect7s
|
||||
RSCP=$(($(echo $rect8s | cut -d, -f0) / 10))
|
||||
ECIO=$(($(echo $rect9s | cut -d, -f0) / 10))
|
||||
if [ "$CSQ_PER" = "-" ]; then
|
||||
CSQ_PER=$((100 - (($RSCP + 31) * 100/-125)))"%"
|
||||
fi
|
||||
SINR=$(($(echo $rect10s | cut -d, -f0) / 10))" dB"
|
||||
fi
|
||||
w=$(echo $rec |grep "LTE"|grep "EUTRAN"| wc -l)
|
||||
if [ $w -ge 1 ];then
|
||||
rec1=${rec#*EUTRAN-}
|
||||
lte_band=${rec1%%,*} #EUTRAN-BAND
|
||||
rec1=${rec1#*,}
|
||||
rec1=${rec1#*,}
|
||||
rec1=${rec1#*,}
|
||||
rec1=${rec1#*,}
|
||||
#rec1=${rec1#*,}
|
||||
rec1=${rec1#*,}
|
||||
lte_rssi=${rec1%%,*} #LTE_RSSI
|
||||
lte_rssi=`expr $lte_rssi / 10` #LTE_RSSI
|
||||
debug "LTE_BAND=$lte_band LTE_RSSI=$lte_rssi"
|
||||
if [ $rssi == 0 ];then
|
||||
rssi=$lte_rssi
|
||||
fi
|
||||
fi
|
||||
w=$(echo $rec |grep "WCDMA"| wc -l)
|
||||
if [ $w -ge 1 ];then
|
||||
w=$(echo $rec |grep "UNKNOWN"|wc -l)
|
||||
if [ $w -ge 1 ];then
|
||||
debug "UNKNOWN BAND"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
#CNMP
|
||||
OX=$( sh modem_at.sh $at_port "AT+CNMP?")
|
||||
CNMP=$(echo "$OX" | grep -o "+CNMP:[ ]*[0-9]\{1,3\}" | grep -o "[0-9]\{1,3\}")
|
||||
if [ -n "$CNMP" ]; then
|
||||
case $CNMP in
|
||||
"2"|"55" )
|
||||
NETMODE="1" ;;
|
||||
"13" )
|
||||
NETMODE="3" ;;
|
||||
"14" )
|
||||
NETMODE="5" ;;
|
||||
"38" )
|
||||
NETMODE="7" ;;
|
||||
"71" )
|
||||
NETMODE="9" ;;
|
||||
"109" )
|
||||
NETMODE="8" ;;
|
||||
* )
|
||||
NETMODE="0" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# CMGRMI 信息
|
||||
OX=$( sh modem_at.sh $at_port "AT+CMGRMI=4")
|
||||
CAINFO=$(echo "$OX" | grep -o "$REGXz" | tr ' ' ':')
|
||||
if [ -n "$CAINFO" ]; then
|
||||
for CASV in $(echo "$CAINFO"); do
|
||||
LBAND=$LBAND"<br />B"$(echo "$CASV" | cut -d, -f4)
|
||||
BW=$(echo "$CASV" | cut -d, -f5)
|
||||
decode_bw
|
||||
LBAND=$LBAND" (CA, Bandwidth $BW MHz)"
|
||||
CHANNEL="$CHANNEL, "$(echo "$CASV" | cut -d, -f2)
|
||||
PCI="$PCI, "$(echo "$CASV" | cut -d, -f7)
|
||||
done
|
||||
fi
|
||||
}
|
8
luci-app-modem/root/usr/share/modem/modem_at.sh
Normal file
8
luci-app-modem/root/usr/share/modem/modem_at.sh
Normal file
@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
current_dir="$(dirname "$0")"
|
||||
source "$current_dir/modem_debug.sh"
|
||||
|
||||
#发送at命令
|
||||
# $1 AT串口
|
||||
# $2 AT命令
|
||||
at $1 $2
|
166
luci-app-modem/root/usr/share/modem/modem_data.sh
Normal file
166
luci-app-modem/root/usr/share/modem/modem_data.sh
Normal file
@ -0,0 +1,166 @@
|
||||
#!/bin/sh
|
||||
current_dir="$(dirname "$0")"
|
||||
source "$current_dir/modem_debug.sh"
|
||||
source "$current_dir/modem_scan.sh"
|
||||
source "$current_dir/quectel.sh"
|
||||
source "$current_dir/fibocom.sh"
|
||||
source "$current_dir/simcom.sh"
|
||||
|
||||
#初值化数据结构
|
||||
initData()
|
||||
{
|
||||
Date=''
|
||||
CHANNEL="-"
|
||||
ECIO="-"
|
||||
RSCP="-"
|
||||
ECIO1=" "
|
||||
RSCP1=" "
|
||||
NETMODE="-"
|
||||
LBAND="-"
|
||||
PCI="-"
|
||||
CTEMP="-"
|
||||
net_type="-"
|
||||
SINR="-"
|
||||
IMEI='-'
|
||||
IMSI='-'
|
||||
ICCID='-'
|
||||
phone='-'
|
||||
manufacturer=''
|
||||
modem=''
|
||||
}
|
||||
|
||||
#保存模块数据
|
||||
setData()
|
||||
{
|
||||
{
|
||||
echo $modem #'RM520N-GL'
|
||||
echo $manufacturer #制造商
|
||||
# echo '1e0e:9001' #厂商号
|
||||
echo $COPS #运营商
|
||||
echo $at_port #AT串口
|
||||
echo $TEMP #温度
|
||||
echo $mode #拨号模式
|
||||
echo '---------------------------------'
|
||||
echo $IMEI #imei
|
||||
echo $IMSI #imsi
|
||||
echo $ICCID #iccid
|
||||
echo $phone #phone
|
||||
echo '---------------------------------'
|
||||
|
||||
echo $net_type
|
||||
echo $CSQ
|
||||
echo $CSQ_PER
|
||||
echo $CSQ_RSSI
|
||||
echo $ECIO #参考信号接收质量 RSRQ ecio
|
||||
echo $ECIO1 #参考信号接收质量 RSRQ ecio1
|
||||
echo $RSCP #参考信号接收功率 RSRP rscp0
|
||||
echo $RSCP1 #参考信号接收功率 RSRP rscp1
|
||||
echo $SINR #信噪比 SINR rv["sinr"]
|
||||
echo $NETMODE #连接状态监控 rv["netmode"]
|
||||
echo '---------------------------------'
|
||||
|
||||
echo $COPS_MCC #MCC
|
||||
echo $$COPS_MNC #MNC
|
||||
echo $LAC #eNB ID
|
||||
echo '' #LAC_NUM
|
||||
echo $RNC #TAC
|
||||
echo '' #RNC_NUM
|
||||
echo $CID
|
||||
echo '' #CID_NUM
|
||||
echo $LBAND
|
||||
echo $CHANNEL
|
||||
echo $PCI
|
||||
|
||||
echo $Date
|
||||
|
||||
echo $MODTYPE
|
||||
echo $QTEMP
|
||||
|
||||
} > /tmp/modem_cell.file
|
||||
}
|
||||
|
||||
#采集模块数据(暂时设置为单模块信息收集)
|
||||
data_acquisition()
|
||||
{
|
||||
debug "--检查模块的AT串口--"
|
||||
#获取模块AT串口
|
||||
at_port=$(uci -q get modem.modem0.at_port)
|
||||
if [ -z "$at_port" ]; then
|
||||
debug "模块0没有找到AT串口"
|
||||
return
|
||||
fi
|
||||
|
||||
debug "--检查SIM状态--"
|
||||
local sim_status=$(echo `sh modem_at.sh $at_port "AT+CPIN?"`)
|
||||
local sim_error=$(echo "$sim_status" | grep "ERROR")
|
||||
if [ -n "$sim_error" ]; then
|
||||
debug "未插入SIM卡"
|
||||
sleep 5s
|
||||
return
|
||||
fi
|
||||
local sim_ready=$(echo "$sim_status" | grep "READY")
|
||||
if [ -n "$sim_ready" ]; then
|
||||
debug "SIM卡正常"
|
||||
else
|
||||
debug "SIM卡被锁定"
|
||||
sleep 5s
|
||||
return
|
||||
fi
|
||||
|
||||
debug "--根据模块类型开始采集数据--"
|
||||
# 获取模块基本信息
|
||||
modem=$(uci -q get modem.modem0.name) #模块名称
|
||||
manufacturer=$(uci -q get modem.modem0.manufacturer) #制造商
|
||||
mode=$(uci -q get modem.@config[0].mode) #制造商
|
||||
|
||||
#信号获取
|
||||
case $manufacturer in
|
||||
"quectel") get_quectel_data $at_port ;;
|
||||
"fibocom") get_fibocom_data $at_port ;;
|
||||
"simcom") et_simcom_data $at_port ;;
|
||||
"*") debug "未适配该模块" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
#数据采集循环
|
||||
data_acquisition_task()
|
||||
{
|
||||
while true; do
|
||||
enable=$(uci -q get modem.global.enable)
|
||||
if [ "$enable" = "1" ] ;then
|
||||
modem_scan
|
||||
debug "------------------------------开启任务---------------------------"
|
||||
data_acquisition
|
||||
setData
|
||||
debug "------------------------------结束任务---------------------------"
|
||||
fi
|
||||
sleep 10s
|
||||
done
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
#扫描并配置模块信息
|
||||
modem_scan
|
||||
sleep 1s
|
||||
|
||||
#初值化模块数据
|
||||
debug "开启数据采集服务"
|
||||
initData
|
||||
debug "初值化数据完成"
|
||||
sleep 1s
|
||||
|
||||
#采集模块数据
|
||||
debug "采集数据"
|
||||
data_acquisition
|
||||
#保存模块数据
|
||||
setData
|
||||
|
||||
#数据采集循环
|
||||
data_acquisition_task
|
||||
|
||||
#移动网络联网检查
|
||||
# checkMobileNetwork
|
||||
}
|
||||
|
||||
main
|
32
luci-app-modem/root/usr/share/modem/modem_debug.sh
Normal file
32
luci-app-modem/root/usr/share/modem/modem_debug.sh
Normal file
@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
#调试开关
|
||||
# 0关闭
|
||||
# 1打开
|
||||
# 2输出到文件
|
||||
switch=1
|
||||
out_file="/tmp/modem.log" #输出文件
|
||||
#日志信息
|
||||
debug()
|
||||
{
|
||||
time=$(date "+%Y-%m-%d %H:%M:%S") #获取系统时间
|
||||
if [ $switch = 1 ]; then
|
||||
echo $time $1 #打印输出
|
||||
elif [ $switch = 2 ]; then
|
||||
echo $time $1 >> $outfile #输出到文件
|
||||
fi
|
||||
}
|
||||
|
||||
#发送at命令
|
||||
# $1 AT串口
|
||||
# $2 AT命令
|
||||
at()
|
||||
{
|
||||
local new_str="${2/[$]/$}"
|
||||
local atCommand="${new_str/\"/\"}"
|
||||
sms_tool -d $1 at $atCommand 2>&1
|
||||
}
|
||||
|
||||
#测试时打开
|
||||
# debug $1
|
||||
# at $1 $2
|
9
luci-app-modem/root/usr/share/modem/modem_info
Normal file
9
luci-app-modem/root/usr/share/modem/modem_info
Normal file
@ -0,0 +1,9 @@
|
||||
quectel;rg200u-cn;usb;ecm,mbim,rndis,ncm
|
||||
quectel;rm500u-cn;usb;ecm,mbim,rndis,ncm
|
||||
quectel;rm500q-gl;usb;qmi,gobinet,ecm,mbim,rndis,ncm
|
||||
quectel;rm500q-gl;pcie;qmi,gobinet,ecm,mbim,rndis,ncm
|
||||
fibocom;fm650-cn;usb;ecm,mbim,rndis,ncm
|
||||
fibocom;fm150-ae;usb;qmi,gobinet,ecm,mbim,rndis,ncm
|
||||
fibocom;fm150-ae;pcie;qmi
|
||||
unknown;unknown;usb;qmi,gobinet,ecm,mbim,rndis,ncm
|
||||
unknown;unknown;pcie;qmi,gobinet,mbim
|
231
luci-app-modem/root/usr/share/modem/modem_scan.sh
Normal file
231
luci-app-modem/root/usr/share/modem/modem_scan.sh
Normal file
@ -0,0 +1,231 @@
|
||||
#!/bin/sh
|
||||
|
||||
#获取设备总线地址
|
||||
getDeviceBusPath()
|
||||
{
|
||||
local device_name="$(basename "$1")"
|
||||
local device_path="$(find /sys/class/ -name $device_name)"
|
||||
local device_physical_path="$(readlink -f $device_path/device/)"
|
||||
|
||||
local device_bus_path=$device_physical_path
|
||||
if [ "$device_name" != "mhi_BHI" ]; then #未考虑多个mhi_BHI的情况
|
||||
device_bus_path=$(dirname "$device_physical_path")
|
||||
fi
|
||||
echo $device_bus_path
|
||||
}
|
||||
|
||||
#设置模块配置
|
||||
# $1:模块序号
|
||||
# $2:设备(设备节点)
|
||||
# $3:设备数据接口
|
||||
# $4:总线地址
|
||||
setModemConfig()
|
||||
{
|
||||
#处理获取到的地址
|
||||
# local substr="${4/\/sys\/devices\//}" #x86平台,替换掉/sys/devices/
|
||||
# local substr="${4/\/sys\/devices\/platform\//}" #arm平台,替换掉/sys/devices/platform/
|
||||
# local substr="${4/\/sys\/devices\/platform\/soc\//}" #arm平台,替换掉/sys/devices/platform/soc/
|
||||
local substr=$4 #路径存在不同,暂不处理
|
||||
|
||||
#获取网络接口
|
||||
local net_path="$(find $substr -name net | sed -n '1p')"
|
||||
local net_net_interface_path=$net_path
|
||||
|
||||
#子目录下存在网络接口
|
||||
local net_count="$(find $substr -name net | wc -l)"
|
||||
if [ "$net_count" = "2" ]; then
|
||||
net_net_interface_path="$(find $substr -name net | sed -n '2p')"
|
||||
|
||||
fi
|
||||
local net=$(ls $net_path)
|
||||
local net_interface=$(ls $net_net_interface_path)
|
||||
|
||||
#设置配置
|
||||
uci set modem.modem$1="modem-device"
|
||||
uci set modem.modem$1.device_node="$2"
|
||||
uci set modem.modem$1.data_interface="$3"
|
||||
uci set modem.modem$1.path="$substr"
|
||||
uci set modem.modem$1.net="$net"
|
||||
uci set modem.modem$1.net_interface="$net_interface"
|
||||
}
|
||||
|
||||
#设置模块网络接口
|
||||
# $1:模块序号
|
||||
# $2:总线地址
|
||||
setModemNet()
|
||||
{
|
||||
local net_count="$(find $2 -name net | wc -l)"
|
||||
local net_path
|
||||
if [ "$net_count" = "1" ]; then
|
||||
net_path="$(find $2 -name net | sed -n '1p')"
|
||||
elif [ "$net_count" = "2" ]; then
|
||||
net_path="$(find $2 -name net | sed -n '2p')"
|
||||
fi
|
||||
local net=$(ls $net_path)
|
||||
|
||||
#设置配置
|
||||
uci set modem.modem$1.net="$net"
|
||||
}
|
||||
|
||||
#设置模块串口配置
|
||||
# $modem_count:模块计数
|
||||
# $1:总线地址
|
||||
# $2:串口
|
||||
setPortConfig()
|
||||
{
|
||||
#处理获取到的地址
|
||||
# local substr="${1/\/sys\/devices\//}" #x86平台,替换掉/sys/devices/
|
||||
# local substr="${1/\/sys\/devices\/platform\//}" #arm平台,替换掉/sys/devices/platform/
|
||||
# local substr="${1/\/sys\/devices\/platform\/soc\//}" #arm平台,替换掉/sys/devices/platform/soc/
|
||||
local substr=$1 #路径存在不同,暂不处理
|
||||
|
||||
for i in $(seq 0 $((modem_count-1))); do
|
||||
#当前模块的物理地址
|
||||
local path=$(uci -q get modem.modem$i.path)
|
||||
if [ "$substr" = "$path" ]; then
|
||||
#添加新的串口
|
||||
uci add_list modem.modem$i.ports="$2"
|
||||
#判断是不是AT串口
|
||||
local result=$(sh modem_at.sh $2 "ATI")
|
||||
local str1="No response from modem."
|
||||
local str2="failed"
|
||||
if [ "$result" != "$str1" ] && [[ "$result" != *"failed"* ]]; then
|
||||
uci set modem.modem$i.at_port="$2"
|
||||
setModemInfoConfig $i $2
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
#设置模块信息(名称、制造商、拨号模式)
|
||||
# $modem_count:模块计数
|
||||
# $1:模块序号
|
||||
# $2:AT串口
|
||||
setModemInfoConfig()
|
||||
{
|
||||
#获取数据接口
|
||||
local data_interface=$(uci -q get modem.modem$1.data_interface)
|
||||
|
||||
#遍历模块信息文件
|
||||
local line_count=$(wc -l < "$modem_info_file")
|
||||
local line_context
|
||||
for i in $(seq 1 $(($line_count))); do
|
||||
|
||||
#获取一行的内容
|
||||
local line_context=$(sed -n $i'p' "$modem_info_file")
|
||||
#获取数据接口内容
|
||||
local data_interface_info=$(echo "$line_context" | cut -d ";" -f 3)
|
||||
if [ "$data_interface" = "$data_interface_info" ]; then
|
||||
#获取模块名
|
||||
local modem_name=$(echo "$line_context" | cut -d ";" -f 2)
|
||||
#获取AT命令返回的内容
|
||||
local at_result=$(echo `sh modem_at.sh $2 "ATI" | sed -n '3p' | tr 'A-Z' 'a-z'`)
|
||||
if [[ "$at_result" = *"$modem_name"* ]]; then
|
||||
#设置模块名
|
||||
uci set modem.modem$1.name="$modem_name"
|
||||
|
||||
#设置制造商
|
||||
local manufacturer=$(echo "$line_context" | cut -d ";" -f 1)
|
||||
uci set modem.modem$1.manufacturer="$manufacturer"
|
||||
|
||||
#设置拨号模式
|
||||
local modes=$(echo "$line_context" | cut -d ";" -f 4 | tr ',' ' ')
|
||||
|
||||
#删除原来的拨号模式列表
|
||||
uci del modem.modem$1.modes
|
||||
#添加新的拨号模式列表
|
||||
for mode in $modes; do
|
||||
uci add_list modem.modem$1.modes="$mode"
|
||||
done
|
||||
break
|
||||
fi
|
||||
|
||||
#数据库中没有此模块的信息,使用默认值
|
||||
if [ $i -ge $(($line_count-1)) ]; then
|
||||
|
||||
#设置模块名
|
||||
uci set modem.modem$1.name="$modem_name"
|
||||
#设置制造商
|
||||
local manufacturer=$(echo "$line_context" | cut -d ";" -f 1)
|
||||
uci set modem.modem$1.manufacturer="$manufacturer"
|
||||
#删除原来的拨号模式列表
|
||||
uci del modem.modem$1.modes
|
||||
#添加新的拨号模式列表
|
||||
for mode in $modes; do
|
||||
uci add_list modem.modem$1.modes="$mode"
|
||||
done
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
#设置模块数量
|
||||
setModemCount()
|
||||
{
|
||||
uci set modem.global.modem_number="$modem_count"
|
||||
}
|
||||
|
||||
#模块计数
|
||||
modem_count=0
|
||||
#模块信息文件
|
||||
modem_info_file="modem_info"
|
||||
#设置模块信息
|
||||
modem_scan()
|
||||
{
|
||||
#初始化
|
||||
modem_count=0
|
||||
########设置模块基本信息########
|
||||
#USB
|
||||
local usb_devices=$(ls /dev/cdc-wdm*)
|
||||
for device in $usb_devices; do
|
||||
local usb_device_bus_path=$(getDeviceBusPath $device)
|
||||
setModemConfig $modem_count $device "usb" $usb_device_bus_path
|
||||
modem_count=$((modem_count + 1))
|
||||
done
|
||||
#PCIE
|
||||
local pcie_devices=$(ls /dev/mhi_QMI*)
|
||||
for device in $pcie_devices; do
|
||||
local pcie_device_bus_path=$(getDeviceBusPath $device)
|
||||
setModemConfig $modem_count $device "pcie" $pcie_device_bus_path
|
||||
modem_count=$((modem_count + 1))
|
||||
done
|
||||
|
||||
#写入到配置中
|
||||
# uci commit modem
|
||||
|
||||
########设置模块串口########
|
||||
#清除原串口配置
|
||||
for i in $(seq 0 $((modem_count-1))); do
|
||||
uci del modem.modem$i.ports
|
||||
done
|
||||
#USB串口
|
||||
local usb_port=$(ls /dev/ttyUSB*)
|
||||
for port in $usb_port; do
|
||||
local device_node=$(uci -q get modem.modem$i.device_node)
|
||||
if [ "$port" = "$device_node" ]; then
|
||||
continue
|
||||
fi
|
||||
local usb_port_device_bus_path=$(getDeviceBusPath $port)
|
||||
setPortConfig $usb_port_device_bus_path $port
|
||||
done
|
||||
#PCIE串口
|
||||
local pcie_port=$(ls /dev/mhi*)
|
||||
for port in $pcie_port; do
|
||||
local device_node=$(uci -q get modem.modem$i.device_node)
|
||||
if [ "$port" = "$device_node" ]; then
|
||||
continue
|
||||
fi
|
||||
local pcie_port_device_bus_path=$(getDeviceBusPath $port)
|
||||
setPortConfig $pcie_port_device_bus_path $port
|
||||
done
|
||||
|
||||
########设置模块数量########
|
||||
setModemCount
|
||||
|
||||
#写入到配置中
|
||||
uci commit modem
|
||||
}
|
||||
|
||||
#测试时打开
|
||||
# modem_scan
|
505
luci-app-modem/root/usr/share/modem/quectel.sh
Normal file
505
luci-app-modem/root/usr/share/modem/quectel.sh
Normal file
@ -0,0 +1,505 @@
|
||||
#!/bin/sh
|
||||
|
||||
#quectel
|
||||
lte_bw() {
|
||||
BW=$(echo $BW | grep -o "[0-5]\{1\}")
|
||||
case $BW in
|
||||
"0")
|
||||
BW="1.4" ;;
|
||||
"1")
|
||||
BW="3" ;;
|
||||
"2"|"3"|"4"|"5")
|
||||
BW=$((($(echo $BW) - 1) * 5)) ;;
|
||||
esac
|
||||
}
|
||||
#quectel
|
||||
nr_bw() {
|
||||
BW=$(echo $BW | grep -o "[0-9]\{1,2\}")
|
||||
case $BW in
|
||||
"0"|"1"|"2"|"3"|"4"|"5")
|
||||
BW=$((($(echo $BW) + 1) * 5)) ;;
|
||||
"6"|"7"|"8"|"9"|"10"|"11"|"12")
|
||||
BW=$((($(echo $BW) - 2) * 10)) ;;
|
||||
"13")
|
||||
BW="200" ;;
|
||||
"14")
|
||||
BW="400" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
#查询信息强度
|
||||
All_CSQ()
|
||||
{
|
||||
debug "All_CSQ"
|
||||
#信号
|
||||
OX=$( sh modem_at.sh $at_port "AT+CSQ" |grep "+CSQ:")
|
||||
OX=$(echo $OX | tr 'a-z' 'A-Z')
|
||||
CSQ=$(echo "$OX" | grep -o "+CSQ: [0-9]\{1,2\}" | grep -o "[0-9]\{1,2\}")
|
||||
if [ $CSQ = "99" ]; then
|
||||
CSQ=""
|
||||
fi
|
||||
if [ -n "$CSQ" ]; then
|
||||
CSQ_PER=$(($CSQ * 100/31))"%"
|
||||
CSQ_RSSI=$((2 * CSQ - 113))" dBm"
|
||||
else
|
||||
CSQ="-"
|
||||
CSQ_PER="-"
|
||||
CSQ_RSSI="-"
|
||||
fi
|
||||
}
|
||||
|
||||
Quectel_SIMINFO()
|
||||
{
|
||||
debug "Quectel_SIMINFO"
|
||||
# 获取IMEI
|
||||
IMEI=$( sh modem_at.sh $at_port "AT+CGSN" | sed -n '2p' )
|
||||
# 获取IMSI
|
||||
IMSI=$( sh modem_at.sh $at_port "AT+CIMI" | sed -n '2p' )
|
||||
# 获取ICCID
|
||||
ICCID=$( sh modem_at.sh $at_port "AT+ICCID" | grep -o "+ICCID:[ ]*[-0-9]\+" | grep -o "[-0-9]\{1,4\}" )
|
||||
# 获取电话号码
|
||||
phone=$( sh modem_at.sh $at_port "AT+CNUM" | grep "+CNUM:" )
|
||||
|
||||
}
|
||||
# SIMCOM获取基站信息
|
||||
Quectel_Cellinfo()
|
||||
{
|
||||
# return
|
||||
#cellinfo0.gcom
|
||||
OX1=$( sh modem_at.sh $at_port "AT+COPS=3,0;+COPS?")
|
||||
OX2=$( sh modem_at.sh $at_port "AT+COPS=3,2;+COPS?")
|
||||
OX=$OX1" "$OX2
|
||||
|
||||
#cellinfo.gcom
|
||||
OY1=$( sh modem_at.sh $at_port "AT+CREG=2;+CREG?;+CREG=0")
|
||||
OY2=$( sh modem_at.sh $at_port "AT+CEREG=2;+CEREG?;+CEREG=0")
|
||||
OY3=$( sh modem_at.sh $at_port "AT+C5GREG=2;+C5GREG?;+C5GREG=0")
|
||||
OY=$OY1" "$OY2" "$OY3
|
||||
|
||||
|
||||
OXx=$OX
|
||||
OX=$(echo $OX | tr 'a-z' 'A-Z')
|
||||
OY=$(echo $OY | tr 'a-z' 'A-Z')
|
||||
OX=$OX" "$OY
|
||||
|
||||
#debug "$OX"
|
||||
#debug "$OY"
|
||||
|
||||
COPS="-"
|
||||
COPS_MCC="-"
|
||||
COPS_MNC="-"
|
||||
COPSX=$(echo $OXx | grep -o "+COPS: [01],0,.\+," | cut -d, -f3 | grep -o "[^\"]\+")
|
||||
|
||||
if [ "x$COPSX" != "x" ]; then
|
||||
COPS=$COPSX
|
||||
fi
|
||||
|
||||
COPSX=$(echo $OX | grep -o "+COPS: [01],2,.\+," | cut -d, -f3 | grep -o "[^\"]\+")
|
||||
|
||||
if [ "x$COPSX" != "x" ]; then
|
||||
COPS_MCC=${COPSX:0:3}
|
||||
COPS_MNC=${COPSX:3:3}
|
||||
if [ "$COPS" = "-" ]; then
|
||||
COPS=$(awk -F[\;] '/'$COPS'/ {print $2}' $ROOTER/signal/mccmnc.data)
|
||||
[ "x$COPS" = "x" ] && COPS="-"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$COPS" = "-" ]; then
|
||||
COPS=$(echo "$O" | awk -F[\"] '/^\+COPS: 0,0/ {print $2}')
|
||||
if [ "x$COPS" = "x" ]; then
|
||||
COPS="-"
|
||||
COPS_MCC="-"
|
||||
COPS_MNC="-"
|
||||
fi
|
||||
fi
|
||||
COPS_MNC=" "$COPS_MNC
|
||||
|
||||
OX=$(echo "${OX//[ \"]/}")
|
||||
CID=""
|
||||
CID5=""
|
||||
RAT=""
|
||||
REGV=$(echo "$OX" | grep -o "+C5GREG:2,[0-9],[A-F0-9]\{2,6\},[A-F0-9]\{5,10\},[0-9]\{1,2\}")
|
||||
if [ -n "$REGV" ]; then
|
||||
LAC5=$(echo "$REGV" | cut -d, -f3)
|
||||
LAC5=$LAC5" ($(printf "%d" 0x$LAC5))"
|
||||
CID5=$(echo "$REGV" | cut -d, -f4)
|
||||
CID5L=$(printf "%010X" 0x$CID5)
|
||||
RNC5=${CID5L:1:6}
|
||||
RNC5=$RNC5" ($(printf "%d" 0x$RNC5))"
|
||||
CID5=${CID5L:7:3}
|
||||
CID5="Short $(printf "%X" 0x$CID5) ($(printf "%d" 0x$CID5)), Long $(printf "%X" 0x$CID5L) ($(printf "%d" 0x$CID5L))"
|
||||
RAT=$(echo "$REGV" | cut -d, -f5)
|
||||
fi
|
||||
REGV=$(echo "$OX" | grep -o "+CEREG:2,[0-9],[A-F0-9]\{2,4\},[A-F0-9]\{5,8\}")
|
||||
REGFMT="3GPP"
|
||||
if [ -z "$REGV" ]; then
|
||||
REGV=$(echo "$OX" | grep -o "+CEREG:2,[0-9],[A-F0-9]\{2,4\},[A-F0-9]\{1,3\},[A-F0-9]\{5,8\}")
|
||||
REGFMT="SW"
|
||||
fi
|
||||
if [ -n "$REGV" ]; then
|
||||
LAC=$(echo "$REGV" | cut -d, -f3)
|
||||
LAC=$(printf "%04X" 0x$LAC)" ($(printf "%d" 0x$LAC))"
|
||||
if [ $REGFMT = "3GPP" ]; then
|
||||
CID=$(echo "$REGV" | cut -d, -f4)
|
||||
else
|
||||
CID=$(echo "$REGV" | cut -d, -f5)
|
||||
fi
|
||||
CIDL=$(printf "%08X" 0x$CID)
|
||||
RNC=${CIDL:1:5}
|
||||
RNC=$RNC" ($(printf "%d" 0x$RNC))"
|
||||
CID=${CIDL:6:2}
|
||||
CID="Short $(printf "%X" 0x$CID) ($(printf "%d" 0x$CID)), Long $(printf "%X" 0x$CIDL) ($(printf "%d" 0x$CIDL))"
|
||||
|
||||
else
|
||||
REGV=$(echo "$OX" | grep -o "+CREG:2,[0-9],[A-F0-9]\{2,4\},[A-F0-9]\{2,8\}")
|
||||
if [ -n "$REGV" ]; then
|
||||
LAC=$(echo "$REGV" | cut -d, -f3)
|
||||
CID=$(echo "$REGV" | cut -d, -f4)
|
||||
if [ ${#CID} -gt 4 ]; then
|
||||
LAC=$(printf "%04X" 0x$LAC)" ($(printf "%d" 0x$LAC))"
|
||||
CIDL=$(printf "%08X" 0x$CID)
|
||||
RNC=${CIDL:1:3}
|
||||
CID=${CIDL:4:4}
|
||||
CID="Short $(printf "%X" 0x$CID) ($(printf "%d" 0x$CID)), Long $(printf "%X" 0x$CIDL) ($(printf "%d" 0x$CIDL))"
|
||||
else
|
||||
LAC=""
|
||||
fi
|
||||
else
|
||||
LAC=""
|
||||
fi
|
||||
fi
|
||||
REGSTAT=$(echo "$REGV" | cut -d, -f2)
|
||||
if [ "$REGSTAT" == "5" -a "$COPS" != "-" ]; then
|
||||
COPS_MNC=$COPS_MNC" (Roaming)"
|
||||
fi
|
||||
if [ -n "$CID" -a -n "$CID5" ] && [ "$RAT" == "13" -o "$RAT" == "10" ]; then
|
||||
LAC="4G $LAC, 5G $LAC5"
|
||||
CID="4G $CID<br />5G $CID5"
|
||||
RNC="4G $RNC, 5G $RNC5"
|
||||
elif [ -n "$CID5" ]; then
|
||||
LAC=$LAC5
|
||||
CID=$CID5
|
||||
RNC=$RNC5
|
||||
fi
|
||||
if [ -z "$LAC" ]; then
|
||||
LAC="-"
|
||||
CID="-"
|
||||
RNC="-"
|
||||
fi
|
||||
}
|
||||
|
||||
#Quectel公司查找基站AT
|
||||
# $1:AT串口
|
||||
get_quectel_data()
|
||||
{
|
||||
debug "get quectel data"
|
||||
#设置AT串口
|
||||
at_port=$1
|
||||
|
||||
Quectel_SIMINFO
|
||||
All_CSQ
|
||||
|
||||
Quectel_Cellinfo
|
||||
|
||||
#
|
||||
OX=$( sh modem_at.sh $at_port 'AT+QENG="servingcell"' | grep "+QENG:" )
|
||||
NR_NSA=$(echo $OX | grep -o -i "+QENG:[ ]\?\"NR5G-NSA\",")
|
||||
NR_SA=$(echo $OX | grep -o -i "+QENG: \"SERVINGCELL\",[^,]\+,\"NR5G-SA\",\"[DFT]\{3\}\",")
|
||||
if [ -n "$NR_NSA" ]; then
|
||||
QENG=",,"$(echo $OX" " | grep -o -i "+QENG: \"LTE\".\+\"NR5G-NSA\"," | tr " " ",")
|
||||
QENG5=$(echo $OX | grep -o -i "+QENG:[ ]\?\"NR5G-NSA\",[0-9]\{3\},[0-9]\{2,3\},[0-9]\{1,5\},-[0-9]\{2,5\},[-0-9]\{1,3\},-[0-9]\{2,3\},[0-9]\{1,7\},[0-9]\{1,3\}.\{1,6\}")
|
||||
if [ -z "$QENG5" ]; then
|
||||
QENG5=$(echo $OX | grep -o -i "+QENG:[ ]\?\"NR5G-NSA\",[0-9]\{3\},[0-9]\{2,3\},[0-9]\{1,5\},-[0-9]\{2,3\},[-0-9]\{1,3\},-[0-9]\{2,3\}")
|
||||
if [ -n "$QENG5" ]; then
|
||||
QENG5=$QENG5",,"
|
||||
fi
|
||||
fi
|
||||
elif [ -n "$NR_SA" ]; then
|
||||
QENG=$(echo $NR_SA | tr " " ",")
|
||||
QENG5=$(echo $OX | grep -o -i "+QENG: \"SERVINGCELL\",[^,]\+,\"NR5G-SA\",\"[DFT]\{3\}\",[ 0-9]\{3,4\},[0-9]\{2,3\},[0-9A-F]\{1,10\},[0-9]\{1,5\},[0-9A-F]\{2,6\},[0-9]\{6,7\},[0-9]\{1,3\},[0-9]\{1,2\},-[0-9]\{2,5\},-[0-9]\{2,3\},[-0-9]\{1,3\}")
|
||||
else
|
||||
QENG=$(echo $OX" " | grep -o -i "+QENG: [^ ]\+ " | tr " " ",")
|
||||
fi
|
||||
|
||||
|
||||
# debug "$QENG"
|
||||
# debug "$QENG5"
|
||||
|
||||
RAT=$(echo $QENG | cut -d, -f4 | grep -o "[-A-Z5]\{3,7\}")
|
||||
case $RAT in
|
||||
"GSM")
|
||||
MODE="GSM"
|
||||
;;
|
||||
"WCDMA")
|
||||
MODE="WCDMA"
|
||||
CHANNEL=$(echo $QENG | cut -d, -f9)
|
||||
RSCP=$(echo $QENG | cut -d, -f12)
|
||||
RSCP="-"$(echo $RSCP | grep -o "[0-9]\{1,3\}")
|
||||
ECIO=$(echo $QENG | cut -d, -f13)
|
||||
ECIO="-"$(echo $ECIO | grep -o "[0-9]\{1,3\}")
|
||||
;;
|
||||
"LTE"|"CAT-M"|"CAT-NB")
|
||||
MODE=$(echo $QENG | cut -d, -f5 | grep -o "[DFT]\{3\}")
|
||||
if [ -n "$MODE" ]; then
|
||||
MODE="$RAT $MODE"
|
||||
else
|
||||
MODE="$RAT"
|
||||
fi
|
||||
PCI=$(echo $QENG | cut -d, -f9)
|
||||
CHANNEL=$(echo $QENG | cut -d, -f10)
|
||||
LBAND=$(echo $QENG | cut -d, -f11 | grep -o "[0-9]\{1,3\}")
|
||||
BW=$(echo $QENG | cut -d, -f12)
|
||||
lte_bw
|
||||
BWU=$BW
|
||||
BW=$(echo $QENG | cut -d, -f13)
|
||||
lte_bw
|
||||
BWD=$BW
|
||||
if [ -z "$BWD" ]; then
|
||||
BWD="unknown"
|
||||
fi
|
||||
if [ -z "$BWU" ]; then
|
||||
BWU="unknown"
|
||||
fi
|
||||
if [ -n "$LBAND" ]; then
|
||||
LBAND="B"$LBAND" (Bandwidth $BWD MHz Down | $BWU MHz Up)"
|
||||
fi
|
||||
RSRP=$(echo $QENG | cut -d, -f15 | grep -o "[0-9]\{1,3\}")
|
||||
if [ -n "$RSRP" ]; then
|
||||
RSCP="-"$RSRP
|
||||
RSRPLTE=$RSCP
|
||||
fi
|
||||
RSRQ=$(echo $QENG | cut -d, -f16 | grep -o "[0-9]\{1,3\}")
|
||||
if [ -n "$RSRQ" ]; then
|
||||
ECIO="-"$RSRQ
|
||||
fi
|
||||
RSSI=$(echo $QENG | cut -d, -f17 | grep -o "\-[0-9]\{1,3\}")
|
||||
if [ -n "$RSSI" ]; then
|
||||
CSQ_RSSI=$RSSI" dBm"
|
||||
fi
|
||||
SINRR=$(echo $QENG | cut -d, -f18 | grep -o "[0-9]\{1,3\}")
|
||||
if [ -n "$SINRR" ]; then
|
||||
if [ $SINRR -le 25 ]; then
|
||||
SINR=$((($(echo $SINRR) * 2) -20))" dB"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$NR_NSA" ]; then
|
||||
MODE="LTE/NR EN-DC"
|
||||
echo "0" > /tmp/modnetwork
|
||||
if [ -n "$QENG5" ] && [ -n "$LBAND" ] && [ "$RSCP" != "-" ] && [ "$ECIO" != "-" ]; then
|
||||
PCI="$PCI, "$(echo $QENG5 | cut -d, -f4)
|
||||
SCHV=$(echo $QENG5 | cut -d, -f8)
|
||||
SLBV=$(echo $QENG5 | cut -d, -f9)
|
||||
BW=$(echo $QENG5 | cut -d, -f10 | grep -o "[0-9]\{1,3\}")
|
||||
if [ -n "$SLBV" ]; then
|
||||
LBAND=$LBAND"<br />n"$SLBV
|
||||
if [ -n "$BW" ]; then
|
||||
nr_bw
|
||||
LBAND=$LBAND" (Bandwidth $BW MHz)"
|
||||
fi
|
||||
if [ "$SCHV" -ge 123400 ]; then
|
||||
CHANNEL=$CHANNEL", "$SCHV
|
||||
else
|
||||
CHANNEL=$CHANNEL", -"
|
||||
fi
|
||||
else
|
||||
LBAND=$LBAND"<br />nxx (unknown NR5G band)"
|
||||
CHANNEL=$CHANNEL", -"
|
||||
fi
|
||||
RSCP=$RSCP" dBm<br />"$(echo $QENG5 | cut -d, -f5)
|
||||
SINRR=$(echo $QENG5 | cut -d, -f6 | grep -o "[0-9]\{1,3\}")
|
||||
if [ -n "$SINRR" ]; then
|
||||
if [ $SINRR -le 30 ]; then
|
||||
SINR=$SINR"<br />"$((($(echo $SINRR) * 2) -20))" dB"
|
||||
fi
|
||||
fi
|
||||
ECIO=$ECIO" (4G) dB<br />"$(echo $QENG5 | cut -d, -f7)" (5G) "
|
||||
fi
|
||||
fi
|
||||
if [ -z "$LBAND" ]; then
|
||||
LBAND="-"
|
||||
else
|
||||
if [ -n "$QCA" ]; then
|
||||
QCA=$(echo $QCA | grep -o "\"S[CS]\{2\}\"[-0-9A-Z,\"]\+")
|
||||
for QCAL in $(echo "$QCA"); do
|
||||
if [ $(echo "$QCAL" | cut -d, -f7) = "2" ]; then
|
||||
SCHV=$(echo $QCAL | cut -d, -f2 | grep -o "[0-9]\+")
|
||||
SRATP="B"
|
||||
if [ -n "$SCHV" ]; then
|
||||
CHANNEL="$CHANNEL, $SCHV"
|
||||
if [ "$SCHV" -gt 123400 ]; then
|
||||
SRATP="n"
|
||||
fi
|
||||
fi
|
||||
SLBV=$(echo $QCAL | cut -d, -f6 | grep -o "[0-9]\{1,2\}")
|
||||
if [ -n "$SLBV" ]; then
|
||||
LBAND=$LBAND"<br />"$SRATP$SLBV
|
||||
BWD=$(echo $QCAL | cut -d, -f3 | grep -o "[0-9]\{1,3\}")
|
||||
if [ -n "$BWD" ]; then
|
||||
UPDOWN=$(echo $QCAL | cut -d, -f13)
|
||||
case "$UPDOWN" in
|
||||
"UL" )
|
||||
CATYPE="CA"$(printf "\xe2\x86\x91") ;;
|
||||
"DL" )
|
||||
CATYPE="CA"$(printf "\xe2\x86\x93") ;;
|
||||
* )
|
||||
CATYPE="CA" ;;
|
||||
esac
|
||||
if [ $BWD -gt 14 ]; then
|
||||
LBAND=$LBAND" ("$CATYPE", Bandwidth "$(($(echo $BWD) / 5))" MHz)"
|
||||
else
|
||||
LBAND=$LBAND" ("$CATYPE", Bandwidth 1.4 MHz)"
|
||||
fi
|
||||
fi
|
||||
LBAND=$LBAND
|
||||
fi
|
||||
PCI="$PCI, "$(echo $QCAL | cut -d, -f8)
|
||||
fi
|
||||
done
|
||||
fi
|
||||
fi
|
||||
if [ $RAT = "CAT-M" ] || [ $RAT = "CAT-NB" ]; then
|
||||
LBAND="B$(echo $QENG | cut -d, -f11) ($RAT)"
|
||||
fi
|
||||
;;
|
||||
"NR5G-SA")
|
||||
MODE="NR5G-SA"
|
||||
if [ -n "$QENG5" ]; then
|
||||
#AT+qnwcfg="NR5G_AMBR" #查询速度
|
||||
MODE="$RAT $(echo $QENG5 | cut -d, -f4)"
|
||||
PCI=$(echo $QENG5 | cut -d, -f8)
|
||||
CHANNEL=$(echo $QENG5 | cut -d, -f10)
|
||||
LBAND=$(echo $QENG5 | cut -d, -f11)
|
||||
BW=$(echo $QENG5 | cut -d, -f12)
|
||||
nr_bw
|
||||
LBAND="n"$LBAND" (Bandwidth $BW MHz)"
|
||||
RSCP=$(echo $QENG5 | cut -d, -f13)
|
||||
ECIO=$(echo $QENG5 | cut -d, -f14)
|
||||
if [ "$CSQ_PER" = "-" ]; then
|
||||
RSSI=$(rsrp2rssi $RSCP $BW)
|
||||
CSQ_PER=$((100 - (($RSSI + 51) * 100/-62)))"%"
|
||||
CSQ=$((($RSSI + 113) / 2))
|
||||
CSQ_RSSI=$RSSI" dBm"
|
||||
fi
|
||||
SINRR=$(echo $QENG5 | cut -d, -f15 | grep -o "[0-9]\{1,3\}")
|
||||
if [ -n "$SINRR" ]; then
|
||||
if [ $SINRR -le 30 ]; then
|
||||
SINR=$((($(echo $SINRR) * 2) -20))" dB"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
#
|
||||
OX=$( sh modem_at.sh $at_port "AT+QCAINFO" | grep "+QCAINFO:" )
|
||||
QCA=$(echo $OX" " | grep -o -i "+QCAINFO: \"S[CS]\{2\}\".\+NWSCANMODE" | tr " " ",")
|
||||
|
||||
|
||||
#
|
||||
OX=$( sh modem_at.sh $at_port 'AT+QCFG="nwscanmode"' | grep "+QCAINFO:" )
|
||||
QNSM=$(echo $OX | grep -o -i "+QCFG: \"NWSCANMODE\",[0-9]")
|
||||
QNSM=$(echo "$QNSM" | grep -o "[0-9]")
|
||||
if [ -n "$QNSM" ]; then
|
||||
MODTYPE="6"
|
||||
case $QNSM in
|
||||
"0" )
|
||||
NETMODE="1" ;;
|
||||
"1" )
|
||||
NETMODE="3" ;;
|
||||
"2"|"5" )
|
||||
NETMODE="5" ;;
|
||||
"3" )
|
||||
NETMODE="7" ;;
|
||||
esac
|
||||
fi
|
||||
if [ -n "$QNWP" ]; then
|
||||
MODTYPE="6"
|
||||
case $QNWP in
|
||||
"AUTO" )
|
||||
NETMODE="1" ;;
|
||||
"WCDMA" )
|
||||
NETMODE="5" ;;
|
||||
"LTE" )
|
||||
NETMODE="7" ;;
|
||||
"LTE:NR5G" )
|
||||
NETMODE="8" ;;
|
||||
"NR5G" )
|
||||
NETMODE="9" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
OX=$( sh modem_at.sh $at_port 'AT+QNWPREFCFG="mode_pref"' | grep "+QNWPREFCFG:" )
|
||||
QNWP=$(echo $OX | grep -o -i "+QNWPREFCFG: \"MODE_PREF\",[A-Z5:]\+" | cut -d, -f2)
|
||||
|
||||
#温度
|
||||
OX=$( sh modem_at.sh $at_port 'AT+QTEMP' | grep "+QTEMP:" )
|
||||
QTEMP=$(echo $OX | grep -o -i "+QTEMP: [0-9]\{1,3\}")
|
||||
if [ -z "$QTEMP" ]; then
|
||||
QTEMP=$(echo $OX | grep -o -i "+QTEMP:[ ]\?\"XO[_-]THERM[_-][^,]\+,[\"]\?[0-9]\{1,3\}" | grep -o "[0-9]\{1,3\}")
|
||||
fi
|
||||
if [ -z "$QTEMP" ]; then
|
||||
QTEMP=$(echo $OX | grep -o -i "+QTEMP:[ ]\?\"MDM-CORE-USR.\+[0-9]\{1,3\}\"" | cut -d\" -f4)
|
||||
fi
|
||||
if [ -z "$QTEMP" ]; then
|
||||
QTEMP=$(echo $OX | grep -o -i "+QTEMP:[ ]\?\"MDMSS.\+[0-9]\{1,3\}\"" | cut -d\" -f4)
|
||||
fi
|
||||
if [ -n "$QTEMP" ]; then
|
||||
CTEMP=$(echo $QTEMP | grep -o -i "[0-9]\{1,3\}")$(printf "\xc2\xb0")"C"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
#
|
||||
OX=$( sh modem_at.sh $at_port "AT+QRSRP" | grep "+QRSRP:" )
|
||||
QRSRP=$(echo "$OX" | grep -o -i "+QRSRP:[^,]\+,-[0-9]\{1,5\},-[0-9]\{1,5\},-[0-9]\{1,5\}[^ ]*")
|
||||
if [ -n "$QRSRP" ] && [ "$RAT" != "WCDMA" ]; then
|
||||
QRSRP1=$(echo $QRSRP | cut -d, -f1 | grep -o "[-0-9]\+")
|
||||
QRSRP2=$(echo $QRSRP | cut -d, -f2)
|
||||
QRSRP3=$(echo $QRSRP | cut -d, -f3)
|
||||
QRSRP4=$(echo $QRSRP | cut -d, -f4)
|
||||
QRSRPtype=$(echo $QRSRP | cut -d, -f5)
|
||||
if [ "$QRSRPtype" == "NR5G" ]; then
|
||||
if [ -n "$NR_SA" ]; then
|
||||
RSCP=$QRSRP1
|
||||
if [ -n "$QRPRP2" -a "$QRSRP2" != "-32768" ]; then
|
||||
RSCP1="RxD "$QRSRP2
|
||||
fi
|
||||
if [ -n "$QRSRP3" -a "$QRSRP3" != "-32768" ]; then
|
||||
RSCP=$RSCP" dBm<br />"$QRSRP3
|
||||
fi
|
||||
if [ -n "$QRSRP4" -a "$QRSRP4" != "-32768" ]; then
|
||||
RSCP1="RxD "$QRSRP4
|
||||
fi
|
||||
else
|
||||
RSCP=$RSRPLTE
|
||||
if [ -n "$QRSRP1" -a "$QRSRP1" != "-32768" ]; then
|
||||
RSCP=$RSCP" (4G) dBm<br />"$QRSRP1
|
||||
if [ -n "$QRSRP2" -a "$QRSRP2" != "-32768" ]; then
|
||||
RSCP="$RSCP,$QRSRP2"
|
||||
if [ -n "$QRSRP3" -a "$QRSRP3" != "-32768" ]; then
|
||||
RSCP="$RSCP,$QRSRP3"
|
||||
if [ -n "$QRSRP4" -a "$QRSRP4" != "-32768" ]; then
|
||||
RSCP="$RSCP,$QRSRP4"
|
||||
fi
|
||||
fi
|
||||
RSCP=$RSCP" (5G) "
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
elif [ "$QRSRP2$QRSRP3$QRSRP4" != "-44-44-44" -a -z "$QENG5" ]; then
|
||||
RSCP=$QRSRP1
|
||||
if [ "$QRSRP3$QRSRP4" == "-140-140" -o "$QRSRP3$QRSRP4" == "-44-44" -o "$QRSRP3$QRSRP4" == "-32768-32768" ]; then
|
||||
RSCP1="RxD "$(echo $QRSRP | cut -d, -f2)
|
||||
else
|
||||
RSCP=$RSCP" dBm (RxD "$QRSRP2" dBm)<br />"$QRSRP3
|
||||
RSCP1="RxD "$QRSRP4
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
}
|
299
luci-app-modem/root/usr/share/modem/simcom.sh
Normal file
299
luci-app-modem/root/usr/share/modem/simcom.sh
Normal file
@ -0,0 +1,299 @@
|
||||
#!/bin/sh
|
||||
|
||||
#查询信息强度
|
||||
All_CSQ()
|
||||
{
|
||||
debug "All_CSQ"
|
||||
#信号
|
||||
OX=$( sh modem_at.sh $at_port "AT+CSQ" |grep "+CSQ:")
|
||||
OX=$(echo $OX | tr 'a-z' 'A-Z')
|
||||
CSQ=$(echo "$OX" | grep -o "+CSQ: [0-9]\{1,2\}" | grep -o "[0-9]\{1,2\}")
|
||||
if [ $CSQ = "99" ]; then
|
||||
CSQ=""
|
||||
fi
|
||||
if [ -n "$CSQ" ]; then
|
||||
CSQ_PER=$(($CSQ * 100/31))"%"
|
||||
CSQ_RSSI=$((2 * CSQ - 113))" dBm"
|
||||
else
|
||||
CSQ="-"
|
||||
CSQ_PER="-"
|
||||
CSQ_RSSI="-"
|
||||
fi
|
||||
}
|
||||
|
||||
# SIMCOM获取基站信息
|
||||
SIMCOM_Cellinfo()
|
||||
{
|
||||
#baseinfo.gcom
|
||||
OX=$( sh modem_at.sh 2 "ATI")
|
||||
OX=$( sh modem_at.sh 2 "AT+CGEQNEG=1")
|
||||
|
||||
#cellinfo0.gcom
|
||||
OX1=$( sh modem_at.sh 2 "AT+COPS=3,0;+COPS?")
|
||||
OX2=$( sh modem_at.sh 2 "AT+COPS=3,2;+COPS?")
|
||||
OX=$OX1" "$OX2
|
||||
|
||||
#cellinfo.gcom
|
||||
OY1=$( sh modem_at.sh 2 "AT+CREG=2;+CREG?;+CREG=0")
|
||||
OY2=$( sh modem_at.sh 2 "AT+CEREG=2;+CEREG?;+CEREG=0")
|
||||
OY3=$( sh modem_at.sh 2 "AT+C5GREG=2;+C5GREG?;+C5GREG=0")
|
||||
OY=$OY1" "$OY2" "$OY3
|
||||
|
||||
|
||||
OXx=$OX
|
||||
OX=$(echo $OX | tr 'a-z' 'A-Z')
|
||||
OY=$(echo $OY | tr 'a-z' 'A-Z')
|
||||
OX=$OX" "$OY
|
||||
|
||||
#debug "$OX"
|
||||
#debug "$OY"
|
||||
|
||||
COPS="-"
|
||||
COPS_MCC="-"
|
||||
COPS_MNC="-"
|
||||
COPSX=$(echo $OXx | grep -o "+COPS: [01],0,.\+," | cut -d, -f3 | grep -o "[^\"]\+")
|
||||
|
||||
if [ "x$COPSX" != "x" ]; then
|
||||
COPS=$COPSX
|
||||
fi
|
||||
|
||||
COPSX=$(echo $OX | grep -o "+COPS: [01],2,.\+," | cut -d, -f3 | grep -o "[^\"]\+")
|
||||
|
||||
if [ "x$COPSX" != "x" ]; then
|
||||
COPS_MCC=${COPSX:0:3}
|
||||
COPS_MNC=${COPSX:3:3}
|
||||
if [ "$COPS" = "-" ]; then
|
||||
COPS=$(awk -F[\;] '/'$COPS'/ {print $2}' $ROOTER/signal/mccmnc.data)
|
||||
[ "x$COPS" = "x" ] && COPS="-"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$COPS" = "-" ]; then
|
||||
COPS=$(echo "$O" | awk -F[\"] '/^\+COPS: 0,0/ {print $2}')
|
||||
if [ "x$COPS" = "x" ]; then
|
||||
COPS="-"
|
||||
COPS_MCC="-"
|
||||
COPS_MNC="-"
|
||||
fi
|
||||
fi
|
||||
COPS_MNC=" "$COPS_MNC
|
||||
|
||||
OX=$(echo "${OX//[ \"]/}")
|
||||
CID=""
|
||||
CID5=""
|
||||
RAT=""
|
||||
REGV=$(echo "$OX" | grep -o "+C5GREG:2,[0-9],[A-F0-9]\{2,6\},[A-F0-9]\{5,10\},[0-9]\{1,2\}")
|
||||
if [ -n "$REGV" ]; then
|
||||
LAC5=$(echo "$REGV" | cut -d, -f3)
|
||||
LAC5=$LAC5" ($(printf "%d" 0x$LAC5))"
|
||||
CID5=$(echo "$REGV" | cut -d, -f4)
|
||||
CID5L=$(printf "%010X" 0x$CID5)
|
||||
RNC5=${CID5L:1:6}
|
||||
RNC5=$RNC5" ($(printf "%d" 0x$RNC5))"
|
||||
CID5=${CID5L:7:3}
|
||||
CID5="Short $(printf "%X" 0x$CID5) ($(printf "%d" 0x$CID5)), Long $(printf "%X" 0x$CID5L) ($(printf "%d" 0x$CID5L))"
|
||||
RAT=$(echo "$REGV" | cut -d, -f5)
|
||||
fi
|
||||
REGV=$(echo "$OX" | grep -o "+CEREG:2,[0-9],[A-F0-9]\{2,4\},[A-F0-9]\{5,8\}")
|
||||
REGFMT="3GPP"
|
||||
if [ -z "$REGV" ]; then
|
||||
REGV=$(echo "$OX" | grep -o "+CEREG:2,[0-9],[A-F0-9]\{2,4\},[A-F0-9]\{1,3\},[A-F0-9]\{5,8\}")
|
||||
REGFMT="SW"
|
||||
fi
|
||||
if [ -n "$REGV" ]; then
|
||||
LAC=$(echo "$REGV" | cut -d, -f3)
|
||||
LAC=$(printf "%04X" 0x$LAC)" ($(printf "%d" 0x$LAC))"
|
||||
if [ $REGFMT = "3GPP" ]; then
|
||||
CID=$(echo "$REGV" | cut -d, -f4)
|
||||
else
|
||||
CID=$(echo "$REGV" | cut -d, -f5)
|
||||
fi
|
||||
CIDL=$(printf "%08X" 0x$CID)
|
||||
RNC=${CIDL:1:5}
|
||||
RNC=$RNC" ($(printf "%d" 0x$RNC))"
|
||||
CID=${CIDL:6:2}
|
||||
CID="Short $(printf "%X" 0x$CID) ($(printf "%d" 0x$CID)), Long $(printf "%X" 0x$CIDL) ($(printf "%d" 0x$CIDL))"
|
||||
|
||||
else
|
||||
REGV=$(echo "$OX" | grep -o "+CREG:2,[0-9],[A-F0-9]\{2,4\},[A-F0-9]\{2,8\}")
|
||||
if [ -n "$REGV" ]; then
|
||||
LAC=$(echo "$REGV" | cut -d, -f3)
|
||||
CID=$(echo "$REGV" | cut -d, -f4)
|
||||
if [ ${#CID} -gt 4 ]; then
|
||||
LAC=$(printf "%04X" 0x$LAC)" ($(printf "%d" 0x$LAC))"
|
||||
CIDL=$(printf "%08X" 0x$CID)
|
||||
RNC=${CIDL:1:3}
|
||||
CID=${CIDL:4:4}
|
||||
CID="Short $(printf "%X" 0x$CID) ($(printf "%d" 0x$CID)), Long $(printf "%X" 0x$CIDL) ($(printf "%d" 0x$CIDL))"
|
||||
else
|
||||
LAC=""
|
||||
fi
|
||||
else
|
||||
LAC=""
|
||||
fi
|
||||
fi
|
||||
REGSTAT=$(echo "$REGV" | cut -d, -f2)
|
||||
if [ "$REGSTAT" == "5" -a "$COPS" != "-" ]; then
|
||||
COPS_MNC=$COPS_MNC" (Roaming)"
|
||||
fi
|
||||
if [ -n "$CID" -a -n "$CID5" ] && [ "$RAT" == "13" -o "$RAT" == "10" ]; then
|
||||
LAC="4G $LAC, 5G $LAC5"
|
||||
CID="4G $CID<br />5G $CID5"
|
||||
RNC="4G $RNC, 5G $RNC5"
|
||||
elif [ -n "$CID5" ]; then
|
||||
LAC=$LAC5
|
||||
CID=$CID5
|
||||
RNC=$RNC5
|
||||
fi
|
||||
if [ -z "$LAC" ]; then
|
||||
LAC="-"
|
||||
CID="-"
|
||||
RNC="-"
|
||||
fi
|
||||
}
|
||||
SIMCOM_SIMINFO()
|
||||
{
|
||||
debug "Quectel_SIMINFO"
|
||||
# 获取IMEI
|
||||
IMEI=$( sh modem_at.sh $at_port "AT+CGSN" | sed -n '2p' )
|
||||
# 获取IMSI
|
||||
IMSI=$( sh modem_at.sh $at_port "AT+CIMI" | sed -n '2p' )
|
||||
# 获取ICCID
|
||||
ICCID=$( sh modem_at.sh $at_port "AT+ICCID" | grep -o "+ICCID:[ ]*[-0-9]\+" | grep -o "[-0-9]\{1,4\}" )
|
||||
# 获取电话号码
|
||||
phone=$( sh modem_at.sh $at_port "AT+CNUM" | grep "+CNUM:" )
|
||||
}
|
||||
#simcom查找基站AT
|
||||
get_simcom_data()
|
||||
{
|
||||
debug "get simcom data"
|
||||
#设置AT串口
|
||||
at_port=$1
|
||||
|
||||
All_CSQ
|
||||
SIMCOM_SIMINFO
|
||||
SIMCOM_Cellinfo
|
||||
|
||||
#温度
|
||||
OX=$( sh modem_at.sh $at_port "AT+CPMUTEMP")
|
||||
TEMP=$(echo "$OX" | grep -o "+CPMUTEMP:[ ]*[-0-9]\+" | grep -o "[-0-9]\{1,4\}")
|
||||
if [ -n "$TEMP" ]; then
|
||||
TEMP=$(echo $TEMP)$(printf "\xc2\xb0")"C"
|
||||
fi
|
||||
|
||||
|
||||
#基站信息
|
||||
OX=$( sh modem_at.sh $at_port "AT+CPSI?")
|
||||
rec=$(echo "$OX" | grep "+CPSI:")
|
||||
w=$(echo $rec |grep "NO SERVICE"| wc -l)
|
||||
if [ $w -ge 1 ];then
|
||||
debug "NO SERVICE"
|
||||
return
|
||||
fi
|
||||
w=$(echo $rec |grep "NR5G_"| wc -l)
|
||||
if [ $w -ge 1 ];then
|
||||
|
||||
w=$(echo $rec |grep "32768"| wc -l)
|
||||
if [ $w -ge 1 ];then
|
||||
debug "-32768"
|
||||
return
|
||||
fi
|
||||
|
||||
debug "$rec"
|
||||
rec1=${rec##*+CPSI:}
|
||||
#echo "$rec1"
|
||||
MODE="${rec1%%,*}" # MODE="NR5G"
|
||||
rect1=${rec1#*,}
|
||||
rect1s="${rect1%%,*}" #Online
|
||||
rect2=${rect1#*,}
|
||||
rect2s="${rect2%%,*}" #460-11
|
||||
rect3=${rect2#*,}
|
||||
rect3s="${rect3%%,*}" #0xCFA102
|
||||
rect4=${rect3#*,}
|
||||
rect4s="${rect4%%,*}" #55744245764
|
||||
rect5=${rect4#*,}
|
||||
rect5s="${rect5%%,*}" #196
|
||||
rect6=${rect5#*,}
|
||||
rect6s="${rect6%%,*}" #NR5G_BAND78
|
||||
rect7=${rect6#*,}
|
||||
rect7s="${rect7%%,*}" #627264
|
||||
rect8=${rect7#*,}
|
||||
rect8s="${rect8%%,*}" #-940
|
||||
rect9=${rect8#*,}
|
||||
rect9s="${rect9%%,*}" #-110
|
||||
# "${rec1##*,}" #最后一位
|
||||
rect10=${rect9#*,}
|
||||
rect10s="${rect10%%,*}" #最后一位
|
||||
PCI=$rect5s
|
||||
LBAND="n"$(echo $rect6s | cut -d, -f0 | grep -o "BAND[0-9]\{1,3\}" | grep -o "[0-9]\+")
|
||||
CHANNEL=$rect7s
|
||||
RSCP=$(($(echo $rect8s | cut -d, -f0) / 10))
|
||||
ECIO=$(($(echo $rect9s | cut -d, -f0) / 10))
|
||||
if [ "$CSQ_PER" = "-" ]; then
|
||||
CSQ_PER=$((100 - (($RSCP + 31) * 100/-125)))"%"
|
||||
fi
|
||||
SINR=$(($(echo $rect10s | cut -d, -f0) / 10))" dB"
|
||||
fi
|
||||
w=$(echo $rec |grep "LTE"|grep "EUTRAN"| wc -l)
|
||||
if [ $w -ge 1 ];then
|
||||
rec1=${rec#*EUTRAN-}
|
||||
lte_band=${rec1%%,*} #EUTRAN-BAND
|
||||
rec1=${rec1#*,}
|
||||
rec1=${rec1#*,}
|
||||
rec1=${rec1#*,}
|
||||
rec1=${rec1#*,}
|
||||
#rec1=${rec1#*,}
|
||||
rec1=${rec1#*,}
|
||||
lte_rssi=${rec1%%,*} #LTE_RSSI
|
||||
lte_rssi=`expr $lte_rssi / 10` #LTE_RSSI
|
||||
debug "LTE_BAND=$lte_band LTE_RSSI=$lte_rssi"
|
||||
if [ $rssi == 0 ];then
|
||||
rssi=$lte_rssi
|
||||
fi
|
||||
fi
|
||||
w=$(echo $rec |grep "WCDMA"| wc -l)
|
||||
if [ $w -ge 1 ];then
|
||||
w=$(echo $rec |grep "UNKNOWN"|wc -l)
|
||||
if [ $w -ge 1 ];then
|
||||
debug "UNKNOWN BAND"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
#CNMP
|
||||
OX=$( sh modem_at.sh $at_port "AT+CNMP?")
|
||||
CNMP=$(echo "$OX" | grep -o "+CNMP:[ ]*[0-9]\{1,3\}" | grep -o "[0-9]\{1,3\}")
|
||||
if [ -n "$CNMP" ]; then
|
||||
case $CNMP in
|
||||
"2"|"55" )
|
||||
NETMODE="1" ;;
|
||||
"13" )
|
||||
NETMODE="3" ;;
|
||||
"14" )
|
||||
NETMODE="5" ;;
|
||||
"38" )
|
||||
NETMODE="7" ;;
|
||||
"71" )
|
||||
NETMODE="9" ;;
|
||||
"109" )
|
||||
NETMODE="8" ;;
|
||||
* )
|
||||
NETMODE="0" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# CMGRMI 信息
|
||||
OX=$( sh modem_at.sh $at_port "AT+CMGRMI=4")
|
||||
CAINFO=$(echo "$OX" | grep -o "$REGXz" | tr ' ' ':')
|
||||
if [ -n "$CAINFO" ]; then
|
||||
for CASV in $(echo "$CAINFO"); do
|
||||
LBAND=$LBAND"<br />B"$(echo "$CASV" | cut -d, -f4)
|
||||
BW=$(echo "$CASV" | cut -d, -f5)
|
||||
decode_bw
|
||||
LBAND=$LBAND" (CA, Bandwidth $BW MHz)"
|
||||
CHANNEL="$CHANNEL, "$(echo "$CASV" | cut -d, -f2)
|
||||
PCI="$PCI, "$(echo "$CASV" | cut -d, -f7)
|
||||
done
|
||||
fi
|
||||
|
||||
}
|
11
luci-app-modem/root/usr/share/rpcd/acl.d/luci-app-modem.json
Normal file
11
luci-app-modem/root/usr/share/rpcd/acl.d/luci-app-modem.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"luci-app-modem": {
|
||||
"description": "Grant UCI access for luci-app-modem",
|
||||
"read": {
|
||||
"uci": [ "modem" ]
|
||||
},
|
||||
"write": {
|
||||
"uci": [ "modem" ]
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user