Skip to content

Commit

Permalink
LWIP integrated StandardFirmataEthernet
Browse files Browse the repository at this point in the history
  • Loading branch information
veeraadlink committed Feb 23, 2024
1 parent e73f29b commit de8659e
Show file tree
Hide file tree
Showing 7 changed files with 2,032 additions and 6 deletions.
Binary file modified OT2ITEth.zip
Binary file not shown.
32 changes: 26 additions & 6 deletions OT2ITEth/OT2ITEth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


bool link_up = false;
bool dhcp_up = false;
uint8_t speed;
char buffer[1024];

Expand Down Expand Up @@ -55,7 +56,7 @@ void mac_receive_cb(struct mac_async_descriptor *desc)

void link_status_print(void)
{
Serial.print(" Eth: ");
Serial.print("Eth: ");
if (link_up)
{
Serial.print("UP. ");
Expand Down Expand Up @@ -111,6 +112,7 @@ void OT2ITEth::begin(uint8_t *hwaddr)
void OT2ITEth::get_link_sts()
{
int ret;
static int lup;
do
{
ret = ethernet_phy_get_link_status(&ETHERNET_PHY_0_desc, &link_up, &speed);
Expand All @@ -121,7 +123,17 @@ void OT2ITEth::get_link_sts()
delay(200);
} while (true);

Serial.println("Ethernet link up");
if(lup != link_up) {
if(link_up) {
Serial.println("Ethernet link up");
link_status_print();
}
lup = link_up;
}

//if (!(link_up && TCPIP_STACK_INTERFACE_0_desc.ip_addr.addr)) {
receive();
//}
}

void OT2ITEth::ip_stack_init(uint8_t *hwaddr)
Expand All @@ -137,9 +149,9 @@ void OT2ITEth::ip_stack_init(uint8_t *hwaddr)
netif_set_up(&TCPIP_STACK_INTERFACE_0_desc); // enable this for Static IP
#endif

ot2it_print_ipaddress();
//ot2it_print_ipaddress();
/*Handles web server events*/
lwip_raw_api_init();
//lwip_raw_api_init();
}

void OT2ITEth::receive()
Expand All @@ -155,8 +167,11 @@ void OT2ITEth::receive()
/* Print IP address info */
if (link_up && TCPIP_STACK_INTERFACE_0_desc.ip_addr.addr)
{
link_up = false;
ot2it_print_ipaddress();
//link_up = false;
if(dhcp_up == false) {
ot2it_print_ipaddress();
dhcp_up = true;
}
}
}

Expand All @@ -179,3 +194,8 @@ void OT2ITEth::setSubnetMask(IPAddress ipAddr)
{
TCPIP_STACK_INTERFACE_0_desc.netmask.addr = ipAddr;
}

int OT2ITEth::maintain(void)
{
return (link_up && dhcp_up);
}
1 change: 1 addition & 0 deletions OT2ITEth/OT2ITEth.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,6 @@ class OT2ITEth
void setIPAddress(IPAddress ipAddr);
void setGatewayIp(IPAddress ipAddr);
void setSubnetMask(IPAddress ipAddr);
int maintain(void);
};
#endif
Loading

0 comments on commit de8659e

Please sign in to comment.