Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: ESP8266Interface NetworkSocketAPI mbed
main.cpp
- Committer:
 - sam_grove
 - Date:
 - 2015-05-28
 - Revision:
 - 4:cb8a17dd6746
 - Parent:
 - 2:7283ce112304
 - Child:
 - 6:751245e265f6
 
File content as of revision 4:cb8a17dd6746:
/* 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", NetworkInterface::NI_WPA2);
    
    printf("Wifi is %s\n", (wifi.isConnected() > 0) ? "Connected" : "Disconnected");
    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;
    }
}