From 06fbf85bceb5e09004898147840612ee54ff265a Mon Sep 17 00:00:00 2001 From: logicog Date: Mon, 8 Dec 2025 12:24:20 +0100 Subject: [PATCH] Add SFP information in send_basic_info() --- httpd/page_impl.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/httpd/page_impl.c b/httpd/page_impl.c index da342d5..fef1e46 100644 --- a/httpd/page_impl.c +++ b/httpd/page_impl.c @@ -139,6 +139,20 @@ void reg_to_html(register uint16_t reg) sfr_data_to_html(); } + +void send_sfp_info(uint8_t sfp) +{ + // This loops over the Vendor-name, Vendor OUI, Vendor PN and Vendor rev ASCII fields + for (uint8_t i = 20; i < 60; i++) { + if (i >= 36 && i < 40) // Skip Non-ASCII codes + continue; + uint8_t c = sfp_read_reg(sfp, i); + if (c && c != 0xa0) // a0 is the byte read from a non-existant I2C EEPROM + char_to_html(c); + } +} + + void send_basic_info(void) { slen = strtox(outbuf, HTTP_RESPONCE_JSON); @@ -167,7 +181,16 @@ void send_basic_info(void) byte_to_html(uip_ethaddr.addr[5]); slen += strtox(outbuf + slen, "\",\"sw_ver\":\""); slen += strtox(outbuf + slen, VERSION_SW); - slen += strtox(outbuf + slen, "\",\"hw_ver\":\"SWGT024-V2.0\"}"); + slen += strtox(outbuf + slen, "\",\"hw_ver\":\"SWGT024-V2.0\""); + slen += strtox(outbuf + slen, ",\"sfp_slot_0\":\""); + send_sfp_info(0); + char_to_html('"'); +#if NSFP == 2 + slen += strtox(outbuf + slen, ",\"sfp_slot_1\":\""); + send_sfp_info(1); + char_to_html('"'); +#endif + char_to_html('}'); }