Positioning method and device
Obtaining the longitude and latitude of the device through AT mode and SDK mode solves the problem of long R&D cycle and high cost when the device lacks a GPS module, realizes efficient positioning function and reduces costs.
Patent Information
- Application Number
- CN202410694522.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-31
- Publication Date
- 2024-09-20
AI Technical Summary
In the existing technology, when a device lacks a GPS positioning module, it is necessary to readjust the hardware structure, design circuit diagrams, and test, resulting in a long development cycle and high cost.
Obtain the longitude and latitude through the dual guarantee of AT method and SDK method, determine whether the device has a GPS module, and calculate the average value to achieve positioning, avoiding hardware adjustment and circuit design.
It shortens the research and development cycle, reduces labor and material costs, improves the fault tolerance rate of the positioning function, and avoids the necessity of hardware adjustment and circuit design.
Smart Images

Figure CN118671802A
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of positioning technology, and in particular relates to a positioning method and device. Background Art
[0002] When customers customize some existing equipment, they need to use the positioning function, but there is no GPS positioning module in the equipment. In the existing technology, if you want to solve the problem of lack of GPS positioning module, you need to readjust the internal hardware structure of the machine, redesign the circuit diagram, redraw the PCB, retest, etc., which makes the entire R&D cycle very long and inefficient. Summary of the invention
[0003] In order to overcome the above technical defects, the present invention provides a positioning method and device, which can reduce the time required to add a positioning function to a device.
[0004] The present invention is implemented according to the following technical solutions:
[0005] A positioning method comprises the steps of:
[0006] Determine whether the device hardware has a GPS module;
[0007] If there is no GPS module, the first longitude and the first latitude are obtained by using AT;
[0008] Use SDK to obtain the second longitude and latitude;
[0009] The longitude and latitude are calculated based on the first longitude, the first latitude, the second longitude, and the second latitude.
[0010] As a further improvement of the present invention, the step of determining whether the device hardware has a GPS module includes:
[0011] Capture the native positioning interface of the device. If the capture is abnormal, it is determined that the device hardware does not have a GPS module.
[0012] As a further improvement of the present invention, if no capture exception occurs, it is determined that there is a GPS module in the device hardware.
[0013] As a further improvement of the present invention, the step of obtaining the first longitude and the first latitude by using the AT method includes:
[0014] Open the AT module serial port;
[0015] Verify the AT module serial port;
[0016] If the serial port of the AT module is normal, the 4G module is identified and the first longitude and the first latitude are obtained.
[0017] As a further improvement of the present invention, the step of verifying the serial port of the AT module includes:
[0018] Send a verification command to the AT module serial port. If the return value of the AT module serial port is received, the AT module serial port is normal.
[0019] If the return value of the AT module serial port is not received, the AT module serial port is abnormal and the log is sent to the terminal.
[0020] As a further improvement of the present invention, the step of obtaining the second longitude and the second latitude by using SDK includes:
[0021] Login secure hash algorithm 1;
[0022] Get the SDK package name;
[0023] Get the second longitude and latitude.
[0024] As a further improvement of the present invention, if the first longitude, the first latitude, the second longitude, and the second latitude are not null values, the step of calculating the longitude and latitude includes: taking the average value of the first longitude and the second longitude as the longitude, and taking the average value of the first latitude and the second latitude as the latitude.
[0025] As a further improvement of the present invention, if the first longitude and the first latitude are not null values, and the second longitude and the second latitude are both null values, the step of calculating the longitude and the latitude includes: using the first longitude and the first latitude as the longitude and the latitude, and the terminal sends a log at the same time;
[0026] If the first longitude and the first latitude are both null values, and the second longitude and the second latitude are not null values, the step of calculating the longitude and the latitude includes: using the second longitude and the second latitude as the longitude and the latitude, and the terminal sends a log at the same time.
[0027] The present invention provides an electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
[0028] The memory is used to store computer programs;
[0029] The processor is used to implement the above positioning method when executing the program stored in the memory.
[0030] The present invention also provides one or more computer-readable media having instructions stored thereon, which, when executed by one or more processors, enable the processors to execute the above positioning method.
[0031] Compared with the prior art, the present invention has the following beneficial effects: the longitude and latitude are acquired by the dual guarantee method of the AT method and the SDK method, and the positioning function is realized while its fault tolerance is also increased, so there is no need to readjust the internal hardware structure of the machine, redesign the circuit diagram, redraw the PCB, retest, etc., which greatly shortens the entire R&D cycle and also greatly reduces the manpower and material costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] The specific embodiments of the present invention are further described in detail below in conjunction with the accompanying drawings, wherein:
[0033] Figure 1 This is a flow chart of the positioning method described in Example 1;
[0034] Figure 2 This is a detailed flow chart of the positioning method described in Example 1. DETAILED DESCRIPTION
[0035] The preferred embodiments of the present invention are described below in conjunction with the accompanying drawings. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present invention, and are not used to limit the present invention.
[0036] Example 1
[0037] This embodiment provides a positioning method, which can be applied to Android devices, Linux devices, and Windows devices. This embodiment takes an Android device as an example for description. Figure 1 and Figure 2 As shown, the steps include:
[0038] S1. Determine whether the device hardware has a GPS module. If the device hardware already has a GPS module, there is no need to use the positioning method of this embodiment. The device can use its own GPS module for positioning. If the device hardware does not have a GPS module, the positioning method of this embodiment can be used to achieve automatic positioning. The device can be an Android device.
[0039] The native positioning interface of the device can be captured to determine whether the device hardware has a GPS module. If the capture is abnormal, it is determined that the device hardware does not have a GPS module; if no capture exception occurs, it is determined that the device hardware has a GPS module.
[0040] In a specific application, the built-in try...catch exception-catching method in the Java language can be used to capture the native positioning interface information of an Android device. If an exception is caught and returned, it indicates that the Android device's hardware does not have a GPS module. If no exception is caught, it means that the Android device's hardware has a GPS module. At this time, the positioning method self-closes to release memory.
[0041] S2. If it does not have a GPS module, the AT method is used to obtain the first longitude and the first latitude. The AT method refers to using a control protocol based on AT commands to achieve communication and control between devices. Step S2 includes:
[0042] S21. Open the serial port of the AT module. Sending the command "grep AT" to the AT module can achieve this function. The AT module is built into the Android device. The AT module has AT commands and can communicate with a 4G module or a virtual 4G module to perform positioning. If the Android device does not have a 4G module, it can also simulate opening the 4G network through the virtual 4G module for positioning.
[0043] S22. Verify the serial port of the AT module. Specifically, send the verification command "dev / AT / ttyUSB1" to the serial port of the AT module. If the return value "AT<OK" of the serial port of the AT module is received, the serial port of the AT module is normal; if the return value of the serial port of the AT module is not received, the serial port of the AT module is abnormal, and send a log to the terminal. The terminal can be a computer or a mobile phone. The OA system of the R & D personnel's enterprise is installed on the computer and the mobile phone. At this time, the log can be sent to the OA system to notify the R & D personnel to repair the AT module.
[0044] S23. If the serial port of the AT module is normal, identify the 4G module and obtain the first longitude and the first latitude. The 4G module includes two types of modules, one is the SIM7600 module, and the other is the A7600C module.
[0045] First send the SIM7600 command "echo-e"AT+CLBS=0\r">dev / AT / ttyUSB1" to the 4G module. If there is a return value, for example, "AT<+CLBS:0,23.026815,113.172920,550" is returned, it means that the 4G module is a SIM7600 module, the longitude is 23.026815, and the latitude is 113.172920. If there is no return value, send the A7600C command "echo-e"AT+CGDCONT=1,\"IP\",\"cmnet\"\r"> / dev / AT / ttyUSB1" to the 4G module. If there is a return value, such as "AT<+CLBS:0,23.026815,113.172920,550", it means that the 4G module is an A7600C module, with a longitude of 23.026815 and a latitude of 113.172920. If there is no return value, send the log to the OA system to notify the R&D personnel to repair the AT module.
[0046] S3. Use SDK to obtain the second longitude and latitude. The SDK method uses the SDK positioning interface opened by Baidu to obtain the second longitude and latitude:
[0047] S31. Log in to Secure Hash Algorithm 1. In order to increase the security of Secure Hash Algorithm 1, the specific implementation method is as follows: send the command "keytool-list-v-keystore R&D enterprise SHA1 path" and obtain the internal account and password entered by the R&D personnel and the SHA1 certificate password.
[0048] S32. Get the package name of the SDK, such as scanning the build.gradle file using the Java reflection mechanism, and the package name of the SDK is followed by "applicationId". For example: "applicationIdandroid.com.baidu", "android.com.baidu" is the package name of the SDK.
[0049] S33, obtaining the second longitude and the second latitude, specifically, by calling the interface GetLocation(), if there is a return value, for example, "23.03,113.17", it means that the longitude is 23.03 and the latitude is 113.17. If there is no return value, the log is sent to the OA system to notify the R&D personnel to repair the SDK module.
[0050] Step S2 and step S3 are performed simultaneously.
[0051] S4. Calculate the longitude and latitude according to the first longitude, the first latitude, the second longitude, and the second latitude.
[0052] (1) If the first longitude, first latitude, second longitude, and second latitude are not null values, the average of the first longitude and the second longitude is used as the longitude, and the average of the first latitude and the second latitude is used as the latitude. The calculation formula is: longitude = (first longitude + second longitude) ÷ 2, latitude = (first latitude + second latitude) ÷ 2, that is, the longitude and longitude are [(first longitude + second longitude) ÷ 2, (first latitude + second latitude) ÷ 2].
[0053] If the first longitude and the first latitude are not null values, and the second longitude and the second latitude are both null values, the first longitude and the first latitude are used as the longitude and latitude, and the calculation formula is: longitude = first longitude, latitude first latitude, that is, the longitude and longitude are (first longitude, first latitude). At the same time, the terminal sends a log to notify the R&D personnel to repair the SDK module.
[0054] If the first longitude and the first latitude are both null values, and the second longitude and the second latitude are not null values, the second longitude and the second latitude are used as the longitude and latitude, and the calculation formula is: longitude = second longitude, latitude = second latitude, that is, the longitude and longitude are (second longitude, second latitude). At the same time, the terminal sends a log to notify the R&D personnel to repair the SDK module.
[0055] If the first longitude, the first latitude, the second longitude, and the second latitude are all null values, it means that the SDK module is faulty. At this time, the terminal sends a log to notify the R&D personnel to repair the SDK module.
[0056] In the specific use process, the above method can be used to build a middleware, applet, software, etc., and the device can use the middleware, applet, and software to achieve positioning without a GPS module. This embodiment uses the AT method and the Baidu positioning SDK's dual guarantee method to obtain longitude and latitude, which realizes the positioning function while also increasing its fault tolerance, so there is no need to readjust the internal hardware structure of the machine, redesign the circuit diagram, redraw the PCB, retest, etc. The entire process only requires downloading the middleware, which greatly shortens the entire R&D cycle and also greatly reduces the cost of manpower and material resources.
[0057] Example 2
[0058] This embodiment provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other via the communication bus.
[0059] Memory, used to store computer programs;
[0060] The processor is used to implement the high-speed traffic concurrency control method described in the above embodiment when executing the program stored in the memory.
[0061] The communication bus mentioned in the above terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. The communication interface is used for communication between the above terminal and other devices.
[0062] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0063] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0064] Example 3
[0065] This embodiment provides one or more computer-readable storage media, which store instructions. When the computer-readable storage media are executed on a computer, the computer executes the high-speed traffic concurrency control method described in the above embodiment.
[0066] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.
[0067] The above are only preferred embodiments of the present application and are not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the protection scope of the present application.
Claims
1. A positioning method, characterized in that: Includes steps: Determine whether the device hardware has a GPS module; If there is no GPS module, the first longitude and the first latitude are obtained by using AT; Use SDK to obtain the second longitude and latitude; The longitude and latitude are calculated based on the first longitude, the first latitude, the second longitude, and the second latitude.
2. The positioning method according to claim 1, characterized in that: The step of determining whether the device hardware has a GPS module includes: Capture the native positioning interface of the device. If the capture is abnormal, it is determined that the device hardware does not have a GPS module.
3. The positioning method according to claim 2, characterized in that: If no capture exception occurs, it is determined that the device hardware has a GPS module.
4. The positioning method according to claim 1, characterized in that: The step of acquiring the first longitude and the first latitude by using the AT method includes: Open the AT module serial port; Verify the AT module serial port; If the serial port of the AT module is normal, the 4G module is identified and the first longitude and the first latitude are obtained.
5. The positioning method according to claim 4, characterized in that: The step of verifying the serial port of the AT module includes: Send a verification command to the AT module serial port. If the return value of the AT module serial port is received, the AT module serial port is normal. If the return value of the AT module serial port is not received, the AT module serial port is abnormal and the log is sent to the terminal.
6. The positioning method according to claim 1, characterized in that: The step of obtaining the second longitude and the second latitude by using SDK includes: Login secure hash algorithm 1; Get the SDK package name; Get the second longitude and latitude.
7. The positioning method according to claim 1, characterized in that: If the first longitude, the first latitude, the second longitude, and the second latitude are not null values, the step of calculating the longitude and the latitude includes: taking the average of the first longitude and the second longitude as the longitude, and taking the average of the first latitude and the second latitude as the latitude.
8. The positioning method according to claim 1, characterized in that: If the first longitude and the first latitude are not null values, and the second longitude and the second latitude are both null values, the step of calculating the longitude and the latitude includes: using the first longitude and the first latitude as the longitude and the latitude, and the terminal sends a log at the same time; If the first longitude and the first latitude are both null values, and the second longitude and the second latitude are not null values, the step of calculating the longitude and the latitude includes: using the second longitude and the second latitude as the longitude and the latitude, and the terminal sends a log at the same time.
9. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; The memory is used to store computer programs; The processor is used to implement the positioning method according to any one of claims 1 to 8 when executing the program stored in the memory.
10. One or more computer-readable media having instructions stored thereon, which, when executed by one or more processors, enable the processors to perform the positioning method according to any one of claims 1 to 8.
