Tests for LWIPInterface

Dependencies:   LWIPInterface NSAPITests NetworkSocketAPI mbed-rtos mbed

Committer:
Christopher Haster
Date:
Thu Apr 21 01:55:23 2016 -0500
Revision:
3:50ac0af2ea9c
Parent:
2:9181decb4d5c
Updated NSAPITests to match changes to the NSAPI

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bridadan 0:5290cb128aed 1 /* NetworkSocketAPI Example Program
bridadan 0:5290cb128aed 2 * Copyright (c) 2015 ARM Limited
bridadan 0:5290cb128aed 3 *
bridadan 0:5290cb128aed 4 * Licensed under the Apache License, Version 2.0 (the "License");
bridadan 0:5290cb128aed 5 * you may not use this file except in compliance with the License.
bridadan 0:5290cb128aed 6 * You may obtain a copy of the License at
bridadan 0:5290cb128aed 7 *
bridadan 0:5290cb128aed 8 * http://www.apache.org/licenses/LICENSE-2.0
bridadan 0:5290cb128aed 9 *
bridadan 0:5290cb128aed 10 * Unless required by applicable law or agreed to in writing, software
bridadan 0:5290cb128aed 11 * distributed under the License is distributed on an "AS IS" BASIS,
bridadan 0:5290cb128aed 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
bridadan 0:5290cb128aed 13 * See the License for the specific language governing permissions and
bridadan 0:5290cb128aed 14 * limitations under the License.
bridadan 0:5290cb128aed 15 */
bridadan 0:5290cb128aed 16
bridadan 0:5290cb128aed 17 #include "mbed.h"
bridadan 0:5290cb128aed 18 #include "LWIPInterface.h"
bridadan 0:5290cb128aed 19 #include "NSAPITests.h"
sam_grove 2:9181decb4d5c 20
bridadan 0:5290cb128aed 21 LWIPInterface iface;
sam_grove 2:9181decb4d5c 22
Christopher Haster 3:50ac0af2ea9c 23 Ticker blinker;
Christopher Haster 3:50ac0af2ea9c 24 DigitalOut led(LED_GREEN);
Christopher Haster 3:50ac0af2ea9c 25 void blink() {
Christopher Haster 3:50ac0af2ea9c 26 led = !led;
Christopher Haster 3:50ac0af2ea9c 27 }
Christopher Haster 3:50ac0af2ea9c 28
bridadan 0:5290cb128aed 29 int main()
bridadan 0:5290cb128aed 30 {
Christopher Haster 3:50ac0af2ea9c 31 blinker.attach(blink, 0.5);
sam_grove 2:9181decb4d5c 32
Christopher Haster 3:50ac0af2ea9c 33 int result = iface.connect();
bridadan 0:5290cb128aed 34 if (result) {
sam_grove 2:9181decb4d5c 35 printf("Interface failed to connect with code %d\r\n", result);
Christopher Haster 3:50ac0af2ea9c 36 while (1);
bridadan 0:5290cb128aed 37 }
Christopher Haster 3:50ac0af2ea9c 38
Christopher Haster 3:50ac0af2ea9c 39 nsapi_tests("LWIPInterface Tests", &iface, "0.0.0.0", 4000);
Christopher Haster 3:50ac0af2ea9c 40
Christopher Haster 3:50ac0af2ea9c 41 result = iface.disconnect();
Christopher Haster 3:50ac0af2ea9c 42 if (result) {
Christopher Haster 3:50ac0af2ea9c 43 printf("Interface failed to disconnect with code %d\r\n", result);
Christopher Haster 3:50ac0af2ea9c 44 while (1);
Christopher Haster 3:50ac0af2ea9c 45 }
Christopher Haster 3:50ac0af2ea9c 46
sam_grove 2:9181decb4d5c 47 while(1);
bridadan 0:5290cb128aed 48 }