Simplest MurataWifi ping server

Dependencies:   NySNICInterface mbed-rtos mbed

Fork of SNIC-xively-jumpstart-demo by muRata

Committer:
nyatla
Date:
Fri Nov 21 02:49:54 2014 +0000
Revision:
28:df78c368a69c
Parent:
27:147059276246
1st commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kishino 21:25b85cbbdd82 1 /* Copyright (C) 2014 Murata Manufacturing Co.,Ltd., MIT License
kishino 23:39cf9f03b076 2 * muRata, SWITCH SCIENCE Wi-FI module TypeYD SNIC-UART.
kishino 21:25b85cbbdd82 3 *
kishino 21:25b85cbbdd82 4 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
kishino 21:25b85cbbdd82 5 * and associated documentation files (the "Software"), to deal in the Software without restriction,
kishino 21:25b85cbbdd82 6 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
kishino 21:25b85cbbdd82 7 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
kishino 21:25b85cbbdd82 8 * furnished to do so, subject to the following conditions:
kishino 21:25b85cbbdd82 9 *
kishino 21:25b85cbbdd82 10 * The above copyright notice and this permission notice shall be included in all copies or
kishino 21:25b85cbbdd82 11 * substantial portions of the Software.
kishino 21:25b85cbbdd82 12 *
kishino 21:25b85cbbdd82 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
kishino 21:25b85cbbdd82 14 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
kishino 21:25b85cbbdd82 15 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
kishino 21:25b85cbbdd82 16 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
kishino 21:25b85cbbdd82 17 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
kishino 21:25b85cbbdd82 18 */
nyatla 27:147059276246 19 /**
nyatla 27:147059276246 20 * modified by nyatlan
nyatla 27:147059276246 21 * Simplest Murata TypeYD ping server.
nyatla 27:147059276246 22 */
xively 0:efdea27c3b81 23 #include "mbed.h"
kishino 14:6d58d3855feb 24 #include "SNIC_WifiInterface.h"
xively 7:0eff5db44b8b 25
nyatla 27:147059276246 26 /**
nyatla 27:147059276246 27 * Wifi AP parameter
nyatla 27:147059276246 28 */
nyatla 27:147059276246 29 #define DEMO_AP_SSID "WIFI_SSID"
nyatla 27:147059276246 30 #define DEMO_AP_SECURITY_TYPE e_SEC_WPA2_MIXED
nyatla 27:147059276246 31 #define DEMO_AP_SECUTIRY_KEY "WIFI_KEY"
kishino 19:4e2900daad59 32
kishino 14:6d58d3855feb 33 /** Wi-Fi SNIC UART Interface*/
kishino 22:e567f0d4b05d 34 #if defined(TARGET_LPC1768)
kishino 14:6d58d3855feb 35 C_SNIC_WifiInterface mSNICwifi( p9, p10, NC, NC, p30 );
kishino 25:39099b3b173f 36 #elif defined(TARGET_KL46Z)
kishino 25:39099b3b173f 37 C_SNIC_WifiInterface mSNICwifi( D1, D0, NC, NC, D3 );
kishino 22:e567f0d4b05d 38 #endif
kishino 17:0bf3c49a83d5 39
nyatla 27:147059276246 40 int main()
nyatla 27:147059276246 41 {
kishino 14:6d58d3855feb 42 // Initialize Wi-Fi interface
nyatla 27:147059276246 43 if(mSNICwifi.init()!=0){
nyatla 27:147059276246 44 mbed_die();
nyatla 27:147059276246 45 }
kishino 20:f0c7f5ca7e8a 46 wait(0.5);
nyatla 27:147059276246 47 if(mSNICwifi.disconnect()!= 0 )
kishino 20:f0c7f5ca7e8a 48 {
nyatla 27:147059276246 49 mbed_die();
kishino 20:f0c7f5ca7e8a 50 }
kishino 19:4e2900daad59 51 wait(0.3);
nyatla 27:147059276246 52
kishino 14:6d58d3855feb 53 // Connect AP
nyatla 27:147059276246 54 if(mSNICwifi.connect( DEMO_AP_SSID, strlen(DEMO_AP_SSID), DEMO_AP_SECURITY_TYPE, DEMO_AP_SECUTIRY_KEY, strlen(DEMO_AP_SECUTIRY_KEY))!=0)
nyatla 27:147059276246 55 {
nyatla 27:147059276246 56 mbed_die();
nyatla 27:147059276246 57 }
kishino 14:6d58d3855feb 58 wait(0.5);
kishino 14:6d58d3855feb 59
nyatla 27:147059276246 60 //update IP configuration
nyatla 27:147059276246 61 mSNICwifi.setIPConfig(false,"192.168.128.39","255.255.255.0","192.168.128.254");
xively 0:efdea27c3b81 62
nyatla 27:147059276246 63 DigitalOut led1(LED1);
nyatla 27:147059276246 64 led1=1;
nyatla 27:147059276246 65
nyatla 27:147059276246 66 //OK. you can do ping to Wifi address.
nyatla 27:147059276246 67 for(;;){
nyatla 27:147059276246 68 wait(1);
xively 0:efdea27c3b81 69 }
Ilya Dmitrichenko 6:9e4f4a8c1829 70 }