NetworkSocketAPI Test Suite for X-NUCLEO-IDW01M1 Wi-Fi expansion board.

Dependencies:   NSAPITests NetworkSocketAPI X_NUCLEO_IDW01M1v2 mbed

Fork of SpwfInterface_NSAPI_Testsv2 by ST Expansion SW Team

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /* NetworkSocketAPI Example Program
00002  * Copyright (c) 2015 ARM Limited
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016  
00017 #include "mbed.h"
00018 #include "SpwfInterface.h"
00019 #include "NSAPITests.h"
00020 
00021 //------------------------------------
00022 // Hyperterminal configuration
00023 // 9600 bauds, 8-bit data, no parity
00024 //------------------------------------
00025 
00026 Serial pc(USBTX, USBRX);
00027 DigitalOut myled(LED1);
00028 SpwfSAInterface spwf(D8, D2, false);
00029  
00030 int main()
00031 {
00032     int32_t err;  
00033     char * ssid = "STM";
00034     char * seckey = "STMdemoPWD";
00035       
00036     pc.printf("\r\nSpwf Interface NSAPI Tests\r\n");
00037     pc.printf("\r\nconnecting to AP\r\n");
00038             
00039     err = spwf.connect(ssid, seckey, NSAPI_SECURITY_WPA);
00040  
00041     if (!err) {
00042         printf("Interface failed to connect with code %d\r\n", err);
00043     } else {
00044         nsapi_tests("SPWF Tests", &spwf, "192.168.1.6", 32001);
00045         spwf.disconnect();
00046     }
00047 
00048     while(1)
00049     {
00050         wait(1);
00051         myled = !myled;
00052     }
00053 }