"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)
- 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)
- 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).
- 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.
- 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:
- UDP Broadcast (port: 49000) Send instruction FF 00 01 01 02 (Hex)
- The module returns the routing list after receiving the instruction
- 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