Knight KE / Mbed OS Game_Master
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers NanostackEthernetInterface.h Source File

NanostackEthernetInterface.h

00001 /*
00002  * Copyright (c) 2016 ARM Limited. All rights reserved.
00003  * SPDX-License-Identifier: Apache-2.0
00004  * Licensed under the Apache License, Version 2.0 (the License); you may
00005  * 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, WITHOUT
00012  * 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 #ifndef NANOSTACKETHERNETINTERFACE_H
00018 #define NANOSTACKETHERNETINTERFACE_H
00019 
00020 #include "EthInterface.h"
00021 #include "MeshInterfaceNanostack.h"
00022 #include "NanostackEthernetPhy.h"
00023 
00024 class Nanostack::EthernetInterface : public Nanostack::Interface {
00025 public:
00026     virtual nsapi_error_t bringup(bool dhcp, const char *ip,
00027                                   const char *netmask, const char *gw,
00028                                   nsapi_ip_stack_t stack = DEFAULT_STACK,
00029                                   bool blocking = true);
00030     virtual nsapi_error_t bringdown();
00031 
00032 private:
00033     friend Nanostack;
00034     friend class NanostackEthernetInterface;
00035     EthernetInterface(NanostackEthernetPhy &phy) : Interface(phy) {}
00036     nsapi_error_t initialize();
00037 protected:
00038     NanostackEthernetPhy &get_phy() const { return static_cast<NanostackEthernetPhy &>(Interface::get_phy()); }
00039 };
00040 
00041 /** Ethernet interface for Nanostack.
00042  *
00043  * Configure Nanostack to use Ethernet connectivity.
00044  */
00045 class NanostackEthernetInterface : public InterfaceNanostack, public EthInterface, private mbed::NonCopyable<NanostackEthernetInterface> {
00046 public:
00047     NanostackEthernetInterface() { }
00048     //NanostackEthernetInterface(NanostackEthernetPhy *phy);
00049 
00050     nsapi_error_t initialize(NanostackEthernetPhy *phy);
00051 
00052     /** Start the interface
00053      *
00054      *  @return     0 on success, negative on failure
00055      */
00056     virtual nsapi_error_t connect();
00057 
00058     /** Stop the interface
00059      *
00060      *  @return     0 on success, negative on failure
00061      */
00062     virtual nsapi_error_t disconnect();
00063 
00064 protected:
00065     Nanostack::EthernetInterface *get_interface() const { return static_cast<Nanostack::EthernetInterface *>(_interface); }
00066 
00067 };
00068 
00069 #endif // NANOSTACKETHERNETINTERFACE_H