Device upgrading method based on Web serial port function, computer device and storage medium
Through the Web Serial API, the direct communication between the browser and the device is realized, solving the problem of additional drivers during the equipment upgrade process, improving the convenience and efficiency of upgrades, and ensuring the real -time and performance of data transmission.
Patent Information
- Application Number
- CN202411446400.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-16
- Publication Date
- 2025-01-21
AI Technical Summary
When upgrading the system, existing devices require users to download and install additional upgrade drivers or software, which leads to cumbersome upgrade process and may affect the real-time and performance of data transmission when the network is unstable.
By using the Web Serial API, communication between the browser and the device to be upgraded is realized, the upgrade instructions are obtained and the upgrade file is downloaded or uploaded, and the device system is upgraded directly without the need for additional drivers or software.
It improves the convenience and efficiency of the equipment system upgrade, reduces the complexity of user operations, and can also ensure the real -time and performance of data transmission when the network conditions are not good.
Smart Images

Figure CN119341909A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of intelligent device control technology, and in particular, to a device upgrade method based on a Web serial port function, a computer device applying the device upgrade method based on a Web serial port function, and a computer-readable storage medium applying the device upgrade method based on a Web serial port function. Background Art
[0002] Currently, most interactions between clients and hardware devices are based on the traditional client / server architecture, which focuses more on security and platform independence. This is more suitable for scenarios that require cross-platform access and data security, but there are also some difficulties. For example, the interaction between clients and hardware devices is highly dependent on network connections. When the network is unstable, there will be high latency, which may even affect the real-time data transmission and network transmission performance. In addition, for large amounts of data transmission, network bandwidth may become a bottleneck.
[0003] Requesting access to serial devices through the Web Serial API provided by the browser is more suitable for scenarios of real-time data processing and large-scale data transmission. The Web Serial API allows web applications to communicate directly with serial devices without the need for users to download and install additional drivers or software. This allows direct two-way communication between web applications and serial devices, just like in local applications, enabling convenient and intelligent control of traditional home appliances.
[0004] When upgrading the system of some existing devices, users are required to download and install additional upgrade drivers or upgrade software, which will cause a certain burden on the device. Therefore, in order to improve the convenience of device system upgrades, it is possible to consider applying the WebSerial API to the system upgrade of smart devices. Summary of the invention
[0005] The first object of the present invention is to provide a device upgrade method based on a Web serial port function that improves the convenience of device system upgrade.
[0006] A second object of the present invention is to provide a computer device that improves the convenience of equipment system upgrades.
[0007] A third object of the present invention is to provide a computer-readable storage medium that improves the convenience of device system upgrades.
[0008] In order to achieve the above-mentioned first purpose, the device upgrade method based on Web serial port function provided by the present invention includes: opening the control platform webpage in the browser, and pairing and connecting the serial port corresponding to the device to be upgraded on the control platform webpage; opening the serial port corresponding to the device to be upgraded, so that the browser can communicate with the device to be upgraded; when the upgrade instruction is obtained, obtaining the upgrade file corresponding to the device to be upgraded, and performing the upgrade operation on the device to be upgraded.
[0009] It can be seen from the above scheme that the device upgrade method based on the Web serial port function of the present invention realizes the communication between the browser and the device to be upgraded by utilizing the Web serial port function, and when the upgrade instruction is obtained, the upgrade file corresponding to the device to be upgraded is obtained, and the upgrade operation is performed on the device to be upgraded, thereby realizing the system upgrade of the device to be upgraded by using the web page, without downloading and installing additional upgrade drivers or upgrade software, thereby improving the convenience of device upgrade.
[0010] In a further scheme, the step of pairing and connecting the serial port corresponding to the device to be upgraded on the control platform web page includes: displaying a list of serial port devices connected to the upgrade control device; when an instruction to authorize the connection to the serial port corresponding to the device to be upgraded is obtained, pairing and connecting the serial port corresponding to the device to be upgraded.
[0011] It can be seen that the control platform webpage pairs and connects the serial port corresponding to the device to be upgraded, and displays a list of serial port devices connected to the upgraded control device, which is convenient for users to make connection selections.
[0012] In a further solution, the step of opening the serial port corresponding to the device to be upgraded includes: setting configuration parameters of the serial port corresponding to the device to be upgraded.
[0013] It can be seen that when opening the serial port corresponding to the device to be upgraded, the configuration parameters of the serial port corresponding to the device to be upgraded are set so that the serial port can perform protocol and parameter verification at the data transmission level.
[0014] In a further scheme, the step of setting the configuration parameters of the serial port corresponding to the device to be upgraded includes: generating test configuration parameters of the serial port corresponding to the device to be upgraded, and using the test configuration parameters to change the parameter settings of the serial port corresponding to the device to be upgraded; sending preset test instructions to the device to be upgraded and obtaining response data; if the preset response data is obtained, determining that the test configuration parameters are the configuration parameters of the serial port corresponding to the device to be upgraded.
[0015] It can be seen that when setting the configuration parameters of the serial port corresponding to the device to be upgraded, by automatically generating the test configuration parameters of the serial port corresponding to the device to be upgraded and detecting whether the test configuration parameters are consistent with the current serial port, the work efficiency is significantly improved, the possibility of manual configuration errors is reduced, and the debugging and maintenance of the device becomes more convenient and quick.
[0016] In a further solution, the step of opening the serial port corresponding to the device to be upgraded includes: if the serial port corresponding to the device to be upgraded fails to be opened, after clearing the cached data of the browser, pairing and connecting the serial port corresponding to the device to be upgraded and opening the serial port.
[0017] It can be seen that when opening the serial port corresponding to the device to be upgraded, if the serial port opening fails, the browser cache data needs to be cleared to release the cached data that has not been released by the data read and write stream generated after the user previously opened the Web serial port, ensuring that the current serial port is in an idle state.
[0018] In a further scheme, the step of obtaining the upgrade file corresponding to the device to be upgraded includes: if the upgrade file has been pre-stored in the upgrade control device, uploading the upgrade file stored on the upgrade control device to the control platform web page; if the upgrade file is stored in a remote server, the control platform web page downloads the upgrade file from the remote server.
[0019] It can be seen that when obtaining the upgrade file corresponding to the device to be upgraded, the upgrade file can be obtained by obtaining the local file or downloading the file from the server, which can help expand the acquisition channels of the upgrade file and improve the convenience of device upgrade.
[0020] In a further solution, after the step of performing an upgrade operation on the device to be upgraded, the method further includes: closing the serial port corresponding to the device to be upgraded and canceling the connection authorization.
[0021] It can be seen from this that after upgrading the device to be upgraded, close the Web serial port and cancel the connection authorization to avoid excessive browser resource consumption and cause freezing problems.
[0022] In a further solution, after opening the control platform webpage in the browser, it also includes: confirming whether the current browser supports the Web serial port function, and if not, sending a prompt message to change the browser.
[0023] It can be seen that by confirming whether the current browser supports the Web serial port function, the user can be informed and change the browser when the current browser does not support the Web serial port function.
[0024] In order to achieve the second objective of the present invention, the present invention provides a computer device including a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the steps of the above-mentioned device upgrade method based on the Web serial port function are implemented.
[0025] In order to achieve the third objective of the present invention, the present invention provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a controller, the steps of the above-mentioned device upgrade method based on the Web serial port function are implemented. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Figure 1 It is a flow chart of an embodiment of a device upgrade method based on a Web serial port function of the present invention.
[0027] Figure 2 It is a flow chart of the steps of pairing and connecting the serial ports corresponding to the devices to be upgraded on the control platform web page in the embodiment of the device upgrade method based on the Web serial port function of the present invention.
[0028] Figure 3 It is a schematic diagram of a serial port device list in an embodiment of a device upgrade method based on a Web serial port function of the present invention.
[0029] Figure 4 It is a flow chart of setting configuration parameters of the serial port corresponding to the device to be upgraded in the device upgrade method embodiment based on the Web serial port function of the present invention.
[0030] The present invention is further described below in conjunction with the accompanying drawings and embodiments. DETAILED DESCRIPTION
[0031] Device upgrade method embodiment based on Web serial port function:
[0032] The device upgrade method based on the Web serial port function of the present invention is a computer program applied to the upgrade control device, which is used to perform system upgrade on the device to be upgraded. In this embodiment, the upgrade control device includes one of a mobile phone, a computer, and a central control screen, and the device to be upgraded includes household appliances such as air conditioners, washing machines, and refrigerators. The upgrade control device communicates with the device to be upgraded through a serial port.
[0033] like Figure 1 As shown, in this embodiment, when the device upgrade method based on the Web serial port function is working, step S1 is first executed to open the control platform webpage in the browser. When the device needs to be upgraded, the user can open the visual control platform webpage in the form of a URL link on a mobile phone, computer or other smart device to control the smart device to perform the upgrade operation.
[0034] After opening the control platform webpage, step S2 is executed to confirm whether the current browser supports the Web serial port function. Whether the current browser supports the Web serial port function can be confirmed by using known technical means, for example, Web Serial API example webpages, which can be opened in the current browser to check whether the serial port function can be used normally. If the webpage can successfully detect the serial port device and communicate, the browser supports the function. Otherwise, if an error message appears or the function cannot work normally, the browser does not support the function.
[0035] If it is confirmed that the current browser does not support the Web serial port function, step S3 is executed to send a browser change prompt message. By sending the browser change prompt message, the user can be reminded to change the browser.
[0036] If it is confirmed that the current browser supports the Web serial port function, step S4 is executed to pair the serial port corresponding to the device to be upgraded on the control platform webpage. If the current browser supports the Web serial port function, a further serial port pairing operation can be performed to enable the browser to communicate with the device to be upgraded.
[0037] In this embodiment, see Figure 2 When pairing the serial port corresponding to the device to be upgraded on the control platform webpage, first execute step S41 to display a list of serial port devices connected to the upgraded control device. In order to facilitate the user to make a connection selection, it is necessary to display a list of all serial port devices connected to the upgraded control device, for example, Figure 3 The serial port device list is shown.
[0038] After the list of serial port devices connected to the upgrade control device is displayed, step S42 is executed to determine whether an instruction to authorize the serial port corresponding to the device to be upgraded is obtained. After the list of serial port devices connected to the upgrade control device is displayed, the user can select the device to be upgraded according to the serial port device list for authorized connection. The instruction to authorize the serial port corresponding to the device to be upgraded can be obtained through the virtual button in the serial port device list.
[0039] If an instruction to authorize the serial port corresponding to the device to be upgraded is obtained, step S42 is continued to be executed for continuous detection. When an instruction to authorize the serial port corresponding to the device to be upgraded is obtained, step S43 is executed to pair the serial port corresponding to the device to be upgraded. The pairing connection of the device is a technology well known to those skilled in the art and will not be described in detail here. Of course, if the device to be upgraded is already in a pairing state, the pairing connection operation may not be performed.
[0040] After pairing and connecting the serial port corresponding to the device to be upgraded, step S5 is executed to open the serial port corresponding to the device to be upgraded so that the browser can communicate with the device to be upgraded. After pairing and connecting the serial port corresponding to the device to be upgraded, the serial port corresponding to the device to be upgraded needs to be opened to realize communication between the browser and the device to be upgraded.
[0041] In this embodiment, the step of opening the serial port corresponding to the device to be upgraded includes: setting the configuration parameters of the serial port corresponding to the device to be upgraded. When opening the serial port corresponding to the device to be upgraded, the configuration parameters of the serial port corresponding to the device to be upgraded are set so that the serial port can perform protocol and parameter verification at the data transmission level. The configuration parameters of the serial port include parameters such as baud rate, data bit, stop bit, check bit, flow control, etc.
[0042] The configuration parameters of the serial port corresponding to the device to be upgraded can be set by manual input or by automatic detection input.
[0043] In an optional embodiment, see Figure 4 When setting the configuration parameters of the serial port corresponding to the device to be upgraded, first execute step S51 to generate the test configuration parameters of the serial port corresponding to the device to be upgraded, and use the test configuration parameters to change the parameter settings of the serial port corresponding to the device to be upgraded. By automatically generating the test configuration parameters of the serial port corresponding to the device to be upgraded, different configuration parameters can be set to test which configuration parameter meets the requirements of the current serial port.
[0044] After the parameter settings of the serial port corresponding to the device to be upgraded are changed using the test configuration parameters, step S52 is executed to send a preset test instruction to the device to be upgraded and obtain response data. The preset test instruction can be preset according to experimental data.
[0045] After the response data is obtained, step S53 is executed to determine whether the preset response data is obtained. The preset response data is set according to the preset test instruction. By comparing the response data with the preset response data, it can be determined whether the preset response data is obtained.
[0046] If the preset response data is not obtained, then continue to execute step S51 to generate the next set of test configuration parameters. If the preset response data is obtained, execute step S54 to determine that the test configuration parameters are the configuration parameters of the serial port corresponding to the device to be upgraded. When setting the configuration parameters of the serial port corresponding to the device to be upgraded, by automatically generating the test configuration parameters of the serial port corresponding to the device to be upgraded, and detecting whether the test configuration parameters are consistent with the current serial port, the work efficiency is significantly improved, the possibility of manual configuration errors is reduced, and the debugging and maintenance of the device becomes more convenient and quick.
[0047] In this embodiment, the step of opening the serial port corresponding to the device to be upgraded also includes: if the serial port corresponding to the device to be upgraded fails to be opened, after clearing the cached data of the browser, pairing and connecting the serial port corresponding to the device to be upgraded and opening the serial port.
[0048] There are three reasons why the unreleased cached data in the data read and write streams may cause the serial port to fail to open: (1) Resource occupation: When opening a serial port connection through the Web Serial API, the browser will allocate corresponding system resources to manage the connection. If these resources (such as cached data) are not properly processed and released before closing the connection, these resources may still be occupied. In this case, when trying to reopen the same serial port, the system may think that the serial port is still occupied, resulting in a failure to open. (2) Incomplete I / O operations: If there are uncompleted read and write operations before closing the serial port connection, these operations may block the connection closing process, which may cause the browser or operating system to think that the serial port is still in use, thereby blocking new connection requests. (3) Inconsistent serial port status: If the serial port is abnormally closed in the middle of data transmission (such as a sudden power outage or disconnection), it may cause the serial port to be in an uncertain state. This state may require a specific reset command or reinitialization to return to normal.
[0049] To clear the cached data in the browser, you can refresh the page. When the page is refreshed, all resources and scripts related to the page will be reloaded, and the serial port that has been opened will be automatically closed. To clear the cached data in the browser, you can also clear it by closing the page. When you close the tab or window of the page containing the open serial port, the serial port will also be automatically closed. To clear the cached data in the browser, you can also clear it by navigating away from the current page. If you navigate from the current page to another page (even in the same tab), the serial port will be closed.
[0050] In addition, to avoid the situation where the browser cache data is not cleared, the following measures can be taken when ending communication: automatically release resources. After the communication between the web page and the hardware is completed, make sure to call the appropriate method to close the data read and write streams. For example, in the communication between the web page and the hardware, if the serial port has finished reading the data, make sure to close the data read stream when the data is no longer needed. For the data write stream, make sure to close the data write stream after all the data has been sent to release resources. Finally, after the data read and write streams are closed correctly, the serial port connection needs to be closed. These operations can ensure that all related resources are released and the serial port is in an idle state.
[0051] After opening the serial port corresponding to the device to be upgraded, step S6 is executed to determine whether an upgrade instruction is obtained. The upgrade instruction can be obtained by controlling the system upgrade virtual button displayed on the platform webpage.
[0052] If the upgrade instruction is not obtained, continue to execute step S6 for continuous detection. When the upgrade instruction is obtained, execute step S7 to obtain the upgrade file corresponding to the device to be upgraded and perform the upgrade operation on the device to be upgraded. When the upgrade instruction is obtained, the upgrade operation needs to be performed. The system upgrade is completed by obtaining the upgrade file corresponding to the device to be upgraded and transmitting data with the device to be upgraded through the web serial port.
[0053] In this embodiment, the step of obtaining the upgrade file corresponding to the device to be upgraded includes: if the upgrade file has been pre-stored in the upgrade control device, the upgrade file stored in the upgrade control device is uploaded to the control platform webpage; if the upgrade file is stored in a remote server, the control platform webpage downloads the upgrade file from the remote server. If the air-conditioning system upgrade file has been pre-stored on the local computer, the user can choose to click the "Select File" virtual button to upload the local upgrade file to the webpage. If the air-conditioning system upgrade file exists on the remote server, the webpage will first download the upgrade file from the remote server. When uploading the upgrade file on the webpage, the system can automatically detect whether the firmware is compatible with the target device to avoid device failure caused by firmware mismatch. The webpage can also provide a safer file transfer and storage environment. During the upload process, the upgrade firmware file can be checked, such as verifying the integrity and authenticity of the file to prevent the implantation of malicious software. At the same time, the webpage also processes the upgrade firmware file, such as subpackaging and managing data transmission, to complete the upgrade of the smart device. During the upgrade process, the communication log between the browser and the device to be upgraded and the system upgrade log of the device to be upgraded can be displayed to the webpage for the user to view the specific situation of the upgrade of the device to be upgraded.
[0054] After the upgrade operation is completed for the device to be upgraded, step S8 is executed to close the serial port corresponding to the device to be upgraded and cancel the connection authorization. After the upgrade operation is completed for the device to be upgraded, the Web serial port is closed and the connection authorization is canceled to avoid the problem of freezing caused by excessive browser resource consumption.
[0055] From the above, it can be seen that the device upgrade method based on the Web serial port function of the present invention realizes the communication between the browser and the device to be upgraded by utilizing the Web serial port function, and when the upgrade instruction is obtained, the upgrade file corresponding to the device to be upgraded is obtained, and the upgrade operation is performed on the device to be upgraded, thereby realizing the system upgrade of the device to be upgraded by using the web page, without downloading and installing additional upgrade drivers or upgrade software, thereby improving the convenience of device upgrade.
[0056] Computer device embodiment:
[0057] The computer device of this embodiment includes a controller, and when the controller executes a computer program, the steps in the above-mentioned device upgrade method embodiment based on the Web serial port function are implemented.
[0058] For example, a computer program may be divided into one or more modules, one or more modules are stored in a memory and executed by a controller to implement the present invention. One or more modules may be a series of computer program instruction segments capable of implementing specific functions, and the instruction segments are used to describe the execution process of the computer program in a computer device.
[0059] The computer device may include, but is not limited to, a controller and a memory. Those skilled in the art will appreciate that the computer device may include more or fewer components, or a combination of certain components, or different components, for example, the computer device may also include input and output devices, network access devices, buses, etc.
[0060] For example, the controller may be a central processing unit (CPU), other general controllers, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general controller may be a microcontroller or any conventional controller, etc. The controller is the control center of the computer device, and uses various interfaces and lines to connect the various parts of the entire computer device.
[0061] The memory can be used to store computer programs and / or modules. The controller realizes various functions of the computer device by running or executing the computer programs and / or modules stored in the memory, and calling the data stored in the memory. For example, the memory may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound receiving function, a sound conversion to text function, etc.), etc.; the data storage area may store data created according to the use of the mobile phone (such as audio data, text data, etc.), etc. In addition, the memory may include a high-speed random access memory, and may also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (FlashCard), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0062] Computer readable storage medium embodiment:
[0063] If the module integrated in the computer device of the above embodiment is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the above embodiment of the device upgrade method based on the Web serial port function can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by the controller, the steps of the above embodiment of the device upgrade method based on the Web serial port function can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The storage medium may include: any entity or device capable of carrying computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the computer-readable medium does not include electric carrier signals and telecommunication signals.
[0064] It should be noted that the above are only preferred embodiments of the present invention, but the design concept of the invention is not limited thereto, and any non-substantial modifications made to the present invention using this concept also fall within the protection scope of the present invention.
Claims
1. A device upgrade method based on Web serial port function, applied to upgrade control equipment, characterized in that: The method comprises: Open the control platform webpage in the browser, and pair and connect the serial port corresponding to the device to be upgraded on the control platform webpage; Opening the serial port corresponding to the device to be upgraded, so that the browser communicates with the device to be upgraded; When the upgrade instruction is obtained, the upgrade file corresponding to the device to be upgraded is obtained, and the upgrade operation is performed on the device to be upgraded.
2. The device upgrade method based on Web serial port function according to claim 1 is characterized in that: The steps of pairing and connecting the serial port corresponding to the device to be upgraded on the control platform webpage include: Display a list of serial port devices connected to the upgrade control device; When an instruction to authorize the serial port corresponding to the device to be upgraded is obtained, a pairing connection is performed on the serial port corresponding to the device to be upgraded.
3. The device upgrade method based on Web serial port function according to claim 1 is characterized in that: The steps of opening the serial port corresponding to the device to be upgraded include: Set the configuration parameters of the serial port corresponding to the device to be upgraded.
4. The device upgrade method based on Web serial port function according to claim 3 is characterized in that: The step of setting the configuration parameters of the serial port corresponding to the device to be upgraded includes: Generate test configuration parameters of the serial port corresponding to the device to be upgraded, and use the test configuration parameters to change parameter settings of the serial port corresponding to the device to be upgraded; Sending a preset test instruction to the device to be upgraded and obtaining response data, if the preset response data is obtained, determining that the test configuration parameter is a configuration parameter of the serial port corresponding to the device to be upgraded.
5. The device upgrade method based on Web serial port function according to claim 1 is characterized in that: The steps of opening the serial port corresponding to the device to be upgraded include: If the serial port corresponding to the device to be upgraded fails to be opened, after the cache data of the browser is cleared, the serial port corresponding to the device to be upgraded is paired and connected and the serial port is opened.
6. The device upgrade method based on Web serial port function according to any one of claims 1 to 5, characterized in that: The step of obtaining the upgrade file corresponding to the device to be upgraded includes: If the upgrade file has been pre-stored in the upgrade control device, uploading the upgrade file stored in the upgrade control device to the control platform webpage; If the upgrade file is stored in a remote server, the control platform webpage downloads the upgrade file from the remote server.
7. The device upgrade method based on Web serial port function according to any one of claims 1 to 5, characterized in that: After the step of performing an upgrade operation on the device to be upgraded, the method further includes: Close the serial port corresponding to the device to be upgraded and cancel the connection authorization.
8. The device upgrade method based on Web serial port function according to any one of claims 1 to 5, characterized in that: After opening the control platform webpage in the browser, it also includes: Confirm whether the current browser supports the Web serial port function. If not, send a prompt message to change the browser.
9. A computer device comprising a processor and a memory, characterized in that: The memory stores a computer program, and when the computer program is executed by the processor, the steps of the device upgrade method based on the Web serial port function as claimed in any one of claims 1 to 8 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by the controller, the steps of the device upgrade method based on the Web serial port function as claimed in any one of claims 1 to 8 are implemented.
Citation Information
Patent Citations
Smart home communication system and method equipped with Web Service functions
CN104994129A
Remote serial port upgrade method of network devices
CN108768709A
Firmware upgrading method and intelligent household electrical appliance
CN109361528A
A device upgrading method and a WEB server
CN109683931A