Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 193a513

Browse filesBrowse files
gdsportsfpistm
authored andcommitted
Add Ethernet.linkStatus
Also remove 2 printf debug.
1 parent cfe4f64 commit 193a513
Copy full SHA for 193a513

File tree

Expand file treeCollapse file tree

4 files changed

+22
-4
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+22
-4
lines changed

‎src/STM32Ethernet.cpp

Copy file name to clipboardExpand all lines: src/STM32Ethernet.cpp
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ void EthernetClass::begin(uint8_t *mac, IPAddress local_ip, IPAddress dns_server
101101
macAddress(mac);
102102
}
103103

104+
EthernetLinkStatus EthernetClass::linkStatus()
105+
{
106+
return (stm32_eth_link_up() ? LinkON : LinkOFF);
107+
}
108+
104109
int EthernetClass::maintain(){
105110
int rc = DHCP_CHECK_NONE;
106111

‎src/STM32Ethernet.h

Copy file name to clipboardExpand all lines: src/STM32Ethernet.h
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
#include "EthernetServer.h"
88
#include "Dhcp.h"
99

10+
enum EthernetLinkStatus {
11+
Unknown,
12+
LinkON,
13+
LinkOFF
14+
};
15+
1016
class EthernetClass {
1117
private:
1218
IPAddress _dnsServerAddress;
@@ -19,6 +25,7 @@ class EthernetClass {
1925
// configuration through DHCP.
2026
// Returns 0 if the DHCP configuration failed, and 1 if it succeeded
2127
int begin(unsigned long timeout = 60000, unsigned long responseTimeout = 4000);
28+
EthernetLinkStatus linkStatus();
2229
void begin(IPAddress local_ip);
2330
void begin(IPAddress local_ip, IPAddress subnet);
2431
void begin(IPAddress local_ip, IPAddress subnet, IPAddress gateway);

‎src/utility/stm32_eth.cpp

Copy file name to clipboardExpand all lines: src/utility/stm32_eth.cpp
+9-4Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,15 @@ void stm32_eth_init(const uint8_t *mac, const uint8_t *ip, const uint8_t *gw, co
246246
stm32_eth_scheduler();
247247
}
248248

249+
/**
250+
* @brief Return Ethernet link status
251+
* @param None
252+
* @retval 1 for link up, 0 for link down
253+
*/
254+
uint8_t stm32_eth_link_up(void) {
255+
return netif_is_link_up(&gnetif);
256+
}
257+
249258
/**
250259
* @brief This function must be called in main loop in standalone mode.
251260
* @param None
@@ -479,8 +488,6 @@ void ethernetif_notify_conn_changed(struct netif *netif)
479488
{
480489
if(netif_is_link_up(netif))
481490
{
482-
printf("Link up\n");
483-
484491
/* Update DHCP state machine if DHCP used */
485492
if(DHCP_Started_by_user == 1) {
486493
DHCP_state = DHCP_START;
@@ -498,8 +505,6 @@ void ethernetif_notify_conn_changed(struct netif *netif)
498505

499506
/* When the netif link is down this function must be called.*/
500507
netif_set_down(netif);
501-
502-
printf("Link down\n");
503508
}
504509
}
505510

‎src/utility/stm32_eth.h

Copy file name to clipboardExpand all lines: src/utility/stm32_eth.h
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ extern struct netif gnetif;
121121

122122
/* Exported functions ------------------------------------------------------- */
123123
void stm32_eth_init(const uint8_t *mac, const uint8_t *ip, const uint8_t *gw, const uint8_t *netmask);
124+
uint8_t stm32_eth_link_up(void);
124125
void stm32_eth_scheduler(void);
125126

126127
void User_notification(struct netif *netif);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.