Communication method, device and system between applets, electronic equipment and computer readable storage medium
By starting the communication service application on the on-board equipment in the autonomous driving vehicle, using mDNS and Socket protocols to achieve rapid discovery and data transmission between applets, the problems of low LAN communication efficiency and poor stability are solved, and the user experience is improved.
Patent Information
- Application Number
- CN202410981556.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-22
- Publication Date
- 2024-11-29
AI Technical Summary
The prior art has low efficiency and poor stability in local area network communication between mini programs in autonomous driving vehicles, especially in areas with poor network signals. User experience is poor.
By starting the preset communication service application on the on-board device, broadcasting service information, and using mDNS and Socket communication services to realize rapid service discovery and data transmission between applets, the on-board device serves as a transit node to forward data.
It improves the communication efficiency and stability between mini programs in the LAN, avoids external network dependence, and improves user interaction experience.
Smart Images

Figure CN119052949A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a method, device, system, electronic device and computer-readable storage medium for communication between applets. Background Art
[0002] With the development of autonomous driving technology, autonomous driving vehicles are becoming more and more common in daily life. Many companies have provided online car-hailing services based on autonomous driving vehicles. While meeting daily transportation needs, they also provide more business forms, indirectly giving rise to the demand for entertainment among users in the car. For example, when riding in an autonomous taxi, acquaintances may have the need for multiplayer interactive games, or they may need to control other devices in the car within the local area network.
[0003] In order to meet the needs of the above-mentioned scenarios, a solution for communication between terminal devices of multiple users needs to be implemented. Currently, there are two common methods:
[0004] The first solution is to discover the other device by polling the IP address through the Ping command after the device is connected to a local area network, and try to establish a communication connection. The specific steps include the following:
[0005] 1) Ping all IP addresses in this network segment;
[0006] 2) Based on the result of step 1), distinguish the IP addresses that can be pinged and those that cannot be pinged;
[0007] 3) Based on step 2), use polling to connect to the IP addresses and ports that can be pinged one by one, and discard the IP addresses that cannot be pinged;
[0008] 4) Based on step 3), after the connection is successful, network data interaction is performed;
[0009] 5) If a new device or mini-program is added, you need to restart from step 1) to access the new device or mini-program;
[0010] The second solution is to establish a communication connection between each user terminal device and a cloud, and transfer through the cloud, which specifically includes the following steps:
[0011] 1) Each user in the LAN logs in;
[0012] 2) Join the same room or group, identify each user terminal device, and then transfer the data of each user terminal device through the cloud.
[0013] However, the above two solutions have certain problems. Although the first solution does not rely on the external network, it requires continuous trial and error through polling to discover devices. This method is inefficient and has a large performance loss. The actual user experience is that it may take a relatively long time to discover other devices in the same LAN.
[0014] The second solution needs to rely on the external network to be implemented and requires the parameters of the cloud server. In some weak network areas with poor network signals, communication will be delayed and data loss may occur, which greatly affects the interactive experience between users. Summary of the invention
[0015] The embodiments of the present application provide a method, device, system, electronic device and computer-readable storage medium for communication between mini-programs to improve the communication efficiency and stability between mini-programs in a local area network and improve user experience.
[0016] The present application embodiment adopts the following technical solutions:
[0017] In a first aspect, an embodiment of the present application provides a method for communication between mini-programs, wherein the method for communication between mini-programs is executed by a vehicle-mounted device, and the method for communication between mini-programs includes:
[0018] Starting a preset communication service application on the vehicle-mounted device and broadcasting the service information of the vehicle-mounted device in the local area network, so that the applets of multiple user-end devices in the local area network can obtain the service information of the vehicle-mounted device;
[0019] Receiving communication connection requests initiated by applets on multiple user-end devices;
[0020] Establishing communication connections between the vehicle-mounted device and the applets of multiple user-end devices respectively according to the communication connection request;
[0021] Data transmission between mini-programs is performed based on the communication connection between the vehicle-mounted device and the mini-programs of multiple user-end devices.
[0022] Optionally, the preset communication service application provides an mDNS service, and the broadcasting of the service information of the vehicle-mounted device in the local area network includes:
[0023] Broadcasting the service information of the vehicle-mounted device in the local area network based on the mDNS service;
[0024] The preset communication service application also provides a Socket communication service, and the communication connection between the vehicle-mounted device and the applets of multiple user-end devices respectively established according to the communication connection request includes:
[0025] Based on the Socket communication service and the communication connection request, Socket communication connections are established between the vehicle-mounted device and the applets of multiple user-end devices.
[0026] Optionally, the communication method between mini-programs further includes:
[0027] After establishing a communication connection between the vehicle-mounted device and the applet of the user terminal device, the user terminal device information corresponding to the applet connected to the vehicle-mounted device is stored in a preset record table, wherein the user terminal device information includes the IP address of the user terminal device and the user terminal identity;
[0028] When the communication connection between the vehicle-mounted device and the applet of the user-end device changes, the preset record table is updated according to the type of change, and the type of change includes at least one of disconnection and new connection.
[0029] Optionally, the data transmission between mini-programs based on the communication connection between the in-vehicle device and the mini-programs of the plurality of user-end devices includes:
[0030] Based on the communication connection between the in-vehicle device and the applet of the first user terminal device, receiving a data transmission request sent by the applet of the first user terminal device, wherein the data transmission request carries device information of the second user terminal device;
[0031] Based on the communication connection between the vehicle-mounted device and the applet of the second user-end device and the device information of the second user-end device, the data transmission request of the applet of the first user-end device is forwarded to the applet of the second user-end device to realize data transmission between the applet of the first user-end device and the applet of the second user-end device.
[0032] In a second aspect, an embodiment of the present application further provides a method for communication between mini-programs, wherein the method for communication between mini-programs is executed by a mini-program on a user terminal device, and the method for communication between mini-programs includes:
[0033] When the user terminal device is connected to the local area network where the vehicle-mounted device is located, obtaining service information of the vehicle-mounted device in the local area network;
[0034] Sending a communication connection request to the vehicle-mounted device according to the service information of the vehicle-mounted device;
[0035] Establishing a communication connection between the applet of the user terminal device and the vehicle-mounted device according to the communication connection request;
[0036] Data is transmitted between the applets on the user-side device based on the communication connection between the applets on the user-side device and the vehicle-mounted device.
[0037] Optionally, a service discovery interface is provided on the mini-program, and when the user terminal device is connected to the local area network where the vehicle-mounted device is located, obtaining service information of the vehicle-mounted device in the local area network includes:
[0038] Obtain service information of all devices in the local area network through the service discovery interface and mDNS protocol;
[0039] Analyze the service information of all acquired devices;
[0040] The service information of the vehicle-mounted device in the local area network is determined according to the analysis result.
[0041] Optionally, the service information of the vehicle-mounted device includes an IP address and a Socket port number of the vehicle-mounted device, a Socket connection interface is provided on the applet, and sending a communication connection request to the vehicle-mounted device according to the service information of the vehicle-mounted device includes:
[0042] Sending a communication connection request to the vehicle-mounted device through the Socket connection interface according to the IP address of the vehicle-mounted device and the Socket port number;
[0043] The connection status of the vehicle-mounted device is determined using a callback method.
[0044] In a third aspect, an embodiment of the present application further provides a communication device between mini-programs, wherein the communication device between mini-programs is applied to a vehicle-mounted device, and the communication device between mini-programs includes:
[0045] A broadcast unit, used to start a preset communication service application on the vehicle-mounted device and broadcast the service information of the vehicle-mounted device in the local area network, so that the applets of multiple user-end devices in the local area network can obtain the service information of the vehicle-mounted device;
[0046] A receiving unit, used to receive communication connection requests initiated by mini-programs on multiple user-end devices;
[0047] A first establishing unit, configured to establish communication connections between the vehicle-mounted device and the mini-programs of multiple user-end devices respectively according to the communication connection request;
[0048] The first transmission unit is used to transmit data between mini-programs based on the communication connection between the vehicle-mounted device and the mini-programs of multiple user-end devices.
[0049] In a fourth aspect, an embodiment of the present application further provides a communication device between mini-programs, wherein the communication device between mini-programs is applied to a mini-program on a user terminal device, and the communication device between mini-programs includes:
[0050] An acquisition unit, used to acquire service information of the vehicle-mounted device in the local area network when the user terminal device is connected to the local area network where the vehicle-mounted device is located;
[0051] A sending unit, configured to send a communication connection request to the vehicle-mounted device according to the service information of the vehicle-mounted device;
[0052] A second establishing unit, configured to establish a communication connection between the mini program of the user terminal device and the vehicle-mounted device according to the communication connection request;
[0053] The second transmission unit is used to perform data transmission between the mini-programs of the user terminal device based on the communication connection between the mini-program of the user terminal device and the vehicle-mounted device.
[0054] In the fifth aspect, an embodiment of the present application also provides a communication system between mini-programs, wherein the communication system between mini-programs includes a vehicle-mounted device and a user-end device, a mini-program is running on the user-end device, the vehicle-mounted device is used to execute any of the aforementioned communication methods between mini-programs, and the mini-program on the user-end device is used to execute any of the aforementioned communication methods between mini-programs.
[0055] In a sixth aspect, an embodiment of the present application further provides an electronic device, including:
[0056] Processor; and
[0057] A memory arranged to store computer executable instructions, which, when executed, cause the processor to perform any of the aforementioned methods for communication between applets.
[0058] In the seventh aspect, an embodiment of the present application also provides a computer-readable storage medium, which stores one or more programs. When the one or more programs are executed by an electronic device including multiple application programs, the electronic device executes any of the aforementioned communication methods between mini-programs.
[0059] At least one of the above technical solutions adopted in the embodiments of the present application can achieve the following beneficial effects: the communication method between mini-programs in the embodiments of the present application is executed by the vehicle-mounted device, first starting the preset communication service application on the vehicle-mounted device, and broadcasting the service information of the vehicle-mounted device in the local area network, so that the mini-programs of multiple user-end devices in the local area network can obtain the service information of the vehicle-mounted device; then receiving the communication connection request initiated by the mini-programs on multiple user-end devices; then establishing the communication connection between the vehicle-mounted device and the mini-programs of multiple user-end devices respectively according to the communication connection request; finally, based on the communication connection between the vehicle-mounted device and the mini-programs of multiple user-end devices, data transmission between mini-programs is performed. The communication method between mini-programs in the embodiments of the present application makes full use of the characteristics of the vehicle-mounted device itself in the vehicle-mounted scenario, uses the vehicle-mounted device as a transit node for communication between mini-programs, and combines the fast service discovery mechanism of the mini-program to improve the communication efficiency between mini-programs in the local area network, and can realize the communication transmission between mini-programs in the same local area network, without relying on the external network environment, improving the stability of communication transmission, and thus improving the user experience of using mini-programs to interact. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0061] Figure 1 A flow chart of a method for communication between mini-programs in an embodiment of the present application;
[0062] Figure 2 A flowchart of another method for communicating between mini-programs in an embodiment of the present application;
[0063] Figure 3 This is a schematic diagram of the structure of a communication device between mini-programs in an embodiment of the present application;
[0064] Figure 4 This is a schematic diagram of the structure of another communication device between mini-programs in an embodiment of the present application;
[0065] Figure 5 A communication system between mini-programs in an embodiment of the present application;
[0066] Figure 6 This is a schematic diagram of the structure of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION
[0067] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.
[0068] The technical solutions provided by various embodiments of the present application are described in detail below in conjunction with the accompanying drawings.
[0069] In order to meet the company's functional iteration goals and reduce the need for application installation and management, more and more companies have begun to prioritize the development and use of mini-programs such as WeChat mini-programs to carry out business functions. However, mini-programs cannot establish a service that passively waits for mini-program discovery through the existing API interface in the local area network, resulting in mini-programs being unable to directly discover each other, and thus unable to directly communicate with each other.
[0070] Based on this, the present application embodiment provides a communication method between mini-programs, such as Figure 1 As shown, a flow chart of a communication method between mini-programs in an embodiment of the present application is provided. The communication method between mini-programs is executed by a vehicle-mounted device, and the communication method between mini-programs at least includes the following steps S110 to S140:
[0071] Step S110, starting a preset communication service application on the vehicle-mounted device, and broadcasting the service information of the vehicle-mounted device in the local area network, so that the applets of multiple user-end devices in the local area network can obtain the service information of the vehicle-mounted device.
[0072] The communication method between mini-programs in the embodiment of the present application is executed by a vehicle-mounted device, which may be a device in an autonomous driving vehicle that can support the deployment of communication service functions, such as a driver screen device using an Android system, etc. After the vehicle-mounted device is turned on, it can automatically connect to a local area network, such as a fixed vehicle-mounted local area network WiFi.
[0073] The vehicle-mounted device of the embodiment of the present application is pre-installed with an application for realizing the communication service function between the device and the applet. After the vehicle-mounted device is turned on and connected to a fixed local area network, the preset communication service application installed on the vehicle-mounted device is started and can run in the background. Based on the preset communication service application, the vehicle-mounted device can broadcast its own service information in the local area network, for example, it can include the IP address, port number and other information of the vehicle-mounted device.
[0074] Step S120, receiving communication connection requests initiated by mini-programs on multiple user-end devices.
[0075] After the vehicle-mounted device broadcasts its own service information, all other mini-programs on user-end devices connected to the local area network can obtain the service information of the vehicle-mounted device through the automatic service discovery mechanism. And because the vehicle-mounted device is installed with an application with communication service function, the mini-program can initiate a communication connection request to the vehicle-mounted device through a service call, and the vehicle-mounted device can receive the communication connection request initiated by the mini-program on the user-end device.
[0076] Step S130 , establishing communication connections between the vehicle-mounted device and the applets of multiple user-end devices respectively according to the communication connection request.
[0077] After receiving communication connection requests from applets of multiple user-end devices, the in-vehicle device can establish communication connections with the applets of each user-end device respectively based on the communication protocol provided by the preset communication service application.
[0078] Step S140 , data transmission between mini-programs is performed based on the communication connection between the vehicle-mounted device and the mini-programs of multiple user-end devices.
[0079] In the embodiment of the present application, the vehicle-mounted device is used as a transit node for communication transmission between mini-programs. Based on the communication connection between the vehicle-mounted device and the mini-program of each user-end device, data transmission between mini-programs can be indirectly realized.
[0080] It should be emphasized here that because the current mini-programs do not support the establishment of a service that passively waits for other mini-programs to be discovered through the existing API, mini-programs cannot communicate directly with each other. However, since the embodiment of the present application has pre-installed an application that can provide communication service functions in the vehicle-mounted device, the mini-program can establish a communication connection with the vehicle-mounted device and transmit data, thereby indirectly meeting the data transmission needs between mini-programs through the transit of the vehicle-mounted device.
[0081] The communication method between mini-programs in the embodiment of the present application makes full use of the characteristics of the vehicle-mounted equipment itself in the vehicle-mounted scenario, uses the vehicle-mounted equipment as a transit node for communication between mini-programs, and combines the mini-program's fast service discovery mechanism to improve the communication efficiency between mini-programs in the local area network, and can realize communication transmission between mini-programs in the same local area network without relying on the external network environment, thereby improving the stability of communication transmission and improving the user experience of interacting with mini-programs.
[0082] In some embodiments of the present application, the preset communication service application provides an mDNS service, and the broadcasting of the service information of the vehicle-mounted device in the local area network includes: broadcasting the service information of the vehicle-mounted device in the local area network based on the mDNS service; the preset communication service application also provides a Socket communication service, and the establishing of communication connections between the vehicle-mounted device and the applets of multiple user-end devices respectively according to the communication connection request includes: establishing Socket communication connections between the vehicle-mounted device and the applets of multiple user-end devices respectively based on the Socket communication service and the communication connection request.
[0083] Considering that the current mini-programs only support obtaining service information such as the IP addresses of other devices in the local area network through the mDNS protocol, mDNS is multicast DNS, which mainly enables hosts in the local area network to discover and communicate with each other without a traditional DNS server. Therefore, the preset communication service application of the embodiment of the present application provides an mDNS service, that is, the service discovery of the mini-program and the device is performed through the mDNS protocol.
[0084] Through the mDNS protocol, devices can broadcast and publish their service information in the local area network. By parsing this service information, the mini program can quickly discover and identify devices in the local area network, and the fast service discovery mechanism further optimizes the speed and efficiency of device discovery, so that the advantages of the mDNS protocol can be used to quickly discover vehicle-mounted devices in the same local area network.
[0085] In order to realize the communication connection between the applet and the device, the preset communication service application in the embodiment of the present application also provides a Socket communication service, that is, a Socket communication connection between the applet and the device is established through the Socket communication service.
[0086] In some embodiments of the present application, the communication method between the mini-programs also includes: after establishing a communication connection between the mini-program of the vehicle-mounted device and the user-end device, storing the user-end device information corresponding to the mini-program connected to the vehicle-mounted device in a preset record table, the user-end device information including the IP address of the user-end device and the user-end identity identification; when the communication connection between the mini-program of the vehicle-mounted device and the user-end device changes, updating the preset record table according to the type of change, the type of change including at least one of disconnecting and adding a new connection.
[0087] As a transit node for communication between mini-programs, the vehicle-mounted device can also uniformly maintain and manage the device information of the connected mini-programs. When a new device or mini-program establishes Socket communication with the vehicle-mounted device, the vehicle-mounted device can record the IP address and unique identifier of the user-end device into the record table and save it locally, while also saving the Socket connection established between the mini-program and the vehicle-mounted device.
[0088] When other devices are disconnected, such as when the mini program is closed, the IP address and unique identifier of the device are removed from the record table, so as to maintain a list of devices arranged in the order of connection. At the same time, the IP address of the new mini program device and the unique identifier of the mini program user are broadcasted to other mini programs that are already in the record table to inform them that a new mini program has joined the local area network. Later, data transmission within the local area network can be carried out between mini programs through the vehicle device node as needed.
[0089] In some embodiments of the present application, the data transmission between mini-programs based on the communication connection between the vehicle-mounted device and the mini-programs of multiple user-end devices includes: based on the communication connection between the vehicle-mounted device and the mini-program of the first user-end device, receiving a data transmission request sent by the mini-program of the first user-end device, the data transmission request carrying the device information of the second user-end device; based on the communication connection between the vehicle-mounted device and the mini-program of the second user-end device and the device information of the second user-end device, forwarding the data transmission request of the mini-program of the first user-end device to the mini-program of the second user-end device, so as to realize data transmission between the mini-program of the first user-end device and the mini-program of the second user-end device.
[0090] When two applets need to perform data transmission within a local area network, a data transmission request can be first sent to the vehicle-mounted device based on the communication connection between the vehicle-mounted device and the applet of the second user-end device. The data transmission request contains specific data to be transmitted, which can be in a custom protocol format, such as JSON or XML, so that the device and the applet can communicate. In addition, the data transmission request must carry the device IP and user unique identification information of the target applet. Since each applet can obtain the device information of all other applets in the local area network through the vehicle-mounted device during the service discovery phase, the user can select the device information of the target applet that needs to be transmitted.
[0091] After the vehicle-mounted device receives the data transmission request from the mini program, it queries the Socket connection of the target mini program in the maintained record table through the user unique identifier and device IP of the target mini program carried in the data transmission request, and sends the data to be transmitted to the target mini program through the Socket connection of the target mini program, thereby achieving the purpose of data forwarding.
[0092] When it is necessary to implement mutual communication between two or more mini-programs within a local area network, the specific process can be inferred according to the description in the above embodiment in combination with various business scenarios, and will not be repeated here.
[0093] The present application embodiment also provides another communication method between mini-programs, such as Figure 2 As shown, a flow chart of another method for communicating between mini-programs in an embodiment of the present application is provided. The method for communicating between mini-programs is executed by a mini-program on a user terminal device, and the method for communicating between mini-programs includes at least the following steps S210 to S240:
[0094] Step S210, when the user terminal device is connected to the local area network where the vehicle-mounted device is located, obtain service information of the vehicle-mounted device in the local area network.
[0095] Another communication method between mini-programs provided in the embodiment of the present application is executed by a mini-program deployed on a user-end device, where the mini-program can be a mini-program that implements various business functions in actual business scenarios, such as mini-program games, etc. The mini-program runs on a user-end device such as a mobile phone. When the user-end device enters the LAN range where the vehicle-mounted device is located, the user-end device can access the LAN WiFi connected to the vehicle-mounted device. After successfully connecting to the LAN, the user opens the mini-program on the user-end device. The mini-program can perform service discovery through the configured API interface and search for device information in the LAN, including service information of the vehicle-mounted device in the LAN.
[0096] Step S220: sending a communication connection request to the vehicle-mounted device according to the service information of the vehicle-mounted device.
[0097] Step S230: establishing a communication connection between the mini-program of the user terminal device and the vehicle-mounted device according to the communication connection request.
[0098] After the service information of the vehicle-mounted device is acquired, a communication connection request is sent to the vehicle-mounted device based on the service information of the vehicle-mounted device including the device IP and port number, so as to establish a communication connection with the vehicle-mounted device.
[0099] Step S240 , data transmission between the mini-programs of the user terminal device is performed based on the communication connection between the mini-program of the user terminal device and the vehicle-mounted device.
[0100] After establishing the communication connection between the mini program and the vehicle-mounted device, the vehicle-mounted device can be used as a transit node to realize data transmission between the mini programs based on the communication connection between the mini program and the vehicle-mounted device.
[0101] In some embodiments of the present application, a service discovery interface is provided on the mini program, and when the user-end device is connected to the local area network where the vehicle-mounted device is located, obtaining the service information of the vehicle-mounted device in the local area network includes: obtaining the service information of all devices in the local area network through the service discovery interface and the mDNS protocol; parsing the service information of all devices obtained; and determining the service information of the vehicle-mounted device in the local area network based on the parsing results.
[0102] The mini program can obtain the service information of the vehicle-mounted equipment in the local area network through the relevant API to search the device information of the local area network. The API is packaged with relevant business processes in advance. Taking the WeChat mini program as an example, the relevant APIs are:
[0103] 1) Start service discovery: wx.startLocalServiceDiscovery(Object object)
[0104] 2) End service discovery: wx.stopLocalServiceDiscovery(Object object)
[0105] 3) Listening for service discovery: wx.onLocalServiceFound(function listener)
[0106] Service discovery is performed through the above-mentioned API provided by the mini program. The API provided by the mini program mainly utilizes some characteristics of each mobile device. For example, the WeChat mini program currently only supports obtaining the IP addresses of other devices in the local area network through the mDNS protocol. The implementation of the mDNS API on iOS is based on Bonjour, and on Android it is based on the Android system interface. The embodiment of the present application adopts the mDNS protocol and the fast service discovery mechanism as new means to achieve rapid discovery and access of devices. Through the mDNS protocol, the device can broadcast in the local area network and publish its own service information. By parsing this service information, the mini program can quickly discover and identify devices in the local area network. The fast service discovery mechanism further optimizes the speed and efficiency of device discovery, so that the advantages of the mDNS protocol can be used to quickly discover vehicle-mounted devices in the same local area network.
[0107] In some embodiments of the present application, the service information of the vehicle-mounted device includes the IP address and Socket port number of the vehicle-mounted device, and a Socket connection interface is provided on the applet, and sending a communication connection request to the vehicle-mounted device according to the service information of the vehicle-mounted device includes: sending a communication connection request to the vehicle-mounted device through the Socket connection interface according to the IP address and the Socket port number of the vehicle-mounted device; and determining the connection status of the vehicle-mounted device by using a callback method.
[0108] After the quick service discovers the vehicle-mounted device in the same LAN, the IP address and agreed Socket port of the vehicle-mounted device can be obtained. Use the API provided by the mini program to implement Socket connection to establish a Socket connection and perform data communication. For example, use the wx.connectSocket(Object object) connection function provided by the WeChat mini program to establish a Socket connection with the vehicle-mounted device, and return a SocketTask object. Use SocketTask.onOpen(functionlistener) and other related callback methods to determine the connection status callback, as well as the method callback for sending and receiving messages.
[0109] In some embodiments of the present application, the communication method between mini-programs also includes: determining the network connection status between the mini-program and the cloud; when the network connection status between the mini-program and the cloud is a weak network state, switching the network connected to the mini-program to the local area network where the vehicle-mounted device is located.
[0110] The communication between mini-programs in the embodiments of the present application can also be based on the establishment of a communication connection to the external network, as a supplementary solution to supplement and optimize the external network communication solution. For example, when the external network is in a weak network state, the network connection can be switched to a local area network connection to ensure stable communication between mini-programs.
[0111] In summary, the main improvements and technical effects of the communication method between mini-programs of the present application are as follows:
[0112] 1) In a local area network similar to a vehicle environment, there is generally an Android vehicle device. The API in the vehicle device system provides a similar API interface. The embodiment of the present application cleverly reuses this Android device and installs an APP that can provide passive service discovery and Socket service communication in the device to provide a passive service discovery node and the node can provide a message forwarding function;
[0113] 2) By using the existing relevant API interfaces of the mini-programs and the broadcast and query mechanism of the mDNS protocol, mini-programs and devices in the local area network can be discovered quickly and automatically;
[0114] 3) By introducing the mDNS protocol, Socket protocol and fast service discovery mechanism and combining them, the small programs in the vehicle network can quickly discover, identify and securely access the internal devices of the vehicle;
[0115] 4) Multiple mini-programs automatically establish network connections through vehicle-mounted devices in the local area network without the user's knowledge, avoiding problems such as poor user experience caused by weak network when relying solely on the external network.
[0116] The present application embodiment also provides a communication device 300 between mini-programs, such as Figure 3 As shown, a schematic diagram of the structure of a communication device between mini-programs in an embodiment of the present application is provided. The communication device between mini-programs is applied to a vehicle-mounted device. The communication device 300 between mini-programs includes: a broadcast unit 310, a receiving unit 320, a first establishing unit 330, and a first transmission unit 340, wherein:
[0117] The broadcast unit 310 is used to start the preset communication service application on the vehicle-mounted device and broadcast the service information of the vehicle-mounted device in the local area network so that the applets of multiple user-end devices in the local area network can obtain the service information of the vehicle-mounted device;
[0118] The receiving unit 320 is used to receive communication connection requests initiated by mini-programs on multiple user terminal devices;
[0119] A first establishing unit 330 is used to establish communication connections between the vehicle-mounted device and the mini-programs of multiple user-end devices respectively according to the communication connection request;
[0120] The first transmission unit 340 is used to perform data transmission between mini-programs based on the communication connection between the vehicle-mounted device and the mini-programs of multiple user-end devices.
[0121] In some embodiments of the present application, the preset communication service application provides an mDNS service, and the broadcast unit 310 is specifically used to: broadcast the service information of the vehicle-mounted device in the local area network based on the mDNS service; the preset communication service application also provides a Socket communication service, and the first establishment unit 330 is specifically used to: establish Socket communication connections between the vehicle-mounted device and the applets of multiple user-end devices based on the Socket communication service and the communication connection request.
[0122] In some embodiments of the present application, the communication device between the mini-programs also includes: a storage unit, which is used to store the user-end device information corresponding to the mini-program connected to the vehicle-mounted device in a preset record table after establishing a communication connection between the vehicle-mounted device and the mini-program of the user-end device, and the user-end device information includes the IP address of the user-end device and the user-end identity identification; an update unit, which is used to update the preset record table according to the type of change when the communication connection between the vehicle-mounted device and the mini-program of the user-end device changes, and the type of change includes at least one of disconnection and new connection.
[0123] In some embodiments of the present application, the first transmission unit 340 is specifically used to: based on the communication connection between the vehicle-mounted device and the applet of the first user-end device, receive a data transmission request sent by the applet of the first user-end device, wherein the data transmission request carries the device information of the second user-end device; based on the communication connection between the vehicle-mounted device and the applet of the second user-end device and the device information of the second user-end device, forward the data transmission request of the applet of the first user-end device to the applet of the second user-end device, so as to realize data transmission between the applet of the first user-end device and the applet of the second user-end device.
[0124] It can be understood that the above-mentioned communication device between mini-programs can implement the various steps of the communication method between mini-programs provided in the aforementioned embodiments. The relevant explanations about the communication method between mini-programs are applicable to the communication device between mini-programs and will not be repeated here.
[0125] The present application embodiment also provides another communication device 400 between mini-programs, such as Figure 4 As shown, a schematic diagram of the structure of another communication device between mini-programs in an embodiment of the present application is provided. The communication device between mini-programs is applied to a mini-program on a user terminal device. The communication device 400 between mini-programs includes: an acquisition unit 410, a sending unit 420, a second establishment unit 430, and a second transmission unit 440, wherein:
[0126] The acquisition unit 410 is used to acquire the service information of the vehicle-mounted device in the local area network when the user terminal device is connected to the local area network where the vehicle-mounted device is located;
[0127] A sending unit 420, configured to send a communication connection request to the vehicle-mounted device according to the service information of the vehicle-mounted device;
[0128] A second establishing unit 430 is used to establish a communication connection between the mini program of the user terminal device and the vehicle-mounted device according to the communication connection request;
[0129] The second transmission unit 440 is used to perform data transmission between the mini-programs of the user terminal device based on the communication connection between the mini-program of the user terminal device and the vehicle-mounted device.
[0130] In some embodiments of the present application, a service discovery interface is provided on the mini program, and the acquisition unit 410 is specifically used to: obtain the service information of all devices in the local area network through the service discovery interface and the mDNS protocol; parse the service information of all devices obtained; and determine the service information of the vehicle-mounted devices in the local area network based on the parsing results.
[0131] In some embodiments of the present application, the service information of the vehicle-mounted device includes the IP address and Socket port number of the vehicle-mounted device, a Socket connection interface is provided on the applet, and the sending unit 420 is specifically used to: send a communication connection request to the vehicle-mounted device through the Socket connection interface according to the IP address and the Socket port number of the vehicle-mounted device; and determine the connection status of the vehicle-mounted device using a callback method.
[0132] In some embodiments of the present application, the communication device between the mini-programs also includes: a determination unit, used to determine the network connection status between the mini-program and the cloud; a switching unit, used to switch the network connected to the mini-program to the local area network where the vehicle-mounted device is located when the network connection status between the mini-program and the cloud is a weak network state.
[0133] It can be understood that the above-mentioned communication device between mini-programs can implement the various steps of the communication method between mini-programs provided in the aforementioned embodiments. The relevant explanations about the communication method between mini-programs are applicable to the communication device between mini-programs and will not be repeated here.
[0134] The present application also provides a communication system between mini-programs. Figure 5 As shown, a communication system between mini-programs in an embodiment of the present application is provided, and the communication system between mini-programs includes a vehicle-mounted device and a user-end device, a mini-program is running on the user-end device, the vehicle-mounted device is used to execute any of the aforementioned communication methods between mini-programs executed by the vehicle-mounted device, and the mini-program on the user-end device is used to execute any of the aforementioned communication methods between mini-programs executed by the mini-program on the user-end device.
[0135] Figure 6 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. Figure 6At the hardware level, the electronic device includes a processor, and optionally also includes an internal bus, a network interface, and a memory. The memory may include a memory, such as a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage. Of course, the electronic device may also include hardware required for other services.
[0136] The processor, network interface and memory can be interconnected through an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 6 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0137] The memory is used to store the program. Specifically, the program may include a program code, and the program code includes a computer operation instruction. The memory may include a memory and a non-volatile memory, and provides instructions and data to the processor.
[0138] The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming a communication device between small programs at the logical level. The processor executes the program stored in the memory and is specifically used to perform the following operations:
[0139] Starting a preset communication service application on the vehicle-mounted device and broadcasting the service information of the vehicle-mounted device in the local area network, so that the applets of multiple user-end devices in the local area network can obtain the service information of the vehicle-mounted device;
[0140] Receiving communication connection requests initiated by applets on multiple user-end devices;
[0141] Establishing communication connections between the vehicle-mounted device and the applets of multiple user-end devices respectively according to the communication connection request;
[0142] Data transmission between mini-programs is performed based on the communication connection between the vehicle-mounted device and the mini-programs of multiple user-end devices.
[0143] The above application Figure 1The method executed by the communication device between mini-programs disclosed in the illustrated embodiment can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor or an instruction in software form. The above processor may 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 gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module can be located in a storage medium mature in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.
[0144] The electronic device may also perform Figure 1 The method for executing the communication device between small programs and realizing the communication device between small programs Figure 1 The functions of the illustrated embodiment will not be described in detail in the embodiments of the present application.
[0145] The present application also provides a computer-readable storage medium, which stores one or more programs, wherein the one or more programs include instructions, which, when executed by an electronic device including multiple application programs, enable the electronic device to execute Figure 1 The method executed by the communication device between mini-programs in the illustrated embodiment is specifically used to execute:
[0146] Starting a preset communication service application on the vehicle-mounted device and broadcasting the service information of the vehicle-mounted device in the local area network, so that the applets of multiple user-end devices in the local area network can obtain the service information of the vehicle-mounted device;
[0147] Receiving communication connection requests initiated by applets on multiple user-end devices;
[0148] Establishing communication connections between the vehicle-mounted device and the applets of multiple user-end devices respectively according to the communication connection request;
[0149] Data transmission between mini-programs is performed based on the communication connection between the vehicle-mounted device and the mini-programs of multiple user-end devices.
[0150] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0151] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0152] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0153] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0154] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0155] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0156] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0157] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0158] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0159] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. A communication method between mini-programs, wherein: The communication method between the mini-programs is executed by the vehicle-mounted device, and the communication method between the mini-programs includes: Starting a preset communication service application on the vehicle-mounted device and broadcasting the service information of the vehicle-mounted device in the local area network, so that the applets of multiple user-end devices in the local area network can obtain the service information of the vehicle-mounted device; Receiving communication connection requests initiated by applets on multiple user-end devices; Establishing communication connections between the vehicle-mounted device and the applets of multiple user-end devices respectively according to the communication connection request; Data transmission between mini-programs is performed based on the communication connection between the vehicle-mounted device and the mini-programs of multiple user-end devices.
2. The method for communication between mini-programs as claimed in claim 1, wherein: The preset communication service application provides an mDNS service, and the service information of the vehicle-mounted device broadcasted in the local area network includes: Broadcasting the service information of the vehicle-mounted device in the local area network based on the mDNS service; The preset communication service application also provides a Socket communication service, and the communication connection between the vehicle-mounted device and the applets of multiple user-end devices respectively established according to the communication connection request includes: Based on the Socket communication service and the communication connection request, Socket communication connections are established between the vehicle-mounted device and the applets of multiple user-end devices.
3. The communication method between mini-programs as claimed in claim 1, wherein: The communication method between the mini-programs also includes: After establishing a communication connection between the vehicle-mounted device and the applet of the user terminal device, the user terminal device information corresponding to the applet connected to the vehicle-mounted device is stored in a preset record table, wherein the user terminal device information includes the IP address of the user terminal device and the user terminal identity; When the communication connection between the vehicle-mounted device and the applet of the user-end device changes, the preset record table is updated according to the type of change, and the type of change includes at least one of disconnection and new connection.
4. The method for communication between mini-programs as claimed in claim 1, wherein: The data transmission between mini-programs based on the communication connection between the vehicle-mounted device and the mini-programs of multiple user-end devices includes: Based on the communication connection between the in-vehicle device and the applet of the first user terminal device, receiving a data transmission request sent by the applet of the first user terminal device, wherein the data transmission request carries device information of the second user terminal device; Based on the communication connection between the vehicle-mounted device and the applet of the second user-end device and the device information of the second user-end device, the data transmission request of the applet of the first user-end device is forwarded to the applet of the second user-end device to realize data transmission between the applet of the first user-end device and the applet of the second user-end device.
5. A method for communication between mini-programs, wherein: The communication method between mini-programs is executed by a mini-program on a user terminal device, and the communication method between mini-programs includes: When the user terminal device is connected to the local area network where the vehicle-mounted device is located, obtaining service information of the vehicle-mounted device in the local area network; Sending a communication connection request to the vehicle-mounted device according to the service information of the vehicle-mounted device; Establishing a communication connection between the applet of the user terminal device and the vehicle-mounted device according to the communication connection request; Data is transmitted between the applets on the user-side device based on the communication connection between the applets on the user-side device and the vehicle-mounted device.
6. The method for communication between mini-programs as claimed in claim 5, wherein: The mini program is provided with a service discovery interface, and when the user terminal device is connected to the local area network where the vehicle-mounted device is located, obtaining the service information of the vehicle-mounted device in the local area network includes: Obtain service information of all devices in the local area network through the service discovery interface and mDNS protocol; Analyze the service information of all acquired devices; The service information of the vehicle-mounted device in the local area network is determined according to the analysis result.
7. The method for communication between mini-programs as claimed in claim 5, wherein: The service information of the vehicle-mounted device includes the IP address and the Socket port number of the vehicle-mounted device, the mini-program is provided with a Socket connection interface, and sending a communication connection request to the vehicle-mounted device according to the service information of the vehicle-mounted device includes: Sending a communication connection request to the vehicle-mounted device through the Socket connection interface according to the IP address of the vehicle-mounted device and the Socket port number; The connection status of the vehicle-mounted device is determined using a callback method.
8. A communication device between mini-programs, wherein: The communication device between mini-programs is applied to a vehicle-mounted device, and the communication device between mini-programs includes: A broadcast unit, used to start a preset communication service application on the vehicle-mounted device and broadcast the service information of the vehicle-mounted device in the local area network, so that the applets of multiple user-end devices in the local area network can obtain the service information of the vehicle-mounted device; A receiving unit, used to receive communication connection requests initiated by mini-programs on multiple user-end devices; A first establishing unit, configured to establish communication connections between the vehicle-mounted device and the mini-programs of multiple user-end devices respectively according to the communication connection request; The first transmission unit is used to transmit data between mini-programs based on the communication connection between the vehicle-mounted device and the mini-programs of multiple user-end devices.
9. A communication device between mini-programs, wherein: The communication device between mini-programs is applied to the mini-programs on the user terminal device, and the communication device between mini-programs includes: An acquisition unit, used to acquire service information of the vehicle-mounted device in the local area network when the user terminal device is connected to the local area network where the vehicle-mounted device is located; A sending unit, configured to send a communication connection request to the vehicle-mounted device according to the service information of the vehicle-mounted device; A second establishing unit, configured to establish a communication connection between the mini program of the user terminal device and the vehicle-mounted device according to the communication connection request; The second transmission unit is used to perform data transmission between the mini-programs of the user terminal device based on the communication connection between the mini-program of the user terminal device and the vehicle-mounted device.
10. A communication system between mini-programs, wherein: The communication system between mini-programs includes a vehicle-mounted device and a user-end device, a mini-program is running on the user-end device, the vehicle-mounted device is used to execute the communication method between mini-programs described in any one of claims 1 to 4, and the mini-program on the user-end device is used to execute the communication method between mini-programs described in any one of claims 5 to 7.
11. An electronic device, comprising: processor; as well as A memory arranged to store computer executable instructions, which, when executed, causes the processor to execute the communication method between applets described in any one of claims 1 to 4, or the communication method between applets described in any one of claims 5 to 7.
12. A computer-readable storage medium storing one or more programs, which, when executed by an electronic device comprising multiple application programs, enables the electronic device to execute the communication method between mini-programs described in any one of claims 1 to 4, or execute the communication method between mini-programs described in any one of claims 5 to 7.
