WIZnet / Mbed 2 deprecated WizFi310_AP_HelloWorld

Dependencies:   NetworkSocketAPI mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /*
00002  * Copyright (C) 2015 Wiznet, MIT License
00003  *
00004  * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
00005  * and associated documentation files (the "Software"), to deal in the Software without restriction,
00006  * including without limitation the rights to use, copy, modify, merge, publish, distribute,
00007  * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
00008  * furnished to do so, subject to the following conditions:
00009  *
00010  * The above copyright notice and this permission notice shall be included in all copies or
00011  * substantial portions of the Software.
00012  *
00013  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
00014  * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00015  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
00016  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00017  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00018  */
00019 
00020 #include <stdio.h>
00021 #include "mbed.h"
00022 #include "WizFi310Interface.h"
00023 
00024 
00025 
00026 #if defined(TARGET_WIZwiki_W7500)
00027 Serial pc(USBTX, USBRX);
00028 WizFi310Interface wifi(D1, D0, D7, D6, D9, NC, 115200);
00029 #endif
00030 
00031 #define AP_SSID "<SSID>" // Input SSID
00032 #define AP_PASSWORD "<PW>" // Input PW
00033 
00034 #define AP_SECURITY NSAPI_SECURITY_WPA2
00035 
00036 /**
00037  *  \brief Hello World
00038  *  \param none
00039  *  \return int
00040  */
00041 int main()
00042 {
00043     pc.baud(115200);
00044     printf("WizFi310 Hello World demo. \r\n");
00045     if ( wifi.connectAP(AP_SSID, AP_PASSWORD, AP_SECURITY))      return -1; // AP mode
00046     printf("IP Address is %s\r\n", wifi.get_ip_address());
00047     
00048     while(1);
00049     
00050     wifi.disconnect();
00051 }