WizFi310_hello_world_demo

Dependencies:   NetworkSocketAPI WizFi310Interface 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 //#define AP_SSID "<SSID>" // Input SSID
00026 //#define AP_PASSWORD "<PW>" // Input PW
00027 #define AP_SECURITY NSAPI_SECURITY_WPA2
00028 
00029 #if defined(TARGET_WIZwiki_W7500)
00030 Serial pc(USBTX, USBRX);
00031 WizFi310Interface wifi(D1, D0, D7, D6, D9, NC, 115200);
00032 #endif
00033 
00034 
00035 /**
00036  *  \brief Hello World
00037  *  \param none
00038  *  \return int
00039  */
00040 int main()
00041 {
00042     pc.baud(115200);
00043  
00044     printf("WizFi310 Hello World demo. \r\n");
00045     if ( wifi.connect(AP_SSID, AP_PASSWORD, AP_SECURITY))     return -1;
00046     printf("IP Address is %s\r\n", wifi.get_ip_address());
00047     
00048     wifi.disconnect();
00049 }