Patent ID: 12192885

DESCRIPTION OF EMBODIMENTS

The technical solutions according to embodiments of this application are clearly and completely described in the following with reference to the accompanying drawings.

First, referring toFIG.1,FIG.1is a schematic diagram of a network architecture of a smart home system according to an embodiment of this application.

As shown inFIG.1, the network architecture of the smart home system may include an electronic device100, a router200, a smart home device300, and a cloud server400. The electronic device100may communicate with the router200to obtain an operating channel of the router200and a channel range supported by the router200. The operating channel is a band used by the router200to send data. The channel range supported by the router200is determined by a country to which the router200is applicable, and channel ranges supported by devices in different countries may be different. For example, there are 14 channels separated every 5 MHz in a 2.4 GHz band range (except that channel 14 and channel 13 are 12 MHz apart), a bandwidth of each channel is 20 MHz, and the channels may be sequentially numbered as channel 1 to channel 14, A channel range supported by devices in China in a 2.4 GHz band is channel 1 to channel 13. A channel range supported by devices in the United States in this band is channel 1 to channel 11, Because bands between channel 1, channel 6, and channel 13 do not overlap at all, signal interference does not occur with each other. Therefore, channel 1, channel 6, and channel 13 are relatively common channels.

The electronic device100may further receive information broadcast by the smart home device300, to obtain a channel range supported by the smart home device300. The electronic device100may send a Wi-Fi name and a password of the router200to the smart home device300. The electronic device100may determine whether the operating channel of the router200is within the channel range supported by the smart home device300; and if the operating channel of the router200is not within the channel range supported by the smart home device300, the electronic device100may indicate the router200to switch the operating channel, so that the operating channel of the router200is within the channel range supported by the smart home device300. Therefore, the smart home device300can connect to the router200, and connect to the cloud server400through the router200. The electronic device100may send a control instruction to the smart home device300by using the cloud server400. Application software (application software, APP) used to control the smart home device may be installed on the electronic device100. The app may be, for example, a smart home app. The cloud server400may be an application server corresponding to the application software, and the cloud server400may be, for example, an application server of a smart home app.

The electronic device100in this embodiment of this application may be a mobile phone, a tablet computer, a desktop computer, a laptop computer, a notebook computer, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a handheld computer, a netbook, or a personal digital assistant (personal digital assistant, PDA), a wearable electronic device, a virtual reality device, or the like.

The smart home device300in this embodiment of this application may be a smart speaker, a floor sweeping robot, a smart socket, a smart lamp, a smart body fat scale, a smart desk lamp, an air purifier, a smart refrigerator, a smart air conditioner, a smart washing machine, a smart water heater, a smart microwave oven, a smart rice cooker, a smart curtain, a smart fan, a smart TV, a smart set-top box, or the like.

Not limited to the smart home device300, the system may further be applicable to a vehicle-mounted device, a wearable electronic device, or the like, so that the device such as the vehicle-mounted device or the wearable electronic device can smoothly connect to the router. This is not limited in this embodiment of this application.

The following describes example electronic devices provided in the following embodiments of this application.

FIG.2is a schematic structural diagram of an electronic device100.

The electronic device100may include a processor110, an external memory interface120, an internal memory121, a universal serial bus (universal serial bus, USB) port130, a charging management module140, a power management module141, a battery142, an antenna1, an antenna2, a mobile communications module150, a wireless communications module160, an audio module170, a speaker170A, a receiver170B, a microphone170C, a headset jack170D, a sensor module180, a key190, a motor191, an indicator192, a camera193, a display194, a subscriber identification module (subscriber identification module, SIM) card interface195, and the like. The sensor module180may include a pressure sensor180A, a gyroscope sensor180B, a barometric pressure sensor180C, a magnetic sensor180D, an acceleration sensor180E, a distance sensor180F, an optical proximity sensor180G, a fingerprint sensor180H, a temperature sensor180J, a touch sensor180K, an ambient light sensor180L, a bone conduction sensor180M, and the like.

It may be understood that a structure shown in the embodiments of the present invention does not constitute a specific limitation on the electronic device100. In some other embodiments of this application, the electronic device100may include more or fewer components than those shown in the figure, or some components may be combined, or some components may be split, or there may be a different component layout. The components shown in the figure may be implemented by hardware, software, or a combination of software and hardware.

The processor110may include one or more processing units. For example, the processor110may include 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), a controller, a memory, a video codec, a digital signal processor (digital signal processor, DSP), a baseband processor, a neural-network processing unit (neural-network processing unit, NPU), and/or the like. Different processing units may be independent devices, or may be integrated into one or more processors.

The controller may be a nerve center and a command center of the electronic device100. The controller may generate an operation control signal based on instruction operation code and a time sequence signal, to control to read instructions and execute instructions.

The memory ma further be disposed in the processor110, and is configured to store instructions and data. In some embodiments, the memory in the processor110is a cache. The memory may store instructions or data just used or cyclically used by the processor110. If the processor110needs to use the instructions or the data again, the processor110may directly invoke the instructions or the data from the memory, to avoid repeated access. This reduces a waiting time of the processor110, and improves system efficiency.

In some embodiments, the processor110may include one or more interfaces. The interface may include an inter-integrated circuit (inter-integrated circuit, I2C) interface, an inter-integrated circuit sound (inter-integrated circuit sound, I2S) interface, a pulse code modulation (pulse code modulation, PCM) interface, a universal asynchronous receiver/transmitter (universal asynchronous receiver/transmitter, UART) interface, a mobile industry processor interface (mobile industry processor interface, MIPI), a general-purpose input/output (general-purpose input/output, GPIO) interface, a subscriber identity module (subscriber identity module, SIM) interface, a universal serial bus (universal serial bus, USB) port, and/or the like.

It can be understood that an interface connection relationship between the modules shown in the embodiments of the present invention is merely an example for description, and does not constitute a limitation on the structure of the electronic device100. In some other embodiments of this application, the electronic device100may alternatively use an interface connection mode different from that in the foregoing embodiment, or use a combination of a plurality of interface connection modes.

The charging management module140is configured to receive a charging input from the charger. The charger may be a wireless charger or a wired charger. In some embodiments in which wired charging is used, the charging management module140may receive a charging input from the wired charger through the USB port130. In some embodiments in which wireless charging is used, the charging management module140may receive a wireless charging input through a wireless charging coil of the electronic device100. The charging management module140may further supply power to the electronic device by using the power management module141when the battery142is charged.

The power management module141is configured to connect the battery142and the charging management module140to the processor110. The power management module141receives an input from the battery142and/or the charging management module140, and supplies power to the processor110, the internal memory121, an external memory, the display194, the camera193, the wireless communications module160, and the like. The power management module141may be further configured to monitor parameters such as battery power, a battery cycle count, and a battery health status (electric leakage or impedance). In some other embodiments, the power management module141may alternatively be disposed in the processor110. In some other embodiments, the power management module141and the charging management module140may alternatively be disposed in a same component.

A wireless communication function of the electronic device100may be implemented by using the antenna1, the antenna2, the mobile communications module150, the wireless communications module160, the modem processor, the baseband processor, and the like.

The antenna1and the antenna2each are configured to transmit and receive electromagnetic wave signals. Each antenna in the electronic device100may be configured to cover one or more communication frequency bands. Different antennas may be further multiplexed to improve antenna utilization. For example, the antenna1may be multiplexed as a diversity antenna of a wireless local area network. In some other embodiments, the antenna may be used in combination with a tuning switch.

The mobile communications module150may provide a solution, applied to the electronic device100, to wireless communication including 2G/3G/4G/5G, and the like. The mobile communications module150may include at least one filter, a switch, a power amplifier, a low noise amplifier (low noise amplifier, LNA), and the like. The mobile communications module150may receive an electromagnetic wave through the antenna1, perform processing such as filtering or amplification on the received electromagnetic wave, and transmit a processed electromagnetic wave to the modem processor for demodulation. The mobile communications module150may further amplify a signal modulated by the modem processor, and convert an amplified signal into an electromagnetic wave through the antenna1for radiation. In some embodiments, at least some function modules of the mobile communications module150may be disposed in the processor110. In some embodiments, at least some function modules of the mobile communications module150and at least some modules of the processor110may be disposed in a same device.

The modem processor may include a modulator and a demodulator. In some embodiments, the modem processor may be an independent device. In some other embodiments, the modem processor may be independent of the processor110, and is disposed in a same device as the mobile communications module150or another function module.

The wireless communications module160may provide a wireless communication solution that includes a wireless local area network (wireless local area networks, WLAN) (for example, a wireless fidelity (wireless fidelity, Wi-Fi) network), Bluetooth (Bluetooth, BT), a global navigation satellite system (global navigation satellite system, (NGS), frequency modulation (frequency modulation, FM), a near field communication (near field communication, NFC) technology, an infrared (infrared, IR) technology, or the like and that is applied to the electronic device100. The wireless communications module160may be one or more devices that integrate at least one communications processing module. The wireless communications module160receives an electromagnetic wave through the antenna2, performs frequency modulation and filtering on an electromagnetic wave signal, and sends a processed signal to the processor110. The wireless communications module160may further receive a to-be-sent signal from the processor110, perform frequency modulation and amplification on the signal, and convert the signal into an electromagnetic wave for radiation through the antenna2. In the embodiments of this application, the wireless communications module160may be a Wi-Fi module. The electronic device100may find, by using the Wi-Fi module, a beacon frame broadcast by a router200, and may establish a connection to the router200after finding the beacon frame broadcast by the router200. In the embodiments of this application, the electronic device100may further find, by using the Wi-Fi module, the beacon frame broadcast by a smart home device300, and may further establish a connection to the smart home device300after finding the beacon frame broadcast by the smart home device300.

In some embodiments, the antenna1and the mobile communications module150in the electronic device100are coupled, and the antenna2and the wireless communications module160in the electronic device100are coupled, so that the electronic device100can communicate with a network and another device by using a wireless communications technology. The wireless communications technology may include a global system for mobile communications (global system for mobile communications, GSM), a general packet radio service (general packet radio service, GPRS), code division multiple access (code division multiple access, CDMA), wideband 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, a GNSS, a WLAN, NFC, FM, an IR technology, and/or the like. 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 (heidou navigation satellite system, BDS), a quasi-zenith satellite system (quasi-zenith satellite system, QZSS), and/or satellite based augmentation systems (satellite based augmentation systems, SBAS).

The electronic device100implements a display function by using the GPU, the display194, the application processor, and the like. The GPU is a microprocessor for image processing, and is connected to the display194and the application processor. The GPU is configured to perform mathematical and geometric calculation, and perform graphics rendering. The processor110may include one or more GPUs that execute program instructions to generate or change display information.

The display194is configured to display an image, a video, and the like. The display194includes a display panel. A liquid crystal display (liquid crystal display, LCD), an organic light-emitting diode (organic light-emitting diode, OLED), an active-matrix organic light emitting diode (active-matrix organic light emitting diode, AMOLED), a flexible light-emitting diode (flex light-emitting diode, FLED), a mini-LED, a micro-LED, a micro-OLED, quantum dot light emitting diodes (quantum dot light emitting diodes, QLED), or the like may be used for the display panel. In some embodiments, the electronic device100may include one or N displays194, where N is a positive integer greater than 1.

The electronic device100may implement a shooting function by using the ISP, the camera193, the video codec, the GPU, the display194, the application processor, and the like.

The ISP is configured to process data fed back by the camera193. For example, during shooting, a shutter is pressed, and light is transmitted to a photosensitive element of the camera through a lens. The photosensitive element of the camera converts an optical signal into an electrical signal, and transmits the electrical signal to the ISP for processing. The ISP converts the electrical signal into an image that is perceptible to the eye. The ISP may further perform algorithm optimization on noise, brightness, and complexion of the image. The ISP may further optimize parameters such as exposure and color temperature of a shooting scenario. In some embodiments, the ISP may be disposed in the camera193.

The camera193is configured to capture a static image or a video. An optical image of an object is generated through the lens, and is projected onto the photosensitive element. The photosensitive element may be a charge coupled device (charge coupled device. CCD) or a complementary metal-oxide-semiconductor (complementary metal-oxide-semiconductor, CMOS) photoelectric transistor. The photosensitive element converts an optical signal into an electrical signal, and then transmits the electrical signal to the ISP to convert the electrical signal into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into a standard image signal in an RGB format, a YUV format, or the like. In some embodiments, the electronic device100may include one or N cameras193, where N is a positive integer greater than 1.

The digital signal processor is configured to process a digital signal, and may further process another digital signal in addition to a digital image signal. For example, when the electronic device100selects a frequency, the digital signal processor is configured to perform Fourier transform and the like on frequency energy.

The video codec is configured to compress or decompress a digital video. The electronic device100may support one or more video codecs. In this way, the electronic device100can play or record videos in a plurality of coding formats, for example, moving picture experts group (moving picture experts group, MPEG)-1, MPEG-2, MPEG-3, MPEG-4, and the like.

The NPU is a neural-network (neural-network, NN) computing processor, quickly processes input information by referring to a structure of a biological neural network, for example, by referring to a mode of transmission between human brain neurons, and may further continuously perform self-learning. Applications such as intelligent cognition of the electronic device100, for example, image recognition, facial recognition, speech recognition, and text understanding, can be implemented by using the NPU.

The external memory interface120may be configured to connect to an external storage card, for example, a micro SD card, to extend a storage capability of the electronic device100. The external storage card communicates with the processor110through the external memory interface120to implement a data storage function. For example, files such as music and a video are stored in the external memory card.

The internal memory121may be configured to store computer-executable program code. The executable program code includes instructions. The processor110runs the instructions stored in the internal memory121to perform various function applications of the electronic device100and process data. The internal memory121may include a program storage area and a data storage area. The program storage area may store an operating system, an application required by at least one function (for example, a sound playing function or an image playing function), and the like. The data storage area may store data (for example, audio data, and a phone book) created in a process of using the electronic device100, and the like. In addition, the internal memory121may include a high-speed random access memory, and may further include a nonvolatile memory, for example, at least one magnetic disk storage device, a flash memory device, or a universal flash storage (universal flash storage, UFS).

The electronic device100may implement audio functions, for example, music playing and recording, by using the audio module170, the speaker170A, the receiver170B, the microphone1700, the headset jack170D, the application processor, and the like.

The audio module170is configured to convert digital audio information into an analog audio signal output, and is further configured to convert an analog audio input into a digital audio signal. The audio module170may be further configured to code and decode an audio signal. In some embodiments, the audio module170may be disposed in the processor110, or some function modules of the audio module170are disposed in the processor110.

The speaker170A, also referred to as a “horn”, is configured to convert an audio electrical signal into a sound signal. The electronic device100may be configured to listen to music or answer a hands-free call by using the speaker170A.

The receiver170B, also referred to as an “earpiece”, is configured to convert an audio electrical signal into a sound signal. When the electronic device100answers a call or receives voice information, the receiver170B may be placed near a human ear to listen to a voice.

The microphone170C, also referred to as a “mike” or a “microphone”, is configured to convert a sound signal into an electrical signal. When making a call or sending a voice message, a user may make a sound near the microphone170C, to input a sound signal to the microphone1700. At least one microphone170C may be disposed in the electronic device100. In some other embodiments, two microphones170C may be disposed in the electronic device100, to implement a noise reduction function, in addition to collecting a sound signal. In some other embodiments, three, four, or more microphones170C may alternatively be disposed in the electronic device100, to collect a sound signal and reduce noise. The microphones may further identify a sound source, to implement a directional recording function, and the like.

The headset jack170D is configured to connect to a wired headset. The headset jack170D may be the USB port130, or may be a 3.5 mm open mobile terminal platform (open mobile terminal platform, OMTP) standard interface or a cellular telecommunications industry association of the USA (cellular telecommunications industry association of the USA, CTIA) standard interface.

The pressure sensor180A is configured to sense a pressure signal, and may convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor180A may be disposed on the display194. There is a plurality of types of pressure sensors180A, such as a resistive pressure sensor, an inductive pressure sensor, and a capacitive pressure sensor. The capacitive pressure sensor may include at least two parallel plates made of conductive materials. Capacitance between electrodes changes when force is applied to the pressure sensor180A. The electronic device100determines pressure strength based on a capacitance change. When a touch operation is performed on the display194, the electronic device100detects intensity of the touch operation by using the pressure sensor180A, The electronic device100may also calculate a touch position based on a detection signal of the pressure sensor180A. In some embodiments, touch operations that are performed in a same touch position but have different touch operation intensity may correspond to different operation instructions. For example, when a touch operation whose touch operation intensity is less than a first pressure threshold is performed on a Messages icon, an instruction for viewing an SMS message is executed. When a touch operation whose touch operation intensity is greater than or equal to the first pressure threshold is performed on a Messages icon, an instruction for creating a new SMS message is executed.

The gyroscope sensor180B may be configured to determine a motion posture of the electronic device100.

The barometric pressure sensor180C is configured to measure barometric pressure.

The magnetic sensor180D includes a Hall sensor.

The acceleration sensor180E may detect magnitude of accelerations in various directions (usually on three axes) of the electronic device100, and may detect magnitude and a direction of gravity when the electronic device100is still. The acceleration sensor180E may be further configured to identify a posture of the electronic device, and is applied to an application such as switching between a landscape mode and a portrait mode or a pedometer.

The distance sensor180F is configured to measure a distance.

The optical proximity sensor180G may include, for example, a light emitting diode (LED) and an optical detector, for example, a photodiode.

The ambient light sensor180L, is configured to sense ambient light brightness.

The fingerprint sensor180H is configured to collect a fingerprint. The electronic device100may use a feature of the collected fingerprint to implement fingerprint-based unlocking, application lock access, fingerprint-based shooting, fingerprint-based call answering, and the like.

The temperature sensor180J is configured to detect a temperature. In some embodiments, the electronic device100executes a temperature processing policy based on the temperature detected by the temperature sensor180J.

The touch sensor180K is also referred to as a “touch panel”. The touch sensor180K may be disposed on the display194, and the touch sensor180K and the display194form a touchscreen, which is also referred to as a “touch screen”. The touch sensor180K is configured to detect a touch operation performed on or near the touch sensor180K. The touch sensor may transfer the detected touch operation to the application processor, to determine a type of the touch event. A visual output related to the touch operation may be provided by using the display194. In some other embodiments, the touch sensor180K may alternatively be disposed on a surface of the electronic device100at a position different from that of the display194.

The bone conduction sensor180M may obtain a vibration signal. In some embodiments, the bone conduction sensor180M may obtain a vibration signal of a vibration bone of a human vocal-cord part. The bone conduction sensor180M may also be in contact with a human pulse, to receive a blood pressure beating signal. In some embodiments, the bone conduction sensor180M may alternatively be disposed in a headset, to obtain a bone conduction headset. The audio module170may obtain a voice signal through parsing based on the vibration signal that is of the vibration bone of the vocal part and that is obtained by the bone conduction sensor180M, to implement a voice function. The application processor may parse heart rate information based on the blood pressure beating signal obtained by the bone conduction sensor180M, to implement a heart rate detection function.

The key190includes a power key, a volume key, and the like. The key190may be a mechanical button, or may be a touch-sensitive key. The electronic device100may receive a key input, and generate a key signal input related to user settings and function control of the electronic device100.

The motor191may generate a vibration prompt. The motor191may be configured to provide an incoming call vibration prompt and a touch vibration feedback. For example, touch operations performed on different applications (for example, shooting and audio playing) may correspond to different vibration feedback effects. The motor191may also correspond to different vibration feedback effects for touch operations performed on different areas of the display194. Different application scenarios (for example, a time reminder, information receiving, an alarm clock, a game) may also correspond to different vibration feedback effects. A touch vibration feedback effect may further be customized.

The indicator192may be an indicator light, and may be configured to indicate a charging status and a power change, or may be configured to indicate a message, a missed call, a notification, and the like.

The SIM card interface195is configured to connect to a SIM card. The SIM card may be inserted in the SIM card interface195or removed from the SIM card interface195, to implement contact with or separation from the electronic device100. The electronic device100may support one or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface195may support a nano-SIM card, a micro-SIM card, a SIM card, and the like. A plurality of cards may be simultaneously inserted in a same SIM card interface195. The plurality of cards may be of a same type or of different types. The SIM card interface195may also be compatible with different types of SIM cards. The SIM card interface195may further be compatible with an external memory card. The electronic device100interacts with a network through the SIM card, to implement functions such as calling and data communication. In some embodiments, the electronic device100uses an eSIM, namely, an embedded SIM card. The eSIM card may be embedded in the electronic device100, and cannot be separated from the electronic device100.

A software system of the electronic device100may use a layered architecture, an event-driven architecture, a microkernel architecture, a micro service architecture, or a cloud architecture. In this embodiment of the present invention, an Android system with the layered architecture is used as an example to illustrate a software structure of the electronic device100.

FIG.3is a block diagram of the software structure of the electronic device100according to an embodiment of the present invention.

In the layered architecture, software is divided into several layers, and each layer has a clear role and task. The layers communicate with each other through a software interface. In some embodiments, the Android system is divided into four layers: an application layer, an application framework layer, an Android runtime (Android runtime), a system library, and a kernel layer from top to bottom.

The application layer may include a series of application packages.

As shown inFIG.3, the application packages may include applications such as “camera”, “gallery”, “calendar”, “calls”, “maps”, “navigation”, “WLAN”, “Bluetooth”, “music”, “videos”, and “messages”.

The application framework layer provides an application programming interface (application programming interface, API) and a programming framework for an application at the application layer. The application framework layer includes some predefined functions.

As shown inFIG.3, the application framework layer may include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, and the like.

The window manager is configured to manage a window program. The window manager may obtain a size of the display, determine whether there is a status bar, perform screen locking, take a screenshot, and the like.

The content provider is configured to: store and obtain data, and enable the data to be accessed by an application. The data may include a video, an image, an audio, calls that are made and received, a browsing history and a bookmark, a phone book, and the like.

The view system includes visual controls such as a control for displaying text and a control for displaying an image. The view system may be configured to construct an application. A display interface may include one or more views. For example, a display interface including a Messages notification icon may include a text display view and an image display view.

The phone manager is configured to provide a communication function of the electronic device100, for example, management of a call status (including answering, declining, or the like).

The resource manager provides various resources for an application, such as a localized character string, an icon, an image, a layout file, and a video file.

The notification manager enables an application to display notification information in the status bar, and may be configured to convey a notification message. The notification manager may automatically disappear after a short pause without requiring a user interaction.

The Android runtime includes a kernel library and a virtual machine. The Android runtime is responsible for scheduling and managing the Android system.

The kernel library includes two parts: a function that needs to be invoked in java language and a kernel library of Android.

The application layer and the application framework layer run in the virtual machine. The virtual machine executes java files of the application layer and the application framework layer as binary files. The virtual machine is configured to perform functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.

The system library may include a plurality of function modules, for example, a surface manager (surface manager), a media library (Media Libraries), a three-dimensional graphics processing library (for example, OpenGL ES), and a 2D graphics engine (for example, SGL).

The surface manager is configured to manage a display subsystem and provide fusion of 2D and 3D layers for a plurality of applications.

The media library supports playback and recording of a plurality of commonly used audio and video formats, static image files, and the like. The media library may support a plurality of audio and video coding formats, such as MPEG-4, H.264, MP3, AAC, AMR, JPG, and PNG.

The three-dimensional graphics processing library is configured to implement three-dimensional graphics drawing, image rendering, composition, layer processing, and the like.

The 2D graphics engine is a drawing engine for 2D drawing.

The kernel layer is a layer between hardware and software. The kernel layer includes at least a display driver, a camera driver, an audio driver, and a sensor driver.

The following describes an example of a working process of software and hardware of the electronic device100with reference to a shooting scenario.

When the touch sensor180K receives a touch operation, a corresponding hardware interruption is sent to the kernel layer. The kernel layer processes the touch operation into an original input event (including information such as touch coordinates and a timestamp of the touch operation). The original input event is stored at the kernel layer. The application framework layer obtains the original input event from the kernel layer, and identifies a control corresponding to the input event. An example in which the touch operation is a touch tap operation, and a control corresponding to the tap operation is a control of a camera application icon is used. The camera application invokes an interface at the application framework layer to enable the camera application, then enables a camera driver by invoking the kernel layer, and captures a static image or a video by using the camera193.

FIG.4shows an example of a user interface for an application menu on the electronic device100.

The user interface40inFIG.4may include a status bar401, a time component icon402, a weather component icon403, and a plurality of application icons, such as a camera icon, a WeChat icon, a setting icon404, an album icon, a Weibo icon, and a smart home icon405. The user interface40may further include a page indicator406, a phone icon407, a short message icon408, a contact icon409, a navigation bar410, and the like.

The status bar402may include an operator indicator (for example, an operator name “China Mobile”), one or more signal strength indicators of a wireless fidelity (wireless fidelity, Wi-Fi) signal, one or more signal strength indicators of a mobile communication signal (also referred to as a cellular signal), and a battery status indicator.

The time component icon402may be used to indicate a current time, such as a date, day of the week, and hour and minute information.

The weather component icon403may be used to indicate a weather type, such as cloudy to sunny or light rain, and may further be used to indicate information such as temperature.

The page indicator406may be used to indicate an application on which page a user is currently browsing. The user can swipe left or right on an area of a plurality of application icons to browse application icons on other pages.

The navigation bar410may include system navigation keys such as a back button411, a home screen (Home screen) button412, and an outbound task history button413. A home screen is an interface displayed by the electronic device100after any user interface detects a user operation that acts on the home screen button412. When detecting that the user taps the back button411, the electronic device100may display a previous user interface of the current user interface. When detecting that the user taps the home screen button412, the electronic device100may display the home screen. When detecting that the user taps the outbound task history button413, the electronic device100may display a task recently opened by the user. The navigation keys may have other names. For example,411may be referred to as a Back Button,412may be referred to as a Home button, and413may be referred to as a Menu Button. This is not limited in this application. The navigation keys in the navigation bar410are not limited to virtual keys, and may also be implemented as physical keys.

It may be understood thatFIG.4merely shows an example of a user interface on the electronic device100, and should not constitute a limitation on this embodiment of this application.

The electronic device100may detect a user operation that acts on the setting icon404(for example, a tap operation on the setting icon404), and in response to the operation, the electronic device100may display a user interface50shown inFIG.5for setting a system parameter. The system parameter may be, for example, an airplane mode status (enabled or disabled), a wireless local area network (wireless LAN, WLAN) status (enabled or disabled), a Bluetooth status (enabled or disabled), a personal hotspot status (enabled or disabled), a mobile network status (enabled or disabled), a Do Not Disturb mode status (enabled or disabled), a display and brightness level, or a volume level. The user interface50may include a setting entry of each system parameter, for example, a WLAN setting entry501. The electronic device100may detect a user operation that acts on the WLAN setting entry501(for example, a tap operation on the WLAN setting entry501), and in response to the operation, the electronic device100may display a user interface60in the embodiment ofFIG.6. In other words, the user may tap the WLAN setting entry501to open a user interface for setting a WL AN.

The following describes a user interface (user interface, UI) embodiment provided in the embodiments of this application with reference to schematic diagrams of application scenarios shown inFIG.4toFIG.5.

FIG.6shows an example of a user interface60for setting a WLAN.

As shown inFIG.6, the user interface60may include a switch control601and an available WLAN list602.

The switch control601is used to enable or disable a WLAN. The electronic device100may detect a right slide operation that acts on the switch control601, and in response to the right slide operation, the electronic device100may enable a WLAN, and search for an accessible device within a channel range supported by the electronic device100.

The available WLAN list602is used to display an accessible device that is in an access point (access point, AP) mode and that is found by the electronic device100, and signal strength of the device. Devices in the AP mode all broadcast a beacon frame on operating channels of the devices to wait for device access. The AP refers to a wireless access point, is a creator of a wireless network, and is a central node of the network. A device operating in the AP mode may provide a wireless access service to allow access of other wireless devices and provide data access. The device in the AP mode may be a router or a smart home device. The smart home device may be, but is not limited to, a smart speaker, a floor sweeping robot, a smart socket, a smart lamp, a smart body fat scale, a smart desk lamp, an air purifier, a smart refrigerator, a smart air conditioner, a smart washing machine, a smart water heater, a smart microwave oven, a smart rice cooker, a smart curtain, a smart fan, a smart TV, a smart set-top box, or the like.

The available WLAN list602may include an option of an accessible device for device access, for example, an option6021of a router001and an option6022of a smart home device Huawei AI speaker. The electronic device100may detect a user operation that acts on an option (for example, a tap operation on the option), and in response to the user operation, the electronic device100may initiate an access request to a device corresponding to the option.

The following separately describes, in two different cases, how the electronic device100connects to the router200. An example in which the electronic device100connects to the router200whose Wi-Fi name is001is used for description.

Case 1: If the electronic device100has never been connected to the router200whose Wi-Fi name is001, the electronic device100may detect a user operation that acts on the option6021(for example, a tap operation on the option6021), and in response to the user operation, the electronic device100may prompt the user to enter a password. After detecting that the user enters the password, the electronic device100may send the password to the router200whose Wi-Fi name is001. The router200whose Wi-Fi name is001may compare the password sent by the electronic device100with a prestored password. If the password sent by the electronic device100is consistent with the prestored password, the router200whose Wi-Fi name is001establishes a connection to the electronic device100. The electronic device100may store identification information and the password of the router200whose Wi-Fi name is001to an internal memory121. The identification information of the router may be a media access control address (media access control address, MAC) address or a Wi-Fi name. (SSID) of the router. The MAC address or the Wi-Fi name of the router may be carried in a beacon frame broadcast by the router.

Case 2: if the electronic device100has been once connected to the router200whose Wi-Fi name is001, after detecting a beacon frame broadcast by the router200whose Wi-Fi name is001, the electronic device100obtains identification information of the router based on the beacon frame, finds a password of the router from an internal memory121based on the identification information, and sends the password to the router, to connect to the router.

The following describes how the electronic device100sends the Wi-Fi name and the password of the router to the smart home device300. An example in which the router is a router200whose Wi-Fi name is001and the smart home device is a Huawei AI speaker is used for description.

In a possible embodiment, when the electronic device100has been connected to the router200, if the electronic device100detects a user operation that acts on the option6022(for example, a tap operation on the option6022), the electronic device100may send the Wi-Fi name and the password of the router200to the Huawei AI speaker.

In another possible embodiment, the electronic device100has not been connected to any router. If the electronic device100detects a user operation that acts on the option6022(for example, a tap operation on the option6022), the electronic device100may display a user interface70shown inFIG.7for connecting to the router200. Specifically, the user interface70may include a option701, a password entry bar702, and a connection control703.

The Wi-Fi option701may be used to select a target router. In a possible implementation, the Wi-Fi option701may display names of routers that have been recently connected to the electronic device100. The user may further use a drop-down control7011to view names of other connectable routers, and tap a corresponding name to select the target router. In another possible implementation, the Wi-Fi option701does not display names of routers. The user may use the drop-down control7011to view names of connectable routers, and tap a corresponding name to select the target router.

The password entry bar702may be used to enter a Wi-Fi password of the router. After the user selects the target router by using the Wi-Fi option701, the electronic device100may detect a user operation that acts on the password entry bar702(for example, a tap operation on the password entry bar702), and in response to the operation, the electronic device100may display a keyboard for entering a password, and receive the password entered by the user.

The connection control703is used to connect to the router. The electronic device100may detect a user operation that acts on the connection control703(for example, a tap operation on the connection control703), and in response to the operation, the electronic device100may send the name of the router selected in the Wi-Fi option701and the password entered by the user in the password entry bar702to the Huawei AI speaker.

The foregoing embodiment describes how the electronic device100sends the Wi-Fi name and the password of the router to the smart home device after the electronic device100detects a user operation that acts on the setting icon404.

Not limited to the foregoing manner, in this embodiment of this application, after detecting a user operation that acts on the smart home icon405, the electronic device100may send the Wi-Fi name and the password of the router to the smart home device.

Specifically, the electronic device100may detect a user operation that acts on the smart home icon405(for example, a tap operation on the smart home icon405), and in response to the operation, the electronic device100may display a user interface80shown inFIG.8. The user interface80may include at least a device adding control801.

The electronic device100may detect a user operation that acts on the device adding control801(for example, a tap operation on the device adding control801), and in response to the operation, the electronic device100may search for addable devices within the channel range supported by the electronic device100, and display a list of addable devices in a user interface90shown inFIG.9.

As shown inFIG.9, the user interface90may include options of addable devices, for example, an option901of a Huawei AI speaker and an option of a Huawei air purifier. The electronic device100may detect a user operation that acts on an option (for example, a tap operation on the option901), and in response to the user operation, the electronic device100may display the user interface70shown inFIG.7for connecting to the router. The electronic device100may send the name of the router selected in the Wi-Fi option701and the password entered by the user in the password entry bar702to the Huawei AI speaker based on the user interface70. For a specific sending process, refer to the related description in the embodiment inFIG.7. Details are not described herein again.

In a possible embodiment, when the electronic device100has been connected to the router200whose Wi-Fi name is001, when detecting a tap operation that acts on the option901of the Huawei AI speaker, the electronic device100may directly send the Wi-Fi name and the password of the router200to the Huawei AI speaker.

In another possible embodiment, when the electronic device100has been connected to the router200whose Wi-Fi name is001, when detecting a tap operation that acts on the option901of the Huawei AI speaker, the electronic device100may directly display the password in the password entry bar702of the user interface.70, and the user only needs to tap the connection control703to send the Wi-Fi name and the password of the router200to the Huawei AI speaker.

The Huawei AI speaker receiving the Wi-Fi name and the password may switch the operating mode from the AP mode to a station (station, STA) mode. The STA station is that each device for example, a notebook computer, a PDA, or another smart home device that can connect to a network) connected to a wireless network may be referred to as a station. A device operating in the STA mode does not receive wireless access and can connect to an AP The Huawei AI speaker searches for a router with a Wi-Fi name consistent with the received Wi-Fi name within a channel range supported by the Huawei AI speaker and sends a password to the router. After the router confirms that the password is correct, the router establishes a connection to the Huawei AI speaker. In this case, the Huawei AI speaker connects to the network successfully. A manner in which the electronic device100connects to the router200may be any one of the foregoing two manners.

Not limited to sending the Wi-Fi name of the router, during specific implementation, the electronic device100may further send a MAC address (BSSID) of the router200to the smart home device300.

The following describes a method for accessing a network by a smart home device provided in an embodiment of this application.

As shown inFIG.10, a method for accessing a network by a smart home device may include at least the following several steps:S101. An electronic device determines an operating channel of a router and a channel range supported by the router.S102. The electronic device determines a channel range supported by the smart home device.S103. The electronic device determines whether the operating channel of the router is within the channel range supported by the smart home device; if yes, performs S106; and if no, performs S104.S104. The electronic device sends an operating channel switching instruction to the router.S105. The router switches the operating channel.S106. The electronic device sends a Wi-Fi name and a password of the router to the smart home device.S107, The smart home device connects to the router.

An electronic device100determines an operating channel of a router200and a channel range supported by the router200in the following several implementations:

In a possible implementation, the electronic device100may determine, by using a beacon frame broadcast by the router200, the operating channel of the router200and the channel range supported by the router200.

Specifically, the router200operates in an AP mode, and broadcasts a beacon frame to surrounding devices on operating channel X of the router200at a specific period. A sending period of the beacon frame may be, for example, 100 milliseconds or 200 milliseconds. A longer sending period of the beacon frame indicates a longer sleep period of the router200, and that more energy is saved. A smaller sending period of the beacon frame indicates that a shorter time is consumed by the device to find the router.

After enabling a WLAN, the electronic device100may perform polling in a channel range supported by the electronic device100, and receive, on channel X, the beacon frame broadcast by the router200. The electronic device100may determine that channel X on which the beacon frame is received is the operating channel of the router200. For a manner in which the electronic device100enables the WLAN, refer to the description in the embodiment inFIG.6.

For example, it is assumed that the channel range supported by the electronic device100is channel 1 to channel 13. After enabling the WLAN, the electronic device100may sequentially scan, starting from channel 1, each channel for the beacon frame broadcast by the router200, and it may be determined that channel X is the operating channel of the router200after the beacon frame broadcast by the router200is received on channel X (X may be, for example, 12 or 13). A process in which the electronic device100sequentially scans each channel for the beacon frame broadcast by the router200may be referred to as polling.

The electronic device100may determine, by using a country field of the beacon frame, the channel range supported by the router200.

For example, a format of the country field is shown inFIG.11. The country field may carry at least information such as an element ID (element ID), a length (length), a country code (country string), a first channel number (first channel number), the number of channels (number of channels), and a maximum transmit power (maximum transmit power).

The element ID is an identifier of the country field. The electronic device100may determine, based on the element ID, whether the field is a country field. Generally, the element ID of the country field is 7.

The length indicates the number of bytes in content of the country field (excluding a length occupied by the element ID and the length).

The country code is used to represent a country to which the device is applicable, and different countries correspond to different available channels. The first channel number is used to represent a number of the first channel supported by the device. The number of channels is used to represent the number of channels supported by the device. The maximum transmit power is used to represent a maximum power of the device when the device transmits signals. Different countries correspond to different available bands, including the number of the first channel and the number of supported channels. Different countries further correspond to different maximum transmit powers. A channel range supported by the device can be learned from the number of the first channel and the number of supported channels.

FIG.12shows an example of correspondences between different countries and a country code, a first channel number, number of channels, and a supported channel range in a 2.4 GHz band range.

It is assumed that the router200in the embodiments of this application is a router applicable to China, and the smart home device300in the embodiments of this application is a smart home device applicable to the United States.

It can be learned fromFIG.12that the router200applicable to China may operate on any one of channel 1 to channel 13, and a channel range supported by the smart home device300applicable to the United States is [1, 11]. When the router200operates on channel 12 or channel 13, the smart home device300cannot connect to the router200.

Specifically, the electronic device100may determine, based on the country code in the country field, the channel range supported by the router200. For example, if the country code is CN, it may be determined that the channel range supported by the router is [1, 13]. If the country code is US, it may be determined that the channel range supported by the router is [1, 11]. If the country code is JP, it may be determined that the channel range supported by the router is [1, 14]. If the country code is IL, it may be determined that the channel range supported by the router is [3, 9].

Specifically, the electronic device100may further determine, based on the first channel number and the number of channels, the channel range supported by the router200. For example, if the first channel number is 1 and the number of channels is 13, it may be determined that the channel range supported by the router is [1, 13]. If the first channel number is 3 and the number of channels is 7, it may be determined that the channel range supported by the router200is [3, 9].

In another possible implementation, the electronic device100may determine, by using a probe response frame sent by the router200, the operating channel of the router200and the channel range supported by the router.

Specifically, after enabling the WLAN, the electronic device100may sequentially broadcast a probe request frame on each channel supported by the electronic device100. After receiving the probe request frame on channel X, the router200may send a probe response frame to the electronic device100on channel X. The electronic device100may perform polling in the channel range supported by the electronic device100until receiving, on channel X, the probe response frame sent by the router200. The electronic device100may determine that channel X on which the probe response frame is received is the operating channel of the router200. For a manner in which the electronic device100enables the WLAN, refer to the description in the embodiment inFIG.6.

The electronic device100may determine, by using a country field of the probe response frame, the channel range supported by the router200. A format of the country field of the probe response frame is similar to the format of the country field of the beacon frame. Details are not described herein again.

Not limited to the country field in the beacon frame or the probe response frame, the electronic device100may further determine, by using a vendor specific field in the beacon frame or the probe response frame, the channel range supported by the router200. The vendor specific field may include at least a country code, or the vendor specific field may include a first channel number and the number of channels, or the vendor specific field may include a country code, a first channel number, and the number of channels. The format of the vendor specific field may be defined by vendors.

After receiving, on channel X, the beacon frame or the probe response frame sent by the router200, the electronic device100can connect to the router200, There may be two different cases in which the electronic device100connects to the router200. For a connection manner in each case, refer to the description in the foregoing embodiment. Details are not described herein again.

The following describes how the electronic device determines the channel range supported by the smart home device.

Specifically, the electronic device100may determine, by using a beacon broadcast by the smart home device300, the channel range supported by the smart home device300.

Specifically, the current operating mode of the smart home device300is an AP mode, and the beacon frame is broadcast to surrounding devices on channel Y at a specific period. A sending period of the beacon frame is similar to the sending period of the beacon frame broadcast by the router200. Details are not described herein again.

The following separately describes, in two cases, how the electronic device receives a beacon broadcast by the smart home device.

Case 1: If the electronic device100has been connected to the router200, the electronic device100may sequentially scan each channel at a specific time interval, and return to channel X each time a channel is scanned, until the beacon frame sent by the smart home device300is scanned on channel Y. It is ensured that data transmission between the electronic device100and the router200is not affected during scanning of the smart home device300. The time interval may be, for example, 100 milliseconds or 200 milliseconds.

Case 2: If the electronic device100has not been connected to the router200, the electronic device100may perform polling in the channel range supported by the electronic device100until receiving, on channel Y, the beacon frame broadcast by the smart home device300.

Specifically, before the electronic device100scans the beacon of the smart home device300, the electronic device100may further receive a device adding instruction input by the user. The user may input the device adding instruction by tapping the device adding control801in the embodiment inFIG.8.

After receiving the beacon frame broadcast by the smart home device300, the electronic device100may determine, by using the country field of the beacon frame, the channel range supported by the smart home device300. For the format of the country field, refer to the related description in the embodiment inFIG.11. Details are not described herein again.

Not limited to the beacon frame, in another implementation, the electronic device100may further determine, by using the probe response frame, the channel range supported by the smart home device300. A process of determining, by using the probe response frame, the channel range supported by the smart home device300is similar to the process of determining, by using the probe response frame, the channel range supported by the router200in the foregoing embodiment. Details are not described herein again.

Not limited to the country field, in another implementation, the electronic device100may further determine, by using the vendor specific field in the beacon frame or the probe response frame, the channel range supported by the smart home device300. A process of determining, by using the vendor specific field, the channel range supported by the smart home device300is similar to the process of determining, by using the vendor specific field, the channel range supported by the router200in the foregoing embodiment. Details are not described herein again.

In a possible implementation, after the electronic device100determines that the operating channel of the router200is not within the channel range supported by the smart home device300, the electronic device100may send an operating channel switching instruction to the router200. The operating channel switching instruction may carry the channel range supported by the smart home device300.

In another possible implementation, after the electronic device100determines that the operating channel of the router200is not within the channel range supported by the smart home device300, the electronic device100may send, to the router200, an operating channel switching instruction and information that carries the channel range supported by the smart home device300.

The router200may select, from the channel range supported by the smart home device300and the channel range supported by the router200, a channel with relatively good channel quality as a new operating channel, for example, channel M. The channel quality may be measured by using a signal-to-noise ratio. A higher signal-to-noise ratio indicates better channel quality.

In addition, the router200may record the channel range supported by the smart home device300, to ensure that an operating channel selected after the router200is restarted next time is within the channel range supported by the smart home device200, so that the smart home device300can quickly access a network.

The following describes how the electronic device sends the Wi-Fi name and the password of the router to the smart home device.

In a possible implementation, the electronic device100can connect to the smart home device300, and send the Wi-Fi name and the password of the router200to the smart home device300on channel Y. A manner in which the electronic device100connects to the smart home device300may be that the user taps the option6022in the embodiment inFIG.6. A manner in which the electronic device100connects to the smart home device300may alternatively be that the user taps the option901in the embodiment inFIG.9.

In another possible implementation, the electronic device100does not connect to the smart home device300, and the electronic device100may sequentially broadcast, on each channel supported by the electronic device100, a data frame that carries the Wi-Fi name and the password of the router200. The smart home device300may sequentially perform polling on each channel supported by the smart home device300until receiving, on a channel, the Wi-Fi name and the password of the router200that are broadcast by the electronic device100. The data frame broadcast by the electronic device100may further carry identification information of the smart home device300, and the identification information may be, for example, a MAC address or a hotspot name of the smart home device300when the smart home device300operates in an AP mode. The identification information may be carried in the beacon frame broadcast by the smart home device300. After receiving the data broadcast by the electronic device100, the smart home device300may determine whether the identification information carried in the data frame is consistent with the identification information of the smart home device300, and if the identification information carried in the data frame is consistent with the identification information of the smart home device300, obtain the Wi-Fi name and the password of the router200that are carried in the data frame. It can be learned that the data frame that carries the Wi-Fi name and the password of the router200may be a plurality of frames.

In another possible implementation, the electronic device100may send the Wi-Fi name and the password of the router200to the smart home device300by using a near field communication (near field communication, NFC) technology, Bluetooth, a Wi-Fi direct connection port, or the like.

After receiving the Wi-Fi name and the password of the router200, the smart home device300switches the operating mode from the AP mode to the STA mode, performs polling in the channel range supported by the smart home device300, and searches for a router200whose Wi-Fi name is consistent with the Wi-Fi name of the router200. The smart home device300may receive, on channel M, the beacon frame sent by the router200whose Wi-Fi name is consistent with the Wi-Fi name. The password is then sent to the router200on channel M. The router200may verify whether the password sent by the smart home device300is correct. If the password is correct, the smart home device300connects to the router200successfully.

In another possible embodiment, S106may be implemented before S103to S105. If the electronic device100determines that the operating channel of the router200is within the channel range supported by the smart home device300, the smart home device300may directly connect to the router200to access a network. If the current operating channel of the router200is not within the channel range supported by the smart home device300, after the smart home device300receives the name and the password of the router200that are sent by the electronic device100, when polling is performed within the channel range supported by the smart home device300, the router200whose Wi-Fi name is consistent with the Wi-Fi name of the router200cannot be found until the router200switches the operating channel to the channel range supported by the smart home device300.

In this embodiment of this application, the electronic device100may determine whether the operating channel of the router200is within the channel range supported by the smart device300, and if the operating channel is not within the channel range supported by the smart device300, send an operating channel switching instruction to the router200, so that an operating channel obtained through switching is within the channel range supported by the smart home device300. In this way, the smart home device300can quickly connect to a network without affecting user experience.

An embodiment inFIG.1of this application provides a smart home system. An electronic device100in the smart home system may be configured to perform all or some of the steps performed by the electronic device100in the embodiment inFIG.10. The router200in the smart home system may be configured to perform all or some of the steps performed by the router200in the embodiment inFIG.10. The smart home device300in the smart home system may be configured to perform all or some of the steps performed by the smart home device300in the embodiment inFIG.10.

An embodiment of this application provides a specific method for accessing a network by a smart home device.

As shown inFIG.13, a method for accessing a network by a smart home device may include at least the following several steps.S201, A router broadcasts a beacon frame.

Specifically, the router200may broadcast the beacon frame on channel X at a specific period.S202. An electronic device determines a current operating channel of the router and a channel range supported by the router.

Specifically, after enabling a WLAN, the electronic device100may perform polling in a channel range supported by the electronic device100, and receive, on channel X, the beacon frame broadcast by the router200. The electronic device100may determine that the channel on which the beacon frame is received is the operating channel of the router200; and determine, based on a country field of the beacon frame, the channel range supported by the router200.S203. The electronic device connects to the router.

In a possible embodiment, the electronic device100has been once connected to the router200, and the electronic device100may automatically connect to the router200after receiving, on channel X, the beacon frame broadcast by the router200.

In another possible embodiment, the electronic device100has never been connected to the router200, and can connect to the router200after the user enters a correct password. Possibly, the electronic device100may not connect to the router200.S204, The smart home device broadcasts a beacon frame.

Specifically, the smart home device300operates in an AP mode, and broadcasts the beacon frame on channel Y at a specific period.S205. The electronic device determines a channel range supported by the smart home device.

Specifically, after the electronic device100receives a device adding instruction entered by the user (for example, the user taps the device adding control801in the embodiment inFIG.8), the electronic device100may sequentially scan each channel at a specific time interval, and each time a channel is scanned, the electronic device100returns to channel X to connect to the router200, until the beacon frame sent by the smart home device300is scanned on channel Y.S206, The electronic device determines whether the current operating channel of the router is within the channel range supported by the smart home device; if yes, performs S209; and if no, performs S207.S207. The electronic device sends an operating channel switching instruction to the router.

Specifically, the operating channel switching instruction may carry the channel range supported by the smart home device300. The router200may select, based on the channel range supported by the router200and the channel range supported by the smart home device300, a channel with relatively good channel quality as a new operating channel, for example, channel M.S208. The router switches the operating channel.

Specifically, after switching the operating channel to channel M, the router200broadcasts the beacon frame to surrounding devices on channel M at a specific period, and waits for device access.S209. The electronic device connects to the smart home device, and sends a Wi-Fi name and a password of the router.

Specifically, the electronic device100disconnects from the router200, and connects to the smart home device300. A manner in which the electronic device100connects to the smart home device300may be that the user taps the option6022in the embodiment inFIG.6, or the user taps the option901in the embodiment inFIG.9.

In a possible embodiment, the electronic device100does not connect to the router200. When sending the Wi-Fi name and the password of the router to the smart home device300, the electronic device100may directly select a target router in the user interface70shown inFIG.7and enter the password of the router.

In another possible embodiment, the electronic device100may not connect to the smart home device200, and the electronic device100may send the Wi-Fi name and the password of the router200to the smart home device300in a multicast or broadcast manner. For a specific sending process, refer to part of the related description about how the electronic device sends the Wi-Fi name and the password of the router to the smart home device described in the foregoing embodiment. Details are not described herein again. S210. The smart home device switches the operating mode from an AP mode to a STA mode.

Specifically, after receiving the Wi-Fi name and the password of the router200, the smart home device300switches the operating mode from the AP mode to the STA mode, performs polling in the channel range supported by the smart home device300, and searches for a router whose Wi-Fi name is consistent with the received Wi-Fi name.S211. The smart home device connects to the router.

Specifically, the smart home device300may receive, on channel M, a beacon frame broadcast by the router200, where the beacon frame may carry a Wi-Fi name (SSID) of the router200. After finding the router200, the smart home device300sends the password to the router200on channel M. The router200may determine whether the password sent by the smart home device300is correct, and if the password is correct, access of the smart home device300is allowed. In this case, the smart home device300connects to the router200successfully, and the smart home device300accesses a network successfully.

An embodiment inFIG.1of this application provides a smart home system. An electronic device100in the smart home system may be configured to perform all or some of the steps performed by the electronic device100in the embodiment inFIG.11. The router200in the smart home system may be configured to perform all or some of the steps performed by the router200in the embodiment inFIG.11. The smart home device300in the smart home system may be configured to perform all or some of the steps performed by the smart home device300in the embodiment inFIG.11.

Not limited to sending the channel switching instruction to the router200, the electronic device100may further send a channel range extension instruction to the smart home device300.

Specifically, as shown inFIG.14, a method for accessing a network by a smart home device may include at least the following several steps:S301. An electronic device determines an operating channel of a router.S302. The electronic device determines a channel range supported by the smart home device.S303. The electronic device determines whether the operating channel of the router is within the channel range supported by the smart home device; if yes, performs S306; and if no, performs S304.S304. The electronic device sends a channel range extension instruction to the smart home device.S305. The smart home device extends the channel range.S306, The electronic device sends a name and a password of the router to the smart home device.S307, The smart home device connects to the router.

Specifically, an implementation in which the electronic device100determines the operating channel of the router200is consistent with the implementation described in the embodiment inFIG.10. Details are not described herein again.

Specifically, an implementation in which the electronic device100determines the channel range supported by the smart home device300is consistent with the implementation described in the embodiment inFIG.10. Details are not described herein again.

When the electronic device100determines that the operating channel of the router200is not within the channel range supported by the smart home device300, the electronic device100sends the channel range extension instruction to the smart home device300. The channel range extension instruction may carry the operating channel of the router200.

After receiving the channel range extension instruction sent by the electronic device100, the smart home device300extends the channel range supported by the smart home device300to a channel range that may include the operating channel of the router200.

In a possible implementation, the smart home device300may extend the channel range supported by the smart home device300to the channel range supported by the router200. The electronic device100may determine the channel range supported by the router200. A specific implementation is the same as that described in the embodiment inFIG.10. Details are not described herein again.

For example, if the channel range supported by the smart home device300is [1, 11], and the channel range supported by the router300is [1,13], the channel range supported by the smart home device300needs to be extended from [1, 11] to [1, 13].

Specifically, the channel range extension instruction sent by the electronic device100to the smart home device300may carry a country code (for example, CN) and a channel range (for example, channel 1 to channel 13) that are supported by the router200. After receiving the channel extension instruction, the smart home device300changes a country code of the smart home device300to the country code (for example, CN) supported by the router200, and changes a channel range supported by the smart home device300to the channel range (for example, channel 1 to channel 13) supported by the router200.

Specifically, for an implementation in which the electronic device100sends the Wi-Fi name and the password of the router200to the smart home device300, refer to the related description in the embodiment inFIG.10. Details are not described herein again.

In this embodiment of this application, the electronic device100may determine whether the operating channel of the router200is within the channel range supported by the smart device300, and if the operating channel of the router200is not within the channel range supported by the smart device300, send a channel extension instruction to the smart home device300, so that the smart home device300after channel extension may establish a connection to the router200. In this way, the smart home device300can quickly connect to a network without affecting user experience.

An embodiment inFIG.1of this application provides a smart home system. An electronic device100in the smart home system may be configured to perform all or some of the steps performed by the electronic device100in the embodiment inFIG.12. The router200in the smart home system may be configured to perform all or some of the steps performed by the router200in the embodiment inFIG.12. The smart home device300in the smart home system may be configured to perform all or some of the steps performed by the smart home device300in the embodiment inFIG.12.

An embodiment of this application further provides a computer readable storage medium. All or some of the procedures in the foregoing method embodiments may be completed by a computer program instructing related hardware. The program may be stored in the foregoing computer storage medium. When the program is executed, the procedures in the foregoing method embodiments may be included. The computer readable storage medium includes: any medium that can store program code, such as a read-only memory (read-only memory, ROM), a random access memory (random access memory, RAM), a magnetic disk, or an optical disc.

All or some of the foregoing embodiments may be implemented by using software, hardware, firmware, or any combination thereof. When software is used to implement the embodiments, the embodiments may be implemented completely or partially in a 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 procedure or functions according to the embodiments of this application are all or partially generated. The computer may be a general-purpose computer, a dedicated computer, a computer network, or other programmable apparatuses. The computer instruction may be stored in a computer readable storage medium, or may be transmitted by using the computer readable storage medium. The computer readable storage medium may be any usable medium accessible by a computer, or a data storage device, such as a server or a data center, integrating one or more usable media. The usable medium may be a magnetic medium (for example, a floppy disk, a hard disk, or a magnetic tape), an optical medium (for example, a DVD), a semiconductor medium (for example, a solid-state drive (solid state disk, SSD)), or the like.

A sequence of the steps of the method in the embodiments of this application may be adjusted, combined, or removed based on an actual requirement.

The modules in the apparatus in the embodiments of this application may be combined, divided, and deleted based on an actual requirement.

In conclusion, the foregoing embodiments are merely intended for describing the technical solutions of this application, but not for limiting this application. Although this application is described in detail with reference to the foregoing embodiments, persons of ordinary skill in the art should understand that they may still make modifications to the technical solutions described in the foregoing embodiments or make equivalent replacements to some technical features thereof, without departing from the scope of the technical solutions of the embodiments of this application.