In the http://www.cnblogs.com/heat-man/p/4564539.html, on the embedded Linux Development Board, we realized a remote control system of smart home from the lowest level, but the use of a network cable connected to the switch, feeling old-fashioned. Qiao is, to find a job in Beijing, find a Do WiFi module company, these days the boss gave me the task is on the Development Board on the min210 to run our WiFi module, in order to be familiar with the environment, finally yesterday just do well, the server rack to write their own tried, MD, wireless feeling is not the same AH!
Here's a look at the idea:
First you need some hardware facilities: ARM Development Board, computer (Ubuntu system, virtual machine), WiFi module (of course, any home company can, of course, with drivers and some added to the module support some open source software).
Embedded environment Construction: First of all, the arm Development Board to burn Linux system.
With the preparation above you can enter the substantive preparation, the following steps to summarize:
1 to think of their own embedded system to support the WiFi function, we have a WiFi module, also need the corresponding driver, the first step needs to compile the module corresponding driver. (The general module supplier will provide the corresponding driver package, according to the instructions compiled)
2 Load driver. (now our embedded Linux system can do some wireless operation, but we did nothing, equivalent to buy a WiFi module according to the instructions, loaded on the driver)
3 Use HOSTAPD Open source software to build our WiFi into a hotspot. (This allows networked terminals to scan our embedded Linux systems for access to our smart Home control systems)
4 Turn on DHCP service to automatically assign IP. (Forgive me, this is the first time I have heard of this thing, but once I fell in love with, no longer manually set the IP!) )
5 Turn on the smart Home Service system and other networked terminals to access the smart home service system via WiFi. (Test Next)
In the above five steps, the first step and WiFi provider close contact, operation follow the instructions generally no big problem, here do not explain, here mainly record HOSTAPD and DHCP two open source software configuration and use.
So, we went directly to the third step, at this time your embedded system already has the WiFi function, we want to use HOSTAPD to build it into a master. (WiFi hotspot)
hostapd--Manufacturing Wireless Routers
About HOSTAPD, the official website is elegant and concise. This is a user-space daemon for access point control and authentication services. This is a service for access point control and authentication services, so the management of access points and authentication services what does that sound like, a router's function? Forgive my ignorance! I think this hostapd is to build a router! (The professional language should say: "HOSTAPD can switch WiFi to master mode, can imitate the function of the router, create a soft AP").
HOSTAPD is an open source software, when you use it must be sure to check whether it supports the wireless network card on your machine, the company's HOSTAPD is to add support for the company's modules, so from the night to download the HOSTAPD and no eggs, but the following configuration is similar, Only the WiFi module vendor provides support for their modules within the HOSTAPD.
In summary, be sure to support your wireless card, whether it's from a module vendor or an online HOSTAPD.
After obtaining the source code, cross-compiling to get HOSTAPD, hostapd_cli two commands, the two commands copied to the target board under the/bin. So we have the command to open HOSTAPD.
Open the HOSTAPD service, we also need a parameter, because you build a router, need name, need password, need encryption way .... , these parameters are concentrated in a configuration file, of course, the name of the file you can be casually named, the suffix is best. conf. I wipe, said so easy, configuration files do not do! Is there a demo? The answer is yes, it seems that Linux under the open source is also very thoughtful service. This file is the hostapd.conf that exists in the HOSTAPD source file directory. We want to build what kind of router, it is necessary to look at the various parameters inside.
There is a description of each of the configuration items, of course, are the birds! After a good enough, you can add their own birds in the inside.
such as SSID: Set the name of your Hotspot interface: Network interface WPA set your authentication related, according to your needs to set the parameters inside, you have a router setup scheme.
Copy your router setup scheme, that is, hostapd.conf to the target board/etc, and then you can start the service:
./hostapd/etc/hostapd.conf-b
When the above command executes, a WiFi hotspot is created based on the information you set, and-B represents the background run. (Suppose you create a hot spot called Heat, the name, so you pull out the phone the latter open the computer network wireless list will find heat impressively in the eye, however you connect the link, the total tm timeout, why? )
Originally this is, IP is not a network segment in mischief, that is, you create WiFi host IP and your phone and computer is not in a LAN, so, then manually set the computer and WiFi hotspot host IP for the same network segment, sure enough, but you want every person who even your wifi to manually set the IP? The key is to know that not everyone can skillfully set up IP, and the customer is God, at a time must be able to enable customers to automatically assign IP network terminal.
dhcp--assigning IP to an access point dynamically
How to do it? The answer is to open the DHCP service on our embedded Linux system, about the DHCP service you can look at the bird Brother's book, speak more clearly, the main purpose of this service is to allow the terminal to connect your network automatically assigned and you can be connected to the IP. This command is in the sbin/directory, the name is UDHCP, you can configure BusyBox to get the relevant commands, but also in the kernel configuration to check the support of this feature.
So, IP auto-allocation, its range is how much, the maximum connection length is how much, where are these things set? The answer is still the configuration file, the reason and hostapd.conf very similar, not much to say, as to how to configure a lot of online tutorials.
You can then start the DHCP service, and during the boot process, be sure to execute the ifconfig wlan0 up command while assigning IP to Wlan0.
Next Execute:
Udhcpd-fs/etc/udhcpd.conf
Then the error said in the directory is missing a file, directly with touch name creation continue to execute the above command!
Next: The terminal will print out the UDHCPD service has started: and then it looks like it's not responding ...
In fact, you have been successful-using your mobile phone or computer to connect your WiFi hotspot, the allocation of IP information will be printed.
Finally, open my smart home control system, through the mobile phone and computer connected to the WiFi hotspot, the success of the system can see the home page, oh yes! The wireless server is running under the embedded Linux system.
In this way, you can use the mobile phone to control the electrical appliances in the home switch! If you can make an app, it's even bigger.
Embedded Linux uses WiFi to build wireless server (Internet of Things Practice wireless Gateway)