demo of the murata wifi chip. This demo tries to connect to an open wifi access point and prints out all the relevant information about the connection. It then scans all wifi access points nearby and reports their information.

Dependencies:   SNICInterface mbed-rtos mbed

Fork of SNIC-xively-jumpstart-demo by muRata

Committer:
mbedAustin
Date:
Wed Apr 01 22:37:22 2015 +0000
Revision:
28:174412ff9671
Parent:
27:6949291ca38d
Child:
29:9f08c7152c7a
got documentation working, stripped out extra fluff

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 */
xively 0:efdea27c3b81 19 #include "mbed.h"
kishino 14:6d58d3855feb 20 #include "SNIC_WifiInterface.h"
xively 7:0eff5db44b8b 21
mbedAustin 28:174412ff9671 22 Serial pc(USBTX, USBRX);
xively 7:0eff5db44b8b 23
errordeveloper 10:86ffba646df1 24
mbedAustin 28:174412ff9671 25 #define WIFI_SSID "AP_SSID"
mbedAustin 28:174412ff9671 26 #define WIFI_SECURITY_TYPE e_SEC_WPA2_AES
mbedAustin 28:174412ff9671 27 #define WIFI_SECUTIRY_KEY "WPA2_PASSPHRASE"
mbedAustin 28:174412ff9671 28 #define WIFI_SECUTIRY_KEY_LEN 15
errordeveloper 11:bdf601a405fc 29
mbedAustin 28:174412ff9671 30 C_SNIC_WifiInterface wifi( D1, D0, NC, NC, D3 );
kishino 17:0bf3c49a83d5 31
mbedAustin 28:174412ff9671 32 int main()
mbedAustin 28:174412ff9671 33 {
mbedAustin 28:174412ff9671 34 // for built in debug printouts
mbedAustin 28:174412ff9671 35 // pc.baud( 115200 );
mbedAustin 28:174412ff9671 36
kishino 14:6d58d3855feb 37 // Initialize Wi-Fi interface
mbedAustin 28:174412ff9671 38 if( wifi.init() != 0 ) {
mbedAustin 28:174412ff9671 39 printf( "Wifi could not be initialized, halting.\r\n" );
kishino 14:6d58d3855feb 40 return -1;
mbedAustin 28:174412ff9671 41 }else {
mbedAustin 28:174412ff9671 42 printf("wifi initialized successfully!\r\n");
mbedAustin 28:174412ff9671 43 }
kishino 19:4e2900daad59 44 wait(0.5);
kishino 19:4e2900daad59 45
mbedAustin 28:174412ff9671 46 // good form to make sure you are disconnected from all AP's
mbedAustin 28:174412ff9671 47 if( wifi.disconnect() != 0 ) {
mbedAustin 28:174412ff9671 48 printf( "disconnect failed\r\n" );
mbedAustin 28:174412ff9671 49 return -1;
mbedAustin 28:174412ff9671 50 }else{
mbedAustin 28:174412ff9671 51 printf("disconnection successful!\r\n");
mbedAustin 28:174412ff9671 52 }
mbedAustin 28:174412ff9671 53 wait(0.3);
kishino 19:4e2900daad59 54
mbedAustin 28:174412ff9671 55 // Connect AP
mbedAustin 28:174412ff9671 56 wifi.connect( WIFI_SSID
mbedAustin 28:174412ff9671 57 , strlen(WIFI_SSID)
mbedAustin 28:174412ff9671 58 , WIFI_SECURITY_TYPE
mbedAustin 28:174412ff9671 59 , WIFI_SECUTIRY_KEY
mbedAustin 28:174412ff9671 60 , WIFI_SECUTIRY_KEY_LEN );
mbedAustin 28:174412ff9671 61 printf("connect();\r\n");
kishino 14:6d58d3855feb 62 wait(0.5);
kishino 14:6d58d3855feb 63
mbedAustin 28:174412ff9671 64 printf("IP Config();\r\n");
mbedAustin 28:174412ff9671 65 wifi.setIPConfig( true );
xively 0:efdea27c3b81 66
mbedAustin 28:174412ff9671 67 printf( "done...\n" );
mbedAustin 28:174412ff9671 68
mbedAustin 28:174412ff9671 69 wait( 1.0 );
Ilya Dmitrichenko 6:9e4f4a8c1829 70 }