title: Process to test and add new wireless network configuration through wpa_cli
body: <p>I am trying to implement a code which is using wpa_cli &amp; iw to configure/add/remove/test new network entry to my wpa conf.</p>
  
  <p>To add a new network my process is :</p>
  
  <p><strong>wpa_cli list_network</strong></p>
  
  <p>my new entry already exist ?  yes -> remove it</p>
  
  <p><strong>wpa_cli add_network</strong>
  -> create entry empty entry with id 42</p>
  
  <p><strong>wpa_cli set_network 42 ssid '"tutu"'</strong> </p>
  
  <p><strong>wpa_cli set_network 42 psk '"mypassword"'</strong> </p>
  
  <p><strong>wpa_cli enable 42</strong> </p>
  
  <p><strong>wpa_cli save_config</strong></p>
  
  <p>-> update wpa_conf file with new entry</p>
  
  <p><strong>wpa_cli select_network 42</strong></p>
  
  <p>-> use this command to test connexion with only this network entry check every second during 10 seconds, iw dev wlan0 link result to check that ssid/psk info are good.</p>
  
  <p>I am not very sure about this process. Moreover, it seems that there is a cache somewhere. If I replace an existing entry  but with fake psk, I am always connected to this entry.</p>
  
  <p>example : </p>
  
  <p>I have a wireless network setup like this :
  ssid : tutu
  password : mypassword</p>
  
  <p>I add the configuration tutu/mypassword thanks to my process. After the select_network, the iw link show "Connected". Great.</p>
  
  <p>Now I add the configuration tutu/badpassword with the same process. The older configuration is removed. The select_network and iw link always success even if the new password is wrong...</p>
  
  <p>EDIT :</p>
  
  <p>I found some good information here to validate my process : <a href="http://rtl8192cu.googlecode.com/hg-history/bdd3a2265bdd6a92f24cef3d52fa594b2844c9c1/document/wpa_cli_with_wpa_supplicant.pdf" rel="nofollow">http://rtl8192cu.googlecode.com/hg-history/bdd3a2265bdd6a92f24cef3d52fa594b2844c9c1/document/wpa_cli_with_wpa_supplicant.pdf</a></p>
  
  <p>But I have always some failed. I run endurance test en wifi connection. On 100 tests with good ssid/psk, 99 success, 1 failed.</p>