"Android Development-smart home series" (ii): Configure the WiFi module with your phone

Source: Internet
Author: User

"Android Development-smart home series" (ii): Configure the WiFi module with your phone

http://blog.csdn.net/u010924834/article/details/49496729

"IP Address"

Broadcast address: x.x.x.255 (for example: 255.255.255.255)
WiFi module Default ip:10.10.100.254
After access to the router, the IP is dynamically assigned by the router.

"Implementation Process description"

Searching for WiFi modules using UDP broadcast mode

    • The first stage is to search the WiFi module in AP mode.
    • The second stage is to search the WiFi module in STA mode.

First Stage :
When the module is operating in AP mode, a UDP port for receiving the "Fast Networking protocol Command" is turned on, with a port number of 48999 (default IP of factory setting is 10.10.100.254)

    1. Via UDP broadcast (broadcast address: x.x.x.255, Port 48899), send Hf-a11assisthread (this password can be set by AT+ASWD command)
      (This can also be a unicast search, the destination address: 10.10.10.254, Port 48899, command unchanged)
    2. After the module receives the instruction, if the password is correct, the IP address, MAC address, and module name are sent to the source address (unicast: Port 48899).
    3. After receiving the IP address and MAC address returned by the module, send back a "+ok" immediately after receiving the module and enter the connection status.
    4. After entering the connection state, the module can receive the network at instruction normally. For example: Set network protocol parameters: at+netp=tcp,client,30000,x.x.x.x set STA network parameters: AT+WANN=DHCP

Transition phase:

    1. UDP Broadcast (port: 49000) Send instruction FF 00 01 01 02 (Hex)
    2. The module returns the routing list after receiving the instruction
    3. Sends the user-selected SSID (route name) and key to the module (port: 49000), the module connects to this route, turns into STA mode, and echoes an instruction FF 00 03 82 01 01 87

Phase II:
  
In STA mode, we want to find this WiFi module and send it on, off and other operating instructions. Step is the same as the first stage, but the IP address returned will be different. Module as the STA link to the route, thought that the IP address of the module is assigned by the router, not to determine the IP address, so the phone can not establish a connection with the module, it is necessary to use a broadcast search, to obtain the module in the STA mode address.

"Android Development-smart home series" (ii): Configure the WiFi module with your phone

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.