modified by ohneta

Dependencies:   DnsQuery ESP8266Interface NetworkSocketAPI mbed

Fork of HelloESP8266Interface by NetworkSocketAPI

main.cpp

Committer:
sam_grove
Date:
2015-05-14
Revision:
2:7283ce112304
Parent:
0:1984a177ff56
Child:
4:cb8a17dd6746

File content as of revision 2:7283ce112304:

/* NetworkSocketAPI Example Program
 * Copyright (c) 2015 ARM Limited
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "mbed.h"
#include "WiFiInterface.h"

DigitalOut myled(LED1);


WiFiInterface wifi;
// or
//NetworkInterface *wifi = new WiFiInterface;

TCPSocket tcp(wifi.getInstance());
// or
//SocketInterface tcp = new TCPSocket(wifi->getInstance();

UDPSocket udp(wifi.getInstance());
// or
//SocketInterface udp = new UDPSocket(wifi->getInstance();

int main()
{
    puts("NetworkSocketAPI Example");
    
    wifi.init();
    wifi.connect("apname", "phrase", WPA2);
    
    printf("IP: %s\n", wifi.getIPAddress());
    printf("Gateway: %s\n", wifi.getGateway());
    printf("Mask: %s\n", wifi.getNetworkMask());
    printf("MAC: %s\n", wifi.getMACAddress());

    wifi.disconnect();
    
    while(1) {
        myled = !myled;
    }
}