0.28.0 #75
Replies: 4 comments 2 replies
-
Hi @ssilverman , amazing work with this library. Thank you so much. This is the complete program #include <QNEthernet.h>
using namespace qindesign::network;
const unsigned int MAX_MESSAGE_LENGTH = 255;
int size;
IPAddress ip{192, 168, 0, 42}; // device IP
IPAddress sn{255, 255, 0, 0}; // Subnet Mask
IPAddress gw{192, 168, 0, 1}; // Default Gateway
EthernetServer server(14555); // server on the 14555 port
//===============================================================================
// Initialization
//===============================================================================
void setup() {
Serial1.begin(57600); // gimbal port
Serial.begin(57600); // USB Port
Serial.println(Ethernet.begin(ip, sn, gw) ? "success" : "failure"); // Print if I have connection with the network
Serial.println(Ethernet.interfaceStatus() ? "UP" : "DOWN"); // preguntar por este codigo que hace ?
// Show whether a cable is plugged in or not.
Ethernet.onLinkState([](bool state)
{ Serial.printf("[Ethernet] Link %s\n", state ? "ON" : "OFF"); });
// start listening for clients
server.begin();
Serial.print("server is at ");
Serial.println(Ethernet.localIP());
}
//===============================================================================
// Main
//===============================================================================
void loop() {
// listen for incoming clients
EthernetClient client = server.available();
if (client) {
Serial.println("new client");
while (client.connected()) {
serial1Event();
delay(100);
static byte message[255];
int size = client.available(); // get the data size
for (int i = 0; i < size; i++)
{
message[i] = client.read();
Serial1.write(message[i]);
// Serial.println(message[i], HEX);
}
}
// give the web browser time to receive the data
delay(1);
// close the connection:
client.stop();
Serial.println("client disconnected");
}
}
void serial1Event() {
static byte messageS[MAX_MESSAGE_LENGTH]; //Create a place to hold the incoming message
while (Serial1.available() > 0)
{
size = Serial1.readBytesUntil('\n',messageS,255); // Read message until the character \n
server.write(messageS, size); // send message to the client
}
return;
} |
Beta Was this translation helpful? Give feedback.
-
[Would you mind modifying your post with code formatting? (i.e. the three backticks followed by “c++”) That would be helpful. Otherwise, I’ll look in a little bit.] Example: |
Beta Was this translation helpful? Give feedback.
-
[Also, would you mind creating an issue for this, copying your comment text? (With code formatted correctly.) I’d like to make sure you’re properly attributed as reporting this.] |
Beta Was this translation helpful? Give feedback.
-
I fixed it up and copied the text over to the issue. |
Beta Was this translation helpful? Give feedback.
-
Added
QNETHERNET_ENABLE_RAW_FRAME_LOOPBACK
macro to enable.EthernetFrameClass
functions:destinationMAC()
,sourceMAC()
,etherTypeOrLength()
, andpayload()
.qnethernet_hal.cpp
.NullPrint
andPrintDecorator
utility classes in theqindesign::network::util
namespace.driver_is_link_state_detectable()
function to the driver. This is for detecting whether the hardware is able to read the link state.EthernetClass::isLinkStateDetectable()
to detect whether the driver is capable of detecting link state.setOutgoingDiffServ(ds)
andoutgoingDiffServ()
functions for modifying and accessing the differentiated services (DiffServ) field, respectively, in the outgoing IP header, toEthernetClient
andEthernetUDP
.EthernetUDP::receivedDiffServ()
for retrieving the DiffServ value of the last received packet.EthernetFrameClass::clear()
for clearing the outgoing and incoming buffers.Changed
mbedtls_hardware_poll()
in MbedTLSDemo example for other platforms.QNETHERNET_ENABLE_CUSTOM_WRITE
toQNETHERNET_CUSTOM_WRITE
.linkStatus()
,linkState()
, andisLinkStateDetectable()
.EthernetClient::setNoDelay(flag)
to return whether successful.MEMP_NUM_SYS_TIMEOUT
option for mDNS, for a total of an additional 8. Timeout exhaustion was still observed with 6. Why 8 and not 7:EthernetClient::connect()
to return a Boolean value. (The function signatures don't change; they still return anint
.) This matches the new definition at Ethernet - client.connect().EthernetClient::connectNoWait()
return types tobool
.Fixed
__has_include()
, per: __has_include (The C Preprocessor)yield()
implementationextern "C"
.EthernetUDP
data copy for zero-length outgoing packets.pbuf_take()
considers NULL data an error, so only copy the data if the packet's size is not zero.This discussion was created from the release 0.28.0.
Beta Was this translation helpful? Give feedback.
All reactions