WO2023142993A1 - 一种探测方法、相关电子设备及系统 - Google Patents
一种探测方法、相关电子设备及系统 Download PDFInfo
- Publication number
- WO2023142993A1 WO2023142993A1 PCT/CN2023/071229 CN2023071229W WO2023142993A1 WO 2023142993 A1 WO2023142993 A1 WO 2023142993A1 CN 2023071229 W CN2023071229 W CN 2023071229W WO 2023142993 A1 WO2023142993 A1 WO 2023142993A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- state
- online
- message
- silent
- status
- Prior art date
Links
- 238000001514 detection method Methods 0.000 title claims abstract description 149
- 238000004891 communication Methods 0.000 claims abstract description 168
- 238000000034 method Methods 0.000 claims abstract description 66
- 230000015654 memory Effects 0.000 claims description 28
- 230000004044 response Effects 0.000 claims description 23
- 230000002159 abnormal effect Effects 0.000 claims description 5
- 230000008859 change Effects 0.000 abstract description 42
- 238000012545 processing Methods 0.000 abstract description 27
- 230000005540 biological transmission Effects 0.000 abstract description 21
- 230000007246 mechanism Effects 0.000 abstract description 21
- 238000012544 monitoring process Methods 0.000 abstract description 12
- 230000003993 interaction Effects 0.000 abstract description 10
- 230000007547 defect Effects 0.000 abstract description 4
- 230000000007 visual effect Effects 0.000 abstract description 3
- 230000001052 transient effect Effects 0.000 abstract 1
- 238000007726 management method Methods 0.000 description 42
- 230000006870 function Effects 0.000 description 35
- 230000008569 process Effects 0.000 description 26
- 238000010586 diagram Methods 0.000 description 22
- 230000001960 triggered effect Effects 0.000 description 20
- 230000007704 transition Effects 0.000 description 15
- 239000000523 sample Substances 0.000 description 11
- 238000010295 mobile communication Methods 0.000 description 10
- 238000004590 computer program Methods 0.000 description 8
- 230000005236 sound signal Effects 0.000 description 8
- 230000008901 benefit Effects 0.000 description 6
- 230000000694 effects Effects 0.000 description 5
- 238000005516 engineering process Methods 0.000 description 5
- 230000007774 longterm Effects 0.000 description 5
- 230000005012 migration Effects 0.000 description 5
- 238000013508 migration Methods 0.000 description 5
- 229920001621 AMOLED Polymers 0.000 description 4
- 230000001133 acceleration Effects 0.000 description 4
- 210000000988 bone and bone Anatomy 0.000 description 3
- 230000033001 locomotion Effects 0.000 description 3
- 230000006855 networking Effects 0.000 description 3
- 230000003287 optical effect Effects 0.000 description 3
- 230000002093 peripheral effect Effects 0.000 description 3
- XLYOFNOQVPJJNP-UHFFFAOYSA-N water Substances O XLYOFNOQVPJJNP-UHFFFAOYSA-N 0.000 description 3
- 238000013473 artificial intelligence Methods 0.000 description 2
- 238000013528 artificial neural network Methods 0.000 description 2
- 230000003190 augmentative effect Effects 0.000 description 2
- 238000013500 data storage Methods 0.000 description 2
- 230000002452 interceptive effect Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 239000002096 quantum dot Substances 0.000 description 2
- 230000009467 reduction Effects 0.000 description 2
- 230000001105 regulatory effect Effects 0.000 description 2
- 238000009877 rendering Methods 0.000 description 2
- 239000004065 semiconductor Substances 0.000 description 2
- 230000011664 signaling Effects 0.000 description 2
- 238000012546 transfer Methods 0.000 description 2
- 239000002699 waste material Substances 0.000 description 2
- 230000009471 action Effects 0.000 description 1
- 238000004458 analytical method Methods 0.000 description 1
- 230000003416 augmentation Effects 0.000 description 1
- 238000004422 calculation algorithm Methods 0.000 description 1
- 238000004364 calculation method Methods 0.000 description 1
- 230000001413 cellular effect Effects 0.000 description 1
- 238000006243 chemical reaction Methods 0.000 description 1
- 239000003086 colorant Substances 0.000 description 1
- 230000000295 complement effect Effects 0.000 description 1
- 238000012790 confirmation Methods 0.000 description 1
- 230000001419 dependent effect Effects 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000001914 filtration Methods 0.000 description 1
- 230000004927 fusion Effects 0.000 description 1
- 230000005484 gravity Effects 0.000 description 1
- 230000003862 health status Effects 0.000 description 1
- 230000010354 integration Effects 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 230000014759 maintenance of location Effects 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
- 230000005855 radiation Effects 0.000 description 1
- 238000011084 recovery Methods 0.000 description 1
- 238000004904 shortening Methods 0.000 description 1
- 239000007787 solid Substances 0.000 description 1
- 230000009182 swimming Effects 0.000 description 1
- 238000012795 verification Methods 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/50—Network services
- H04L67/54—Presence management, e.g. monitoring or registration for receipt of user log-on information, or the connection status of the users
Definitions
- the present application relates to the technical field of communications, and in particular to a detection method, related electronic equipment and a system.
- users have more and more smart terminal devices.
- users can manage all distributed devices in the system through the software platform, such as viewing the status of each device, regulating the hardware resources and capabilities of each device, and distributing and synchronizing business data in the system wait.
- the keep alive between any two or more devices that make up the connection in the system can maintain the connection status through the long connection mechanism or the heartbeat mechanism. Maintaining the long connection mechanism or the heartbeat mechanism will always occupy resources and waste power. It will inevitably cause the terminal equipment to continue to consume traffic and/or power, and shorten the standby time of the terminal equipment, which has obvious defects.
- the present application provides a detection method, related electronic equipment and system.
- the detection method drives the migration of the online state machine of the equipment by monitoring the business message sending and receiving events and sending and receiving results between the equipment, so that the equipment status change can be quickly sensed.
- the method adds an active detection mechanism, and establishes a new device state—silent state, and a silent detection interface, which supports the application to determine UI presentation and business processing strategies for various states of the device.
- the device is in the online state. When the passive detection times out, the online state will change to the silent state. In the silent state, the local device can actively broadcast detection packets as needed to confirm whether the peer device is online.
- the embodiment of the present application provides a detection method, the method includes: establishing a connection between the first device and the second device, wherein the status of the second device recorded by the first device includes online status, offline status, silent status, the online status indicates that the communication between the first device and the second device is normal, the offline status indicates that the communication between the first device and the second device is abnormal, and the silent status indicates that the communication between the first device and the second device Whether it is normal or not is in an uncertain state, and it needs to be detected again to confirm that the second device is in the online state or offline state.
- the first device refreshes the status of the second device as an online status, and starts a timer to start timing. The time interval for the first device to confirm that it has not received the message from the second device exceeds the first time limit.
- the first device changes the state of the second device from the online state to the silent state.
- Implementing the method in the first aspect can solve the problem that the device status cannot be updated in time and is prone to error reporting, effectively reducing the device offline delay, resource power consumption, and transmission bandwidth occupation, and avoiding frequent online and offline events caused by short-term offline It provides users with a more intuitive and easy-to-understand application interface, improves user experience, and further improves communication efficiency.
- the first device is provided with a device status bit
- the device status bit indicates the number of interrupts of the timer
- the device status bit includes reset and set.
- the first device when the first device updates the status of the second device to the online status, the first device changes the device status bit to reset.
- the first device detects the timer overflow interrupt, the first device reads the device status bit. If it is read that the device status bit is reset, the first device changes the device status bit from reset to set. If it is read that the device status bit is set, then the first device confirms that the trigger condition for changing the silent state is met.
- the first device detects the timer overflow interrupt for the first time, and the first device reads that the device status bit is reset.
- the first device changes the device status bit from reset to set, and restarts the timer to start timing.
- the first device detects the timer overflow interrupt for the second time, the first device reads that the device status bit is set, and the first device confirms that the trigger condition for changing the silent state is satisfied.
- the first time required for the timer overflow interrupt for the first time is different from the second time required for the timer overflow interrupt for the second time.
- the second time is longer than the first time.
- Developers can also set the trigger interrupt time according to different types of peer devices or different time periods or other factors. For example, in the time period when users use it frequently, set the time limit of the timer to be shorter. Period, such as night, the time limit of the timer is set longer.
- the first device when the state of the second device is in the silent state, the first device sends the first detection packet to the second device. If the first device receives the second device's response message to the first detection message, the first device changes the state of the second device from the silent state to the online state. If the first device does not receive the second device's response message to the first detection message, the first device changes the state of the second device from the silent state to the offline state.
- the foregoing first detection message may be a broadcast message.
- the advantage of sending broadcast probe messages is that the number of broadcast messages sent per unit time is large, the messages are not easy to be lost, and the sending success rate is higher.
- an icon identifier of the second device is displayed on an application interface of the first device. If the second device is in the online state, the icon logo of the second device is displayed on the application interface with light on. If the second device is in a silent state, the icon identification of the second device is grayed out and displayed in the application interface. If the second device is offline, the icon identification of the second device is not displayed in the application interface. In this way, it is convenient for the user to quickly perceive the status of the second device through the interface.
- the first device detects a user operation of clicking the grayed-out icon identification of the second device. In response to the user operation, the first device sends a first detection packet to the second device.
- the first device detects that the above-mentioned application is called to run in the foreground, and the first device sends a first detection message to the second device. In this way, active detection can be triggered more quickly, and whether the second device is online can be detected early when it is predicted that the user needs to operate.
- the first device is provided with a silence detection interface
- the first device detects that the above-mentioned application calls the silence detection interface
- the event that triggers the application to call the silence detection interface includes that the first device detects a click to set the The user operation identified by the icon of the second device displayed in gray, or the first device detects that the application is transferred to the foreground to run. Then the first device sends a first detection packet to the second device through the silent detection interface.
- the timer is terminated if the first device confirms that the state of the second device is in a silent state or an offline state.
- the first device when the status of the second device is offline, if the first device successfully sends a message to the second device, the first device will change the status of the second device from offline to Status changed to Online.
- the first device when the status of the second device is online, if the first device fails to send a message to the second device, the first device changes the status of the second device from the online status is offline.
- the embodiment of the present application provides an electronic device, and the electronic device may include: a communication device, a display device, a memory, a processor coupled to the memory, multiple application programs, and one or more programs.
- the communication device is used for communication
- the display device is used for displaying an interface
- computer-executable instructions are stored in the memory.
- the processor executes the instructions, the electronic device can realize any function of the first device in the first aspect.
- an embodiment of the present application provides a communication system, where the communication system includes a first device and a second device, where the first device implements any possible implementation manner in the first aspect.
- an embodiment of the present application provides a computer storage medium, in which a computer program is stored, and the computer program includes executable instructions, and when executed by a processor, the executable instruction causes the processor to perform the following steps:
- the methods correspond to the operations provided.
- an embodiment of the present application provides a computer program product, which, when the computer program product runs on an electronic device, causes the electronic device to execute any possible implementation manner in the first aspect.
- the embodiment of the present application provides a chip system, which can be applied to electronic devices, and the chip includes one or more processors, and the processors are used to invoke computer instructions so that the electronic device implements the electronic device as described in the first aspect. any possible implementation.
- the implementation of the above aspects provided by this application can solve the problem that the device status cannot be updated in time and is prone to error reporting, effectively reducing the device offline delay, resource power consumption, and transmission bandwidth occupation, and avoiding frequent online and offline events caused by short-term offline It provides users with a more intuitive and easy-to-understand application interface, improves user experience, and further improves communication efficiency.
- FIG. 1 is a schematic diagram of a communication system provided by an embodiment of the present application.
- FIG. 2A is a schematic diagram of a hardware structure of an electronic device provided in an embodiment of the present application.
- FIG. 2B is a schematic diagram of the software architecture of the electronic device provided by the embodiment of the present application.
- FIG. 3 is a schematic diagram of state transition provided by the embodiment of the present application.
- FIG. 4 is a schematic diagram of state transition provided by the embodiment of the present application.
- FIG. 5 is a schematic diagram of a user interface provided by an embodiment of the present application.
- FIG. 6A is a schematic diagram of the interactive interface provided by the embodiment of the present application.
- FIG. 6B is a schematic diagram of the interactive interface provided by the embodiment of the present application.
- FIG. 7 is a schematic diagram of the information flow process provided by the embodiment of the present application.
- FIG. 8 is a schematic diagram of the information flow process provided by the embodiment of the present application.
- FIG. 9 is a schematic diagram of the information flow process provided by the embodiment of the present application.
- FIG. 10 is a schematic diagram of the information flow process provided by the embodiment of the present application.
- FIG. 11 is a flow chart of a detection method provided by an embodiment of the present application.
- FIG. 12 is a schematic diagram of functional modules of an electronic device provided by an embodiment of the present application.
- first and second are used for descriptive purposes only, and cannot be understood as implying or implying relative importance or implicitly specifying the quantity of indicated technical features. Therefore, the features defined as “first” and “second” may explicitly or implicitly include one or more of these features.
- plurality refers to two or more than two.
- UI user interface
- application application, APP
- operating system operating system
- user interface is a medium interface for interaction and information exchange between an application program (application, APP) or an operating system (operating system, OS) and a user. Realize the conversion between the internal form of information and the form acceptable to users.
- the user interface is the source code written in a specific computer language such as java and extensible markup language (XML).
- the source code of the interface is parsed and rendered on the electronic device, and finally presented as content that can be recognized by the user.
- the commonly used form of user interface is the graphical user interface (graphic user interface, GUI), which refers to the user interface related to computer operation displayed in a graphical way. It may be text, icons, buttons, menus, tabs, text boxes, dialog boxes, status bars, navigation bars, Widgets, and other visible interface elements displayed on the display screen of the electronic device.
- GUI graphical user interface
- the "message" or “information” mentioned in the following embodiments of this application may refer to a specific message or information, or may include multiple different messages or information, which is a collection of some messages or information. limit.
- a message or information may be a session message of a certain application program, or a collection of a session message of an application program and an instruction information, or a combination of a session message of an application program, an instruction information, and a terminal device identifier.
- a collection, the specific interpretation can be inferred according to the context.
- users can manage all distributed devices in the system through the software platform, such as viewing the status of each device, regulating the hardware resources and capabilities of each device, and distributing and synchronizing business data in the system wait.
- connection state can be maintained through a long connection mechanism, such as classic Bluetooth through an asynchronous connectionless (ACL) long connection to keep alive.
- the long-term connection mechanism means that the terminal devices of both parties will not disconnect after establishing a connection, and then transmit messages through the connection until one party actively terminates the connection.
- This long-term connection mechanism can ensure that messages are transmitted to the peer device in a timely manner, but its disadvantages are also obvious. Maintaining this long-term connection will always occupy resources and waste power consumption, which will inevitably cause the terminal device to continue to consume traffic and/or power. the standby time of the terminal equipment.
- traffic may refer to network data traffic, including network traffic generated when a terminal device sends data through a wireless network or a mobile network.
- the heartbeat mechanism can also be used to keep alive.
- the heartbeat mechanism refers to that a device sends a keep alive message to the peer device (or server) at regular intervals, such as sending heartbeat messages periodically to detect whether the peer device is alive, thereby Keep the connection between the two devices valid for a long time, so as to ensure that the data sent by one device to the opposite device can arrive accurately and in time.
- the online status of the terminal device can be maintained by sending heartbeat messages. The online status indicates that the terminal device is authenticated, and no re-authentication is required for sending and receiving messages. Once the time from the sending of the last heartbeat message exceeds the specified time interval, the terminal device will be offline, and when reconnecting, the terminal device needs to be authenticated again.
- a wireless fidelity (Wi-Fi) connection could unicast a transmission control protocol (TCP) connection every ten minutes to keep alive, or a bluetooth low energy , BLE) can broadcast a message every five minutes, and wait for the remote device to reply to keep alive.
- TCP transmission control protocol
- BLE bluetooth low energy
- the heartbeat mechanism also has the following disadvantages: First, the offline status of the peer device cannot be confirmed in time between two heartbeat detections. The device is offline. During this period, the user cannot find that the device has been offline from the interface. When issuing an operation command for the device, an error will be reported, and the user experience is poor. Second, if an application process with a high network load is running and the bandwidth is occupied by the application process, the peer online device may be falsely reported offline, resulting in abnormal service interruption and poor user experience.
- the third is that the local device will continuously send heartbeat messages to the peer device, or passively receive the heartbeat information sent by the peer device, and as the number of connected peer devices increases, the heartbeat messages that the local device needs to send or receive The number of packets also doubles, consuming more traffic.
- the terminal device when the terminal device sends data, it needs to start the radio frequency module, and every time the device sends or receives a heartbeat message, it needs to start the radio frequency module in the terminal, which will wake up the device in the dormant state, and will make the The radio frequency module will be turned on frequently, consuming more power, resulting in increased power consumption of the terminal equipment and shortening the standby time of the terminal equipment.
- the peer device may need to perform the authentication login process again, which increases the communication time of the device. Complicated, reducing communication efficiency, thereby affecting user experience.
- the present application provides a detection method, which is used to detect the state of the device, and solves the above-mentioned problems that the state of the device cannot be changed in time, high power consumption of the device, and cumbersome communication.
- This method cancels the heartbeat mechanism commonly used in communication, completely solves the problems of high power consumption and occupied transmission bandwidth, and further optimizes communication efficiency.
- By monitoring the business packet sending and receiving events and sending and receiving results of passive or active detection between devices it drives the online state machine migration of the device, and the status change of the device can be quickly sensed.
- an active detection mechanism is added, and a new device state—silent state, and a silent detection interface are established to support the application to determine the UI presentation and business processing strategies of various states of the device.
- the device is in the online state.
- the online state will change to the silent state.
- the local device can actively broadcast detection messages as needed to confirm whether the peer device is online, which solves the problems of easy error reporting and poor user experience in the device status, effectively reduces the offline delay and power consumption of the device, and avoids Due to the defect of frequent online and offline due to short-term disconnection, the communication efficiency is further improved.
- the process of describing an object from one state to another through an event-driven transition is called a state transition, and all the state transition processes possessed by an object are called a state machine.
- the implementation of the method provided by this application can solve the problems of high power consumption, occupied transmission bandwidth, frequent online and offline, etc. caused by the heartbeat message keep-alive mechanism between devices in the system.
- a new state of the device that is, the silent state
- it supports the application Determine the UI presentation and business processing strategies of various states, solve the problem that the device state cannot be updated in time, further optimize the communication efficiency, enhance the human-computer interaction performance, and provide users with a more intuitive, understandable, and convenient application interface
- the user can perceive the change of the device state in real time, which improves the user experience.
- the communication system 10 provided by the embodiment of the present application is introduced below.
- FIG. 1 shows a communication system 10 provided by an embodiment of the present application.
- the communication system 10 includes a plurality of terminal devices, and these terminal devices may include mobile phones as shown in the figure, tablet computers (portable android device, PAD), notebook computers, smart TVs (also called smart screens, large screens, etc.), desktop computers , routers, smart watches, smart bracelets, earphones, smart speakers, etc., in addition to the above-mentioned devices shown in Figure 1, the communication system 10 may also include other types of electronic devices, such as a personal computer (personal computer, PC) , desktop computer, laptop computer, handheld computer, augmented reality (augmented reality, AR) equipment, virtual reality (virtual reality, VR) equipment, artificial intelligence (artificial intelligence, AI) equipment, car machine (vehicle equipment), Game consoles, cloud hosts/cloud servers, other smart wearable devices, etc., may also include Internet of Things (IOT) devices or smart home devices such as smart water heaters, smart lamps, smart air conditioners, smart weight scales, etc., this application There are no restrictions on device types.
- a terminal device may also be augmented
- the networking logic model of the communication system 10 may be that each rich device is connected to a network with a router as a node, and multiple thin devices join the network by connecting with a mobile phone, and the mobile phone and multiple Rich device point-to-point connection.
- a rich device can refer to a terminal device with a strong processor processing capability and rich functions, such as a mobile phone, a notebook computer, a tablet computer, a smart TV, a desktop computer, etc.
- a thin device can refer to a terminal device with a weak processor processing capability Relatively few terminal devices, such as smart watches, earphones, smart bracelets, smart speakers, etc. Thin devices can cooperate with rich devices to provide users with richer functions.
- the mobile phone acts as a central device/core device, and can establish communication connections with other collaborative devices/associated devices to form a "super terminal".
- Super terminal refers to the ability to integrate the capabilities of multiple terminals through distributed technology, store them in a virtual hardware resource pool, and provide external services based on the unified management, scheduling, and integration capabilities of each terminal according to business needs. Fast connection, capability mutual assistance, and resource sharing are realized between different terminals.
- a mobile phone and a notebook computer form a hyperterminal, which can realize the function of projecting the screen of the mobile phone interface to the notebook computer;
- hyperterminal can be used to collectively refer to the communication system 10 composed of the mobile phone as the core device and the associated devices having the above-mentioned association relationship with the mobile phone. That is, “hyperterminal” is used to describe a collection of electronic devices having the above-mentioned association relationship.
- the "super terminal” is only an exemplary vocabulary, and it can also be replaced by other words, such as “smart collaboration system", “multi-device collaboration system”, etc., which does not constitute a reference to the communication system in the embodiment of this application. 10 specific limits.
- the communication connection between each terminal device in the communication system 10 may be a wired connection or a wireless connection, which is not limited in this embodiment. Data or instructions can be transmitted between terminals through the established communication connection.
- the communication link may be a short-range communication link.
- a wired connection such as a universal serial bus (uniersalserialbus, USB) connection, a high definition multimedia interface (high definition multimedia interface, HDMI) connection, a display port (display port, DP) connection, and the like.
- wireless connection such as Bluetooth (bluetooth, BT) connection, wireless fidelity (wi-fidelity, Wi-Fi) connection, hotspot connection, near field communication (near field communication, NFC), ZigBee, etc., to realize the connection between each terminal Communicate without an account or with a different account.
- the wireless connection is not bound by wires, and the user has a higher degree of freedom of movement.
- the embodiment of the present application does not limit the type of the communication connection.
- a Bluetooth (bluetooth, BT) module and/or a wireless local area network (wireless local area networks, WLAN) module may be configured in the terminal device.
- the Bluetooth module can provide one or more Bluetooth communication solutions including classic Bluetooth (Bluetooth 2.1) or Bluetooth low energy (Bluetooth low energy, BLE), and the WLAN module can provide wireless fidelity point-to-point connections (wireless fidelity peer-to-peer, Wi-Fi P2P), wireless fidelity local area networks (wireless fidelity local area networks, Wi-Fi LAN) or wireless fidelity software access point (wireless fidelity software access point, Wi-Fi softAP)
- Wi-Fi P2P wireless fidelity point-to-peer
- Wi-Fi P2P wireless fidelity local area networks
- Wi-Fi LAN wireless fidelity local area networks
- Wi-Fi softAP wireless fidelity software access point
- Wi-Fi P2P refers to allowing devices in a wireless network to connect to each other in a point-to-point manner without going through a wireless router. In the system, it may also be called wireless fidelity direct (Wi-Fi direct). Devices that establish a Wi-Fi P2P connection can exchange data directly through Wi-Fi (must be in the same frequency band) without connecting to a network or hotspot, and realize point-to-point communication, such as transferring files, pictures, videos and other data. Compared with Bluetooth, Wi-Fi P2P has the advantages of faster search speed and transmission speed, and longer transmission distance.
- the communication link can also be a long-distance communication link.
- each terminal logs in the same account to realize connection and communication through the Internet.
- Multiple electronic devices in the communication system 10 may also log in to different accounts, but are connected through binding.
- a mobile phone and a smart watch can log in to different accounts, and the mobile phone binds the smart watch to itself in the device management application, and then connects through the device management application.
- the communication connection between a mobile phone and a laptop can be a combination of multiple connections.
- a mobile phone or a laptop can establish a connection with a router through Wi-Fi to access the network, or establish a connection with a base station Access to the network, mobile phones and laptops can communicate through the network.
- the mobile phone sends the information to the cloud server through the network, and the cloud server sends the information to the laptop through the network.
- two terminal devices when two terminal devices are mutually trusted devices, for example, the two terminal devices have been matched or connected before, and when they are to be connected again, the two terminal devices will automatically establish a communication connection, and then For data interaction, the user does not need to manually connect or match again, saving time and effort.
- an electronic device that has been paired with Bluetooth, an electronic device that has been connected to a shared hotspot, or has established a Wi-Fi P2P connection, etc. can be confirmed as having established a trusted relationship, which is not limited in this embodiment.
- Each terminal device in the communication system 10 can carry HarmonyOS or other types of operating systems, the operating systems of each terminal device in the communication system 10 may be the same or different, which is not limited in this application.
- each connected terminal in the communication system 10 is equipped with HarmonyOS, then the communication system 10 may be called a HarmonyOS super virtual device (super virtual device), or a HarmonyOS super terminal.
- a mobile phone or other terminal equipment is installed with a hyper terminal application, which is convenient for users to manage each terminal equipment.
- a smart watch can detect the user's exercise data, such as the number of walking steps, running time, swimming time, etc., and synchronize the user's exercise data to the mobile phone.
- the mobile phone can also synchronize the detected user data to the smart watch.
- Multiple terminals can be used together to achieve more accurate detection of the user's motion data.
- the central device in the communication system 10 can record the connection status of the coordination device and display it in the user interface, so that the user can quickly check whether the current coordination device is online. If the coordination device is online, it means that the central device and the coordination device can communicate normally and send and receive messages. If the collaborative device is offline, it means that the current collaborative device and the central device have been disconnected and cannot communicate normally. If the collaborative device is in the silent state, it means that the current connection status between the collaborative device and the central device is uncertain, and the user can actively initiate a detection operation, such as clicking the grayed cooperative device icon, and the central device will send a detection message to the cooperative device. If the detection is successful , that is, after receiving the response from the cooperative device, the status of the cooperative device will be changed from the silent state to the online state. line status.
- the communication system 10 shown in FIG. 1 is only used to assist in describing the technical solutions provided by the embodiments of the present application, and does not limit other embodiments of the present application.
- more or fewer terminal devices may be included in the communication system 10, and the networking logic model may also be in other star, ring, point-to-point or any combination forms.
- This application applies to the terminal devices in the communication system 10 There are no restrictions on the type, number of terminal devices, networking logic model, connection mode between terminal devices, etc.
- the exemplary electronic device 100 provided by the embodiment of the present application is introduced below.
- FIG. 2A is a schematic diagram of a hardware structure of an electronic device 100 provided by an embodiment of the present application.
- the exemplary electronic device 100 provided in the embodiment of the present application may be, but not limited to, a mobile phone, a notebook computer, a tablet computer, a smart bracelet, a smart watch, a headset, a personal computer (personal computer, PC), a smart TV, a smart speaker, etc.
- It can be desktop computers, laptop computers, handheld computers, AR devices, VR devices, AI devices, car machines (vehicle devices), game consoles, cloud hosts/cloud servers, other smart wearable devices, etc., or the Internet of Things (Internet of things, IOT) equipment or smart home equipment such as smart water heaters, smart lamps, smart air conditioners, smart weight scales and other types of electronic equipment, this application does not impose any restrictions on the type of equipment.
- IOT Internet of things, IOT
- smart home equipment such as smart water heaters, smart lamps, smart air conditioners, smart weight scales and other types of electronic equipment
- the structure shown in this embodiment does not constitute a specific limitation on the electronic device 100 .
- the electronic device 100 may include more or fewer components than those shown in the illustration, some hardware structures may be added or reduced, some components may be combined, some components may be split, or different components layout.
- the illustrated components can be realized in hardware, software or a combination of software and hardware.
- electronic equipment 100 can comprise processor 110, external memory interface 120, internal memory 121, universal serial bus (universal serial bus, USB) interface 130, charging management module 140, power management module 141, battery 142, antenna 1.
- Antenna 2 mobile communication module 150, wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C, earphone jack 170D, sensor module 180, button 190, motor 191, indicator 192, camera 193, display screen 194, and a subscriber identification module (subscriber identification module, SIM) card interface 195, etc.
- SIM subscriber identification module
- the sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, bone conduction sensor 180M, etc.
- the processor 110 is generally used to control the overall operation of the electronic device 100 and may include one or more processing units.
- the processor 110 may include a central processing unit (central processing unit, CPU), an application processor (application processor, AP), a modem processor, a graphics processing unit (graphics processing unit, GPU), an image signal processor ( image signal processor (ISP), video processing unit (video processing unit, VPU), controller, memory, video codec, digital signal processor (digital signal processor, DSP), baseband processor, and/or neural network processing device (neural-network processing unit, NPU), etc.
- different processing units may be independent devices, or may be integrated in one or more processors.
- the controller can generate an operation control signal according to the instruction opcode and timing signal, and complete the control of fetching and executing the instruction.
- a memory may also be provided in the processor 110 for storing instructions and data.
- the memory in processor 110 is a cache memory.
- the memory may hold instructions or data that the processor 110 has just used or recycled. If the processor 110 needs to use the instruction or data again, it can be called directly from the memory. Repeated access is avoided, and the waiting time of the processor 110 is reduced, thereby improving the efficiency of the system.
- processor 110 may include one or more interfaces.
- the interface may include an integrated circuit (inter-integrated circuit, I2C) interface, an integrated circuit built-in audio (inter-integrated circuit sound, I2S) interface, a pulse code modulation (pulse code modulation, PCM) interface, a universal asynchronous transmitter (universal asynchronous receiver/transmitter, UART) interface, mobile industry processor interface (mobile industry processor interface, MIPI), general-purpose input and output (general-purpose input/output, GPIO) interface, subscriber identity module (subscriber identity module, SIM) interface, and /or universal serial bus (universal serial bus, USB) interface, serial peripheral interface (serial peripheral interface, SPI) interface, etc.
- I2C integrated circuit
- I2S integrated circuit built-in audio
- PCM pulse code modulation
- PCM pulse code modulation
- UART universal asynchronous transmitter
- MIPI mobile industry processor interface
- GPIO general-purpose input and output
- subscriber identity module subscriber identity module
- SIM
- the charging management module 140 is configured to receive a charging input from a charger.
- the charger may be a wireless charger or a wired charger.
- the charging management module 140 can receive the charging input of the wired charger through the USB interface 130.
- the charging management module 140 may receive wireless charging input through a wireless charging coil of the electronic device. While the charging management module 140 is charging the battery 142 , it can also supply power to the electronic device through the power management module 141 .
- the power management module 141 is used for connecting the battery 142 , the charging management module 140 and the processor 110 .
- the power management module 141 receives the input from the battery 142 and/or the charging management module 140 to provide power for the processor 110 , the internal memory 121 , the display screen 194 , the camera 193 , and the wireless communication module 160 .
- the power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle times, and battery health status (leakage, impedance).
- the wireless communication function of the electronic device 100 can be realized by the antenna 1 , the antenna 2 , the mobile communication module 150 , the wireless communication module 160 , a modem processor, a baseband processor, and the like.
- Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals.
- Each antenna in electronic device 100 may be used to cover single or multiple communication frequency bands. Different antennas can also be multiplexed to improve the utilization of the antennas.
- Antenna 1 can be multiplexed as a diversity antenna of a wireless local area network.
- the antenna may be used in conjunction with a tuning switch.
- the mobile communication module 150 can provide the second generation (2th generation, 2G) network/third generation (3th generation, 3G) network/fourth generation (4th generation, 4G) network/fifth generation network applied on the electronic device 100. (5th generation, 5G) network and other wireless communication solutions.
- the mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (low noise amplifier, LNA) and the like.
- the mobile communication module 150 can receive electromagnetic waves through the antenna 1, filter and amplify the received electromagnetic waves, and send them to the modem processor for demodulation.
- the mobile communication module 150 can also amplify the signals modulated by the modem processor, and convert them into electromagnetic waves and radiate them through the antenna 1 .
- At least part of the functional modules of the mobile communication module 150 may be set in the processor 110 . In some embodiments, at least part of the functional modules of the mobile communication module 150 and at least part of the modules of the processor 110 may be set in the same device.
- a modem processor may include a modulator and a demodulator.
- the wireless communication module 160 can provide wireless local area networks (wireless local area networks, WLAN) (such as wireless fidelity (Wireless Fidelity, Wi-Fi) network), bluetooth (bluetooth, BT), global navigation satellite, etc. applied on the electronic device 100.
- System global navigation satellite system, GNSS
- frequency modulation frequency modulation, FM
- near field communication technology near field communication, NFC
- infrared technology infrared, IR
- the wireless communication module 160 may be one or more devices integrating at least one communication processing module.
- the wireless communication module 160 receives electromagnetic waves via the antenna 2 , frequency-modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110 .
- the wireless communication module 160 can also receive the signal to be sent from the processor 110 , frequency-modulate it, amplify it, and convert it into electromagnetic waves through the antenna 2 for radiation.
- the antenna 1 of the electronic device 100 is coupled to the mobile communication module 150, and the antenna 2 is coupled to the wireless communication module 160, so that the electronic device 100 can communicate with the network and other devices through wireless communication technology.
- the wireless communication technology may include global system for mobile communications (GSM), general packet radio service (general packet radio service, GPRS), code division multiple access (code division multiple access, CDMA), broadband Code division multiple access (wideband code division multiple access, WCDMA), time division code division multiple access (time-division code division multiple access, TD-SCDMA), long term evolution (long term evolution, LTE), BT, GNSS, WLAN, NFC , FM, and/or IR techniques, etc.
- GSM global system for mobile communications
- GPRS general packet radio service
- code division multiple access code division multiple access
- CDMA broadband Code division multiple access
- WCDMA wideband code division multiple access
- time division code division multiple access time-division code division multiple access
- TD-SCDMA time-division code division multiple access
- the GNSS may include a global positioning system (global positioning system, GPS), a global navigation satellite system (global navigation satellite system, GLONASS), a Beidou navigation satellite system (beidou navigation satellite system, BDS), a quasi-zenith satellite system (quasi -zenith satellite system (QZSS) and/or satellite based augmentation systems (SBAS).
- GPS global positioning system
- GLONASS global navigation satellite system
- Beidou navigation satellite system beidou navigation satellite system
- BDS Beidou navigation satellite system
- QZSS quasi-zenith satellite system
- SBAS satellite based augmentation systems
- the electronic device 100 may implement a display function through a GPU, a display screen 194, an application processor, and the like.
- the GPU is a microprocessor for image processing, and is connected to the display screen 194 and the application processor. GPUs are used to perform mathematical and geometric calculations for graphics rendering.
- Processor 110 may include one or more GPUs that execute program instructions to generate or change display information.
- the display screen 194 is used to display images, videos and the like.
- the display screen 194 includes a display panel.
- the display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active matrix organic light emitting diode or an active matrix organic light emitting diode (active-matrix organic light emitting diode, AMOLED), flexible light-emitting diode (flex light-emitting diode, FLED), Miniled, MicroLed, Micro-oLed, quantum dot light emitting diodes (quantum dot light emitting diodes, QLED), etc.
- the electronic device 100 may include 1 or N display screens 194 , where N is a positive integer greater than 1.
- the electronic device 100 can realize the shooting function through the ISP, the camera 193 , the video codec, the GPU, the display screen 194 and the application processor.
- the ISP is used for processing the data fed back by the camera 193 .
- the light is transmitted to the photosensitive element of the camera through the lens, and the light signal is converted into an electrical signal, and the photosensitive element of the camera transmits the electrical signal to the ISP for processing, and converts it into an image visible to the naked eye.
- ISP can also optimize the algorithm for image noise and brightness.
- ISP can also optimize the exposure, color temperature and other parameters of the shooting scene.
- the ISP may be located in the camera 193 .
- Camera 193 is used to capture still images or video.
- the object generates an optical image through the lens and projects it to the photosensitive element.
- the photosensitive element may be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor.
- CMOS complementary metal-oxide-semiconductor
- the photosensitive element converts the light signal into an electrical signal, and then transmits the electrical signal to the ISP to convert it into a digital image signal.
- the ISP outputs the digital image signal to the DSP for processing.
- DSP converts digital image signals into standard RGB, YUV and other image signals.
- the electronic device 100 may include 1 or N cameras 193 , where N is a positive integer greater than 1.
- the camera 193 may include, but not limited to, a traditional color camera (RGB camera), a depth camera (RGB depth camera), a dynamic vision sensor (dynamic vision sensor, DVS) camera, and the like.
- camera 193 may be a depth camera.
- the depth camera can collect the spatial information of the real environment.
- the internal memory 121 may be used to store computer-executable program codes including instructions.
- the processor 110 executes various functional applications and data processing of the electronic device by executing instructions stored in the internal memory 121 .
- the internal memory 121 may include an area for storing programs and an area for storing data. Wherein, the stored program area can store an operating system, at least one application program required by a function (such as a sound playing function, an image playing function, etc.) and the like.
- the storage data area can store data (such as audio data, phone book, etc.) created during the use of the electronic device.
- the internal memory 121 may include one or more random access memories (random access memory, RAM) and one or more non-volatile memories (non-volatile memory, NVM).
- the external memory interface 120 can be used to connect an external non-volatile memory, so as to expand the storage capacity of the electronic device.
- the external non-volatile memory communicates with the processor 110 through the external memory interface 120 to implement a data storage function. For example, files such as music and video are stored in an external non-volatile memory.
- the electronic device 100 can implement audio functions through the audio module 170 , the speaker 170A, the receiver 170B, the microphone 170C, the earphone interface 170D, and the application processor. Such as music playback, recording, etc.
- the audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signal.
- the audio module 170 may also be used to encode and decode audio signals.
- Speaker 170A also referred to as a "horn" is used to convert audio electrical signals into sound signals.
- the electronic device can listen to music through speaker 170A, or listen to hands-free calls.
- Receiver 170B also called “earpiece” is used to convert audio electrical signals into sound signals.
- the electronic device receives a call or a voice message, it can listen to the voice by placing the receiver 170B close to the human ear.
- the microphone 170C also called “microphone” or “microphone” is used to convert sound signals into electrical signals.
- the electronic device can be provided with two microphones 170C, which can also implement a noise reduction function in addition to collecting sound signals.
- the electronic device can also be equipped with three, four or more microphones 170C to realize the collection of sound signals, noise reduction, identification of sound sources, and realization of directional recording functions, etc.
- the earphone interface 170D is used for connecting wired earphones.
- the earphone interface 170D can be a USB interface 130, or a 3.5mm open mobile terminal platform (OMTP) standard interface, or a cellular telecommunications industry association of the USA (CTIA) standard interface.
- OMTP open mobile terminal platform
- CTIA cellular telecommunications industry association of the USA
- the electronic device 100 may include one or more keys 190 , and these keys 190 may control the electronic device 100 and provide a user with access to functions on the electronic device 100 .
- the key 190 may be in the form of a mechanical case such as a button, a switch, or a dial, or may be a touch or near-touch sensing device (such as a touch sensor).
- the electronic device 100 may receive key input and generate key signal input related to user settings and function control of the electronic device 100 .
- the keys 190 may include a power key, a volume key and the like.
- the motor 191 can generate a vibrating reminder.
- the motor 191 can be used for incoming call vibration prompts, and can also be used for touch vibration feedback.
- touch operations applied to different applications may correspond to different vibration feedback effects.
- the motor 191 may also correspond to different vibration feedback effects for touch operations acting on different areas of the electronic device 100 .
- the touch vibration feedback effect can also support customization.
- the indicator 192 can be an indicator light, which can be used to indicate the charging status, the change of the battery capacity, and can also be used to indicate messages, notifications and the like.
- the electronic device 100 may also include other input and output interfaces, and other devices may be connected to the electronic device 100 through a suitable input and output interface.
- Components may include, for example, audio/video jacks, data connectors, and the like.
- the electronic device 100 is equipped with one or more sensors, including but not limited to a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity sensor 180G, a fingerprint sensor 180H, Temperature sensor 180J, touch sensor 180K, ambient light sensor 180L, bone conduction sensor 180M, etc.
- sensors including but not limited to a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity sensor 180G, a fingerprint sensor 180H, Temperature sensor 180J, touch sensor 180K, ambient light sensor 180L, bone conduction sensor 180M, etc.
- the pressure sensor 180A is used to sense the pressure signal and convert the pressure signal into an electrical signal.
- the gyro sensor 180B can be used to determine the motion posture of the electronic device 100 .
- the air pressure sensor 180C is used to measure air pressure.
- the magnetic sensor 180D includes a Hall sensor.
- the acceleration sensor 180E can detect the acceleration of the electronic device 100 in various directions (generally three axes). The magnitude and direction of gravity can be detected when the electronic device 100 is stationary. It can also be used to identify the posture of electronic devices, and can be used in applications such as horizontal and vertical screen switching, pedometers, etc.
- the distance sensor 180F is used to measure the distance.
- Proximity light sensor 180G may include, for example, light emitting diodes (LEDs) and light detectors, such as photodiodes.
- Electronic device 100 uses photodiodes to detect infrared reflected light from nearby objects. When sufficient reflected light is detected, it may be determined that there is an object near the electronic device 100 .
- the ambient light sensor 180L is used for sensing ambient light brightness.
- the fingerprint sensor 180H is used to collect fingerprints.
- the temperature sensor 180J is used to detect temperature.
- the bone conduction sensor 180M can acquire vibration signals.
- the touch sensor 180K is also called “touch device”.
- the touch sensor 180K can be disposed on the display screen 194, and the touch sensor 180K and the display screen 194 form a touch screen, also called a “touch screen”.
- the touch sensor 180K is used to detect a touch operation on or near it.
- the touch sensor can pass the detected touch operation to the application processor to determine the type of touch event.
- Visual output related to the touch operation can be provided through the display screen 194 .
- the touch sensor 180K may also be disposed on the surface of the electronic device 100 , which is different from the position of the display screen 194 .
- the SIM card interface 195 is used for connecting a SIM card.
- the SIM card can be connected and separated from the electronic device 100 by inserting it into the SIM card interface 195 or pulling it out from the SIM card interface 195 .
- the electronic device 100 may support 1 or N SIM card interfaces, where N is a positive integer greater than 1.
- SIM card interface 195 can support Nano SIM card, Micro SIM card, SIM card etc. Multiple cards can be inserted into the same SIM card interface 195 at the same time. The types of the multiple cards may be the same or different.
- the SIM card interface 195 is also compatible with different types of SIM cards.
- the SIM card interface 195 is also compatible with external memory cards.
- the electronic device 100 interacts with the network through the SIM card to implement functions such as calling and data communication.
- the electronic device 100 adopts an eSIM, that is, an embedded SIM card.
- the eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100 .
- the software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a micro-kernel architecture, a micro-service architecture, or a cloud architecture.
- a mobile operating system with a layered architecture is taken as an example to illustrate the software structure of the electronic device 100 .
- FIG. 2B is a block diagram of the software structure of the electronic device 100 according to the embodiment of the present application.
- the layered architecture divides the software into several layers, and each layer has a clear role and division of labor. Layers communicate through software interfaces.
- the mobile operating system can be divided into four layers, which are application program layer, program framework layer/core service layer, underlying library and runtime, and kernel layer from top to bottom.
- the application layer can consist of a series of application packages.
- the application package may include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, and settings.
- the application program service can obtain the device status of the peer device, and present it on the UI interface, so that the user can perceive the connection status of the peer device.
- the program framework layer provides an application programming interface (application programming interface, API) and a programming framework for applications in the application program layer.
- the program framework layer includes some pre-defined functions.
- the program framework layer may include a window manager, a content provider, a view system, a session manager, a resource manager, a notification manager, a device state manager, and the like.
- a window manager is used to manage window programs.
- the window manager can get the size of the display screen, determine whether there is a status bar, lock the screen, capture the screen, etc.
- Content providers are used to store and retrieve data and make it accessible to applications.
- This data can include videos, images, audio, calls made and received, browsing history and bookmarks, phonebook, etc.
- the view system includes visual controls, such as controls for displaying text, controls for displaying pictures, and so on.
- the view system can be used to build applications.
- a display interface can consist of one or more views.
- a display interface including a text message notification icon may include a view for displaying text and a view for displaying pictures.
- the session manager is used to manage the session state and session life cycle, such as creating a session, maintaining a session, closing a session, removing a session, etc.
- the resource manager provides various resources for the application, such as localized strings, icons, pictures, layout files, video files, and so on.
- the notification manager enables the application to display notification information in the status bar, which can be used to convey notification-type messages, and can automatically disappear after a short stay without user interaction.
- the notification manager is used to notify the download completion, message reminder, etc.
- the notification manager can also be a notification that appears on the top status bar of the system in the form of a chart or scroll bar text, such as a notification of an application running in the background, or a notification that appears on the screen in the form of a dialog window.
- prompting text information in the status bar issuing a prompt sound, vibrating the electronic device, and flashing the indicator light, etc.
- the device state manager is used to record and change the state of the peer device.
- the state of the peer device includes an online state, a silent state, and an offline state.
- the device status manager can send the peer device’s Status changed from Online to Silent.
- the device status manager can change the state of the peer device from the silent state to the online state.
- the device status manager can change the state of the peer device from the silent state to the offline state.
- the device status manager can change the state of the peer device from the online state to the offline state.
- the device status manager can change the state of the peer device from the offline state to the online state.
- the runtime includes the core library and the virtual machine, which are responsible for the scheduling and management of the system, and can refer to all code libraries, frameworks, etc. required for the program to run.
- the runtime includes a series of function libraries required for the operation of the C program.
- the runtime in addition to the core library, the runtime also includes the virtual machine required for the Java program to run.
- the above-mentioned core library may include functions that need to be called by the Java language.
- the application layer and the program framework layer run in the virtual machine.
- the virtual machine executes the java files of the application program layer and the program framework layer as binary files.
- the virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.
- the underlying library can include multiple functional modules. For example: surface manager (surface manager), media library (Media Libraries), 3D graphics processing library (eg: OpenGL ES), 2D graphics engine (eg: SGL), etc.
- surface manager surface manager
- media library Media Libraries
- 3D graphics processing library eg: OpenGL ES
- 2D graphics engine eg: SGL
- the surface manager is used to manage the display subsystem and provides the fusion of 2D and 3D layers for multiple applications.
- the media library supports playback and recording of various commonly used audio and video formats, as well as still image files, etc.
- the media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
- the 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing, etc.
- 2D graphics engine is a drawing engine for 2D drawing.
- the kernel layer is the layer between hardware and software.
- the kernel layer includes at least a display driver, a camera driver, an audio driver, and a sensor driver.
- a corresponding hardware interrupt is sent to the kernel layer.
- the kernel layer processes touch operations into original input events (including touch coordinates, time stamps of touch operations, and other information). Raw input events are stored at the kernel level.
- the application framework layer obtains the original input event from the kernel layer, and identifies the control corresponding to the input event. Take the touch operation as a touch click operation, and the control corresponding to the click operation is the control of the camera application icon as an example.
- the camera application calls the interface of the application framework layer to start the camera application, and then starts the camera driver by calling the kernel layer.
- Camera 193 captures still images or video.
- the software architecture of the electronic device 100 is only an example, and it should be understood that the software architecture shown in the embodiment of the present invention does not constitute a specific limitation to the present application. In other embodiments of the present application, the software architecture of the electronic device 100 may include more or fewer modules than shown in the illustration, or combine some modules, or split some modules, or arrange different architectures.
- the illustrated components can be realized in hardware, software or a combination of software and hardware.
- Any two or more devices in the communication system 10 can be applied to the technical solution provided by this application.
- the interaction between two devices is used as an example to illustrate the following. Any two devices among the multiple devices The interaction between two devices can refer to this example description.
- the two interacting devices are referred to below as the local device and the peer device respectively.
- the local device can mark the status of the peer device.
- the local device may be a mobile phone, or a tablet computer, or a PC
- the peer device may be a mobile phone, or a tablet computer, or a PC, or a smart watch, or a smart bracelet, or headphones etc.
- the status marked by the local device to the peer device includes: online status, offline status, silent status, and so on.
- Online state refers to the state where the local device discovers the peer device and establishes a connection, and can communicate normally, and can also be called “online state (or called online, online state)".
- online state or called online, online state
- the local device can know that it can communicate smoothly with the peer device, and can successfully send or receive messages with each other.
- Offline state refers to the state where the local device does not find the peer device, the connection between them is disconnected or the connection is abnormal, and the local device and the peer device cannot communicate. It can be called “offline state (or offline, offline state)". When it is confirmed that the peer device is offline, the local device can learn that it is currently unable to communicate with the peer device, and there is an obstacle in sending or receiving messages with each other.
- “Silent state (or silent, silent state)” is an intermediate state between the online state and the offline state, which means that it is uncertain whether the current peer device is in a state that can communicate, and it can also be called “retention state” , “silent state” and so on.
- the peer device is in the silent state, which means that there is no communication message (or message) between the two devices for a certain period of time, and it is necessary to check again to confirm that the peer device is in the online or offline state.
- the reason why there is no communication message between the two devices may be that there is no business communication between the two devices, or that the peer device has left the network coverage area of the local device, or the peer device has gone to sleep to save power. mode temporarily disables the wireless connection function, etc.
- a timer can be set as a passive detection, and when the passive detection exceeds a set time threshold, it will trigger to change the state of the peer device from the online state to the silent state.
- the local device initiates an active detection, which may mean that the local device sends a detection message to the peer device. If the detection message is sent successfully, the two parties can communicate normally, which can trigger the change of the state of the peer device from the silent state to the online state. If the detection message fails to be sent and the two parties cannot communicate normally, it can trigger the change of the state of the peer device from the silent state to the offline state.
- a state manager can be set up, and the state manager can use coding marks for the state of the peer device, such as using 0 to represent the online state and 1 to represent the offline state , use 2 to represent the silent state, which is not limited in this embodiment.
- the local device After the local device discovers the peer device and successfully establishes a connection, the local device can display that the peer device is online.
- Various embodiments do not impose any limitation on the specific type of the communication connection established between the local device and the peer device. It can be, for example, a Wi-Fi P2P connection, a Bluetooth connection, a USB connection, etc., or a network connection, or a communication connection established through an access point (AP), such as connecting a router between the local device and the peer device After joining the same Wi-Fi network, the local device and the peer device can establish a communication connection through the Wi-Fi network.
- AP access point
- the local device Before the local device establishes a connection with the peer device, after the local device discovers the peer device, it needs to perform identification. Authentication refers to confirming the identity of the declarer according to the specific information held by the declarer. Common authentication methods include username/password, biometrics (fingerprint, face, iris, voice, etc.), SMS verification code, QR code, gesture password, etc. After the authentication is successful, a communication connection can be established between the local device and the peer device. The local device will migrate the device status of the peer device to the online state, and the local device and the peer device can send messages to each other for normal communication. . This process may also be referred to as "logging in”.
- the authentication information can be saved on the peer device, or the local device can mark the peer device as a trusted device, so that the next time the peer device establishes a connection with the local device, it can automatically communicate with the local device A connection is established without requiring user action to enter authentication information.
- FIG. 3 is a schematic diagram of state transition, which shows the transition between the online state, offline state, and silent state of the peer device, and the state transition conditions are also marked in FIG. 3 .
- the state of the peer device When the peer device is in the online state, when the local device fails to send service packets to the peer device, the state of the peer device will be transferred from the online state to the offline state.
- the peer device When the peer device is offline, when the local device establishes a connection with the peer device and can successfully send service packets to the peer device, or receive service packets from the peer The status transitions from offline to online.
- the device status bit and timer are set inside the local device.
- the device status bit is used to mark the status of the device, including status bits such as reset and set, and the timer is used for timing.
- the local device synchronously starts the timer (or counter) at the same time as the last time the local device receives the heartbeat message from the peer device.
- the online status can be maintained after receiving the heartbeat message from the peer device within a certain time threshold set by the timer.
- the heartbeat message of the peer device is not received within a certain time threshold set by the timer (such as the first time limit), that is, the time difference between the time of the last sent and received message and the current time exceeds the time limit set by the timer, you can Change the status of the peer device from online to silent.
- a certain time threshold set by the timer such as the first time limit
- the silent detection is triggered actively or passively, such as actively sending a broadcast detection message. If the detection is successful, such as receiving a response from the peer device, change the status of the peer device from the silent state to the online state.
- the advantage of sending broadcast probe messages is that the number of broadcast messages sent per unit time is large, the messages are not easy to be lost, and the sending success rate is higher.
- the silent detection triggered by the local device can be triggered actively by the user. For example, when the user opens the application, or when the application is turned to the foreground, or when the user clicks a specific control to trigger the detection, the application will call the silent detection interface. Send a broadcast detection message to detect whether the peer device is online. If a response is received from the peer device, the state of the peer device can be changed from the silent state to the online state.
- the local device When the status of the peer device is in the silent state, when the local device passively receives a new message/package from the peer device, it will also change the status of the peer device from the silent state to the online state.
- the silent detection is triggered actively or passively, such as actively sending a broadcast detection message. If the detection fails, if no response is received from the peer device, the state of the peer device is changed from the silent state to the offline state.
- FIG. 4 is also a state transition diagram between various states of the peer device, especially a specific mechanism for changing from the online state to the silent state in more detail.
- Examples of the state transition mechanism include:
- the local device After the local device discovers the peer device, successfully authenticates and establishes a connection, the local device can display that the peer device is online.
- Various embodiments do not impose any limitation on the specific type of the communication connection established between the local device and the peer device. Such as Wi-Fi P2P connection, Bluetooth connection, USB connection, network communication connection and so on.
- the state of the peer device will be transferred from the online state to the offline state. While the device is offline, (o) terminate the timer.
- the peer device When the peer device is in the offline state, when the local device successfully establishes a connection with the peer device again, and can successfully send service packets to the peer device, or receive service packets from the peer device, the peer device will state transitions from offline to online.
- the device status bit and timer are set inside the local device.
- the device status bit is used to mark the status of the device, including status bits such as reset and set, and the timer is used for timing.
- a reset is represented by a 0 and a set is represented by a 1.
- the local device (a) initializes the device status bit, and synchronously (c) starts the timer (or counter).
- the time set by the timer is not limited.
- the timer does not overflow and interrupt, whenever the local device successfully sends a message to the peer device, or successfully receives a message from the peer device, it will trigger the local device (b) to reset the device status bit, and at the same time restart (c) Start the timer.
- the timer times out for the first time, that is, (d) the timer overflow interrupts, and the local device (e) reads the device status bit. If it is read that the current device status bit is reset, that is, (f) the device status bit is not set, then change the (g) device status bit to set, and at the same time (h) end the timer overflow interrupt, and the timer counts again, That is, re(c)start the timer.
- the local device reads the device status bit, and if it reads (i) the current device status bit is set, it satisfies silence If the trigger condition of the status is not valid, then (j) the identification status of the peer device will be changed, that is, the status of the peer device will be changed from the online state to the silent state, and at the same time (k) the timer will be terminated. That is, when the timer in the reset state times out twice consecutively, the state of the peer device is changed from the online state to the silent state, and the timer is terminated at the same time.
- the length of the first time and the second time may be the same or different, which is not limited in this embodiment of the present application.
- the silent detection is triggered actively or passively, such as actively broadcasting a detection message. If the detection is successful, such as receiving a response from the peer device, change the status of the peer device from the silent state to the online state.
- the advantage of sending broadcast probe messages is that the number of broadcast messages sent per unit time is more, the messages are less likely to be lost, and the sending success rate is higher.
- the silent detection triggered by the local device can be triggered actively by the user. For example, when the user opens the application, or when the application is turned to the foreground, or when the user clicks a specific control to trigger the detection, the application will call the silent detection interface. Send a broadcast detection message to detect whether the peer device is online. If a response is received from the peer device, the state of the peer device can be changed from the silent state to the online state.
- the local device When the state of the peer device is in the silent state, when the local device passively receives a new packet/message from the peer device, it will also change the state of the peer device from the silent state to the online state.
- silent detection is triggered, such as actively sending a broadcast detection message. If the detection fails, if no response is received from the peer device, the state of the peer device is changed from the silent state to the offline state, and the timer is terminated at the same time.
- an application is installed on the local device, and the application can display the status of the peer device, so that the user can perceive the status of the peer device through a user interface.
- the file application can display the identification and name of the peer device connected to the local device, such as the device status bar 501 in the user interface 500, and the device status bar 501 can display information related to the local device.
- the device identification for establishing a connection with the computer such as the MateBook device icon 502, the MatePad device icon, and the HuaWei P50 device icon 503.
- Devices in the online state, silent state, and offline state have different IDs, which is convenient for users to quickly distinguish the device status.
- the MateBook device icon 502 in the device status bar 501 is displayed as highlighted, indicating that the MateBook device is in the online state.
- the HuaWei P50 device icon 503 is displayed as gray, indicating that the HuaWei P50 device is in a silent state , and the offline device is not displayed in the device status bar 501 .
- the online state, silent state, and offline state can also be displayed in different colors, as long as it is convenient for the user to distinguish.
- the user wants to check whether the device in the silent state is still connected, he can click the HuaWei P50 device icon 503 under the silent logo in the user interface 500, and the silent detection is triggered at this time.
- the local device actively sends detection packets to the peer device. If the detection response from the peer device is received, the HuaWei P50 device changes from the silent state to the online state, that is, as shown in the user interface 510 in Figure 6A, the HuaWei P50 device icon 503 changes from gray to bright.
- the HuaWei P50 device will change from the silent state to the offline state, as shown in the user interface 520 in Figure 6B, the HuaWei P50 device icon 503 will disappear and will not be displayed in the device status column 501.
- This example does not limit other possible implementations.
- the application automatically initiates a silent detection to the device in the silent state. If it is still in the active connection state, it will be changed to the online state, and if it has been disconnected, it will be changed to the offline state. Electronic devices do not need to display the silent state mark, the silent state The status transition confirmation of the device will be completed in a very short time, and only the device in the online state and/or the device in the offline state will be presented to the user.
- each user interface described in the embodiments of the present application is only an example interface for assisting readers in understanding the technical solutions described in the present application, and does not limit other embodiments of the present application.
- different interface layouts may be used in the user interface, more or fewer controls may be included, other functional options may be added or reduced, and more or fewer user interfaces may be added or removed according to actual conditions, or Design different human-computer interaction operations, etc., to make the user interface more catering to the user experience.
- the sample interface can also be transferred to other types of devices, as long as the technical solutions based on the same inventive idea provided by this application are within the scope of protection of this application, so I won’t go into details here.
- device A also known as the discovery end device
- device B also known as the discovered end device
- application services such as application services, short-distance communication services, and state management services
- device B also known as the discovered end device
- application services such as application services, short-distance communication services, and state management services, etc.
- the embodiment of the present application does not impose any limitation on specific technical means used for device discovery and device connection.
- the communication connection between device A and device B may be a short-range communication connection or a long-distance communication connection, such as a USB connection, a Bluetooth connection, a Wi-Fi P2P connection, a WLAN connection, a radio frequency identification (radio frequency identification, REID) connection, ZigBee connection, etc., are not limited in this embodiment.
- device A and device B may log in with the same account, or their login accounts belong to the same group (such as the same family account), or they may be different accounts, and they are connected through the cloud server, which is not limited in this embodiment.
- Fig. 7 is a schematic diagram of the information flow process of discovery, connection and authentication between device A and device B. Specifically include:
- Device B publishes a service (publish Service).
- the application service of device B notifies the NFC service to release discoverable services, so that other nearby devices can discover itself.
- the application service of device A notifies the NFC service to start searching for surrounding devices.
- the discovering device sends a search broadcast, and the discovered device replies to the broadcast.
- Passive discovery The device on the discovered side actively sends device information broadcasts, and the device on the discovery side monitors the broadcasts.
- the discovering end device discovers peripheral devices by means of broadcasting or monitoring, and prompts the caller to select a device for connection.
- the discovered device notifies its own device information to surrounding devices through feedback monitoring or broadcasting means, so that its own device can be discovered and sensed by surrounding devices.
- device B After receiving the broadcast information from device A, device B feeds back its own device information, and device B is discovered by device A.
- the result of device discovery includes basic device information and connection capability information. On the lightweight device side, it generally only needs to support the discovery function.
- BLE Bluetooth low energy
- BLE Bluetooth low energy
- BLE Bluetooth low energy
- BLE Bluetooth low energy
- BLE realizes background real-time discovery based on the low-power discovery protocol stack.
- BLE supports two modes of active discovery and passive discovery. Active discovery: The discovering device sends a BLE search broadcast, and the discovered device replies to the broadcast. Passive discovery: The device on the discovered side actively sends device information broadcasts, and the device on the discovery side monitors the broadcasts.
- Wi-Fi wireless access point and terminal device
- the protocol layer uses the Internet protocol (internet protocol, IP) layer multicast or broadcast mechanism for discovery and connection.
- Wi-Fi can discover peer devices based on the constrained application protocol (COAP) protocol.
- COAP constrained application protocol
- the discovery side device sends a broadcast with discovery information in the COAP protocol format in the local area network.
- the device on the discovered side receives the discovery broadcast and unicasts back its own device information.
- a dedicated physical link channel will be established between device A and device B based on different communication methods such as Wi-Fi/BLE/USB for communication.
- Wi-Fi/BLE/USB for communication.
- the channel cannot be monopolized. Therefore, establishing a connection in BLE can be understood as, within the agreed time period, both parties communicate on a designated physical channel Channel.
- Device A opens a channel (open Channel).
- the application service of device A notifies the NFC service to open the channel.
- a channel is established between device A and device B based on a given connection.
- device B opens a channel (on Channel opened).
- the application service of device A notifies the near field communication service to send a message (send Message).
- the application service of device A notifies the near field communication service authentication device (verify Device).
- the two parties When device A and device B, which have established a trust relationship, communicate, the two parties first complete the trust relationship binding, and then authenticate each other based on the peer identity public key stored locally. Two-way identity authentication and session key negotiation are completed during each communication, and then the device uses the session key to decrypt the transmission channel between the two devices.
- security token service security token service, STS
- STS security token service
- Device A performs STS authentication on device B, and negotiates a session key based on the identification keys of both parties. After the authentication is successful, the ID and derived key of device B are returned, and the aforementioned given connection becomes a secure connection.
- the device is authenticated (on Device Verify Pass).
- the NFC service of device A notifies the application service that device B has passed the authentication.
- the application service of device A notifies the NFC service to initiate a connection to authenticated device B.
- Device A establishes a secure connection with device B.
- the NFC service notifies the status manager of the initial device status bit, and the status manager starts timeout counting.
- the device status manager When the device B switches to the online state, the device status manager initializes the device status bit and starts a timer, which is used to measure whether the device B reaches the time limit for turning to the silent state.
- the short-distance communication service of the device A notifies the application service that the device B is connected (on Connected).
- FIG. 8 is a schematic diagram of the information flow process of data transmission and status update after the connection between device A and device B is established.
- the transmission service module can provide session management and session-based data sending and receiving functions to the business module, and provide encryption and decryption protection for sending and receiving messages through the encryption function. That is, the communication data is encrypted using the session key, and device A and device B perform encrypted communication. Specifically include:
- Device A and device B respectively create session servers (create Session Server).
- the application services of device A and device B notify themselves of the NFC service to create a session server and register the monitoring callback function.
- the monitoring callback function is used to passively monitor the messages exchanged between devices in each link of data transmission, including control messages and data messages, and reset the device status bits based on message sending and receiving events.
- device A and device B do not send or receive packets from each other, so the timer keeps counting.
- Device A opens a session channel (open Session).
- the receiving end that is, device B
- the sending end that is, device A
- the sending end that is, device A
- the service opens a session channel.
- Device A notifies device B to create a transmission channel.
- the status managers of device A and device B After obtaining the short-range communication service of device A and sending a message to the short-range communication service of device B, the status managers of device A and device B reset the device status bit, that is, each time a message is successfully sent or received, the device status bit will be set to reset.
- Device B that is, the receiving end, receives the callback, and opens the session channel (on Session opened).
- the short-distance communication service of device B After receiving the request from device A to open the session channel, the short-distance communication service of device B notifies the application service, and the application service opens the session channel and returns the result.
- Device B returns to device A a result of the session channel being opened.
- the status managers of device A and device B After obtaining the short-range communication service of device B and sending a message to the short-range communication service of device A, the status managers of device A and device B reset the device status bit, that is, each time a message is successfully sent or received, the device status bit will be set to reset.
- Device A that is, the sender, receives the callback and has opened the session channel (on Session opened).
- the application service of device A confirms that the session connection takes effect. So far, the transmission channel between device A and device B has been established and opened, and the session connection has been successfully established.
- the device A and device B After the device A and device B successfully establish a session connection, they can send or receive instructions, data, etc. through the session connection.
- the data sent or received may include but not limited to the following three data types: Byte type, used for mass data exchange; Message type, used for instant messages; File type, used for file sending.
- the application service of device A sends a session message (session send Message) to the near field communication service.
- the short-range communication service of device A sends data to the short-range communication service of device B.
- the status managers of device A and device B After acquiring the short-range communication service of device A and successfully sending a message to the short-range communication service of device B, the status managers of device A and device B reset the device status bit.
- the application service of device B receives the session message (on Message Received) received by the NFC service.
- Device B returns a result of receiving the message to device A.
- the state managers of device A and device B After obtaining the message that device B successfully returns the result to device A, the state managers of device A and device B reset the device status bits.
- the application service of device A notifies the near field communication service to close the session (close Session)
- the short-range communication service of device A sends a message of closing the session to the short-range communication service of device B.
- the state managers of device A and device B After obtaining the NFC service of device A and successfully sending a message to the NFC service of device B, the state managers of device A and device B reset the device status bits.
- the application service of device B receives the session closing message (on Session Closed) received by the near field communication service, and the application service of device B closes the session.
- Device A and device B respectively delete the session server (remove Session Server).
- the application services of device A and device B notify themselves of the NFC service to delete the session server and cancel the previously registered monitoring callback function.
- device A and device B do not send or receive packets from each other, so the timer keeps counting.
- FIG. 9 is a schematic diagram of the information flow process when device A and device B are in a normal connection state, suddenly goes online to go offline, and goes back online after going offline.
- a failure to send a control message or a service message sent by device A to device B will trigger a change from online to offline.
- the offline state if device A successfully receives the control packet or service packet sent by device B, it will trigger the change from offline to online.
- the state manager or device state transition state machine
- the monitoring callback function registered by the application is called in real time. Notify the application that the state of the peer device has changed.
- the application service of device A sends a message to the short-range communication service.
- Device A sends a message to device B, and the application service of device A transmits the obtained message to the NFC service, and then the NFC service of device A sends the message to the NFC service of device B.
- the short-range communication service of device A sends a message to the short-range communication service of device B.
- the short-distance communication service of the device A learns that the sending of the message fails, stops the timeout counting, and the state manager changes the device B from the online state to the offline state.
- the peer device that is, device B
- the packet transmission including control packets and data packets
- the message transmission failure event is confirmed, triggering Device B goes offline.
- the short-range communication service of device A notifies the application service that the state of device B is changed from the online state to the offline state.
- the application service of the device A refreshes the application interface, and shields the offline device, that is, does not display the identifier of the device B.
- the identifier of the offline device may not be displayed in the application interface.
- the short-range communication service of device A receives a message sent by the short-range communication service of device B, which is an offline device.
- the local device, device A receives the packets (including control packets and data packets) of the peer device, and triggers device B to go online again.
- the short-range communication service of device A sends a detection message to the short-range communication service of device B.
- device A sends a detection message to device B.
- the short-distance communication service of device A learns that the detection message is sent successfully, that is, device B successfully receives the detection message, and the state manager changes device B from offline state to online state, and resets the device status bit.
- the short-distance communication service of device A notifies the application service that the state of device B is changed from offline state to online state.
- the application service of device A refreshes the application interface, and displays the online device, that is, displays the identifier of device B.
- the icon of the online device can be displayed in the application interface and displayed as a highlighted mark, so that the user can quickly perceive the peer device that is connected to the local device and can communicate normally.
- the device status manager When the device B switches to the online state, the device status manager resets the device status bit, and the timer starts to work and counts overtime again.
- FIG. 10 is a schematic diagram of the information flow process when device A changes the status of device B from online to silent, and actively triggers a detection in the silent state to detect whether the peer device is online.
- the state manager or device state transition state machine
- the monitoring callback function registered by the application is called in real time to notify the application that the state of the peer device has changed.
- the session between device A and device B may be closed, but the session service is not removed.
- the silent state changes to the offline state
- the session service is removed.
- the quiet state returns to the online state
- the session state is restored to the "normal service state”.
- the session between device A and device B is not closed, and the session state may be migrated from "normal service state” to "session hold state".
- the quiet state returns to the online state
- the session state is restored to the "normal service state”.
- the silent state changes to the offline state, close and remove the session service.
- the state manager keeps counting.
- the state manager of device A notifies the short-range communication service of the state change, and device B changes from the online state to the silent state.
- the status of the peer device can be changed to Change from online status to silent status.
- the device B is triggered to change from the online state to the silent state.
- the short-range communication service of device A notifies the application service, and the state of device B changes from the online state to the silent state.
- the application service of device A refreshes the application interface, and sets the device to gray and silent.
- Graying out silent devices means that device A displays the logo of device B as a gray logo that is different from the highlighted logo of online devices. Different logos help users distinguish between online devices and silent devices.
- the user triggers the detection phase:
- Device A detects a user operation on the silent device.
- the embodiment of this application does not limit the user operation that triggers the active detection.
- the user operation triggers the application service of device A to send an active detection message to the silent device, and the application service of device A sends the detection message to the NFC service. That is, after device A detects the user operation on the application for the silent device, based on the device presentation policy, the application calls the silent detection interface provided by the system on demand, initiates silent detection, and quickly detects the real-time status of the silent device.
- the short-range communication service of device A sends a detection message to the short-range communication service of device B.
- sending a detection message may be broadcasting a detection message.
- the advantage of sending broadcast probe messages is that the number of broadcast messages sent per unit time is large, the messages are not easy to be lost, and the sending success rate is higher.
- the probe event response includes two situations: failure to send the probe message and success in sending the probe message. Based on the detection results, perform different state changes, switch the silent state to the online state, or switch the silent state to the offline state, and refresh the application interface synchronously.
- Steps S407-S409 are for the failure to send the detection message.
- the short-distance communication service of the device A learns that the sending of the detection message fails, stops the timeout count, and the state manager changes the device B from the silent state to the offline state.
- device B When the peer device, that is, device B, is in the silent state and confirms that the detection packet fails to be sent, device B is triggered to go offline.
- the near-field communication service of device A notifies the application service that the state of device B is changed from the silent state to the offline state.
- the application service of device A refreshes the application interface, and shields offline devices, that is, does not display the identifier of device B.
- Steps S410-S412 are cases where the detection message is sent successfully.
- the short-distance communication service of device A and device B learns that the detection message is sent successfully, and the state manager changes device B from the silent state to the online state, and resets the device status bit.
- device B When the peer device, that is, device B, is in the silent state and confirms that the detection packet is sent successfully, device B is triggered to go online.
- the short-range communication service of the device A and the device B notifies the application service, and the state of the device B is changed from the silent state to the online state.
- the application service of device A and device B refreshes the application interface, and sets the online device to be bright.
- the display of device B is changed from a gray mark representing a silent state to a highlighted mark representing an online state.
- the timer starts to work, counts overtime again, and at the same time, the device status manager resets the device status bit.
- the silent state is different from the offline state.
- the device B when the device B is in the silent state, the device B is not offline, and the session between the device A and the device B can be on hold state. After it is determined that the device B has changed from the silent state to the online state, the session may be migrated from the session hold state to the normal service state. After it is determined that the device B changes from the silent state to the offline state, the session state may be transferred from the session hold state to the session exit state.
- the state of the session is the initial state. In this state, during the process of requesting login, the amount of exchanged data is large, and more resource analysis and query work is required.
- FIG. 11 is a flow chart of the detection method provided by the embodiment of the present application.
- the embodiment of the method provides a detection method, which is used for a first device to detect the state of a second device, so as to solve problems such as inability to change the state of the device in time, high power consumption of the device, and cumbersome communication.
- This method cancels the heartbeat mechanism commonly used in communication, completely solves the problems of high power consumption and occupied transmission bandwidth, and further optimizes communication efficiency.
- By monitoring the business packet sending and receiving events and sending and receiving results of passive or active detection between devices it drives the online state machine migration of the device, and the status change of the device can be quickly sensed.
- an active detection mechanism is added, and a new device state—silent state, and a silent detection interface are established to support the application to determine the UI presentation and business processing strategies of various states of the device.
- the second device is in the online state, when the passive detection times out, the online state will be changed to the silent state.
- the first device can actively broadcast detection messages as needed to confirm whether the peer device is online, which solves the problems of easy device status error reporting and poor user experience, effectively reduces the device offline delay and power consumption, and avoids The defect of frequent online and offline due to short-term disconnection further improves communication efficiency.
- the method provided in this embodiment may be applied to a communication system composed of a first device and a second device.
- the first device and/or the second device may be a terminal device configured with a communication device, and may receive or send messages such as data and signaling.
- the first device is the local device or device A in the foregoing embodiments
- the second device is the peer device or device B in the foregoing embodiments.
- the local device can identify the current device status of the peer device and display it on the UI In the interface, it is convenient for users to quickly distinguish the connection status of each device.
- the device type of the first device or the second device may be, but not limited to, a mobile phone, a laptop, a PAD, a smart bracelet, a smart watch, a PC, a smart TV (also called a smart screen, a large screen, etc.), a smart speaker, etc. It can also be desktop computers, laptop computers, handheld computers, AR devices, VR devices, AI devices, car machines (vehicle devices), game consoles, treadmills, cloud hosts/cloud servers, other smart wearable devices, etc., or It is an IOT device, or a smart home device such as a smart water heater, a smart lamp, a smart air conditioner, a smart weight scale, and other types of electronic devices.
- This application does not impose any restrictions on the type of the first device or the second device.
- the hardware structure of the first device or the second device reference may be made to the description of the electronic device 100 in the foregoing embodiments.
- Figure 11 is a flow chart of the detection method provided by this embodiment, which shows that the second device changes from the online state to the silent state, from the silent state to the online state, from the silent state to the offline state, from the offline state
- the process of changing the online status to the online status includes the following steps:
- the first device discovers the second device and establishes a connection, the first device communicates with the second device normally, and the state of the second device is an online state.
- the first device may display that the second device is in an online state.
- This embodiment does not impose any limitation on the specific type of the communication connection established between the first device and the second device. It can be wired connection or wireless connection, such as Wi-Fi P2P connection, Bluetooth connection, USB connection, other network communication connections and so on.
- the communication connection can be used for transferring data, signaling and the like.
- the state of the second device recorded by the first device includes an online state, an offline state, and a silent state.
- the online state indicates that the communication between the first device and the second device is normal
- the offline state indicates that the communication between the first device and the second device is normal.
- Inter-communication is abnormal
- the silent state means that whether the communication between the first device and the second device is normal is in an uncertain state, and it is necessary to check again to confirm that the second device is online or offline.
- the first device resets the device status bit, and starts a timer to count time.
- the first device is internally provided with a device status bit and a timer (or counter).
- the device status bit is used to indicate the number of interruptions of the timer.
- the device status bit can include status bits such as reset and setting, and the timer is used for timing.
- a reset is represented by a 0 and a set is represented by a 1.
- the first device When the state of the second device changes to the online state, the first device initializes the device state bit and starts the timer (or counter) synchronously.
- the time set by the timer is not limited.
- the first device judges whether a message from the second device is received.
- step S502 is performed, that is, the device status bit is reset, and the timer is restarted to start counting again. That is, when the timer does not overflow and interrupt, whenever the first device successfully sends a message to the second device, or successfully receives a message from the second device, it will trigger the first device to reset the device status bit and restart the timer at the same time. device.
- step S504 is performed.
- the first device detects that the timer times out for the first time, and interrupts when the timer overflows.
- the first device sets a device status bit, and restarts the timer for timing.
- the first device reads the device status bits.
- the device status bit is triggered and set, and the timer is restarted at the same time.
- the first device judges whether the message from the second device is received.
- step S502 is performed, that is, the device status bit is reset, and the timer is restarted to start counting again. That is, when the device status bit is set, when the second timer has not overflowed and interrupted, whenever the first device successfully sends a message to the second device, or successfully receives a message from the second device, it will The first device is triggered to reset the device status bit and restart the timer at the same time.
- step S507 is performed.
- the timer overflows again and interrupts, the first device changes the state of the second device from the online state to the silent state, and terminates the timer.
- the first device detects that the timer has timed out for the second time, and the timer overflows again to interrupt.
- the first device reads the device status bit.
- the first device A device changes the identification state of the second device, changes the state of the second device from the online state to the silent state, and terminates the timer at the same time. That is, in one implementation manner, when the timer in the reset state times out twice consecutively, the state of the peer device is changed from the online state to the silent state, and the timer is terminated at the same time.
- the length of the first time and the second time may be the same or different, which is not limited in this embodiment of the present application.
- the first device sends a detection message to the second device.
- the detection message is also called the first detection message.
- the application of the first device calls the silent detection interface and sends a detection message to the second device, which is an active detection triggered by a user operation, for example, when the user opens the application, or in other words, when the application turns to When the foreground is running, or when the user clicks a specific control to trigger the detection, the application will call the silent detection interface, send a broadcast detection message, and detect whether the peer device is online. If a response from the peer device is received, the peer device can The status of the device changes from Quiet to Online.
- the first device in the silent state, first receives the message from the second device, and then the first device sends a detection message to the second device to verify whether normal communication is possible.
- sending the detection message may refer to the first device broadcasting the detection message.
- the advantage of sending broadcast probe messages is that the number of broadcast messages sent per unit time is large, the messages are not easy to be lost, and the sending success rate is higher.
- the first device judges whether the detection is successful.
- step S510 is executed.
- step S511 is executed.
- the first device changes the state of the second device from the silent state to the online state, and executes step S502.
- the state of the second device is changed from the silent state to the online state.
- the device status bit is reset, and the timer is restarted to start counting again.
- the first device changes the state of the second device from the silent state to the offline state, and terminates the timer.
- the state of the second device is changed from the silent state to the offline state, and the timer is terminated at the same time.
- the first device resumes normal communication with the second device.
- the first device changes the state of the second device from the offline state to the online state, and executes step S502.
- the first device When the second device is offline, when the first device and the second device successfully establish a connection again and can successfully send messages to each other, the first device will transfer the state of the second device from the offline state to the online state. And at the same time reset the device status bit, restart the timer and start counting again.
- the second device when the second device is in the online state, when the first device fails to send a service message to the second device, it will directly transfer the state of the second device from the online state to the offline state. While the device is offline, terminate the timer.
- Implementing the method provided in this embodiment can solve the problems of high power consumption, occupied transmission bandwidth, frequent online and offline, etc. caused by the heartbeat message keep-alive mechanism between devices in the system.
- the application determines the UI presentation and business processing strategies of various states, solves the problem that the device state cannot be updated in time, further optimizes the communication efficiency, enhances the performance of human-computer interaction, and can provide users with more intuitive, easier to understand, and more convenient application interaction
- the interface monitors the sending and receiving events and results of business packets between devices, and drives the device online state machine migration. Users can perceive changes in device status in real time, which improves user experience.
- module may be a combination of software and/or hardware that realizes a predetermined function.
- FIG. 12 shows a structural block diagram of functional modules of an electronic device 100 .
- the electronic device 100 may include a communication module 1201, a timing module 1202, a judging module 1203, a status management module 1204, a session management module 1205, a detection module 1206, a display module 1207 and the like. Or these functional modules are distributed in the communication system formed by the electronic device 100 and the peer device.
- the communication module 1201 is used to receive or send messages, including data messages and control messages.
- the communication module 1201 may further include a sending module 1208 and a receiving module 1209 .
- a sending module 1208, configured to send the message obtained from the application to the peer device.
- the detection module 1206 detects an active detection instruction triggered by a user operation
- the sending module 1208 sends a detection message to the peer device, and the detection message is used to detect whether the peer device is still in normal state. Connection Status.
- the receiving module 1209 is used to receive the message from the peer device and deliver it to the application.
- the communication module 1201 may notify the state management module 1204, the timing module 1202, etc. of the success or failure of receiving or sending a message.
- the communication module 1201 may notify the state management module 1204, the timing module 1202, etc. of the success or failure of receiving or sending a message.
- the timing module 1202 is used to set the timer. When the electronic device 100 is in the online state, every time the electronic device 100 successfully sends or receives a message, it will reset the device status bit and reset the timer. The timer starts from the last time The timing starts at the time when the message is sent and received, and it is calculated whether the time limit of no communication between the electronic device 100 and the peer device exceeds the timer threshold. When the timer overflows and interrupts, the timing module 1202 will notify the judging module 1203 .
- a judging module 1203 configured to judge whether the current device state satisfies the trigger condition of the silent state.
- the judging module 1203 receives the timer overflow interrupt message from the timing module 1202, the judging module 1203 reads the status bit of the current device. If the current device status bit is read as reset, then the device status bit is changed to set, if the current device status bit is read as set, then the trigger condition of the silent state is satisfied, and the status management module 1204 is notified to change the device state.
- the status management module 1204 is used to record and change the status of the peer device.
- the status of the peer device includes online status, silent status, and offline status.
- the state management module 1204 receives the message of changing the silent state from the judging module 1203, the state management module 1204 can change the state of the peer device from the online state to the silent state.
- the state management module 1204 receives the message that the communication module 1201 has successfully sent and received packets, the state management module 1204 can change the state of the peer device from the silent state to the online state.
- the state management module 1204 can change the state of the peer device from the silent state to the offline state.
- the state management module 1204 can change the state of the peer device from the online state to the offline state.
- the state management module 1204 receives the message that the communication module 1201 has successfully sent and received the message, the state management module 1204 can change the state of the peer device from the offline state to the online state.
- the session management module 1205 is used to manage the session state and session lifecycle, such as creating a session, maintaining a session, closing a session, removing a session, and so on.
- the detection module 1206 can be used to detect the user's operation on the electronic device 100 .
- the detection module 1206 may detect the user's click and swipe operation on the icon of the peer device on the application interface, and generate a detection instruction for the peer device.
- User operations may include: touch operations, voice operations, gesture operations, and the like.
- the display module 1207 can be used to display the user interface, which is convenient for the user to perceive the status of the peer device in the interface. For example, the online status is displayed as the device icon is highlighted, the silent status is displayed as the device icon is grayed out, and the offline status is not displayed on the user interface. in the interface.
- the display module 1207 may display device icon marks in different states corresponding to the change according to the state change notification of the state management module 1204 .
- the communication module 1201 the timing module 1202, the judgment module 1203, the state management module 1204, the session management module 1205, the detection module 1206, the display module 1207, etc.
- the term “when” may be interpreted to mean “if” or “after” or “in response to determining" or “in response to detecting".
- the phrase “in determining” or “if detected (a stated condition or event)” may be interpreted to mean “if determining" or “in response to determining" or “on detecting (a stated condition or event)” or “in response to detecting (a stated condition or event)”.
- all or part of them may be implemented by software, hardware, firmware or any combination thereof.
- software When implemented using software, it may be implemented in whole or in part in the form of a computer program product.
- the computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on the computer, the processes or functions according to the embodiments of the present application will be generated in whole or in part.
- the computer can be a general purpose computer, a special purpose computer, a computer network, or other programmable devices.
- the computer instructions may be stored in or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website, computer, server or data center Transmission to another website site, computer, server, or data center by wired (eg, coaxial cable, optical fiber, DSL) or wireless (eg, infrared, wireless, microwave, etc.) means.
- the computer-readable storage medium may be any available medium that can be accessed by a computer, or a data storage device such as a server or a data center integrated with one or more available media.
- the available media may be magnetic media (eg, floppy disk, hard disk, magnetic tape), optical media (eg, DVD), or semiconductor media (eg, solid state hard disk), etc.
- the processes can be completed by computer programs to instruct related hardware.
- the programs can be stored in computer-readable storage media.
- When the programs are executed may include the processes of the foregoing method embodiments.
- the aforementioned storage medium includes: ROM or random access memory RAM, magnetic disk or optical disk, and other various media that can store program codes.
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Mobile Radio Communication Systems (AREA)
Abstract
本申请公开了探测方法、电子设备及系统,通过监听设备间的业务报文收发事件和收发结果,驱动设备在线状态机迁移,设备状态变化可以被快速感知。该方法增加了主动探测机制,并设立新的设备状态—静默态,以及静默探测接口,支持应用决定该设备各种状态的 UI 呈现和业务处理策略。设备处于上线状态,当被动探测超时,上线状态会变更为静默状态。在静默态下,本端设备可以按需主动广播探测报文,确认对端设备是否在线,解决设备状态不能及时更新、容易报错的问题,有效降低了设备下线时延、资源功耗、传输带宽的占用,避免了由于短暂掉线导致的频繁上线下线的缺陷,给用户提供了更直观易懂的应用交互界面,提高了用户体验,并进一步提高通信效率。
Description
本申请要求于2022年1月29日提交中国专利局、申请号为202210112618.1、申请名称为“一种探测方法、相关电子设备及系统”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。本申请要求于2022年2月28日提交中国专利局、申请号为202210191223.5、申请名称为“一种探测方法、相关电子设备及系统”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
本申请涉及通信技术领域,尤其涉及一种探测方法、相关电子设备及系统。
随着消费升级,用户拥有的智能终端设备的数量越来越丰富。对于多个终端组成的系统,用户可以通过软件平台来统一管理该系统中各个分布式设备,例如查看各个设备的状态,调控各个设备的硬件资源、能力,对系统中的业务数据进行分发和同步等。
系统中组成连接的任意两个或多个设备之间的保活(keep alive),可以通过长连接机制或心跳机制来保持连接状态,维持该长连接机制或心跳机制会一直占用资源和浪费功耗,不可避免地造成终端设备持续消耗流量和/或电量,缩短了终端设备的待机时间,存在明显缺陷。
发明内容
本申请提供了一种探测方法、相关电子设备及系统,该探测方法通过监听设备间的业务报文收发事件和收发结果,驱动设备在线状态机迁移,设备状态变化可以被快速感知。该方法增加了主动探测机制,并设立新的设备状态—静默态,以及静默探测接口,支持应用决定该设备各种状态的UI呈现和业务处理策略。设备处于上线状态,当被动探测超时,上线状态会变更为静默状态。在静默态下,本端设备可以按需主动广播探测报文,确认对端设备是否在线。
上述目标和其他目标将通过独立权利要求中的特征来达成。进一步的实现方式在从属权利要求、说明书和附图中体现。
第一方面,本申请实施例提供了一种探测方法,该方法包括:第一设备与第二设备建立连接,其中,第一设备记录的第二设备的状态包括上线状态、下线状态、静默状态,该上线状态表示第一设备与第二设备之间通信正常,该下线状态表示第一设备与第二设备之间通信异常,该静默状态表示第一设备与第二设备之间的通信是否正常处于不确定状态,需要通过再次探测确认第二设备处于上线状态或下线状态。当接收到第二设备的报文时,第一设备刷新第二设备的状态为上线状态,并启动定时器开始计时。第一设备确认未收到第二设备的报文的时间间隔超出第一时限。第一设备将第二设备的状态由上线状态变更为静默状态。
实施第一方面的方法,可以解决设备状态不能及时更新、容易报错的问题,有效降低了设备下线时延、资源功耗、传输带宽的占用,避免了由于短暂掉线导致的频繁上线下线的缺陷,给用户提供了更直观易懂的应用交互界面,提高了用户体验,并进一步提高通信效率。
结合第一方面,在一些实施例中,该第一设备设置有设备状态位,该设备状态位指示定时器的中断次数,设备状态位包括复位、置位。
结合第一方面,在一些实施例中,当第一设备刷新第二设备的状态为上线状态时,第一设备将设备状态位变为复位。当第一设备检测到定时器溢出中断时,第一设备读取设备状态位。如果读取到设备状态位为复位,那么第一设备将设备状态位由复位变为置位。如果读取到设备状态位为置位,那么第一设备确认满足变更静默状态的触发条件。
结合第一方面,在一些实施例中,第一设备检测到定时器第一次溢出中断,第一设备读取到设备状态位为复位。第一设备将设备状态位由复位变为置位,并重启定时器开始计时。第一设备检测到定时器第二次溢出中断,第一设备读取到设备状态位为置位,第一设备确认满足变更静默状态的触发条件。
设置两次定时器溢出中断才触发上线状态变更静默状态的条件,可以避免第一设备与第二设备之间暂时没有消息来往时,由于连接不稳定使得第二设备暂时掉线从而导致的频繁上下线的问题。
结合第一方面,在一些实施例中,定时器第一次溢出中断所需的第一时间与定时器第二次溢出中断所需的第二时间不同。比如第二时间比第一时间长一些。
开发者还可以根据不同对端设备的类型或不同时间段或其他因素分别设置触发中断的时间,如,在用户使用频繁的时间段,定时器的时限设置短一点,在用户使用频率低的时间段,如夜间,定时器的时限设置长一点。
结合第一方面,在一些实施例中,在第二设备的状态为静默状态时,第一设备向第二设备发送第一探测报文。若第一设备接收到第二设备针对于第一探测报文的响应报文,则第一设备将第二设备的状态由静默状态变更为上线状态。若第一设备未接收到第二设备针对于第一探测报文的响应报文,则第一设备将第二设备的状态由静默状态变更为下线状态。
结合第一方面,在一些实施例中,上述第一探测报文可以为广播消息。相对于单播,发送广播探测报文的优点是广播在单位时间内发送的报文次数多,报文不易丢失,发送成功率更高。
结合第一方面,在一些实施例中,第一设备的应用的界面中显示有第二设备的图标标识。如果第二设备为上线状态,则第二设备的图标标识置亮显示在应用界面中。如果第二设备为静默状态,则第二设备的图标标识置灰显示在应用界面中。如果第二设备为下线状态,则第二设备的图标标识不显示在应用界面中。这样方便用户通过界面快速感知第二设备的状态。
结合第一方面,在一些实施例中,第一设备检测到点击置灰显示的第二设备的图标标识的用户操作。响应于该用户操作,第一设备向第二设备发送第一探测报文。
结合第一方面,在一些实施例中,第一设备检测到上述应用调到前台运行,第一设备向第二设备发送第一探测报文。这样可以更快速的触发主动探测,在预测用户需要操作的时候,及早探测第二设备是否在线。
结合第一方面,在一些实施例中,第一设备设置有静默探测接口,第一设备检测到上述应用调用该静默探测接口,触发该应用调用静默探测接口的事件包括第一设备检测到点击置灰显示的第二设备的图标标识的用户操作,或,第一设备检测到该应用调到前台运行。然后第一设备通过该静默探测接口向第二设备发送第一探测报文。
结合第一方面,在一些实施例中,如果第一设备确认第二设备的状态为静默状态或下线状态,则终止定时器计时。
结合第一方面,在一些实施例中,在第二设备的状态为下线状态的情况下,如果第一设备向第二设备发送消息成功,则第一设备将第二设备的状态由下线状态变更为上线状态。
结合第一方面,在一些实施例中,在第二设备的状态为上线状态的情况下,如果第一设备向第二设备发送消息失败,则第一设备将第二设备的状态由上线状态变更为下线状态。
第二方面,本申请实施例提供了一种电子设备,该电子设备可以包括:通信装置、显示装置、存储器以及耦合于存储器的处理器,多个应用程序,以及一个或多个程序。通信装置用于通信,显示装置用于显示界面,存储器中存储有计算机可执行指令,处理器执行指令时使得电子设备可以实现如第一方面中第一设备所具有的任一功能。
第三方面,本申请实施例提供了一种通信系统,该通信系统包括第一设备和第二设备,其中,第一设备实现如第一方面中任一可能的实现方式。
第四方面,本申请实施例提供了一种计算机存储介质,该存储介质中存储有计算机程序,该计算机程序包括可执行指令,该可执行指令当被处理器执行时使该处理器执行如第一方面所提供的方法对应的操作。
第五方面,本申请实施例提供了一种计算机程序产品,当计算机程序产品在电子设备上运行时,使得电子设备执行如第一方面中任一可能的实现方式。
第六方面,本申请实施例提供了一种芯片系统,该芯片系统可以应用于电子设备,该芯片包括一个或多个处理器,处理器用于调用计算机指令以使得电子设备实现如第一方面中任一可能的实现方式。
实施本申请提供的上述方面,可以解决设备状态不能及时更新、容易报错的问题,有效降低了设备下线时延、资源功耗、传输带宽的占用,避免了由于短暂掉线导致的频繁上线下线的缺陷,给用户提供了更直观易懂的应用交互界面,提高了用户体验,并进一步提高通信效率。
图1为本申请实施例提供的一种通信系统的示意图;
图2A为本申请实施例提供的电子设备的硬件结构示意图;
图2B为本申请实施例提供的电子设备的软件架构示意图;
图3为本申请实施例提供的状态迁移示意图;
图4为本申请实施例提供的状态迁移示意图;
图5为本申请实施例提供的用户界面示意图;
图6A为本申请实施例提供的交互界面示意图;
图6B为本申请实施例提供的交互界面示意图;
图7为本申请实施例提供的信息流转过程示意图;
图8为本申请实施例提供的信息流转过程示意图;
图9为本申请实施例提供的信息流转过程示意图;
图10为本申请实施例提供的信息流转过程示意图;
图11为本申请实施例提供的一种探测方法流程图;
图12为本申请实施例提供的一种电子设备的功能模块示意图。
下面将结合附图对本申请实施例中的技术方案进行清楚、详尽地描述。其中,在本申请实施例的描述中,除非另有说明,“/”表示或的意思,例如,A/B可以表示A或B;文本中的“和/或”仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可 以表示:单独存在A,同时存在A和B,单独存在B这三种情况。
以下,术语“第一”、“第二”仅用于描述目的,而不能理解为暗示或暗示相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括一个或者更多个该特征,另外,在本申请实施例的描述中,“多个”是指两个或多于两个。
本申请以下实施例中的术语“用户界面(user interface,UI)”,是应用程序(application,APP)或操作系统(operating system,OS)与用户之间进行交互和信息交换的介质接口,它实现信息的内部形式与用户可以接受形式之间的转换。用户界面是通过java、可扩展标记语言(extensible markup language,XML)等特定计算机语言编写的源代码,界面源代码在电子设备上经过解析,渲染,最终呈现为用户可以识别的内容。用户界面常用的表现形式是图形用户界面(graphic user interface,GUI),是指采用图形方式显示的与计算机操作相关的用户界面。它可以是在电子设备的显示屏中显示的文本、图标、按钮、菜单、选项卡、文本框、对话框、状态栏、导航栏、Widget等可视的界面元素。
本申请以下实施例中提及的“消息”或“信息”,可以指某个具体的消息或信息,也可以包括多个不同的消息或信息,是一些消息或信息的集合,本实施例不作限制。例如,一个消息或信息可以是某个应用程序的一个会话消息,也可以是应用程序的一个会话消息和一个指令信息的集合,也可以是应用程序的会话消息、一个指令信息和终端设备标识的集合,具体释义可以根据上下文情况推断。
对于多个终端组成的系统,用户可以通过软件平台来统一管理该系统中各个分布式设备,例如查看各个设备的状态,调控各个设备的硬件资源、能力,对系统中的业务数据进行分发和同步等。
系统中组成连接的任意两个或多个设备(或服务器)之间,可以通过长连接机制来保持连接状态,如经典蓝牙通过异步无连接(asynchronous connectionless,ACL)长连接以保活。长连接机制是指双方终端设备建立连接后不断开,然后通过该连接传递消息,直到有一方主动结束该连接为止。这种长连接机制可以保证消息及时传送到对端设备,但是其缺点也很明显,维持该长连接会一直占用资源和浪费功耗,不可避免地造成终端设备持续消耗流量和/或电量,缩短了终端设备的待机时间。其中,流量可以指的是网络数据流量,包括终端设备通过无线网络或移动网络发送数据时所产生的网络流量。
系统中组成连接的任意两个或多个设备(或服务器)之间,还可以通过心跳机制来保活。心跳机制指的是,一个设备每隔一段时间向对端设备(或服务器)发送保活消息(keep alive message),如周期性地发送心跳报文,以探测对端设备是否处于存活状态,从而保持两个设备之间的连接长时间有效,进而保证一个设备向对端设备发送数据时可以准确、及时到达。通过发送心跳报文可以维持终端设备的在线状态,在线状态表示该终端设备是通过认证的,收发消息无需再次认证。一旦距离最后心跳报文的发送时间超过指定的时间间隔,该终端设备会被下线,重新连接时,该终端设备需要再次进行认证。
例如,无线保真(wir eless fidelity,Wi-Fi)连接可以每隔十分钟单播(unicast)传输控制协议(transmission control protocol,TCP)连接以保活,或,低功耗蓝牙(bluetooth low energy,BLE)可以每隔五分钟广播(broadcast)一次报文,等远端设备回复以保活。当对端设备回复超时,本端设备就将对端设备的状态由上线变更为下线。
该心跳机制也存在以下缺点:一是在两次心跳探测之间不能够及时确认对端设备的下线状态,在一台设备断开连接后,其他设备需要待下次心跳探测时才能感知该设备已下线。在这期间,用户也无法从界面上发觉该设备已下线,在发出对于该设备的操作指令时,会产生报错,用户体验差。二是如果在运行高网络负载应用进程的情况下,带宽被该应用进程占用,可能出现对端在线设备被误报下线,导致业务异常中断的情况,用户体验差。三是本端设备会持续性的向对端设备发送心跳报文,或者被动接收对端设备发送的心跳信息,并且随着连接的对端设备数量的增多,本端设备需要发送或接收的心跳报文也成倍增加,耗费更多的流量。四是由于终端设备向外发送数据时,需要启动射频模块,而在设备每次发送或接收心跳报文时,都需要启动终端中的射频模块,会把休眠状态下的设备唤醒,将会使得射频模块会被频繁的开启,耗费较多的电量,导致终端设备功耗增加,缩短了终端设备的待机时间。
另一方面,如果对端设备短暂地离开信号覆盖区等情况导致对端设备暂时掉线,当对端设备再次与本端设备通信时,可能需要重新执行认证登录过程,这增加了设备通信的繁琐度,降低通信效率,从而影响用户的体验。
本申请提供了一种探测方法,用于探测设备状态,解决上述设备状态不能及时更改、设备功耗高、繁琐通信等问题。该方法取消了通信中常用的心跳机制,彻底解决功耗高、传输带宽被占用的问题,还进一步优化了通信效率。通过监听设备间被动或主动探测的业务报文收发事件和收发结果,驱动设备在线状态机迁移,设备状态变化可以被快速感知。该方法中增加了主动探测机制,并设立新的设备状态—静默态,以及静默探测接口,支持应用决定该设备各种状态的UI呈现和业务处理策略。设备处于上线状态,当被动探测超时,上线状态会变更为静默状态。在静默态下,本端设备可以按需主动广播探测报文,确认对端设备是否在线,解决设备状态容易报错、用户体验差的问题,有效降低了设备下线时延和功耗,避免了由于短暂掉线导致的频繁上线下线的缺陷,进一步提高通信效率。其中,描述一个对象从一个状态,经过一个事件驱动转变为另一个状态的过程,叫做一次状态迁移,一个对象所具备的所有状态迁移过程叫做状态机。
实施本申请提供的方法,可以解决系统中设备间通过心跳报文保活机制导致的功耗大、占用传输带宽、频繁上线下线等问题,通过引入设备的新状态,即静默态,支持应用决定各种状态的UI呈现和业务处理策略,解决设备状态不能及时更新的问题,进一步优化了通信效率,增强了人机交互性能,可以给用户提供更直观、更易懂、更便利的应用交互界面,通过监听设备间业务报文收发事件和收发结果,驱动设备在线状态机迁移,用户可以实时感知设备状态的变化,提高了用户体验。
下面介绍本申请实施例提供的通信系统10。
图1示出了本申请实施例提供的通信系统10。
该通信系统10包括多个终端设备,这些终端设备可以包括图示的手机、平板电脑(portable android device,PAD)、笔记本电脑、智能电视(又可称为智慧屏、大屏等)、台式电脑、路由器、智能手表、智能手环、耳机、智能音箱等,除了图1所示的上述设备,通信系统10中还可以包括其他类型的电子设备,比如还可以包括个人计算机(personal computer,PC)、桌面型计算机、膝上型计算机、手持计算机、增强现实(augmented reality,AR)设备、虚拟现实(virtual reality,VR)设备、人工智能(artificial intelligence,AI)设备、车机(车载设备)、 游戏机、云主机/云服务器、其他智能穿戴设备等,还可以包括物联网(internet of things,IOT)设备或智能家居设备如智能热水器、智能灯具、智能空调、智能体重秤等等,本申请对设备类型不作任何限制。在本实施例中,终端设备也可简称为终端,终端设备通常是可以提供用户界面、可以与用户交互、为用户提供业务功能的智能电子设备。
示例性的,如图1所示,该通信系统10的组网逻辑模型可以是各个富设备接入以路由器为节点的组网中,多个瘦设备通过与手机连接加入组网,手机与多个富设备点对点连接。其中,富设备可以是指处理器处理能力较强、功能较为丰富的终端设备,如手机、笔记本电脑、平板电脑、智能电视、台式电脑等,瘦设备可以是指处理器处理能力较弱、功能相对较少的终端设备,如智能手表、耳机、智能手环、智能音箱等。瘦设备可以与富设备协同给用户提供更丰富的功能。
在通信系统10中,手机作为中心设备/核心设备,可以与其他协同设备/关联设备建立通信连接,组成“超级终端”。“超级终端”指的是通过分布式技术将多个终端的能力进行整合,存放在一个虚拟的硬件资源池里,根据业务需求统一管理、调度和整合各个终端的能力,来对外提供服务,使得不同终端之间实现快速连接、能力互助、资源共享。例如,手机和笔记本电脑组成超级终端,可以实现将手机界面投屏到笔记本电脑上的投屏功能;手机与智能音箱组成超级终端,可以实现手机遥控智能音箱的功能,等等。
需要说明的是,在本申请的实施例中,可以用“超级终端”来统称手机作为核心设备,以及与手机具有上述关联关系的关联设备共同组成的通信系统10。即,“超级终端”用于表述具有上述关联关系的电子设备的集合。可以理解的,该“超级终端”仅为示例性说明词汇,也可以替换表达为其他词汇,如“智慧协同系统”、“多设备协同系统”等,这并不构成对本申请实施例中通信系统10的具体限定。
通信系统10中各个终端设备之间的通信连接可以是有线连接或无线连接,本实施例不作限制。各个终端之间可以通过建立的通信连接传输数据或指令。
该通信连接可以为近距离通信连接。比如有线连接,如通用串行总线(uniersalserialbus,USB)连接、高清多媒体接口(high definition multimedia interface,HDMI)连接、显示接口(display port,DP)连接等。或者无线连接,如蓝牙(bluetooth,BT)连接、无线保真(wir eless fidelity,Wi-Fi)连接、热点连接、近场通信(near field communication,NFC)、ZigBee等,实现各个终端之间在无账号或异账号情况下通信。无线连接没有连线束缚,用户活动自由度更高。本申请实施例对通信连接的类型不作限制。终端设备中可以配置有蓝牙(bluetooth,BT)模块和/或无线局域网络(wireless local area networks,WLAN)模块。其中,蓝牙模块可以提供包括经典蓝牙(蓝牙2.1)或蓝牙低功耗(bluetooth low energy,BLE)中一项或多项蓝牙通信的解决方案,WLAN模块可以提供包括无线保真点对点连接(wireless fidelity peer-to-peer,Wi-Fi P2P)、无线保真局域网(wireless fidelity local area networks,Wi-Fi LAN)或无线保真软件接入点(wireless fidelity software access point,Wi-Fi softAP)中一项或多项WLAN通信的解决方案。在一些实施例中,Wi-Fi P2P是指允许无线网络中的设备无需通过无线路由器即可以点对点形式相互连接,在
系统中又可称为无线保真直连(wireless fidelity direct,Wi-Fi direct)。建立Wi-FiP2P连接的设备之间可以在不连接网络或热点的情况下,直接通过Wi-Fi(必须处于同一频段)进行数据交换,实现点对点的通信,如传输文件、图片、视频等数据。相对于蓝牙,Wi-Fi P2P具有搜索速度和传输速度更快、传输距离更远等优点。
该通信连接还可以为远距离通信连接。比如各个终端登录同一个账号从而通过互联网Internet实现连接并通信。通信系统10中的多个电子设备也可以登录不同账号,但通过绑定的方式进行连接。例如,手机和智能手表可以登录不同的账号,手机在设备管理应用中,将智能手表和本身进行绑定,之后通过该设备管理应用来连接。
此外,通信系统10中的多个终端设备也可以结合上述任意几种方式来连接并通信,本申请实施例对此不做限制。例如,手机与笔记本电脑之间的通信连接可以是多个连接组合而成,比如,手机或笔记本电脑通过Wi-Fi与路由器建立连接,从而接入网络,或通过蜂窝信号与基站建立连接,从而接入网络,手机与笔记本电脑可以通过网络进行通信。如手机通过网络将信息发送至云端服务器上,云端服务器再将信息通过网络发送给与笔记本电脑。
在一些实施例中,当两个终端设备互为可信设备时,比如该两个终端设备在之前进行匹配或连接过,待再次连接时,这两个终端设备将会自动建立通信连接,然后进行数据交互,无需用户手动再次进行连接或匹配的操作,省时省力。如,已配对蓝牙的电子设备,连接过分享的热点的电子设备,或者,建立过Wi-Fi P2P连接等,可以确认为已建立可信关系,本实施例对此不作限定。
通信系统10中的各终端设备上可以搭载
HarmonyOS或者其他类型的操作系统,通信系统10中的各个终端设备的操作系统可以相同也可以不同,本申请对此不作限制。在一些实施例中,通信系统10中相连接的各个终端均搭载有HarmonyOS,那么该通信系统10可以称为HarmonyOS超级虚拟终端(super virtual device),亦可称为HarmonyOS超级终端。
在一些实施例中,手机或其他终端设备上安装有超级终端应用,方便用户对各个终端设备进行管理。例如,智能手表可以检测用户的运动数据,如走路步数,跑步时长,游泳时长等,并将用户的运动数据同步给手机。同样的,手机也可以将检测到的用户数据同步给智能手表。多个终端配合使用可以实现对用户的运动数据更为准确的检测。
在本实施例中,通信系统10中中心设备可以记录协同设备的连接状态并显示在用户界面中,方便用户快速查看当前协同设备是否在线。如果协同设备为在线状态,表示中心设备与协同设备当前可以正常通信、收发消息。如果协同设备为离线状态,表示当前协同设备与中心设备之间已断开连接,无法正常通信。如果协同设备为静默状态,表示当前协同设备与中心设备之间连接状态不确定,用户可以主动发起探测操作,如点击置灰的协同设备图标,中心设备会向协同设备发出探测消息,如果探测成功,即收到协同设备的响应,则会将协同设备的状态由静默状态变更为上线状态,如果探测失败,即未收到协同设备的响应,则会将协同设备的状态由静默状态变更为下线状态。
需要说明的是,图1所示的通信系统10仅用于辅助描述本申请实施例提供的技术方案,并不对本申请其他实施例构成限制。在实际业务场景中,通信系统10中可以包括更多或更少的终端设备,组网逻辑模型也可以是其他星形、环形、点对点或任意组合形式,本申请对通信系统10中的终端设备类型、终端设备数量、组网逻辑模型、各终端设备间的连接方式等不作任何限定。
下面介绍本申请实施例提供的示例性电子设备100。
图2A为本申请实施例提供的电子设备100的硬件结构示意图。本申请实施例提供的示 例性电子设备100可以但不限于是手机、笔记本电脑、平板电脑、智能手环、智能手表、耳机、个人计算机(personal computer,PC)、智能电视、智能音箱等,还可以为桌面型计算机、膝上型计算机、手持计算机、AR设备、VR设备、AI设备、车机(车载设备)、游戏机、云主机/云服务器、其他智能穿戴设备等,或者是物联网(internet of things,IOT)设备或智能家居设备如智能热水器、智能灯具、智能空调、智能体重秤等其他类型的电子设备,本申请对设备类型不作任何限制。
可以理解的是,本实施例示意的结构并不构成对电子设备100的具体限定。在本申请另一些实施例中,电子设备100可以包括比图示更多或更少的部件,可以增加或减少部分硬件结构,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。图示的部件可以以硬件,软件或软件和硬件的组合实现。
参考图1,电子设备100可以包括处理器110,外部存储器接口120,内部存储器121,通用串行总线(universal serial bus,USB)接口130,充电管理模块140,电源管理模块141,电池142,天线1,天线2,移动通信模块150,无线通信模块160,音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,传感器模块180,按键190,马达191,指示器192,摄像头193,显示屏194,以及用户标识模块(subscriber identification module,SIM)卡接口195等。其中传感器模块180可以包括压力传感器180A,陀螺仪传感器180B,气压传感器180C,磁传感器180D,加速度传感器180E,距离传感器180F,接近光传感器180G,指纹传感器180H,温度传感器180J,触摸传感器180K,环境光传感器180L,骨传导传感器180M等。
处理器110通常用于控制电子设备100的整体操作,可以包括一个或多个处理单元。例如:处理器110可以包括中央处理器(central processing unit,CPU),应用处理器(application processor,AP),调制解调处理器,图形处理器(graphics processing unit,GPU),图像信号处理器(image signal processor,ISP),视频处理单元(video processing unit,VPU),控制器,存储器,视频编解码器,数字信号处理器(digital signal processor,DSP),基带处理器,和/或神经网络处理器(neural-network processing unit,NPU)等。其中,不同的处理单元可以是独立的器件,也可以集成在一个或多个处理器中。控制器可以根据指令操作码和时序信号,产生操作控制信号,完成取指令和执行指令的控制。
处理器110中还可以设置存储器,用于存储指令和数据。在一些实施例中,处理器110中的存储器为高速缓冲存储器。该存储器可以保存处理器110刚用过或循环使用的指令或数据。如果处理器110需要再次使用该指令或数据,可从所述存储器中直接调用。避免了重复存取,减少了处理器110的等待时间,因而提高了系统的效率。
在一些实施例中,处理器110可以包括一个或多个接口。接口可以包括集成电路(inter-integrated circuit,I2C)接口,集成电路内置音频(inter-integrated circuit sound,I2S)接口,脉冲编码调制(pulse code modulation,PCM)接口,通用异步收发传输器(universal asynchronous receiver/transmitter,UART)接口,移动产业处理器接口(mobile industry processor interface,MIPI),通用输入输出(general-purpose input/output,GPIO)接口,用户标识模块(subscriber identity module,SIM)接口,和/或通用串行总线(universal serial bus,USB)接口,串行外设接口(serial peripheral interface,SPI)接口等。
充电管理模块140用于从充电器接收充电输入。其中,充电器可以是无线充电器,也可以是有线充电器。在一些有线充电的实施例中,充电管理模块140可以通过USB接口130接 收有线充电器的充电输入。在一些无线充电的实施例中,充电管理模块140可以通过电子设备的无线充电线圈接收无线充电输入。充电管理模块140为电池142充电的同时,还可以通过电源管理模块141为电子设备供电。
电源管理模块141用于连接电池142,充电管理模块140与处理器110。电源管理模块141接收电池142和/或充电管理模块140的输入,为处理器110,内部存储器121,显示屏194,摄像头193,和无线通信模块160等供电。电源管理模块141还可以用于监测电池容量,电池循环次数,电池健康状态(漏电,阻抗)等参数。
电子设备100的无线通信功能可以通过天线1,天线2,移动通信模块150,无线通信模块160,调制解调处理器以及基带处理器等实现。
天线1和天线2用于发射和接收电磁波信号。电子设备100中的每个天线可用于覆盖单个或多个通信频带。不同的天线还可以复用,以提高天线的利用率。例如:可以将天线1复用为无线局域网的分集天线。在另外一些实施例中,天线可以和调谐开关结合使用。
移动通信模块150可以提供应用在电子设备100上的包括第二代(2th generation,2G)网络/第三代(3th generation,3G)网络/第四代(4th generation,4G)网络/第五代(5th generation,5G)网络等无线通信的解决方案。移动通信模块150可以包括至少一个滤波器,开关,功率放大器,低噪声放大器(low noise amplifier,LNA)等。移动通信模块150可以由天线1接收电磁波,并对接收的电磁波进行滤波,放大等处理,传送至调制解调处理器进行解调。移动通信模块150还可以对经调制解调处理器调制后的信号放大,经天线1转为电磁波辐射出去。在一些实施例中,移动通信模块150的至少部分功能模块可以被设置于处理器110中。在一些实施例中,移动通信模块150的至少部分功能模块可以与处理器110的至少部分模块被设置在同一个器件中。
调制解调处理器可以包括调制器和解调器。
无线通信模块160可以提供应用在电子设备100上的包括无线局域网(wireless local area networks,WLAN)(如无线保真(wireless fidelity,Wi-Fi)网络),蓝牙(bluetooth,BT),全球导航卫星系统(global navigation satellite system,GNSS),调频(frequency modulation,FM),近距离无线通信技术(near field communication,NFC),红外技术(infrared,IR)等无线通信的解决方案。无线通信模块160可以是集成至少一个通信处理模块的一个或多个器件。无线通信模块160经由天线2接收电磁波,将电磁波信号调频以及滤波处理,将处理后的信号发送到处理器110。无线通信模块160还可以从处理器110接收待发送的信号,对其进行调频,放大,经天线2转为电磁波辐射出去。
在一些实施例中,电子设备100的天线1和移动通信模块150耦合,天线2和无线通信模块160耦合,使得电子设备100可以通过无线通信技术与网络以及其他设备通信。所述无线通信技术可以包括全球移动通讯系统(global system for mobile communications,GSM),通用分组无线服务(general packet radio service,GPRS),码分多址接入(code division multiple access,CDMA),宽带码分多址(wideband code division multiple access,WCDMA),时分码分多址(time-division code division multiple access,TD-SCDMA),长期演进(long term evolution,LTE),BT,GNSS,WLAN,NFC,FM,和/或IR技术等。所述GNSS可以包括全球卫星定位系统(global positioning system,GPS),全球导航卫星系统(global navigation satellite system,GLONASS),北斗卫星导航系统(beidou navigation satellite system,BDS),准天顶卫星系统(quasi-zenith satellite system,QZSS)和/或星基增强系统(satellite based augmentation systems, SBAS)。
电子设备100可以通过GPU,显示屏194,以及应用处理器等实现显示功能。GPU为图像处理的微处理器,连接显示屏194和应用处理器。GPU用于执行数学和几何计算,用于图形渲染。处理器110可包括一个或多个GPU,其执行程序指令以生成或改变显示信息。
显示屏194用于显示图像,视频等。显示屏194包括显示面板。显示面板可以采用液晶显示屏(liquid crystal display,LCD),有机发光二极管(organic light-emitting diode,OLED),有源矩阵有机发光二极体或主动矩阵有机发光二极体(active-matrix organic light emitting diode,AMOLED),柔性发光二极管(flex light-emitting diode,FLED),Miniled,MicroLed,Micro-oLed,量子点发光二极管(quantum dot light emitting diodes,QLED)等制造。在一些实施例中,电子设备100可以包括1个或N个显示屏194,N为大于1的正整数。
电子设备100可以通过ISP,摄像头193,视频编解码器,GPU,显示屏194以及应用处理器等实现拍摄功能。
ISP用于处理摄像头193反馈的数据。例如,拍照时,打开快门,光线通过镜头被传递到摄像头感光元件上,光信号转换为电信号,摄像头感光元件将所述电信号传递给ISP处理,转化为肉眼可见的图像。ISP还可以对图像的噪点,亮度进行算法优化。ISP还可以对拍摄场景的曝光,色温等参数优化。在一些实施例中,ISP可以设置在摄像头193中。
摄像头193用于捕获静态图像或视频。物体通过镜头生成光学图像投射到感光元件。感光元件可以是电荷耦合器件(charge coupled device,CCD)或互补金属氧化物半导体(complementary metal-oxide-semiconductor,CMOS)光电晶体管。感光元件把光信号转换成电信号,之后将电信号传递给ISP转换成数字图像信号。ISP将数字图像信号输出到DSP加工处理。DSP将数字图像信号转换成标准的RGB,YUV等格式的图像信号。在一些实施例中,电子设备100可以包括1个或N个摄像头193,N为大于1的正整数。摄像头193可包括但不限于传统彩色摄像头(RGB camera)、深度摄像头(RGB depth camera)、动态视觉传感器(dynamic vision sensor,DVS)相机等。在一些实施例中,摄像头193可以为深度摄像头。深度摄像头可以采集真实环境的空间信息。
内部存储器121可以用于存储计算机可执行程序代码,该可执行程序代码包括指令。处理器110通过运行存储在内部存储器121的指令,从而执行电子设备的各种功能应用以及数据处理。内部存储器121可以包括存储程序区和存储数据区。其中,存储程序区可存储操作系统,至少一个功能所需的应用程序(比如声音播放功能,图像播放功能等)等。存储数据区可存储电子设备使用过程中所创建的数据(比如音频数据,电话本等)等。内部存储器121可以包括一个或多个随机存取存储器(random access memory,RAM)和一个或多个非易失性存储器(non-volatile memory,NVM)。
外部存储器接口120可以用于连接外部的非易失性存储器,实现扩展电子设备的存储能力。外部的非易失性存储器通过外部存储器接口120与处理器110通信,实现数据存储功能。例如将音乐,视频等文件保存在外部的非易失性存储器中。
电子设备100可以通过音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,以及应用处理器等实现音频功能。例如音乐播放,录音等。
音频模块170用于将数字音频信息转换成模拟音频信号输出,也用于将模拟音频输入转换为数字音频信号。音频模块170还可以用于对音频信号编码和解码。
扬声器170A,也称“喇叭”,用于将音频电信号转换为声音信号。电子设备可以通过扬声 器170A收听音乐,或收听免提通话。
受话器170B,也称“听筒”,用于将音频电信号转换成声音信号。当电子设备接听电话或语音信息时,可以通过将受话器170B靠近人耳接听语音。
麦克风170C,也称“话筒”,“传声器”,用于将声音信号转换为电信号。在另一些实施例中,电子设备可以设置两个麦克风170C,除了采集声音信号,还可以实现降噪功能。在另一些实施例中,电子设备还可以设置三个,四个或更多麦克风170C,实现采集声音信号,降噪,还可以识别声音来源,实现定向录音功能等。
耳机接口170D用于连接有线耳机。耳机接口170D可以是USB接口130,也可以是3.5mm的开放移动电子设备平台(open mobile terminal platform,OMTP)标准接口,美国蜂窝电信工业协会(cellular telecommunications industry association of the USA,CTIA)标准接口。
电子设备100可以包括一个或多个按键190,这些按键190可以控制电子设备100,为用户提供访问电子设备100上的功能。按键190的形式可以是按钮、开关、刻度盘等机械式案件,也可以是触摸或近触摸式传感设备(如触摸传感器)。电子设备100可以接收按键输入,产生与电子设备100的用户设置以及功能控制有关的键信号输入。按键190可以包括开机键,音量键等。
马达191可以产生振动提示。马达191可以用于来电振动提示,也可以用于触摸振动反馈。例如,作用于不同应用(例如拍照,音频播放等)的触摸操作,可以对应不同的振动反馈效果。作用于电子设备100不同区域的触摸操作,马达191也可对应不同的振动反馈效果。触摸振动反馈效果还可以支持自定义。
指示器192可以是指示灯,可以用于指示充电状态,电量变化,也可以用于指示消息,通知等。
电子设备100还可以包括其他输入输出接口,可以通过合适的输入输出接口将其他装置连接到电子设备100。组件例如可以包括音频/视频插孔,数据连接器等。
电子设备100上装备有一个或多个传感器,包括但不限于压力传感器180A,陀螺仪传感器180B,气压传感器180C,磁传感器180D,加速度传感器180E,距离传感器180F,接近光传感器180G,指纹传感器180H,温度传感器180J,触摸传感器180K,环境光传感器180L,骨传导传感器180M等。
压力传感器180A用于感受压力信号,可以将压力信号转换成电信号。陀螺仪传感器180B可以用于确定电子设备100的运动姿态。气压传感器180C用于测量气压。磁传感器180D包括霍尔传感器。加速度传感器180E可检测电子设备100在各个方向上(一般为三轴)加速度的大小。当电子设备100静止时可检测出重力的大小及方向。还可以用于识别电子设备姿态,应用于横竖屏切换,计步器等应用。距离传感器180F,用于测量距离。接近光传感器180G可以包括例如发光二极管(LED)和光检测器,例如光电二极管。电子设备100使用光电二极管检测来自附近物体的红外反射光。当检测到充分的反射光时,可以确定电子设备100附近有物体。环境光传感器180L用于感知环境光亮度。指纹传感器180H用于采集指纹。温度传感器180J用于检测温度。骨传导传感器180M可以获取振动信号。
触摸传感器180K,也称“触控器件”。触摸传感器180K可以设置于显示屏194,由触摸传感器180K与显示屏194组成触摸屏,也称“触控屏”。触摸传感器180K用于检测作用于其上或附近的触摸操作。触摸传感器可以将检测到的触摸操作传递给应用处理器,以确定触摸事件类型。可以通过显示屏194提供与触摸操作相关的视觉输出。在另一些实施例中,触摸 传感器180K也可以设置于电子设备100的表面,与显示屏194所处的位置不同。
SIM卡接口195用于连接SIM卡。SIM卡可以通过插入SIM卡接口195,或从SIM卡接口195拔出,实现和电子设备100的接触和分离。电子设备100可以支持1个或N个SIM卡接口,N为大于1的正整数。SIM卡接口195可以支持Nano SIM卡,Micro SIM卡,SIM卡等。同一个SIM卡接口195可以同时插入多张卡。所述多张卡的类型可以相同,也可以不同。SIM卡接口195也可以兼容不同类型的SIM卡。SIM卡接口195也可以兼容外部存储卡。电子设备100通过SIM卡和网络交互,实现通话以及数据通信等功能。在一些实施例中,电子设备100采用eSIM,即:嵌入式SIM卡。eSIM卡可以嵌在电子设备100中,不能和电子设备100分离。
电子设备100的软件系统可以采用分层架构,事件驱动架构,微核架构,微服务架构,或云架构。本申请实施例以分层架构的移动操作系统为例,示例性说明电子设备100的软件结构。
图2B是本申请实施例的电子设备100的软件结构框图。
分层架构将软件分成若干个层,每一层都有清晰的角色和分工。层与层之间通过软件接口通信。在一些实施例中,可以将移动操作系统分为四层,从上至下分别为应用程序层,程序框架层/核心服务层,底层库和运行时,以及内核层。
应用程序层可以包括一系列应用程序包。
如图2B所示,应用程序包可以包括相机,图库,日历,通话,地图,导航,WLAN,蓝牙,音乐,视频,设置等应用程序。其中,应用程序服务可以获取到对端设备的设备状态,并呈现在UI界面上,方便用户感知对端设备的连接状态。
程序框架层为应用程序层的应用程序提供应用编程接口(application programming interface,API)和编程框架。程序框架层包括一些预先定义的函数。
如图2B所示,程序框架层可以包括窗口管理器,内容提供器,视图系统,会话管理器,资源管理器,通知管理器,设备状态管理器等。
窗口管理器用于管理窗口程序。窗口管理器可以获取显示屏大小,判断是否有状态栏,锁定屏幕,截取屏幕等。
内容提供器用来存放和获取数据,并使这些数据可以被应用程序访问。这些数据可以包括视频,图像,音频,拨打和接听的电话,浏览历史和书签,电话簿等。
视图系统包括可视控件,例如显示文字的控件,显示图片的控件等。视图系统可用于构建应用程序。显示界面可以由一个或多个视图组成的。例如,包括短信通知图标的显示界面,可以包括显示文字的视图以及显示图片的视图。
会话管理器用于管理会话状态和会话生命周期,如创建会话、保持会话、关闭会话、移除会话等。
资源管理器为应用程序提供各种资源,比如本地化字符串,图标,图片,布局文件,视频文件等等。
通知管理器使应用程序可以在状态栏中显示通知信息,可以用于传达告知类型的消息,可以短暂停留后自动消失,无需用户交互。比如通知管理器被用于告知下载完成,消息提醒等。通知管理器还可以是以图表或者滚动条文本形式出现在系统顶部状态栏的通知,例如后 台运行的应用程序的通知,还可以是以对话窗口形式出现在屏幕上的通知。例如在状态栏提示文本信息,发出提示音,电子设备振动,指示灯闪烁等。
设备状态管理器,用于记录、变更对端设备的状态,在一些实施例中,对端设备状态包括上线状态、静默状态、下线状态等。对端设备处于上线状态时,当满足静默状态的触发条件时,如最后收发对端设备报文的时间与当前时间的时间差超过定时器所设置的期限,设备状态管理器可以将对端设备的状态由上线状态变更为静默状态。对端设备处于静默状态时,如果成功收发对端设备的报文,设备状态管理器可以将对端设备的状态由静默状态变更为上线状态。对端设备处于静默状态时,如果收发对端设备的报文失败,设备状态管理器可以将对端设备的状态由静默状态变更为下线状态。对端设备处于上线状态时,如果收发对端设备的报文失败,设备状态管理器可以将对端设备的状态由上线状态变更为下线状态。对端设备处于下线状态时,如果成功收发对端设备的报文,设备状态管理器可以将对端设备的状态由下线状态变更为上线状态。更详细的说明可以参考后述实施例。
运行时包括核心库和虚拟机,负责系统的调度和管理,可以指程序运行时所需的一切代码库、框架等。例如,对于C语言来说,运行时包括一系列C程序运行所需的函数库。对于Java语言来说,除了核心库之外,运行时还包括Java程序运行所需的虚拟机等。上述核心库可包括Java语言需要调用的功能函数。应用程序层和程序框架层运行在虚拟机中。虚拟机将应用程序层和程序框架层的java文件执行为二进制文件。虚拟机用于执行对象生命周期的管理,堆栈管理,线程管理,安全和异常的管理,以及垃圾回收等功能。
底层库可以包括多个功能模块。例如:表面管理器(surface manager),媒体库(Media Libraries),三维图形处理库(例如:OpenGL ES),2D图形引擎(例如:SGL)等。
表面管理器用于对显示子系统进行管理,并且为多个应用程序提供了2D和3D图层的融合。
媒体库支持多种常用的音频,视频格式回放和录制,以及静态图像文件等。媒体库可以支持多种音视频编码格式,例如:MPEG4,H.264,MP3,AAC,AMR,JPG,PNG等。
三维图形处理库用于实现三维图形绘图,图像渲染,合成,和图层处理等。
2D图形引擎是2D绘图的绘图引擎。
内核层是硬件和软件之间的层。内核层至少包含显示驱动,摄像头驱动,音频驱动,传感器驱动。
这里结合启动拍照场景,示例性说明电子设备100软件以及硬件相配合的工作流程。
当触摸传感器180K接收到触摸操作,相应的硬件中断被发给内核层。内核层将触摸操作加工成原始输入事件(包括触摸坐标,触摸操作的时间戳等信息)。原始输入事件被存储在内核层。应用程序框架层从内核层获取原始输入事件,识别该输入事件所对应的控件。以该触摸操作是触摸单击操作,该单击操作所对应的控件为相机应用图标的控件为例,相机应用调用应用框架层的接口,启动相机应用,进而通过调用内核层启动摄像头驱动,通过摄像头193捕获静态图像或视频。
以上对电子设备100的软件架构的介绍仅为示例,可以理解的是,本发明实施例示意的软件架构并不构成对本申请构成具体限定。在本申请另一些实施例中,电子设备100的软件架构可以包括比图示更多或更少的模块,或者组合某些模块,或者拆分某些模块,或者不同的架构布置。图示的部件可以以硬件,软件或软件和硬件的组合实现。
下面结合附图说明本申请提供的技术方案。
通信系统10中任意两个及两个以上的设备均可适用于本申请提供的技术方案,为了方便理解,下面以两个设备之间的交互为示例进行说明,多个设备之中的任意两个设备之间的交互可以参考该示例说明。
为了方便区分和理解,下面将两个发生交互的设备分别称为本端设备和对端设备,本端设备可以标记对端设备的状态,本申请实施例对本端设备或对端设备的设备类型不作任何限制,例如,在一些示例中,本端设备可以为手机,或平板电脑,或PC等设备,对端设备可以为手机,或平板电脑,或PC,或智能手表,或智能手环,或耳机等设备。
在本申请提供的实施例中,本端设备对对端设备标记的状态包括:上线状态、下线状态、静默状态,等等。
“上线状态(或称上线、上线态)”是指本端设备发现对端设备并建立连接、可以正常通信的状态,又可称为“在线状态(或称在线、在线态)”。当确认对端设备处于上线状态时,本端设备可以获知到当前与对端设备可以顺畅通信,相互之间可以成功发送或接收消息。
“下线状态(或称下线、下线态)”是指本端设备未发现对端设备,其之间的连接断开或连接异常,本端设备与对端设备无法通信的状态,又可称为“离线状态(或称离线、离线态)”。当确认对端设备处于下线状态时,本端设备可以获知到当前与对端设备无法通信,相互之间发送或接收消息存在障碍。
“静默状态(或称静默、静默态)”是上线状态与下线状态之间的一个中间态,表示不确定当前对端设备是否处于可通信的一种状态,又可称为“存留状态”、“沉默状态”等。对端设备处于静默状态是在一定时间内双方设备之间暂且没有收发通信消息(或报文),需要通过再次探测确认对端设备处于上线状态或下线状态。具体的两个设备间没有通信消息的原因,可能是两个设备之间暂时没有业务往来,也可能是对端设备离开了本端设备连接网络覆盖区域,或者是对端设备为了省电进入睡眠模式暂时关闭了无线连接功能等。
在一些实施例中,可以设置定时器作为被动探测,当被动探测超过设定的时间阈值的时候,会触发将对端设备的状态由上线状态更改为静默状态。在对端设备处于静默状态的情况下,本端设备发起主动探测,主动探测可以指的是本端设备向对端设备发送一个探测消息。如果探测消息发送成功,双方可以正常通信,可以触发将对端设备的状态由静默状态更改为上线状态。如果探测消息发送失败,双方无法正常通信,可以触发将对端设备的状态由静默状态更改为下线状态。
可以理解的是,本申请中“上线状态”、“下线状态”、“静默状态”等,仅为示例用词,并不对其他实施例构成限定,在其他实施例中,也可以用其他词汇代替这些用语,具体应以所述用词所表示的含义为参考。
在本端设备与对端设备组成的系统中,可以设有状态管理器,该状态管理器可以对对端设备所处的状态使用编码标记,如用0表示上线状态、用1表示下线状态、用2表示静默状态,本实施例不作限制。
在本端设备发现对端设备,并成功建立连接后,本端设备可以显示对端设备为上线状态。各个实施例对本端设备与对端设备之间建立的通信连接的具体类型不作任何限制。可例如为Wi-Fi P2P连接,蓝牙连接,USB连接等等,还可以是网络连接,或者通过接入点(access point,AP)建立的通信连接,如在本端设备和对端设备连接路由器加入同一个Wi-Fi网络后,本端设备和对端设备可以通过该Wi-Fi网络建立通信连接。
在本端设备与对端设备建立连接之前,本端设备在发现对端设备后,需要对其进行认证(identification),认证是指根据声明者持有的特定信息,来确认声明者的身份。常见认证方式包括用户名/密码、生物特征(指纹、面部、虹膜、语音等)、短信验证码、二维码、手势密码等。认证成功后,本端设备和对端设备之间可以建立通信连接,本端设备将对端设备的设备状态迁移到上线状态,本端设备和对端设备之间可以相互传送消息,进行正常通信。这个过程也可以称为“登录”。
在首次建立连接后,在对端设备上可以保存认证信息,或者本端设备将对端设备标记为可信任设备,这样下次对端设备与本端设备建立连接时,可以自动与本端设备建立连接,无需用户操作输入认证信息。
参考图3,图3为状态迁移示意图,示出了对端设备上线状态、下线状态、静默状态等各状态之间的迁移情况,并且,在图3中还标注说明了状态迁移条件。
①上线状态→下线状态
当对端设备处于上线状态时,当本端设备向对端设备发送业务报文失败时,会将对端设备的状态从上线状态迁移到下线状态。
②下线状态→上线状态
当对端设备处于下线状态时,当本端设备与对端设备建立连接,并可以成功向对端设备发送业务报文,或接收到对端设备业务报文时,会将对端设备的状态从下线状态迁移到上线状态。
③上线状态→静默状态
本端设备内部设置设备状态位和定时器(或计数器),设备状态位用于标记设备状态,包括复位、置位等状态位,定时器用于计时。对端设备状态处于上线状态下,在本端设备最后一次接收到对端设备心跳报文的时刻的同时,本端设备同步启动定时器(或计数器)。在定时器设定的一定时间阈值之内接收到对端设备的心跳报文,就可以维持上线状态。当在定时器设定的一定时间阈值之内(如第一时限)未收到对端设备的心跳报文,即最后收发报文的时间与当前时间的时间差超过定时器设置的期限,就可以将对端设备的状态由上线状态变更为静默状态。
④静默状态→上线状态
当对端设备状态处于静默状态时,当本端设备的应用调用静默探测接口,主动或被动触发静默探测,如主动发送广播探测报文。如果探测成功,如收到对端设备的回应,则将对端设备的状态从静默状态变更为上线状态。
相对于单播,发送广播探测报文的优点是广播在单位时间内发送的报文次数多,报文不易丢失,发送成功率更高。
关于本端设备触发静默探测,可以由用户主动触发,比如当用户打开应用,或者说,当应用转为前台运行时,又或者,当用户点击特定控件触发探测,应用就会调用静默探测接口,发送广播探测报文,探测对端设备是否在线,如果收到对端设备的回应,则可以将对端设备的状态从静默状态变更为上线状态。
当对端设备状态处于静默状态时,当本端设备被动接收到对端设备的新的消息/报文时,也会将对端设备的状态从静默状态变更为上线状态。
⑤静默状态→下线状态
当对端设备状态处于静默状态时,当本端设备的应用调用静默探测接口,主动或被动触发静默探测,如主动发送广播探测报文。如果探测失败,如未收到对端设备的回应,则将对端设备的状态从静默状态变更为下线状态。
结合图3,参考图4,图4也是对端设备各状态之间的状态迁移图,尤其是更详细地示出了由上线状态变更为静默状态的一种具体机制。
该状态迁移机制的实施例包括:
(1)设备上线
在本端设备发现对端设备,成功认证并成功建立连接后,本端设备可以显示对端设备为上线状态。各个实施例对本端设备与对端设备之间建立的通信连接的具体类型不作任何限制。如Wi-Fi P2P连接,蓝牙连接,USB连接,网络通信连接等等。
(2)上线状态→下线状态
当对端设备处于上线状态时,当本端设备向对端设备发送业务报文失败时,会将对端设备的状态从上线状态迁移到下线状态。在设备下线的同时,(o)终止定时器。
(3)下线状态→上线状态
当对端设备处于下线状态时,当本端设备与对端设备再次成功建立连接,可以成功向对端设备发送业务报文,或接收到对端设备业务报文时,会将对端设备的状态从下线状态迁移到上线状态。
(4)上线→静默
本端设备内部设置设备状态位和定时器(或计数器),设备状态位用于标记设备状态,包括复位、置位等状态位,定时器用于计时。在一个示例中,复位用0表示,置位用1表示。
当对端设备状态变更为上线状态时,本端设备(a)初始化设备状态位,并同步(c)启动定时器(或计数器)。本实施例对定时器设置的时间不作限制。
在定时器未溢出中断的时候,每当本端设备向对端设备成功发送报文,或成功接收对端设备的报文时,会触发本端设备(b)复位设备状态位,并同时重新(c)启动定时器。
当定时器计时超时第一时间后,即(d)定时器溢出中断,本端设备(e)读取设备状态位。如果读取到当前设备状态位为复位,即(f)设备状态位不是置位,则将(g)设备状态位更改为置位,同时(h)结束定时器溢出中断,定时器重新计时,即重新(c)启动定时器。
当定时器超时第二时间后,即(d)定时器再次溢出中断时,本端设备(e)读取设备状态位,如果读取到(i)当前设备状态位为置位,则满足静默状态的触发条件,那么会(j)变更对端设备的标识状态,即将对端设备的状态从上线状态变更为静默状态,同时(k)终止定时器。即,当处于复位状态的定时器连续超时两次后,则将对端设备的状态从上线状态变更为静默状态,同时终止定时器。
其中,第一时间和第二时间的时间长短可以相同,也可以不同,本申请实施例对此不作限制。
(5)静默→上线
当对端设备状态处于静默状态时,当本端设备的应用调用静默探测接口,主动或被动触发静默探测,如主动广播探测报文。如果探测成功,如收到对端设备的回应,则将对端设备的状态从静默状态变更为上线状态。
相对于单播,发送广播探测报文的优点是广播在单位时间内发送的报文次数多,报文不 易丢失,发送成功率更高。
关于本端设备触发静默探测,可以由用户主动触发,比如当用户打开应用,或者说,当应用转为前台运行时,又或者,当用户点击特定控件触发探测,应用就会调用静默探测接口,发送广播探测报文,探测对端设备是否在线,如果收到对端设备的回应,则可以将对端设备的状态从静默状态变更为上线状态。
当对端设备状态处于静默状态时,当本端设备被动接收到对端设备的新的报文/消息时,也会将对端设备的状态从静默状态变更为上线状态。
(6)静默→下线
当对端设备状态处于静默状态时,当本端设备的应用调用静默探测接口,触发静默探测,如主动发送广播探测报文。如果探测失败,如未收到对端设备的回应,则将对端设备的状态从静默状态变更为下线状态,同时终止定时器。
在一些实施例中,本端设备上安装有应用,该应用中可以显示对端设备的状态,方便用户通过用户界面感知对端设备的状态。
参考图5所示的用户界面500,文件应用中可以显示与本端设备连接的对端设备的标识和名称,如用户界面500中的设备状态栏501,设备状态栏501中可以显示有与本机建立连接的设备标识,如MateBook设备图标502、MatePad设备图标、HuaWei P50设备图标503。处于上线状态、静默状态、下线状态的设备标识不同,方便用户快速区分设备状态。如在本实施例中,设备状态栏501中MateBook设备图标502显示为高亮,表示MateBook设备处于上线状态,区别于高亮显示,HuaWei P50设备图标503显示为灰暗,表示HuaWei P50设备处于静默状态,而下线状态的设备不显示在设备状态栏501中。该示例不对其他可能的实施例构成限制,在其他的实施例中,上线状态、静默状态、下线状态也可以以不同颜色显示,只要便于用户区分就可。
在一种实施方式下,如图6A所示,用户想查看静默状态下的设备是否还在保持连接,可以在用户界面500中点击静默标识下的HuaWei P50设备图标503,此时触发静默探测,本端设备向对端设备主动发送探测报文。如果收到对端设备的探测回应,则HuaWei P50设备由静默状态变更为上线状态,即图6A中用户界面510所示,HuaWei P50设备图标503由灰暗变为高亮。如果在规定时间内未收到对端设备的探测回应,则HuaWei P50设备由静默状态变更为下线状态,即图6B中用户界面520所示,HuaWei P50设备图标503消失,不显示在设备状态栏501中。该示例不对其他可能的实施方式构成限制,在其另一个实施例中,无需用户主动点击设备图标发起静默探测,也可以是用户在打开应用的时刻,或者说将应用调用至前台运行的时刻,应用自动向静默状态的设备发起静默探测,如果还处在连接活跃状态就变更为上线状态,如果已断开连接就变更为下线状态,电子设备也可以不需要显示静默状态的标记,静默状态的设备的状态转换确认会在非常短的时间内完成,只向用户呈现上线状态的设备和/或下线状态的设备。
可以理解的是,本申请实施例中所描述的各个用户界面仅为示例界面,用于辅助阅读者理解本申请描述的技术方案,并不对本申请其他实施例构成限制。在其他实施例中,用户界面中可以采用不同的界面布局,可以包括更多或更少的控件,可以增加或减少其他功能选项,可以根据实际情况增减更多或更少的用户界面,或设计不同的人机交互操作等,使得用户界面更迎合用户的使用体验。示例界面也可以迁移用于其他类型设备上,只要基于本申请提供 的同一发明思想的技术方案,都在本申请保护范围内,这里不多赘述。
结合图3、图4,下面参考图7、图8、图9、图10说明本端设备(设备A)与对端设备(设备B)之间具体的状态变更过程。其中,设备A,又称发现端设备,包括应用服务、近距离通信服务、状态管理服务等服务,设备B,又称被发现端设备,也包括应用服务、近距离通信服务、状态管理服务等服务。
本申请实施例对设备发现、设备连接所使用的具体技术手段不作任何限制。设备A与设备B之间的通信连接可以是近距离通信连接或远距离通信连接,如USB连接、蓝牙连接、Wi-Fi P2P连接、WLAN连接、无线射频识别(radio frequency identification,REID)连接、ZigBee连接等,本实施例不作限制。或者,设备A和设备B可以登录有同一个账号,或者其登录账号属于同一群组(如同一家庭账号),也可以是不同账号,通过云服务器连接,本实施例对这些不作限制。
图7为设备A与设备B之间发现、连接、认证的信息流转过程示意图。具体包括:
设备发现阶段:
S101,设备B发布服务(publish Service)。
设备B的应用服务通知近距离通信服务发布可被发现的服务,方便附近的其他设备发现自己。
S102,设备A开始查找(start Discovery)。
设备A的应用服务通知近距离通信服务开启查找周围设备。
S103,设备A和设备B的近距离通信服务进行广播扫描。
包括主动发现和被动发现两种模式。
主动发现:发现侧设备发送搜索广播,被发现侧设备回复该广播。
被动发现:被发现侧设备主动发送设备信息广播,发现侧设备监听广播。
即,发现端设备通过广播或者监听手段发现周边设备,并提示调用者选择设备进行连接。被发现端设备通过反馈监听或者广播手段对周边设备通告自身的设备信息,使自身设备可以被周边的设备发现感知。
S104,设备A发现设备B(on Device Found)。
设备B在收到设备A的广播信息后,反馈自身的设备信息,设备B被设备A发现。设备发现的结果包含设备基本信息和连接能力信息。轻量级设备侧,一般仅需要支持被发现功能。
示例性的,对于低功耗蓝牙(bluetooth low energe,BLE),可以通过BLE广播和扫描实现低功耗的发现设备,设备发现支持filter函数的过滤。BLE基于低功耗发现协议栈实现后台实时发现。BLE支持主动发现和被动发现两种模式。主动发现:发现侧设备发送BLE搜索广播,被发现侧设备回复该广播。被动发现:被发现侧设备主动发送设备信息广播,发现侧设备监听广播。
示例性的,对于Wi-Fi,仅能发现已经加入局域网的设备。Wi-Fi的无线接入点与终端设备(AP-STA)连接模式下或者有线网络连接下,协议层均使用互联网协议(internet protocol,IP)层组播或者广播机制进行发现与连接。Wi-Fi可以基于受限应用协议(constrained application protocol,COAP)协议实现发现对端设备。具体的,发现侧设备在局域网内以COAP协议格式发送一个带有discovery信息的广播。被发现侧设备收到discovery广播的设备单播 回复自己的设备信息。
非加密信息交换阶段:
在设备A发现设备B之后,在业务触发时或业务触发前,为了方便通信,基于Wi-Fi/BLE/USB等不同通信方式,设备A与设备B之间会建立一条专用的物理链路通道用于通信。在资源有限的通信系统中,如BLE,通道无法独占,因此在BLE中建立了连接可以理解为,在约定的时间段内,双方都到一个指定的物理信道Channel上通信。
S105,设备A打开通道(open Channel)。
设备A的应用服务通知近距离通信服务打开通道。
S106,认证消息服务。
设备A与设备B之间根据给定连接建立通道。
S107,设备B打开通道(on Channel opened)。
S108,设备A的应用服务通知近距离通信服务发送消息(send Message)。
S109,设备A的应用服务通知近距离通信服务认证设备(verify Device)。
连接认证阶段:
当建立信任关系的设备A与设备B在进行通信时,双方首先完成信任关系绑定,然后基于存储在本地的对端身份公钥相互进行认证。在每次通信时完成双向身份认证以及会话密钥协商,之后设备使用此会话密钥来解密双方设备间的传输通道。
S110,安全令牌服务(security token service,STS)认证。
设备A对设备B执行STS认证,基于双方身份标识密钥协商会话密钥。认证成功后,返回设备B的ID和派生密钥,前述给定连接转为安全连接。
S111,设备认证通过(on Device Verify Pass)。
设备A的近距离通信服务通知应用服务该设备B认证通过。
S112,连接已认证设备(connect Verified Device)。
设备A的应用服务通知近距离通信服务向已认证的设备B发起连接。
S113,连接流程。
设备A与设备B建立安全连接。
S114,保存连接。
S115,近距离通信服务通知状态管理器初始设备状态位,状态管理器开启超时计数。
在设备B切换至上线状态的时刻,设备状态管理器初始化设备状态位,并启动定时器,定时器用于计量设备B是否达到转为静默状态的时限。
S116,设备A的近距离通信服务告知应用服务已连接设备B(on Connected)。
图8为设备A与设备B之间建立连接之后,数据传输、状态更新的信息流转过程示意图。传输服务模块可以向业务模块提供会话session管理和基于session的数据收发功能,并且通过加密功能提供收发报文的加解密保护。即,使用会话密钥加密通信数据,设备A与设备B进行加密通信。具体包括:
创建会话服务阶段:
S201,设备A与设备B分别创建会话服务器(create Session Server)。
业务建立会话与执行传输之前,设备A与设备B的应用服务分别通知自己近距离通信服务创建会话服务器,并注册监听回调函数。该监听回调函数用于在数据传输各个环节,被动监听设备间交互的报文,包括控制报文和数据报文,并基于报文收发事件,重置设备状态位。
创建会话服务器的过程中,设备A与设备B并没有收发对方报文,因此定时器持续计数。
建立会话阶段:
S202,设备A打开会话通道(open Session)。
在设备A与设备B创建会话服务器之后,接收端即设备B等待发送端的创建会话的消息,发送端即设备A根据会话服务的名称和设备ID建立一个会话,设备A的应用服务通知近距离通信服务打开会话通道。
S203,设备A通知设备B创建传输通道。
获取到设备A的近距离通信服务向设备B的近距离通信服务发送消息,设备A与设备B的状态管理器重置设备状态位,即每次成功发送或接收消息时,会将设备状态位复位。
S204,设备B即接收端收到回调,打开会话通道(on Session opened)。
设备B的近距离通信服务接收到设备A的打开会话通道的请求后,告知应用服务,应用服务打开会话通道,并返回结果。
S205,设备B向设备A返回已打开会话通道的结果。
获取到设备B的近距离通信服务向设备A的近距离通信服务发送消息,设备A与设备B的状态管理器重置设备状态位,即每次成功发送或接收消息时,会将设备状态位复位。
S206,设备A即发送端收到回调,已打开会话通道(on Session opened)。
S207,返回会话(return session)。
设备A的应用服务确认该会话连接生效。至此,已建立并打开设备A与设备B之间的传输通道,成功建立会话连接。
发送数据阶段:
在设备A与设备B成功建立会话连接之后,可以通过该会话连接互相发送或接收指令、数据等。发送或接收的数据可以包括但不限于以下三种数据类型:Byte型,用于大量数据交换;Message型,用于即时消息;File型,用于文件发送。
S208,设备A的应用服务向近距离通信服务发送会话消息(session send Message)。
S209,设备A的近距离通信服务向设备B的近距离通信服务发送数据。
获取到设备A的近距离通信服务成功向设备B的近距离通信服务发送消息,设备A与设备B的状态管理器重置设备状态位。
S210,设备B的应用服务接收到近距离通信服务收到的会话消息(on Message Received)。
S211,设备B向设备A返回已收到消息的结果。
获取到设备B向设备A成功返回结果的报文,设备A与设备B的状态管理器重置设备状态位。
关闭会话阶段:
关闭设备间的传输通道,释放相关资源。
S212,设备A的应用服务通知近距离通信服务关闭会话(close Session)
S213,设备A的近距离通信服务向设备B的近距离通信服务发送关闭会话的消息。
获取到设备A的近距离通信服务成功向设备B的近距离通信服务发送消息,设备A与设备B的状态管理器重置设备状态位。
S214,设备B的应用服务接收到近距离通信服务收到的关闭会话的消息(on Session Closed),设备B的应用服务关闭该会话。
移除会话服务阶段:
S215,设备A与设备B分别删除会话服务器(remove Session Server)。
在设备A的应用服务与设备B的应用服务关闭会话之后,设备A与设备B的应用服务分别通知自己近距离通信服务删除会话服务器,并撤销先前注册的监听回调函数。
删除会话服务器的过程中,设备A与设备B并没有收发对方报文,因此定时器持续计数。
图9为设备A与设备B正常连接状态下,突发上线变下线,和下线恢复上线的信息流转过程示意图。示例性的,上线状态下,设备A向设备B发送的控制报文或者业务报文发送失败会触发上线变更为下线。下线状态下,设备A成功接收到设备B发送的控制报文或者业务报文会触发下线变更为上线。基于状态管理器(或称设备状态迁移状态机),当设备状态(包括“发现”、“上线”、“下线”、“静默”等)发生变更时,实时调用应用注册的监听回调函数,通知应用该对端设备状态发生变更。
突发下线阶段:
S301,设备A的应用服务将消息发送给近距离通信服务。
设备A向设备B发送消息,设备A的应用服务将获取到的消息传递给近距离通信服务,再由设备A的近距离通信服务将消息发送给设备B的近距离通信服务。
S302,设备A的近距离通信服务向设备B的近距离通信服务发送消息。
S303,设备A的近距离通信服务获知消息发送失败,停止超时计数,状态管理器将设备B由上线状态变更为下线状态。
当对端设备即设备B处于上线状态下,基于确定的重发策略重试若干次后,依然不能成功完成报文发送(包括控制报文和数据报文),确认报文发送失败事件,触发设备B下线。
S304,设备A的近距离通信服务通知应用服务,设备B的状态由上线状态变更为下线状态。
S305,设备A的应用服务刷新应用界面,屏蔽下线设备,即不显示设备B的标识。
在一些实施例中,下线设备的标识可以不显示在应用界面中。
下线恢复阶段:
S306,设备A的近距离通信服务接收到下线设备即设备B的近距离通信服务发送的消息。
当对端设备即设备B处于下线状态时,本端设备即设备A接收到该对端设备的报文(包括控制报文和数据报文),触发设备B重新上线。
S307,设备A的近距离通信服务向设备B的近距离通信服务发送探测消息。
为了确认设备A与设备B之间连接有效,设备A向设备B发送探测消息。
S308,设备A的近距离通信服务获知该探测消息发送成功,即设备B成功接收该探测消息,状态管理器将设备B由下线状态变更为上线状态,并重置设备状态位。
S309,设备A的近距离通信服务通知应用服务,设备B的状态由下线状态变更为上线状态。
S310,设备A的应用服务刷新应用界面,显示上线设备,即显示设备B的标识。
在一些实施例中,上线设备的图标可以显示在应用界面中,以高亮标识显示,方便用户快速感知与本端设备正在连接、可以正常通信的对端设备。
在设备B切换至上线状态的时刻,设备状态管理器重置设备状态位的同时,定时器开始工作,重新超时计数。
图10为设备A将设备B的状态由上线变更为静默的情况,以及,在静默状态下,主动触发探测,探测对端设备是否在线的情况下的信息流转过程示意图。基于状态管理器(或称设备状态迁移状态机),当设备状态发生变更时,实时调用应用注册的监听回调函数,通知应用该对端设备状态发生变更。
在一些实施例中,在设备A将设备B设为静默状态时,设备A与设备B之间可以关闭会话,但不移除会话服务。在静默状态变更为下线状态时,再移除会话服务。在静默状态恢复到上线状态时,再将会话状态恢复到“正常服务状态”。
或者,在一些实施例中,在设备A将设备B设为静默状态时,设备A与设备B之间并不关闭会话,可以将会话状态从“正常服务状态”迁移到“会话保持状态”。在静默状态恢复到上线状态时,再将会话状态恢复到“正常服务状态”。在静默状态变更为下线状态时,再关闭并移除会话服务。
变更通知(上线→静默)阶段:
S401,状态管理器持续计数,当发现超时,设备A的状态管理器向近距离通信服务通知状态变更,设备B由上线状态变更为静默状态。
当在定时器设定的一定时间阈值之内未收到对端设备的心跳报文,即最后收发报文的时间与当前时间的时间差超过定时器设置的期限,就可以将对端设备的状态由上线状态变更为静默状态。
参考前述实施例,可以设置在定时器连续溢出中断两次或两次以上时,触发将设备B由上线状态变更为静默状态。
S402,设备A的近距离通信服务通知应用服务,设备B的状态由上线状态变更为静默状态。
S403,设备A的应用服务刷新应用界面,置灰静默设备。
置灰静默设备即设备A将设备B的标识显示为与上线设备的高亮标识不同的灰色标识,不同的标识有助于用户区分上线设备与静默设备。
用户触发探测阶段:
S404,设备A检测到针对于静默设备的用户操作。
本申请实施例对触发主动探测的用户操作不作限制,在一些实施例中,用户点击置灰的静默设备图标,可以触发应用发出主动探测消息,在另一些实施例中,用户在前台运行应用,即触发该应用发出主动探测消息。
S405,触发静默设备探测。
用户操作触发设备A的应用服务向静默设备发送主动探测消息,设备A的应用服务将探 测消息发送给近距离通信服务。即,设备A检测到作用于应用上针对于静默设备的用户操作之后,基于设备呈现策略,应用按需调用系统提供的静默探测接口,发起静默探测,快速探测静默设备的实时状态。
S406,设备A的近距离通信服务向设备B的近距离通信服务发送探测消息。
为了确认设备A与设备B之间连接有效,设备A向设备B发送探测消息。在一种实现方法中,发送探测消息可以是广播探测报文。相对于单播,发送广播探测报文的优点是广播在单位时间内发送的报文次数多,报文不易丢失,发送成功率更高。
探测事件响应包括探测消息发送失败和发送成功两种情况。基于探测结果,执行不同状态变更,将静默状态切换到上线状态,或将静默状态切换到下线状态,并同步刷新应用界面。
步骤S407-S409为探测消息发送失败的情况。
S407,设备A的近距离通信服务获知探测消息发送失败,停止超时计数,状态管理器将设备B由静默状态变更为下线状态。
当对端设备即设备B处于静默状态下,确认探测报文发送失败时,触发设备B下线。
S408,设备A的近距离通信服务通知应用服务,设备B的状态由静默状态变更为下线状态。
S409,设备A的应用服务刷新应用界面,屏蔽下线设备,即不显示设备B的标识。
在设备A的应用服务获取到设备B已下线,会同步刷新应用界面。
步骤S410-S412为探测消息发送成功的情况。
S410,设备A和设备B的近距离通信服务获知该探测消息发送成功,状态管理器将设备B由静默状态变更为上线状态,并重置设备状态位。
当对端设备即设备B处于静默状态下,确认探测报文发送成功时,触发设备B上线。
S411,设备A和设备B的近距离通信服务通知应用服务,设备B的状态由静默状态变更为上线状态。
S412,设备A和设备B的应用服务刷新应用界面,置亮上线设备。
在一种方式中,将设备B由表示静默状态的灰色标识变更显示为表示上线状态的高亮标识。
在设备B切换至上线状态的时刻,定时器开始工作,重新超时计数,同时设备状态管理器重置设备状态位。
当设备B处于上线状态,设备A与设备B可以正常通信,会话一直保持正常服务状态,并开启定时器计时。超出第一时间阈值T1,设备A与设备B之间未有任何收发消息,读取到当前设备状态位为复位时,会将设备状态位由复位变为置位,并重启定时器。超出第二时间阈值T2,设备A与设备B之间未有任何收发消息,读取到当前设备状态位为置位时,会将设备B的状态由上线变更为静默。可以理解的是,在T1或T2内任意时刻设备A与设备B之间成功收发消息,会触发设备B重置上线状态,复位设备状态位。
可以理解的是,静默状态与下线状态是不同的,在一些实施例中,当设备B处于静默状态时,设备B并未掉线,其设备A与设备B之间的会话可以处于会话保持状态。当判断出设备B由静默状态变更为上线状态后,可以将会话由会话保持状态迁移到正常服务状态。当判断出设备B由静默状态变更为下线状态后,可以将会话状态由会话保持状态迁移到会话退出状态。
可以理解的是,设备B下线通常是移动终端因网络故障或者断开连接、关机等原因造成的掉线,因此当设备B重新登录上线的时候,需重新开始一个会话的创建、配置过程,该会话的状态为初始状态,在此状态下,请求登录过程中,交换数据量较大,需要做较多的资源分析与查询工作。
结合前述各个实施例,下面介绍本申请实施例提供的一种探测方法,图11为本申请实施例提供的探测方法的流程图。
本方法实施例提供了一种探测方法,用于第一设备探测第二设备的状态,解决设备状态不能及时更改、设备功耗高、繁琐通信等问题。该方法取消了通信中常用心跳机制,彻底解决功耗高、传输带宽被占用的问题,还进一步优化了通信效率。通过监听设备间被动或主动探测的业务报文收发事件和收发结果,驱动设备在线状态机迁移,设备状态变化可以被快速感知。该方法中增加了主动探测机制,并设立新的设备状态—静默态,以及静默探测接口,支持应用决定该设备各种状态的UI呈现和业务处理策略。第二设备处于上线状态时,当被动探测超时,上线状态会变更为静默状态。在静默态下,第一设备可以按需主动广播探测报文,确认对端设备是否在线,解决设备状态容易报错、用户体验差的问题,有效降低了设备下线时延和功耗,避免了由于短暂掉线导致的频繁上线下线的缺陷,进一步提高了通信效率。
本实施例提供的方法可以应用于第一设备与第二设备组成的通信系统中。第一设备和/或第二设备可以为配置有通信装置的终端设备,可以接收或发送数据、信令等消息。第一设备即为前述实施例中的本端设备或设备A,第二设备即为前述实施例中的对端设备或设备B,本端设备可以识别对端设备当前的设备状态并呈现在UI界面中,方便用户快速区分各个设备的连接状态。
第一设备或第二设备的设备类型可以但不限于是手机、笔记本电脑、PAD、智能手环、智能手表、PC、智能电视(又可称为智慧屏、大屏等)、智能音箱等,还可以为桌面型计算机、膝上型计算机、手持计算机、AR设备、VR设备、AI设备、车机(车载设备)、游戏机、跑步机、云主机/云服务器、其他智能穿戴设备等,或者是IOT设备,或智能家居设备如智能热水器、智能灯具、智能空调、智能体重秤等其他类型的电子设备,本申请对第一设备或第二设备的设备类型不作任何限制。第一设备或第二设备的硬件结构可以参考前述实施例中对电子设备100的说明。
图11是本实施例提供的探测方法的流程图,该流程图示出了第二设备由上线状态变更为静默状态、由静默状态变更为上线状态、由静默状态变更为下线状态、由下线状态变更为上线状态的过程,具体包括步骤如下:
S501,第一设备发现第二设备并建立连接,第一设备与第二设备正常通信,第二设备的状态为上线状态。
在第一设备发现第二设备,成功认证并成功建立连接后,第一设备可以显示第二设备为上线状态。本实施例对第一设备与第二设备之间建立的通信连接的具体类型不作任何限制。可以是有线连接或无线连接,如Wi-Fi P2P连接,蓝牙连接,USB连接,其他网络通信连接等等。该通信连接可以用于传输数据、信令等。
其中,第一设备记录的第二设备的状态包括上线状态、下线状态、静默状态,上线状态表示第一设备与第二设备之间通信正常,下线状态表示第一设备与第二设备之间通信异常,静默状态表示第一设备与第二设备之间的通信是否正常处于不确定状态,需要通过再次探测 确认第二设备处于上线状态或下线状态。
S502,第一设备复位设备状态位,启动定时器计时。
第一设备内部设置设备状态位和定时器(或计数器),设备状态位用于指示定时器的中断次数,设备状态位可以包括复位、置位等状态位,定时器用于计时。在一个示例中,复位用0表示,置位用1表示。
当第二设备状态变更为上线状态时,第一设备初始化设备状态位,并同步启动定时器(或计数器)。本实施例对定时器设置的时间不作限制。
S503,第一设备判断是否收到第二设备的消息。
如果是,即收到第二设备的消息(或称报文),则执行步骤S502,即复位设备状态位,并重新启动定时器开始重新计时。即在定时器未溢出中断的时候,每当第一设备向第二设备成功发送报文,或成功接收第二设备的报文时,会触发第一设备复位设备状态位,并同时重新启动定时器。
如果否,即未收到第二设备的消息(或称报文),则执行步骤S504。
S504,定时器溢出中断。
第一设备检测到定时器计时超时第一时间,定时器溢出中断。
S505,第一设备置位设备状态位,重新启动定时器计时。
当检测到定时器溢出中断,第一设备读取设备状态位。当读取到当前设备状态位为复位时,触发置位设备状态位,同时重新启动定时器计时。
S506,第一设备判断是否收到第二设备的消息。
如果是,即收到第二设备的消息(或称报文),则执行步骤S502,即复位设备状态位,并重新启动定时器开始重新计时。即在设备状态位为置位时,在第二次定时器计时还未溢出中断的时候,每当第一设备向第二设备成功发送报文,或成功接收第二设备的报文时,会触发第一设备复位设备状态位,并同时重新启动定时器。
如果否,即未收到第二设备的消息(或称报文),则执行步骤S507。
S507,定时器再次溢出中断,第一设备将第二设备的状态由上线状态变更为静默状态,终止定时器。
第一设备检测到定时器计时超时第二时间,定时器再次溢出中断,第一设备读取设备状态位,当读取到当前设备状态位为置位,则满足静默状态的触发条件,那么第一设备会变更第二设备的标识状态,将第二设备的状态从上线状态变更为静默状态,同时终止定时器。即,在一种实现方式中,当处于复位状态的定时器连续超时两次后,则将对端设备的状态从上线状态变更为静默状态,同时终止定时器。其中,第一时间和第二时间的时间长短可以相同,也可以不同,本申请实施例对此不作限制。
S508,第一设备向第二设备发送探测消息。
该探测消息又称第一探测报文。
在一些实施例中,在静默状态下第一设备的应用调用静默探测接口,向第二设备发送探测消息,是由用户操作触发的主动探测,比如当用户打开应用,或者说,当应用转为前台运行时,又或者,当用户点击特定控件触发探测,应用就会调用静默探测接口,发送广播探测报文,探测对端设备是否在线,如果收到对端设备的回应,则可以将对端设备的状态从静默状态变更为上线状态。
在另一些实施例中,在静默状态下第一设备先接收到第二设备的消息,然后第一设备向 第二设备发送探测消息,验证是否可以正常通信。
在一些实施例中,发送探测消息可以是指第一设备广播探测报文。相对于单播,发送广播探测报文的优点是广播在单位时间内发送的报文次数多,报文不易丢失,发送成功率更高。
S509,第一设备判断是否探测成功。
如果是,即第一设备收到第二设备的探测响应,则执行步骤S510。
如果否,即第一设备未收到第二设备的探测响应,则执行步骤S511。
S510,第一设备将第二设备的状态由静默状态变更为上线状态,并执行步骤S502。
如果探测成功,则将第二设备的状态从静默状态变更为上线状态。同时复位设备状态位,并重新启动定时器开始重新计时。
S511,第一设备将第二设备的状态由静默状态变更为下线状态,终止定时器。
如果探测失败,则将第二设备的状态从静默状态变更为下线状态,同时终止定时器。
S512,第一设备与第二设备恢复正常通信。
S513,第一设备将第二设备的状态由下线状态变更为上线状态,并执行步骤S502。
在第二设备已下线状态下,当第一设备与第二设备再次成功建立连接,可以互相成功发送报文时,第一设备会将第二设备的状态从下线状态迁移到上线状态,并同时复位设备状态位,重新启动定时器开始重新计时。
此外,第二设备处于上线状态时,当第一设备向第二设备发送业务报文失败时,会直接将第二设备的状态从上线状态迁移到下线状态。在设备下线的同时,终止定时器。
实施本实施例提供的方法,可以解决系统中设备间通过心跳报文保活机制导致的功耗大、占用传输带宽、频繁上线下线等问题,通过引入设备的新状态,即静默态,支持应用决定各种状态的UI呈现和业务处理策略,解决设备状态不能及时更新的问题,进一步优化了通信效率,增强了人机交互性能,可以给用户提供更直观、更易懂、更便利的应用交互界面,通过监听设备间业务报文收发事件和收发结果,驱动设备在线状态机迁移,用户可以实时感知设备状态的变化,提高了用户体验。
结合前述实施例,下面说明本申请实施例提供的一种电子设备的功能模块。如以下所使用的,术语“模块”可以实现预定功能的软件和/或硬件的组合。
参考图12,图12示出了一种电子设备100的功能模块的结构框图。该电子设备100可以包括通信模块1201,计时模块1202,判断模块1203,状态管理模块1204,会话管理模块1205,检测模块1206,显示模块1207等。或者这些功能模块分布在电子设备100与对端设备所组成的通信系统中。
通信模块1201用于接收或发送报文,包括数据报文和控制报文等。通信模块1201又可以包括发送模块1208和接收模块1209。发送模块1208,用于将从应用获取的消息发送给对端设备。对端设备在静默状态下,在检测模块1206检测到用户操作触发的主动探测的指令时,发送模块1208向对端设备发送探测报文,该探测报文用于探测对端设备是否还处于正常连接状态。接收模块1209用于接收来自对端设备的报文,并传递给应用。通信模块1201可以将接收或发送报文成功或失败的消息通知给状态管理模块1204、计时模块1202等。具体说明可以参考前述实施例,这里不再赘述。
计时模块1202,用于设置定时器,在电子设备100处于上线状态下,每次电子设备100成功发送或接收报文,就会将设备状态位复位,并重置定时器,定时器从最后一次收发报文 的时刻开始计时,计算电子设备100与对端设备之间未通信的时限是否超过定时器阈值。当定时器溢出中断,计时模块1202会通知判断模块1203。
判断模块1203,用于判断当前设备状态是否满足静默状态的触发条件。当判断模块1203收到计时模块1202定时器溢出中断的消息,判断模块1203读取当前设备状态位。如果读取到当前设备状态位为复位,那么就将设备状态位改为置位,如果读取到当前设备状态位为置位,那么就满足静默状态的触发条件,通知状态管理模块1204变更设备状态。
状态管理模块1204,用于记录、变更对端设备的状态,对端设备状态包括上线状态、静默状态、下线状态等。对端设备处于上线状态时,当状态管理模块1204收到判断模块1203变更静默状态的消息时,状态管理模块1204可以将对端设备的状态由上线状态变更为静默状态。对端设备处于静默状态时,当状态管理模块1204收到通信模块1201成功收发报文的消息时,状态管理模块1204可以将对端设备的状态由静默状态变更为上线状态。对端设备处于静默状态时,当状态管理模块1204收到通信模块1201收发报文失败的消息时,状态管理模块1204可以将对端设备的状态由静默状态变更为下线状态。对端设备处于上线状态时,当状态管理模块1204收到通信模块1201收发报文失败的消息时,状态管理模块1204可以将对端设备的状态由上线状态变更为下线状态。对端设备处于下线状态时,当状态管理模块1204收到通信模块1201收发报文成功的消息时,状态管理模块1204可以将对端设备的状态由下线状态变更为上线状态。
会话管理模块1205,用于管理会话状态和会话生命周期,如创建会话、保持会话、关闭会话、移除会话等。
检测模块1206可用于检测用户作用于电子设备100上的用户操作。例如检测模块1206可以检测用户作用于应用界面上对端设备图标的点击、划动操作,并生成对该对端设备的探测指令。用户操作可以包括:触控操作、语音操作、手势操作等。
显示模块1207可以用于显示用户界面,方便用户在界面中感知对端设备的状态,如上线状态显示为该设备图标高亮,静默状态显示为该设备图标置灰,下线状态不显示在用户界面中。显示模块1207可以根据状态管理模块1204的状态变更通知,对应变化显示不同状态的设备图标标识。
关于通信模块1201,计时模块1202,判断模块1203,状态管理模块1204,会话管理模块1205,检测模块1206,显示模块1207等更多功能性的描述,可以参考图1至图11等前述实施例的说明,这里不再赘述。
上述实施例所描述的实现方式仅为示例性说明,并不对本申请其他实施例构成任何限制。具体内部实现方式可能根据电子设备类型不同、所搭载的操作系统的不同、所使用的程序、所调用的接口的不同而不同,本申请实施例不作任何限制,可以实现本申请实施例所描述的特征功能即可。本申请的各实施方式可以任意进行组合,以实现不同的技术效果。
上述实施例中所用,根据上下文,术语“当…时”可以被解释为意思是“如果…”或“在…后”或“响应于确定…”或“响应于检测到…”。类似地,根据上下文,短语“在确定…时”或“如果检测到(所陈述的条件或事件)”可以被解释为意思是“如果确定…”或“响应于确定…”或“在检测到(所陈述的条件或事件)时”或“响应于检测到(所陈述的条件或事件)”。
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。所述计算机程序产品包 括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地产生按照本申请实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线)或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如DVD)、或者半导体介质(例如固态硬盘)等。
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,该流程可以由计算机程序来指令相关的硬件完成,该程序可存储于计算机可读取存储介质中,该程序在执行时,可包括如上述各方法实施例的流程。而前述的存储介质包括:ROM或随机存储记忆体RAM、磁碟或者光盘等各种可存储程序代码的介质。
以上实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的范围。
Claims (16)
- 一种探测方法,其特征在于,所述方法包括:第一设备与第二设备建立连接,其中,所述第一设备记录的所述第二设备的状态包括上线状态、下线状态、静默状态,所述上线状态表示所述第一设备与所述第二设备之间通信正常,所述下线状态表示所述第一设备与所述第二设备之间通信异常,所述静默状态表示所述第一设备与所述第二设备之间的通信是否正常处于不确定状态,需要通过再次探测确认所述第二设备处于所述上线状态或所述下线状态;当接收到所述第二设备的报文时,所述第一设备刷新所述第二设备的状态为所述上线状态,并启动定时器开始计时;所述第一设备确认未收到所述第二设备的报文的时间间隔超出第一时限;所述第一设备将所述第二设备的状态由所述上线状态变更为所述静默状态。
- 根据权利要求1所述的方法,其特征在于,所述第一设备设置有设备状态位,所述设备状态位指示所述定时器的中断次数,所述设备状态位包括复位、置位,所述方法还包括:当所述第一设备刷新所述第二设备的状态为所述上线状态时,所述第一设备将所述设备状态位变为所述复位;当所述第一设备检测到所述定时器溢出中断时,所述第一设备读取所述设备状态位;如果读取到所述设备状态位为所述复位,那么所述第一设备将所述设备状态位由所述复位变为所述置位;如果读取到所述设备状态位为所述置位,那么所述第一设备确认满足变更所述静默状态的触发条件。
- 根据权利要求2所述的方法,其特征在于,所述第一设备确认未收到所述第二设备的报文的时间间隔超出第一时限,具体包括:所述第一设备检测到所述定时器第一次溢出中断,所述第一设备读取到所述设备状态位为所述复位;所述第一设备将所述设备状态位由所述复位变为所述置位,并重启所述定时器开始计时;所述第一设备检测到所述定时器第二次溢出中断,所述第一设备读取到所述设备状态位为所述置位,所述第一设备确认满足变更所述静默状态的触发条件。
- 根据权利要求3所述的方法,其特征在于,所述定时器第一次溢出中断所需的第一时间与所述定时器第二次溢出中断所需的第二时间不同。
- 根据权利要求1-4中任一项所述的方法,其特征在于,所述方法还包括:在所述第二设备的状态为所述静默状态时,所述第一设备向所述第二设备发送第一探测报文;若所述第一设备接收到所述第二设备针对于所述第一探测报文的响应报文,则所述第一设备将所述第二设备的状态由所述静默状态变更为所述上线状态;若所述第一设备未接收到所述第二设备针对于所述第一探测报文的响应报文,则所述第一设备将所述第二设备的状态由所述静默状态变更为下线状态。
- 根据权利要求5中任一项所述的方法,其特征在于,所述第一探测报文为广播消息。
- 根据权利要求1-6中任一项所述的方法,其特征在于,所述第一设备的应用的界面中显示有所述第二设备的图标标识;如果所述第二设备为所述上线状态,则所述第二设备的图标标识置亮显示在所述界面中;如果所述第二设备为所述静默状态,则所述第二设备的图标标识置灰显示在所述界面中;如果所述第二设备为所述下线状态,则所述第二设备的图标标识不显示在所述界面中。
- 根据权利要求7所述的方法,其特征在于,所述第一设备向所述第二设备发送第一探测报文,具体包括:所述第一设备检测到点击置灰显示的所述第二设备的图标标识的用户操作;响应于所述用户操作,所述第一设备向所述第二设备发送第一探测报文。
- 根据权利要求7所述的方法,其特征在于,所述第一设备向所述第二设备发送第一探测报文,具体包括:所述第一设备检测到所述应用调到前台运行;所述第一设备向所述第二设备发送第一探测报文。
- 根据权利要求7-9任一项所述的方法,其特征在于,所述第一设备设置有静默探测接口,所述第一设备向所述第二设备发送第一探测报文,具体包括:所述第一设备检测到所述应用调用所述静默探测接口,触发所述应用调用所述静默探测接口的事件包括所述第一设备检测到所述点击置灰显示的所述第二设备的图标标识的用户操作,或,所述第一设备检测到所述应用调到前台运行;所述第一设备通过所述静默探测接口向所述第二设备发送第一探测报文。
- 根据权利要求1-10中任一项所述的方法,其特征在于,所述方法还包括:如果所述第一设备确认所述第二设备的状态为所述静默状态或所述下线状态,则终止所述定时器计时。
- 根据权利要求1-11中任一项所述的方法,其特征在于,所述方法还包括:在所述第二设备的状态为所述下线状态的情况下,如果所述第一设备向所述第二设备发送消息成功,则所述第一设备将所述第二设备的状态由所述下线状态变更为所述上线状态。
- 根据权利要求1-12中任一项所述的方法,其特征在于,所述方法还包括:在所述第二设备的状态为所述上线状态的情况下,如果所述第一设备向所述第二设备发送消息失败,则所述第一设备将所述第二设备的状态由所述上线状态变更为所述下线状态。
- 一种电子设备,其特征在于,所述电子设备包括:通信装置、显示装置、存储器以及耦合于所述存储器的处理器,以及一个或多个程序;所述通信装置用于通信,所述显示装 置用于显示界面,所述存储器中存储有计算机可执行指令,所述处理器执行所述指令时使得所述电子设备实现如权利要求1至13中任一项所述的方法。
- 一种计算机可读存储介质,包括指令,其特征在于,当所述指令在电子设备上运行时,使得所述电子设备执行如权利要求1至13中任一项所述的方法。
- 一种通信系统,所述通信系统包括第一设备和第二设备,其中,所述第一设备实现如权利要求1至13中任一项所述的方法。
Applications Claiming Priority (4)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210112618 | 2022-01-29 | ||
CN202210112618.1 | 2022-01-29 | ||
CN202210191223.5 | 2022-02-28 | ||
CN202210191223.5A CN116567054A (zh) | 2022-01-29 | 2022-02-28 | 一种探测方法、相关电子设备及系统 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2023142993A1 true WO2023142993A1 (zh) | 2023-08-03 |
Family
ID=87470614
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2023/071229 WO2023142993A1 (zh) | 2022-01-29 | 2023-01-09 | 一种探测方法、相关电子设备及系统 |
Country Status (1)
Country | Link |
---|---|
WO (1) | WO2023142993A1 (zh) |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101897152A (zh) * | 2007-11-12 | 2010-11-24 | 索拉尔弗拉雷通讯公司 | 活动空闲通信系统 |
CN103401714A (zh) * | 2013-08-01 | 2013-11-20 | 广东威创视讯科技股份有限公司 | 一种网络连接状态检测方法及客户端 |
US20170325065A1 (en) * | 2014-11-19 | 2017-11-09 | Hewlett-Packard Development Company, L.P. | Tracking a mobile device |
US20180262577A1 (en) * | 2017-03-07 | 2018-09-13 | Flash Networks, Ltd. | Method and system for signaling and radio connection optimization over a cellular network |
CN109863793A (zh) * | 2016-10-14 | 2019-06-07 | 瑞典爱立信有限公司 | 用于增强无线通信网络中的通信的方法、通信设备和网络节点 |
-
2023
- 2023-01-09 WO PCT/CN2023/071229 patent/WO2023142993A1/zh unknown
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101897152A (zh) * | 2007-11-12 | 2010-11-24 | 索拉尔弗拉雷通讯公司 | 活动空闲通信系统 |
CN103401714A (zh) * | 2013-08-01 | 2013-11-20 | 广东威创视讯科技股份有限公司 | 一种网络连接状态检测方法及客户端 |
US20170325065A1 (en) * | 2014-11-19 | 2017-11-09 | Hewlett-Packard Development Company, L.P. | Tracking a mobile device |
CN109863793A (zh) * | 2016-10-14 | 2019-06-07 | 瑞典爱立信有限公司 | 用于增强无线通信网络中的通信的方法、通信设备和网络节点 |
US20180262577A1 (en) * | 2017-03-07 | 2018-09-13 | Flash Networks, Ltd. | Method and system for signaling and radio connection optimization over a cellular network |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2021052263A1 (zh) | 语音助手显示方法及装置 | |
WO2021036835A1 (zh) | 一种蓝牙搜索方法、系统及相关装置 | |
EP4084486B1 (en) | Cross-device content projection method, and electronic device | |
WO2022257977A1 (zh) | 电子设备的投屏方法和电子设备 | |
WO2021082829A1 (zh) | 蓝牙连接方法及相关装置 | |
WO2020233538A1 (zh) | 一种接入无线局域网的方法和终端 | |
WO2021027666A1 (zh) | 一种蓝牙回连的方法及相关装置 | |
WO2021185141A1 (zh) | Wi-Fi Aware的建链方法、系统、电子设备和存储介质 | |
WO2021185244A1 (zh) | 一种设备交互的方法和电子设备 | |
US20230422154A1 (en) | Method for using cellular communication function, and related apparatus and system | |
WO2020077512A1 (zh) | 语音通话方法、电子设备及系统 | |
WO2021147406A1 (zh) | 一种音频输出方法及终端设备 | |
WO2021175300A1 (zh) | 数据传输方法、装置、电子设备和可读存储介质 | |
WO2020224447A1 (zh) | 一种在联系人中添加智能家居设备的方法及系统 | |
WO2021143314A1 (zh) | 一种降低移动终端功耗的方法及移动终端 | |
WO2022033320A1 (zh) | 蓝牙通信方法、终端设备及计算机可读存储介质 | |
WO2022127661A1 (zh) | 应用共享方法、电子设备和存储介质 | |
WO2021218544A1 (zh) | 一种提供无线上网的系统、方法及电子设备 | |
WO2022052731A1 (zh) | 传输数据的方法和电子设备 | |
WO2022268009A1 (zh) | 一种屏幕共享的方法及相关设备 | |
US20240303024A1 (en) | Display method, electronic device, and system | |
JP2024516668A (ja) | デバイスネットワーキング方法、電子デバイス、及び記憶媒体 | |
WO2021037208A1 (zh) | 一种蓝牙连接的方法和电子设备 | |
WO2023142993A1 (zh) | 一种探测方法、相关电子设备及系统 | |
CN116567054A (zh) | 一种探测方法、相关电子设备及系统 |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 23745878 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |