Simple app demonstrating network join feature of WiConnect Host Library.

Dependencies:   WiConnect mbed

Files at this revision

API Documentation at this revision

Comitter:
dan_ackme
Date:
Wed Aug 13 04:41:54 2014 -0700
Parent:
0:3c71c2753928
Child:
2:4f58a48e8905
Child:
3:15daf72c279c
Commit message:
renamed file

Changed in this revision

example.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example.cpp	Wed Aug 13 04:41:54 2014 -0700
@@ -0,0 +1,141 @@
+/**
+ * @example join/example.cpp
+ *
+ * This is an example of using the join network API to
+ * join a WiFi network.
+ *
+ * It works as follows:
+ * 1. Instantiate the WiConnect Library
+ * 2. Initiate Communication with WiFi Module
+ * 3. Join a network using the specified parameters
+ * 4. Wait for the module to join
+ * 5. That's it!
+ *
+ *
+ */
+
+
+/******************************************************************************
+ * Example Variables
+ */
+
+// This is the name of your WiFi network
+// Look for this name in your WiFi settings
+// (e.g. your phone's list of WiFi networks in the WiFi settings menu)
+// tip: add double-quotes around SSID to add spaces to name
+#define NETWORK_SSID "\"<YOUR NETWORK NAME HERE>\""
+
+// This is the password of your WiFi network
+// Leave as empty string (e.g "") to connect to OPEN network
+#define NETWORK_PASSWORD "\"<YOUR NETWORK PASSWORD HERE>\""
+
+
+
+
+/******************************************************************************
+ * Includes
+ */
+
+// include C library headers
+#include <stdio.h> // needed for printf
+
+// include target specific defines
+#include "target_config.h"
+// include the Wiconnect Host Library API header
+#include "Wiconnect.h"
+
+
+
+/******************************************************************************
+ * Global Defines
+ */
+
+
+// Serial used for printfs to terminal (i.e. NOT used for WiConnect)
+static Serial consoleSerial(STDIO_UART_TX, STDIO_UART_RX);
+
+
+
+
+/******************************************************************************
+ * Starting point of application
+ */
+int main(int argc, char **argv)
+{
+    NetworkStatus networkStatus;
+
+
+    consoleSerial.baud(115200); // console terminal to 115200 baud
+
+    //-------------------------------------------------------------------------
+    // STEP 1: Instantiate WiConnect Library
+    //-------------------------------------------------------------------------
+
+    // Setup  wiconnect serial interface configuration
+    // Here we only specify the rx buffer size and not rx buffer pointer, this means
+    // The serial RX buffer will be dynamically allocated
+    SerialConfig serialConfig(WICONNECT_RX_PIN, WICONNECT_TX_PIN, 256, NULL);
+
+    // Instantiate the Wiconnect library
+    // Here we only specify the buffer size and not buffer pointer, this means
+    // The internal buffer will be dynamically allocated
+    Wiconnect wiconnect(serialConfig, 256, NULL, WICONNECT_RESET_PIN);
+
+
+    //-------------------------------------------------------------------------
+    // STEP 2: Initiate Communication with WiFi Module
+    //-------------------------------------------------------------------------
+
+    printf("Initializing WiConnect Library...\r\n");
+
+    // Initialize communication with WiFi module
+    if(wiconnect.init(true) != WICONNECT_SUCCESS)
+    {
+        printf("Failed to initialize communication with WiFi module!\r\n"
+                "Make sure the wires are connected correctly\r\n");
+        for(;;); // infinite loop
+    }
+
+
+    //-------------------------------------------------------------------------
+    // STEP 3: Join a network using the specified parameters
+    //-------------------------------------------------------------------------
+
+    printf("Joining network: %s....\r\n", NETWORK_SSID);
+
+    // Initiate module join sequence
+    if(wiconnect.join(NETWORK_SSID, NETWORK_PASSWORD) != WICONNECT_SUCCESS)
+    {
+        printf("Failed to send join command\r\n");
+        for(;;); // infinite loop
+    }
+
+    //-------------------------------------------------------------------------
+    // STEP 4: Wait for the module to join the network
+    //-------------------------------------------------------------------------
+
+    printf("Waiting to join network....\r\n");
+
+    do
+    {
+        // poll the module for the network status
+        if(wiconnect.getNetworkStatus(&networkStatus) != WICONNECT_SUCCESS)
+        {
+            printf("Failed to get network status\r\n");
+            for(;;); // infinite loop
+        }
+
+        // loop until the network status is not down
+    } while(networkStatus == NETWORK_STATUS_DOWN);
+
+    //-------------------------------------------------------------------------
+    // STEP 5: Done!
+    //-------------------------------------------------------------------------
+
+    printf("Network join example has completed!\r\n");
+
+    for(;;); // infinite loop
+
+    return 0;
+}
+
--- a/main.cpp	Wed Aug 13 10:23:08 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,141 +0,0 @@
-/**
- * @example join/example.cpp
- *
- * This is an example of using the join network API to
- * join a WiFi network.
- *
- * It works as follows:
- * 1. Instantiate the WiConnect Library
- * 2. Initiate Communication with WiFi Module
- * 3. Join a network using the specified parameters
- * 4. Wait for the module to join
- * 5. That's it!
- *
- *
- */
-
-
-/******************************************************************************
- * Example Variables
- */
-
-// This is the name of your WiFi network
-// Look for this name in your WiFi settings
-// (e.g. your phone's list of WiFi networks in the WiFi settings menu)
-// tip: add double-quotes around SSID to add spaces to name
-#define NETWORK_SSID "\"<YOUR NETWORK NAME HERE>\""
-
-// This is the password of your WiFi network
-// Leave as empty string (e.g "") to connect to OPEN network
-#define NETWORK_PASSWORD "\"<YOUR NETWORK PASSWORD HERE>\""
-
-
-
-
-/******************************************************************************
- * Includes
- */
-
-// include C library headers
-#include <stdio.h> // needed for printf
-
-// include target specific defines
-#include "target_config.h"
-// include the Wiconnect Host Library API header
-#include "Wiconnect.h"
-
-
-
-/******************************************************************************
- * Global Defines
- */
-
-
-// Serial used for printfs to terminal (i.e. NOT used for WiConnect)
-static Serial consoleSerial(STDIO_UART_TX, STDIO_UART_RX);
-
-
-
-
-/******************************************************************************
- * Starting point of application
- */
-int main(int argc, char **argv)
-{
-    NetworkStatus networkStatus;
-
-
-    consoleSerial.baud(115200); // console terminal to 115200 baud
-
-    //-------------------------------------------------------------------------
-    // STEP 1: Instantiate WiConnect Library
-    //-------------------------------------------------------------------------
-
-    // Setup  wiconnect serial interface configuration
-    // Here we only specify the rx buffer size and not rx buffer pointer, this means
-    // The serial RX buffer will be dynamically allocated
-    SerialConfig serialConfig(WICONNECT_RX_PIN, WICONNECT_TX_PIN, 256, NULL);
-
-    // Instantiate the Wiconnect library
-    // Here we only specify the buffer size and not buffer pointer, this means
-    // The internal buffer will be dynamically allocated
-    Wiconnect wiconnect(serialConfig, 256, NULL, WICONNECT_RESET_PIN);
-
-
-    //-------------------------------------------------------------------------
-    // STEP 2: Initiate Communication with WiFi Module
-    //-------------------------------------------------------------------------
-
-    printf("Initializing WiConnect Library...\r\n");
-
-    // Initialize communication with WiFi module
-    if(wiconnect.init(true) != WICONNECT_SUCCESS)
-    {
-        printf("Failed to initialize communication with WiFi module!\r\n"
-                "Make sure the wires are connected correctly\r\n");
-        for(;;); // infinite loop
-    }
-
-
-    //-------------------------------------------------------------------------
-    // STEP 3: Join a network using the specified parameters
-    //-------------------------------------------------------------------------
-
-    printf("Joining network: %s....\r\n", NETWORK_SSID);
-
-    // Initiate module join sequence
-    if(wiconnect.join(NETWORK_SSID, NETWORK_PASSWORD) != WICONNECT_SUCCESS)
-    {
-        printf("Failed to send join command\r\n");
-        for(;;); // infinite loop
-    }
-
-    //-------------------------------------------------------------------------
-    // STEP 4: Wait for the module to join the network
-    //-------------------------------------------------------------------------
-
-    printf("Waiting to join network....\r\n");
-
-    do
-    {
-        // poll the module for the network status
-        if(wiconnect.getNetworkStatus(&networkStatus) != WICONNECT_SUCCESS)
-        {
-            printf("Failed to get network status\r\n");
-            for(;;); // infinite loop
-        }
-
-        // loop until the network status is not down
-    } while(networkStatus == NETWORK_STATUS_DOWN);
-
-    //-------------------------------------------------------------------------
-    // STEP 5: Done!
-    //-------------------------------------------------------------------------
-
-    printf("Network join example has completed!\r\n");
-
-    for(;;); // infinite loop
-
-    return 0;
-}
-