FUNCTIONAL Update from mbed v49: Add APIs for setName/getName so device is name addressible. Also APIs for getting link stats. Also, minor derivative to reduce compiler warnings and tag read-only parameters as const.
Dependencies: Socket lwip-eth lwip-sys lwip
Dependents: WattEye X10Svr SSDP_Server
Fork of EthernetInterface by
EthernetInterface_Mods.h
00001 // 00002 // EthernetInterface Modifications to enhance it slightly. 00003 // 00004 // This set of modifications integrates with the mbed standard EthernetInterface stack. 00005 // It does require one-line modifications of both EthernetInterface.h and EthernetInterface.cpp. 00006 // 00007 // CAUTION: This works with the LPC1768, but some of the interfaces may be unique to that part. 00008 // 00009 // Two steps integrate this: 00010 // 00011 // STEP 1: edit EthernetInterface.h as follows: 00012 // 00013 // class EthernetInterface { 00014 // public: 00015 // ... normal EthernetInterface APIs 00016 // 00017 // add this in the public section, at the bottom 00018 // #include "EthernetInterface_Mods.h" 00019 // }; 00020 // 00021 // STEP 2: edit EthernetInterface.cpp as follows: 00022 // 00023 // // add this at the end of the file 00024 // #include "EthernetInterface_Mods.hxx" 00025 // 00026 #ifndef ETHERNETINTERFACE_MODS_H 00027 #define ETHERNETINTERFACE_MODS_H 00028 00029 //#include "lpc_phy.h" // needed for is_connected() 00030 00031 /** \brief DP83848 PHY status definitions */ 00032 #define DP8_REMOTEFAULT (1 << 6) /**< Remote fault */ 00033 #define DP8_FULLDUPLEX (1 << 2) /**< 1=full duplex */ 00034 #define DP8_SPEED10MBPS (1 << 1) /**< 1=10MBps speed */ 00035 #define DP8_VALID_LINK (1 << 0) /**< 1=Link active */ 00036 00037 00038 /** setName 00039 * 00040 * Set the network name for this device. Apply this before 00041 * calling 'connect'. 00042 * 00043 * \example 00044 * EthernetInterface eth; 00045 * ... 00046 * if (0 == eth.init()) { 00047 * eth.setName("Sensor 3"); 00048 * if (0 == eth.connect()) { 00049 * ... 00050 * 00051 * \param myname is the name to assign for this node. 00052 * Only the first 32 characters will be used if the 00053 * name is longer. 00054 * Only '0'-'9', 'A'-'Z', 'a'-'z' are accepted, 00055 * any others are converted to '-'. 00056 * \return 0 on success, a negative number on failure. 00057 */ 00058 static int setName(const char * myname); 00059 00060 /** getName 00061 * 00062 * Get the network name for this device. 00063 * 00064 * \return pointer to the name (or null) 00065 */ 00066 static const char * getName(void); 00067 00068 /** is_connected 00069 * 00070 * Determine if the interface is up and connected. 00071 * 00072 * \example 00073 * if (eth.is_connected()) 00074 * ethLED = 1; 00075 * else 00076 * ethLED = 0; 00077 * 00078 * \return true if connected, false if not connected. 00079 */ 00080 static bool is_connected(void); 00081 00082 /** get_transmission_status - full or half duplex. 00083 * 00084 * \return 1 = 1/2 (half) duplex, 2 = 2/2 (full) duplex 00085 */ 00086 int get_transmission_status(void); // 1 = 1/2 duplex, 2 = full duplex 00087 00088 /** get the speed of the connection. 00089 * 00090 * \return 10 or 100 Mb 00091 */ 00092 int get_connection_speed(void); // 10 or 100 Mb 00093 00094 /** get the current value in the MII data register. 00095 * 00096 * \return mii register value 00097 */ 00098 uint32_t mii_read_data(void); 00099 00100 00101 00102 /** set whether the link signal blinks on traffic, or is steady. 00103 * 00104 * @param[in] BlinkIt when non-zero sets the PHY register accordingly. 00105 * 00106 * @code 00107 * EthernetInterface eth; 00108 * eth.init(); 00109 * eth.connect(); 00110 * eth.LinkBlinkOnTraffic(1); 00111 * @endcode 00112 */ 00113 void LinkBlinkOnTraffic(int BlinkIt); 00114 00115 #endif // ETHERNETINTERFACE_MODS_H
Generated on Thu Jul 14 2022 10:38:38 by 1.7.2