Base class for IP Based Networking Libraries

Dependencies:   DnsQuery

Dependents:   TempTower BSDInterfaceTests HelloBSDInterface ESP8266InterfaceTests ... more

For a complete getting started guide see the wiki...

Network Socket API

The Network Socket API provides a common interface for using sockets on network devices. The API provides a simple class-based interface that should be familiar to users experienced with other socket APIs. Additionally, the API provides a simple interface for implementing network devices, making it easy to connect hardware agnostic programs to new devices.

Network Interfaces

The NetworkInterface provides an abstract class for network devices that support sockets. Devices should provide a DeviceInterface class that inherits this interface and adds implementation specific methods for using the device. A NetworkInterface must be provided to a Socket constructor to open a socket on the interface. Currently two subclasses are defined for common devices, EthernetInterface and WiFiInterface.

Sockets

The Socket class is used for managing network sockets. Once opened, the socket provides a pipe through which data can sent and recieved to a specific endpoint. The socket class can be instantiated as either a TCPSocket or a UDPSocket which defines the protocol used for the connection.

Committer:
sam_grove
Date:
Wed Mar 09 05:51:38 2016 +0000
Revision:
63:531f4c27f360
Parent:
57:3c873fab4207
update formatting and add comments for documentation

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sam_grove 7:b147c08301be 1 /* WiFiInterface Base Class
sam_grove 7:b147c08301be 2 * Copyright (c) 2015 ARM Limited
sam_grove 7:b147c08301be 3 *
sam_grove 7:b147c08301be 4 * Licensed under the Apache License, Version 2.0 (the "License");
sam_grove 7:b147c08301be 5 * you may not use this file except in compliance with the License.
sam_grove 7:b147c08301be 6 * You may obtain a copy of the License at
sam_grove 7:b147c08301be 7 *
sam_grove 7:b147c08301be 8 * http://www.apache.org/licenses/LICENSE-2.0
sam_grove 7:b147c08301be 9 *
sam_grove 7:b147c08301be 10 * Unless required by applicable law or agreed to in writing, software
sam_grove 7:b147c08301be 11 * distributed under the License is distributed on an "AS IS" BASIS,
sam_grove 7:b147c08301be 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
sam_grove 7:b147c08301be 13 * See the License for the specific language governing permissions and
sam_grove 7:b147c08301be 14 * limitations under the License.
sam_grove 7:b147c08301be 15 */
sam_grove 7:b147c08301be 16
Christopher Haster 21:35ed15069189 17 #ifndef WIFI_INTERFACE_H
Christopher Haster 21:35ed15069189 18 #define WIFI_INTERFACE_H
sam_grove 7:b147c08301be 19
sam_grove 7:b147c08301be 20 #include "NetworkInterface.h"
sam_grove 7:b147c08301be 21
Christopher Haster 21:35ed15069189 22 /** Enum for WiFi encryption types
sam_grove 7:b147c08301be 23 */
Christopher Haster 57:3c873fab4207 24 enum ns_security_t {
sam_grove 63:531f4c27f360 25 NS_SECURITY_NONE = 0, /*!< open access point */
sam_grove 63:531f4c27f360 26 NS_SECURITY_WEP, /*!< phrase conforms to WEP */
sam_grove 63:531f4c27f360 27 NS_SECURITY_WPA, /*!< phrase conforms to WPA */
sam_grove 63:531f4c27f360 28 NS_SECURITY_WPA2, /*!< phrase conforms to WPA2 */
Christopher Haster 42:49893d13c432 29 };
sam_grove 7:b147c08301be 30
Christopher Haster 21:35ed15069189 31
Christopher Haster 21:35ed15069189 32 /** WiFiInterface class
Christopher Haster 21:35ed15069189 33 * Common interface that is shared between WiFi devices
sam_grove 7:b147c08301be 34 */
sam_grove 7:b147c08301be 35 class WiFiInterface : public NetworkInterface
sam_grove 7:b147c08301be 36 {
sam_grove 7:b147c08301be 37 public:
Christopher Haster 21:35ed15069189 38 /** Start the interface
Christopher Haster 21:35ed15069189 39 * @param ssid Name of the network to connect to
Christopher Haster 21:35ed15069189 40 * @param pass Security passphrase to connect to the network
Christopher Haster 21:35ed15069189 41 * @param security Type of encryption to connect with
Christopher Haster 21:35ed15069189 42 * @return 0 on success
sam_grove 7:b147c08301be 43 */
sam_grove 63:531f4c27f360 44 virtual int32_t connect(const char *ssid, const char *pass, ns_security_t security = NS_SECURITY_NONE) = 0;
Christopher Haster 21:35ed15069189 45
Christopher Haster 21:35ed15069189 46 /** Stop the interface
Christopher Haster 21:35ed15069189 47 * @return 0 on success
Christopher Haster 21:35ed15069189 48 */
Christopher Haster 21:35ed15069189 49 virtual int32_t disconnect() = 0;
sam_grove 7:b147c08301be 50 };
sam_grove 7:b147c08301be 51
sam_grove 7:b147c08301be 52 #endif