diff --git a/luci-app-modem/.gitattributes b/luci-app-modem/.gitattributes new file mode 100644 index 0000000..cef6c19 --- /dev/null +++ b/luci-app-modem/.gitattributes @@ -0,0 +1,4 @@ +#指定换行符 +/luasrc/** text eol=lf +# /old/* text eol=lf +/root/** text eol=lf \ No newline at end of file diff --git a/luci-app-modem/LICENSE b/luci-app-modem/LICENSE new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/luci-app-modem/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + 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. + + + Copyright (C) + + 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 . + +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: + + Copyright (C) + 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 +. + + 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 +. diff --git a/luci-app-modem/Makefile b/luci-app-modem/Makefile new file mode 100644 index 0000000..e73330a --- /dev/null +++ b/luci-app-modem/Makefile @@ -0,0 +1,40 @@ +# Copyright (C) 2020 Lienol +# +# 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 +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 + $(LUCI_TITLE) + Version: $(PKG_VERSION) +endef + +include $(TOPDIR)/feeds/luci/luci.mk + +# call BuildPackage - OpenWrt buildroot signature diff --git a/luci-app-modem/README.md b/luci-app-modem/README.md new file mode 100644 index 0000000..82d0f5c --- /dev/null +++ b/luci-app-modem/README.md @@ -0,0 +1,14 @@ +# luci-app-modem + +- 原项目地址:https://github.com/momokind/luci-app-hypermodem + +## 说明 + +- 在原项目的基础上修改代码逻辑 + +- 添加USB和PCIe等依赖支持 + +- 添加多模块支持 + +- 支持USB和PCIE两种连接模式的5G模块用QMI模式进行IPv6拨号,然后下发给内网设备 + diff --git a/luci-app-modem/luasrc/controller/modem.lua b/luci-app-modem/luasrc/controller/modem.lua new file mode 100644 index 0000000..da7a9db --- /dev/null +++ b/luci-app-modem/luasrc/controller/modem.lua @@ -0,0 +1,214 @@ +-- Copyright 2020 Lienol +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 diff --git a/luci-app-modem/luasrc/model/cbi/modem/config.lua b/luci-app-modem/luasrc/model/cbi/modem/config.lua new file mode 100644 index 0000000..0bc42b8 --- /dev/null +++ b/luci-app-modem/luasrc/model/cbi/modem/config.lua @@ -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 diff --git a/luci-app-modem/luasrc/model/cbi/modem/index.lua b/luci-app-modem/luasrc/model/cbi/modem/index.lua new file mode 100644 index 0000000..a85a7de --- /dev/null +++ b/luci-app-modem/luasrc/model/cbi/modem/index.lua @@ -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 diff --git a/luci-app-modem/luasrc/view/modem/at_commands.htm b/luci-app-modem/luasrc/view/modem/at_commands.htm new file mode 100644 index 0000000..d7bf1d9 --- /dev/null +++ b/luci-app-modem/luasrc/view/modem/at_commands.htm @@ -0,0 +1,163 @@ +<%+header%> + + + +

<%:AT Commands%>

+
<%:Web UI for handling AT commands via sms_tool.%>
+

+


+
+ +
+
<%:Modem Select%>:
+ +
+ +
+
+
+ +
+
<%:User AT Commands%>:
+ +
+ +
+
+
+ +
+
<%:Command to send%>:
+ +
+
+ +
+ +
+
<%:Reply%>: +

+

+ +
+
+
+ +
+ + + +<%+footer%> + diff --git a/luci-app-modem/luasrc/view/modem/list_status.htm b/luci-app-modem/luasrc/view/modem/list_status.htm new file mode 100644 index 0000000..0d7a0bc --- /dev/null +++ b/luci-app-modem/luasrc/view/modem/list_status.htm @@ -0,0 +1,19 @@ + diff --git a/luci-app-modem/luasrc/view/modem/modem_info.htm b/luci-app-modem/luasrc/view/modem/modem_info.htm new file mode 100644 index 0000000..3fb4665 --- /dev/null +++ b/luci-app-modem/luasrc/view/modem/modem_info.htm @@ -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 +%> + + + + + +
+

<%:信号状态/模块信息%>

+
请注意该插件所有功能并无适配所有5G模块,不用妄想冷门模块插上就能用(有能力者自行适配) +
+ + + + +
+ <%:综合信息%> + + + + + + +
<%:模块 :%>-
<%:制造商 :%>
<%:温度 : %>
<%:更新时间 : %>
+
+ +<% if nosms == 0 then %> +<% end %> + +
+ <%:通信模块/SIM卡信息%> + + + + + + +
<%:运营商 : %>
<%:IMEI :%>
<%:IMSI : %>
<%:ICCID : %>
<%:SIM卡号码 : %>
+
+ + +
+ <%:信号状态%> + + + + + + + + + + +
<%:蜂窝网络类型 :%>
<%:CSQ : %>
<%:信号强度 : %>
<%:信号接收强度 RSSI : %>
<%:参考信号接收质量 RSRQ : %>
<%:参考信号接收功率 RSRP : %>
<%:信噪比 SINR : %>
<%:连接状态监控 : %>
+
+ +
+ <%:基站信息%> + + + + + + + + + + +
<%:MCC / MNC :%>
<%:eNB ID : %>
<%:TAC : %>
<%:Cell ID : %>
<%:频段 Band : %>
<%:频点 Channel : %>
<%:物理小区标识 PCI : %>
<%:最大Qos级别 Maximum Qos : %>
+
+ + +<% if havegps == 1 then %> +
+ <%:GPS 定位%> + + + + + + + + + + + +
<%:纬度 :%>
     
    <%:经度 :%>
       
      +
      +<% end %> + + +
      +<%+footer%> + diff --git a/luci-app-modem/luasrc/view/modem/status.htm b/luci-app-modem/luasrc/view/modem/status.htm new file mode 100644 index 0000000..241baae --- /dev/null +++ b/luci-app-modem/luasrc/view/modem/status.htm @@ -0,0 +1,3 @@ +<%+cbi/valueheader%> +-- +<%+cbi/valuefooter%> diff --git a/luci-app-modem/note/OpenWRT软件开发.md b/luci-app-modem/note/OpenWRT软件开发.md new file mode 100644 index 0000000..6c94dcd --- /dev/null +++ b/luci-app-modem/note/OpenWRT软件开发.md @@ -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 +``` + diff --git a/luci-app-modem/po/zh-cn/modem.po b/luci-app-modem/po/zh-cn/modem.po new file mode 100644 index 0000000..f46adcb --- /dev/null +++ b/luci-app-modem/po/zh-cn/modem.po @@ -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 "无" \ No newline at end of file diff --git a/luci-app-modem/root/etc/config/modem b/luci-app-modem/root/etc/config/modem new file mode 100644 index 0000000..86e11ca --- /dev/null +++ b/luci-app-modem/root/etc/config/modem @@ -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' \ No newline at end of file diff --git a/luci-app-modem/root/etc/init.d/modem b/luci-app-modem/root/etc/init.d/modem new file mode 100644 index 0000000..f7e1eea --- /dev/null +++ b/luci-app-modem/root/etc/init.d/modem @@ -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" +} diff --git a/luci-app-modem/root/etc/init.d/modeminit b/luci-app-modem/root/etc/init.d/modeminit new file mode 100644 index 0000000..38c3b65 --- /dev/null +++ b/luci-app-modem/root/etc/init.d/modeminit @@ -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 & +} \ No newline at end of file diff --git a/luci-app-modem/root/etc/uci-defaults/luci-app-modem b/luci-app-modem/root/etc/uci-defaults/luci-app-modem new file mode 100644 index 0000000..0e40535 --- /dev/null +++ b/luci-app-modem/root/etc/uci-defaults/luci-app-modem @@ -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 diff --git a/luci-app-modem/root/usr/share/modem/fibocom.sh b/luci-app-modem/root/usr/share/modem/fibocom.sh new file mode 100644 index 0000000..bc0d288 --- /dev/null +++ b/luci-app-modem/root/usr/share/modem/fibocom.sh @@ -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
      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"
      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 +} \ No newline at end of file diff --git a/luci-app-modem/root/usr/share/modem/modem_at.sh b/luci-app-modem/root/usr/share/modem/modem_at.sh new file mode 100644 index 0000000..c1e4636 --- /dev/null +++ b/luci-app-modem/root/usr/share/modem/modem_at.sh @@ -0,0 +1,8 @@ +#!/bin/sh +current_dir="$(dirname "$0")" +source "$current_dir/modem_debug.sh" + +#发送at命令 +# $1 AT串口 +# $2 AT命令 +at $1 $2 \ No newline at end of file diff --git a/luci-app-modem/root/usr/share/modem/modem_data.sh b/luci-app-modem/root/usr/share/modem/modem_data.sh new file mode 100644 index 0000000..36ee0d3 --- /dev/null +++ b/luci-app-modem/root/usr/share/modem/modem_data.sh @@ -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 \ No newline at end of file diff --git a/luci-app-modem/root/usr/share/modem/modem_debug.sh b/luci-app-modem/root/usr/share/modem/modem_debug.sh new file mode 100644 index 0000000..dd45178 --- /dev/null +++ b/luci-app-modem/root/usr/share/modem/modem_debug.sh @@ -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 \ No newline at end of file diff --git a/luci-app-modem/root/usr/share/modem/modem_info b/luci-app-modem/root/usr/share/modem/modem_info new file mode 100644 index 0000000..56d1516 --- /dev/null +++ b/luci-app-modem/root/usr/share/modem/modem_info @@ -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 \ No newline at end of file diff --git a/luci-app-modem/root/usr/share/modem/modem_scan.sh b/luci-app-modem/root/usr/share/modem/modem_scan.sh new file mode 100644 index 0000000..c5d931d --- /dev/null +++ b/luci-app-modem/root/usr/share/modem/modem_scan.sh @@ -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 \ No newline at end of file diff --git a/luci-app-modem/root/usr/share/modem/quectel.sh b/luci-app-modem/root/usr/share/modem/quectel.sh new file mode 100644 index 0000000..8c63438 --- /dev/null +++ b/luci-app-modem/root/usr/share/modem/quectel.sh @@ -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
      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"
      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"
      nxx (unknown NR5G band)" + CHANNEL=$CHANNEL", -" + fi + RSCP=$RSCP" dBm
      "$(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"
      "$((($(echo $SINRR) * 2) -20))" dB" + fi + fi + ECIO=$ECIO" (4G) dB
      "$(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"
      "$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
      "$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
      "$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)
      "$QRSRP3 + RSCP1="RxD "$QRSRP4 + fi + fi + fi + + +} \ No newline at end of file diff --git a/luci-app-modem/root/usr/share/modem/simcom.sh b/luci-app-modem/root/usr/share/modem/simcom.sh new file mode 100644 index 0000000..534f5cf --- /dev/null +++ b/luci-app-modem/root/usr/share/modem/simcom.sh @@ -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
      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"
      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 + +} diff --git a/luci-app-modem/root/usr/share/rpcd/acl.d/luci-app-modem.json b/luci-app-modem/root/usr/share/rpcd/acl.d/luci-app-modem.json new file mode 100644 index 0000000..61edd0c --- /dev/null +++ b/luci-app-modem/root/usr/share/rpcd/acl.d/luci-app-modem.json @@ -0,0 +1,11 @@ +{ + "luci-app-modem": { + "description": "Grant UCI access for luci-app-modem", + "read": { + "uci": [ "modem" ] + }, + "write": { + "uci": [ "modem" ] + } + } +}