Two ways for smart device WiFi distribution network

Smart home equipment is intelligent. Many home appliances are equipped with WiFi modules, which are convenient for users to control and remotely view the home situation through mobile phones. Typical equipment such as smart sockets, smart air conditioners, and smart air purifiers.

The smart device is configured for the first time. This process is simply to initialize the WiFi device and connect it to the wireless router at home. After the first configuration is successful, it is basically done once and for all.

At present, the popular wifi configuration modes generally have the following two types:

  • 1: The smart hardware is in AP mode, the mobile phone is used in station mode, the mobile phone is connected to the AP of the smart socket to form a local area network, the mobile phone sends the SSID and password to the smart socket to connect to the route, and the smart hardware actively connects to the specified route and completes the connection.
  • 2: One-key configuration (smartconfig) mode: the smart hardware is in promiscuous mode, monitoring all the messages in the network; the mobile phone APP encodes the SSID and password into the UDP message, sends it through broadcast packets or multicast reports, and the smart hardware receives it. After decoding the UDP message, get the correct SSID and password, and then actively connect to the route with the specified SSID to complete the connection

AP (compatible) mode

AP is the abbreviation of (Wireless) Access Point, namely (wireless) access point. Simply speaking, it is like a wireless router. After the device is turned on, it enters AP mode. In the network list of the mobile phone, you can search for a name (SSID) similar to TPLINK_XXX.
Connection steps:

  • 1. Connect to the router (get the router name)
  • 2. Request the network token, after the user enters the WiFi name and password
  • 3. Initialize the hardware device, make the device enter AP mode, and the Wifi light flashes slowly
  • 4. Switch the phone back to WiFi: connect to the network with the WiFi name (SSID) that appears on the above device (similar to TPLINK_XXX). After connecting to the device, send the AES encrypted ssid/password/token via UDP
  • 5. The device obtains configuration information through UDP packets, switches the network mode, connects to the home WiFi, and the configuration is completed. Disconnect from device hotspot. Send token, register to the server, log in to the MQTT server
  • 6. Switch the mobile phone back to the WiFi in the home, and according to the token, go to the server to find the device.
  • 7. The server returns the information of the smart device

 

EZ (Express) Easy-Connect Mode

This fast connection method simplifies the operation compared to the AP mode connection, saves a lot of steps, and the first configuration is faster.

  • 1. Connect the mobile phone to WiFi, open the APP software, click "Add new device", enter the configuration interface, enter the WiFi password where the mobile phone is located, and request a network token
  • 2. The intelligent hardware turns on the promiscuous mode to monitor all network packets, and the Wifi light flashes quickly
  • 3. The mobile phone sends ssid/password/token cyclically through broadcast and multicast
  • 4. The hardware device obtains the configuration information through the UDP packet (length) and captures the ssid/password/token, the Wifi light is off, and the router is connected. After the connection is successful, the Wifi light is always on. Send the token, register to the server, and log in to the MQTT server after successful registration. (Broadcast is based on UDP packet length, multicast is based on IP address information)
  • 5. According to the token, the mobile phone goes to the server to find the device and returns the device information

The current mainstream IOT wifi solutions include:

This function was first proposed by TI and applied to CC3200; however, in principle, as long as the chip driver supports enabling the promiscuous mode (WiFi Promiscuous), it can support the one-key network configuration function, but the names and implementation coding methods of various manufacturers are different. ;
The mobile phone encoding transmission adopts UDP multicast or broadcast. Different transmission methods and encodings have different corresponding decoding processes. The current test found that WeChat is implemented through UDP broadcast packets; TI is sent to a fixed IP address. udp packet; other chip manufacturers generally provide UDP multicast mode;
because wireless data transmission must be broadcast, it must be monitored; if the AP is not encrypted, UDP can directly send the relevant information. But the router AP Generally, they are encrypted, and the encryption method is not fixed. The wifi module cannot directly parse out the data packets.

  • 1. Broadcast: The sender can control by changing the length of the data packet it needs to send,
    so as long as a set of communication protocols using length coding is specified, the Lenght field of the data packet can be used for data transmission.
  • 2. Multicast: The multicast address is a reserved class D address from 224.0.0.0-239.255.255.255
    . The mapping relationship between the IP address and the MAC address is: set the first 25 bits of the MAC address to 01.00.5e, and the last 25 bits of the MAC address. 23 bits correspond to the bits of the IP address; therefore, the sender can encode the data in the last 23 bits of the multicast ip, send it through a multicast packet, and the receiver can decode it.



Author: Orange_iOS
Link: https://www.jianshu.com/p/4fca16d8702f
Source : Jianshu The
copyright belongs to the author. For commercial reprints, please contact the author for authorization, and for non-commercial reprints, please indicate the source.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324438154&siteId=291194637