Hey bamos.
I'm currently also doing a project with teensy 4.1 and led strips controlled via UDP direct messages. I am controlling 300 RGB leds using the octows2811 library and sending UDP messages 50 times a second. It's working perfectly, never had any issue with both things working in parallel. I had do increase the UDP_TX_PACKET_MAX_SIZE constant in the file NativeEthernet.h since the buffer size defines was much smaller than my data size. Just doing that made it all work.
int packetSize = Udp.parsePacket();
if (packetSize==40){
Udp.read(recvbuf, UDP_TX_PACKET_MAX_SIZE);
/*decodes the message and respond*/
}
Due to the nature of this wrapper library the performance will never be fully optimal. If you need more precision over what’s going on you will have to learn FNET and make a service for what you want to do. FNET services are handled automatically in the background pretty much as soon as a packet arrives. So from within your service when a packet arrives you just have it use a callback function that triggers your interrupt. In the future when I start doing more Ethernet things I may make an addon to NativeEthernet that simplifies the process of a making a service. But, the caveat is people will have to relearn how to make Ethernet sketches since any tutorial for Ethernet.h wouldn’t be valid when you are making it non-blocking.
if (Ethernet.linkStatus() == LinkOFF) {
Serial.println("Ethernet cable is not connected.");
}
while (Ethernet.linkStatus() == LinkOFF) {
Serial.println("Ethernet cable is not connected.");
delay(100);
}
if (Ethernet.begin(mac) != 0) {
IPAddress myIP = Ethernet.localIP();
Serial.printf( "IP Address %u.%u.%u.%u\n", myIP[0], myIP[1], myIP[2], myIP[3] );
}
if (Ethernet.begin(mac, [B]ip[/B]) != 0) {
IPAddress myIP = Ethernet.localIP();
Serial.printf( "IP Address %u.%u.%u.%u\n", myIP[0], myIP[1], myIP[2], myIP[3] );
}
When you provide a static IP there is no return function, therefore when you try to != 0 it throws an error since there is no value to compare. When you only give it a MAC address it does provide a return value because that shows whether or not it obtained an IP address.
Hi,
Trying to have a way to detect if a cable is connected and the link status method doesn't seems to work the way I initially thought.
For me that was detecting if a cable is attached and you have some level of signal on the line.
But it appears that's more to detect if you have an active connection, after having an ethernet.begin call.
Is that the case or it should detect the cable without the call for the ethernet.begin?
For example the link-status example doesn't work apart if you add the ethernet begin before testing for the link.
Particularly annoying when we want a static IP and the library doesn't have a timeout on the begin function...
Added that on my fork if interested.