In a previous tutorial, we used WPA2 and TKIP encryption as example. Recently, there are users asking if WPA2 with AES encryption works.
In the following, we are going to test if CuHead works with a router with WPA2 security type and Encryption type is AES.
The code base download steps are same as the ones described in previous tutorial.
If the PC and the CuHead are using the same WiFi router, right click the wifi connecton icon on the down right corner of the computer, it will tell which security option is used:
We are still going to use “SimpleServer” as example:
/* * A simple sketch that uses WiServer to serve a web page */ #include #define WIRELESS_MODE_INFRA 1 #define WIRELESS_MODE_ADHOC 2 // Wireless configuration parameters ---------------------------------------- unsigned char local_ip[] = {192,168,1,20}; // IP address of WiShield unsigned char gateway_ip[] = {192,168,1,2}; // router or gateway IP address unsigned char subnet_mask[] = {255,255,255,0}; // subnet mask for the local network const prog_char ssid[] PROGMEM = {"ALPHA-WLAN"}; // max 32 bytes unsigned char security_type = 3; // 0 - open; 1 - WEP; 2 - WPA; 3 - WPA2 // WPA/WPA2 passphrase const prog_char security_passphrase[] PROGMEM = {"abcd1234bd"}; // max 64 characters // WEP 128-bit keys // sample HEX keys prog_uchar wep_keys[] PROGMEM = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, // Key 0 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 1 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 2 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // Key 3 }; // setup the wireless mode // infrastructure - connect to AP // adhoc - connect to another WiFi device unsigned char wireless_mode = WIRELESS_MODE_INFRA; unsigned char ssid_len; unsigned char security_passphrase_len; // End of wireless configuration parameters ---------------------------------------- // This is our page serving function that generates web pages boolean sendMyPage(char* URL) { // Check if the requested URL matches "/" if (strcmp(URL, "/") == 0) { // Use WiServer's print and println functions to write out the page content WiServer.print(""); WiServer.print("Hello World!"); WiServer.print(""); // URL was recognized return true; } // URL not found return false; } void setup() { // Initialize WiServer and have it use the sendMyPage function to serve pages WiServer.init(sendMyPage); // Enable Serial output and ask WiServer to generate log messages (optional) Serial.begin(57600); WiServer.enableVerboseMode(true); } void loop(){ // Run WiServer WiServer.server_task(); delay(10); }
Here gateway_ip can be found by typing “ipconfig” in cmd windows, and local_ip can be set by using a IP address that is far distance from the gateway_ip.
After compiling and loading the code, the red LED which indicates cuhead is connected to the router will be on after around 30 seconds.
Leave a Reply
You must be logged in to post a comment.