mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-08-30 14:52:51 +08:00
Add EEE httpd support
This commit is contained in:
@@ -422,6 +422,8 @@ void httpd_appcall(void)
|
||||
send_vlan(short_parsed);
|
||||
} else if (is_word(q, "/counters.json")) {
|
||||
send_counters(q[19]-'0');
|
||||
} else if (is_word(q, "/eee.json")) {
|
||||
send_eee();
|
||||
} else {
|
||||
send_not_found();
|
||||
}
|
||||
|
||||
@@ -7,8 +7,10 @@
|
||||
#include "uip.h"
|
||||
#include "../html_data.h"
|
||||
#include <stdint.h>
|
||||
#include "../phy.h"
|
||||
|
||||
#pragma codeseg BANK1
|
||||
#pragma constseg BANK1
|
||||
|
||||
extern __xdata uint8_t outbuf[TCP_OUTBUF_SIZE];
|
||||
extern __xdata uint16_t slen;
|
||||
@@ -208,6 +210,76 @@ void send_counters(char port)
|
||||
}
|
||||
|
||||
|
||||
void send_eee()
|
||||
{
|
||||
print_string("send_eee called\n");
|
||||
slen = strtox(outbuf, HTTP_RESPONCE_JSON);
|
||||
print_string("sending EEE status\n");
|
||||
|
||||
reg_read_m(RTL8373_PHY_EEE_ABLTY);
|
||||
uint8_t eee_ablty = sfr_data[3];
|
||||
char_to_html('[');
|
||||
for (uint8_t i = minPort; i <= maxPort; i++) {
|
||||
slen += strtox(outbuf + slen, "{\"portNum\":");
|
||||
if (!isRTL8373)
|
||||
itoa_html(log_to_phys_port[i]);
|
||||
else
|
||||
itoa_html(i + 1);
|
||||
if (IS_SFP(i)) {
|
||||
slen += strtox(outbuf + slen, " ,\"isSFP\": 1");
|
||||
} else {
|
||||
slen += strtox(outbuf + slen, " ,\"isSFP\": 0 ");
|
||||
uint16_t v;
|
||||
phy_read(i, PHY_MMD_AN, PHY_EEE_ADV2);
|
||||
v = SFR_DATA_U16;
|
||||
slen += strtox(outbuf + slen, ",\"eee\":\"");
|
||||
if (v & PHY_EEE_BIT_2G5)
|
||||
char_to_html('1');
|
||||
else
|
||||
char_to_html('0');
|
||||
phy_read(i, PHY_MMD_AN, PHY_EEE_ADV);
|
||||
v = SFR_DATA_U16;
|
||||
if (v & PHY_EEE_BIT_1G)
|
||||
char_to_html('1');
|
||||
else
|
||||
char_to_html('0');
|
||||
if (v & PHY_EEE_BIT_100M)
|
||||
char_to_html('1');
|
||||
else
|
||||
char_to_html('0');
|
||||
|
||||
phy_read(i, PHY_MMD_AN, PHY_EEE_LP_ABILITY2);
|
||||
v = SFR_DATA_U16;
|
||||
slen += strtox(outbuf + slen, "\", \"eee_lp\":\"");
|
||||
if (v & PHY_EEE_BIT_2G5)
|
||||
char_to_html('1');
|
||||
else
|
||||
char_to_html('0');
|
||||
phy_read(i, PHY_MMD_AN, PHY_EEE_LP_ABILITY);
|
||||
v = SFR_DATA_U16;
|
||||
if (v & PHY_EEE_BIT_1G)
|
||||
char_to_html('1');
|
||||
else
|
||||
char_to_html('0');
|
||||
if (v & PHY_EEE_BIT_100M)
|
||||
char_to_html('1');
|
||||
else
|
||||
char_to_html('0');
|
||||
slen += strtox(outbuf + slen, "\", \"active\": ");
|
||||
if (eee_ablty & (1 << i))
|
||||
char_to_html('1');
|
||||
else
|
||||
char_to_html('0');
|
||||
}
|
||||
char_to_html('}');
|
||||
if (i < maxPort)
|
||||
char_to_html(',');
|
||||
else
|
||||
char_to_html(']');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void send_status(void)
|
||||
{
|
||||
slen = strtox(outbuf, HTTP_RESPONCE_JSON);
|
||||
|
||||
@@ -5,5 +5,6 @@ void send_counters(char port);
|
||||
void send_status(void);
|
||||
void send_vlan(register uint16_t vlan);
|
||||
void send_basic_info(void);
|
||||
void send_eee(void);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user