From 7b82cc6df844bfab5794c4fd6dd66c3f3173c1ef Mon Sep 17 00:00:00 2001 From: rechrtb Date: Fri, 25 Nov 2022 13:19:20 +0800 Subject: [PATCH 1/3] Support outgoing connections --- src/GCodes/GCodes2.cpp | 8 +- src/Networking/ESP8266WiFi/WiFiInterface.cpp | 63 ++++++++-- src/Networking/ESP8266WiFi/WiFiInterface.h | 15 ++- src/Networking/ESP8266WiFi/WiFiSocket.cpp | 50 ++++++-- src/Networking/ESP8266WiFi/WiFiSocket.h | 5 +- .../LwipEthernet/LwipEthernetInterface.cpp | 6 +- .../LwipEthernet/LwipEthernetInterface.h | 4 +- src/Networking/Network.cpp | 54 ++++++++- src/Networking/Network.h | 7 +- src/Networking/NetworkClient.cpp | 111 ++++++++++++++++++ src/Networking/NetworkClient.h | 54 +++++++++ src/Networking/NetworkInterface.h | 4 +- src/Networking/Socket.h | 3 +- 13 files changed, 340 insertions(+), 44 deletions(-) create mode 100644 src/Networking/NetworkClient.cpp create mode 100644 src/Networking/NetworkClient.h diff --git a/src/GCodes/GCodes2.cpp b/src/GCodes/GCodes2.cpp index 11abc2493f..2601f7b9a2 100644 --- a/src/GCodes/GCodes2.cpp +++ b/src/GCodes/GCodes2.cpp @@ -3787,7 +3787,13 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx { const int port = (gb.Seen('R')) ? gb.GetIValue() : -1; const int secure = (gb.Seen('T')) ? gb.GetIValue() : -1; - result = reprap.GetNetwork().EnableProtocol(interface, protocol, port, secure, reply); + IPAddress ip; + if (gb.Seen('H')) + { + gb.GetIPAddress(ip); + } + result = reprap.GetNetwork().EnableProtocol(interface, protocol, port, + ip.GetV4LittleEndian(), secure, reply); } else { diff --git a/src/Networking/ESP8266WiFi/WiFiInterface.cpp b/src/Networking/ESP8266WiFi/WiFiInterface.cpp index d6554ec4af..ab9d948f6d 100644 --- a/src/Networking/ESP8266WiFi/WiFiInterface.cpp +++ b/src/Networking/ESP8266WiFi/WiFiInterface.cpp @@ -299,6 +299,7 @@ WiFiInterface::WiFiInterface(Platform& p) noexcept for (size_t i = 0; i < NumProtocols; ++i) { + ipAddresses[i] = AnyIp; portNumbers[i] = DefaultPortNumbers[i]; protocolEnabled[i] = (i == HttpProtocol); } @@ -359,7 +360,7 @@ void WiFiInterface::Init() noexcept currentSocket = 0; } -GCodeResult WiFiInterface::EnableProtocol(NetworkProtocol protocol, int port, int secure, const StringRef& reply) noexcept +GCodeResult WiFiInterface::EnableProtocol(NetworkProtocol protocol, int port, uint32_t ip, int secure, const StringRef& reply) noexcept { if (secure != 0 && secure != -1) { @@ -370,19 +371,22 @@ GCodeResult WiFiInterface::EnableProtocol(NetworkProtocol protocol, int port, in const TcpPort portToUse = (port < 0) ? DefaultPortNumbers[protocol] : port; MutexLocker lock(interfaceMutex); - if (portToUse != portNumbers[protocol] && GetState() == NetworkState::active) + if ((portToUse != portNumbers[protocol] || ip != ipAddresses[protocol]) && GetState() == NetworkState::active) { - // We need to shut down and restart the protocol if it is active because the port number has changed + // We need to shut down and restart the protocol if it is active because the port number has changed. + // Note that clients will probably be unable to close their connections gracefully. ShutdownProtocol(protocol); protocolEnabled[protocol] = false; } + ipAddresses[protocol] = ip; portNumbers[protocol] = portToUse; if (!protocolEnabled[protocol]) { protocolEnabled[protocol] = true; if (GetState() == NetworkState::active) { - StartProtocol(protocol); + // Only start listeners here, connection requests for clients are made in the main loop. + ListenProtocol(protocol); // mDNS announcement is done by the WiFi Server firmware } } @@ -394,13 +398,13 @@ GCodeResult WiFiInterface::EnableProtocol(NetworkProtocol protocol, int port, in return GCodeResult::error; } -GCodeResult WiFiInterface::DisableProtocol(NetworkProtocol protocol, const StringRef& reply) noexcept +GCodeResult WiFiInterface::DisableProtocol(NetworkProtocol protocol, const StringRef& reply, bool shutdown) noexcept { if (protocol < NumProtocols) { MutexLocker lock(interfaceMutex); - if (GetState() == NetworkState::active) + if (shutdown && GetState() == NetworkState::active) { ShutdownProtocol(protocol); } @@ -413,7 +417,7 @@ GCodeResult WiFiInterface::DisableProtocol(NetworkProtocol protocol, const Strin return GCodeResult::error; } -void WiFiInterface::StartProtocol(NetworkProtocol protocol) noexcept +void WiFiInterface::ListenProtocol(NetworkProtocol protocol) noexcept { MutexLocker lock(interfaceMutex); @@ -436,6 +440,18 @@ void WiFiInterface::StartProtocol(NetworkProtocol protocol) noexcept } } +void WiFiInterface::ConnectProtocol(NetworkProtocol protocol) noexcept +{ + MutexLocker lock(interfaceMutex); + + switch(protocol) + { + + default: + break; + } +} + void WiFiInterface::ShutdownProtocol(NetworkProtocol protocol) noexcept { MutexLocker lock(interfaceMutex); @@ -808,6 +824,22 @@ void WiFiInterface::Spin() noexcept } else if (currentMode == WiFiState::connected || currentMode == WiFiState::runningAsAccessPoint) { + // Maintain client connections + for (uint8_t p = 0; p < NumProtocols; p++) + { + if (protocolEnabled[p]) + { + if (reprap.GetNetwork().StartClient(this, p)) + { + ConnectProtocol(p); + } + } + else + { + reprap.GetNetwork().StopClient(this, p); + } + } + // Find the next socket to poll const size_t startingSocket = currentSocket; do @@ -831,6 +863,7 @@ void WiFiInterface::Spin() noexcept currentSocket = 0; } + // Check if the data port needs to be closed if (closeDataPort) { @@ -1440,7 +1473,7 @@ void WiFiInterface::InitSockets() noexcept { if (protocolEnabled[i]) { - StartProtocol(i); + ListenProtocol(i); } } currentSocket = 0; @@ -1454,11 +1487,11 @@ void WiFiInterface::TerminateSockets() noexcept } } -void WiFiInterface::TerminateSockets(TcpPort port) noexcept +void WiFiInterface::TerminateSockets(TcpPort port, bool local) noexcept { for (WiFiSocket *socket : sockets) { - if (socket->GetLocalPort() == port) + if ((local ? socket->GetLocalPort() : socket->GetRemotePort()) == port) { socket->Terminate(); } @@ -2026,6 +2059,16 @@ void WiFiInterface::SendListenCommand(TcpPort port, NetworkProtocol protocol, un SendCommand(NetworkCommand::networkListen, 0, 0, 0, &lcb, sizeof(lcb), nullptr, 0); } +void WiFiInterface::SendConnectCommand(TcpPort remotePort, NetworkProtocol protocol, uint32_t remoteIp) noexcept +{ + ListenOrConnectData lcb; + memset(&lcb, 0, sizeof(lcb)); + lcb.port = remotePort; + lcb.protocol = protocol; + lcb.remoteIp = remoteIp; + SendCommand(NetworkCommand::connCreate, 0, 0, 0, &lcb, sizeof(lcb), nullptr, 0); +} + // Stop listening on a port void WiFiInterface::StopListening(TcpPort port) noexcept { diff --git a/src/Networking/ESP8266WiFi/WiFiInterface.h b/src/Networking/ESP8266WiFi/WiFiInterface.h index 42a41f9b78..d74066e464 100644 --- a/src/Networking/ESP8266WiFi/WiFiInterface.h +++ b/src/Networking/ESP8266WiFi/WiFiInterface.h @@ -61,8 +61,8 @@ class WiFiInterface : public NetworkInterface void Stop() noexcept; GCodeResult EnableInterface(int mode, const StringRef& ssid, const StringRef& reply) noexcept override; // enable or disable the network - GCodeResult EnableProtocol(NetworkProtocol protocol, int port, int secure, const StringRef& reply) noexcept override; - GCodeResult DisableProtocol(NetworkProtocol protocol, const StringRef& reply) noexcept override; + GCodeResult EnableProtocol(NetworkProtocol protocol, int port, uint32_t ip, int secure, const StringRef& reply) noexcept override; + GCodeResult DisableProtocol(NetworkProtocol protocol, const StringRef& reply, bool shutdown = true) noexcept override; GCodeResult ReportProtocols(const StringRef& reply) const noexcept override; GCodeResult GetNetworkState(const StringRef& reply) noexcept override; @@ -100,12 +100,15 @@ class WiFiInterface : public NetworkInterface private: void InitSockets() noexcept; void TerminateSockets() noexcept; - void TerminateSockets(TcpPort port) noexcept; + void TerminateSockets(TcpPort port, bool local = true) noexcept; void StopListening(TcpPort port) noexcept; - void StartProtocol(NetworkProtocol protocol) noexcept + // Protocol socket operations - listen for incoming connections, + // create outgoing connection, kill existing listeners & connections. + void ListenProtocol(NetworkProtocol protocol) noexcept + pre(protocol < NumProtocols); + void ConnectProtocol(NetworkProtocol protocol) noexcept pre(protocol < NumProtocols); - void ShutdownProtocol(NetworkProtocol protocol) noexcept pre(protocol < NumProtocols); @@ -124,6 +127,7 @@ class WiFiInterface : public NetworkInterface } void SendListenCommand(TcpPort port, NetworkProtocol protocol, unsigned int maxConnections) noexcept; + void SendConnectCommand(TcpPort port, NetworkProtocol protocol, uint32_t ip) noexcept; void GetNewStatus() noexcept; void spi_slave_dma_setup(uint32_t dataOutSize, uint32_t dataInSize) noexcept; @@ -144,6 +148,7 @@ class WiFiInterface : public NetworkInterface WiFiSocket *sockets[NumWiFiTcpSockets]; size_t currentSocket; + uint32_t ipAddresses[NumProtocols]; TcpPort portNumbers[NumProtocols]; // port number used for each protocol TcpPort ftpDataPort; bool closeDataPort; diff --git a/src/Networking/ESP8266WiFi/WiFiSocket.cpp b/src/Networking/ESP8266WiFi/WiFiSocket.cpp index 62160b7300..87eeaeea74 100644 --- a/src/Networking/ESP8266WiFi/WiFiSocket.cpp +++ b/src/Networking/ESP8266WiFi/WiFiSocket.cpp @@ -30,7 +30,7 @@ void WiFiSocket::Init(SocketNumber n) noexcept // Close a connection when the last packet has been sent void WiFiSocket::Close() noexcept { - if (state == SocketState::connected || state == SocketState::clientDisconnecting) + if (state == SocketState::connected || state == SocketState::connecting || state == SocketState::peerDisconnecting) { const int32_t reply = GetInterface()->SendCommand(NetworkCommand::connClose, socketNum, 0, 0, nullptr, 0, nullptr, 0); if (reply == ResponseEmpty) @@ -65,7 +65,7 @@ void WiFiSocket::Terminate() noexcept bool WiFiSocket::CanRead() const noexcept { return (state == SocketState::connected) - || (state == SocketState::clientDisconnecting && (hasMoreDataPending || (receivedData != nullptr && receivedData->TotalRemaining() != 0))); + || (state == SocketState::peerDisconnecting && (hasMoreDataPending || (receivedData != nullptr && receivedData->TotalRemaining() != 0))); } // Return true if we can send data to this socket @@ -139,12 +139,32 @@ void WiFiSocket::Poll() noexcept switch (resp.Value().state) { + case ConnState::connecting: + { + // This state might get skipped, if the socket connected before it can be polled + // in this state. This shouldn't matter, as there is no important logic in this + // state, other than to check if we're here a bit too long. + if (state == SocketState::connecting) + { + // Check for timeout + if (millis() - whenInState >= ConnectTimeout) + { + Close(); + } + } + else + { + whenInState = millis(); + state = SocketState::connecting; + } + } + break; case ConnState::otherEndClosed: // Check for further incoming packets before this socket is finally closed. // This must be done to ensure that FTP uploads are not cut off. ReceiveData(resp.Value().bytesAvailable); - if (state == SocketState::clientDisconnecting) + if (state == SocketState::peerDisconnecting) { if (!CanRead()) { @@ -155,15 +175,15 @@ void WiFiSocket::Poll() noexcept } else if (state != SocketState::inactive) { - state = SocketState::clientDisconnecting; + state = SocketState::peerDisconnecting; if (reprap.Debug(moduleNetwork)) { - debugPrintf("Client disconnected on socket %u\n", socketNum); + debugPrintf("Peer disconnected on socket %u\n", socketNum); } break; } - // We can get here if a client has sent very little data and then instantly closed - // the connection, e.g. when an FTP client transferred very small files over the + // We can get here if a peer has sent very little data and then instantly closed + // the connection, e.g. when an FTP peer transferred very small files over the // data port. In such cases we must notify the responder about this transmission! // no break @@ -181,20 +201,28 @@ void WiFiSocket::Poll() noexcept if (state != SocketState::waitingForResponder) { WiFiInterface *iface = static_cast(interface); - protocol = iface->GetProtocolByLocalPort(localPort); + if (isdigit(iface->wiFiServerVersion[0]) && iface->wiFiServerVersion[0] >= '2') + { + // On version 2 onwards, this is a valid field ConnStatusResponse. + protocol = resp.Value().protocol; + } + else + { + protocol = iface->GetProtocolByLocalPort(localPort); + } - whenConnected = millis(); + whenInState = millis(); state = SocketState::waitingForResponder; } if (reprap.GetNetwork().FindResponder(this, protocol)) { - state = (resp.Value().state == ConnState::connected) ? SocketState::connected : SocketState::clientDisconnecting; + state = (resp.Value().state == ConnState::connected) ? SocketState::connected : SocketState::peerDisconnecting; if (reprap.Debug(moduleNetwork)) { debugPrintf("Found responder\n"); } } - else if (millis() - whenConnected >= FindResponderTimeout) + else if (millis() - whenInState >= FindResponderTimeout) { Terminate(); if (reprap.Debug(moduleNetwork)) diff --git a/src/Networking/ESP8266WiFi/WiFiSocket.h b/src/Networking/ESP8266WiFi/WiFiSocket.h index accbc0b1a9..431cca7ec6 100644 --- a/src/Networking/ESP8266WiFi/WiFiSocket.h +++ b/src/Networking/ESP8266WiFi/WiFiSocket.h @@ -43,9 +43,10 @@ class WiFiSocket : public Socket enum class SocketState : uint8_t { inactive, + connecting, waitingForResponder, connected, - clientDisconnecting, + peerDisconnecting, closing, broken }; @@ -56,7 +57,7 @@ class WiFiSocket : public Socket NetworkBuffer *receivedData; // List of buffers holding received data bool hasMoreDataPending; // If there is more data left to read when the buffered data has been processed - uint32_t whenConnected; + uint32_t whenInState; // General purpose timekeeping value for duration spent in various socket states uint16_t txBufferSpace; // How much free transmit buffer space the WiFi mofule reported SocketNumber socketNum; // The WiFi socket number we are using SocketState state; diff --git a/src/Networking/LwipEthernet/LwipEthernetInterface.cpp b/src/Networking/LwipEthernet/LwipEthernetInterface.cpp index 0430a81ce7..0217a7fc23 100644 --- a/src/Networking/LwipEthernet/LwipEthernetInterface.cpp +++ b/src/Networking/LwipEthernet/LwipEthernetInterface.cpp @@ -155,7 +155,7 @@ void LwipEthernetInterface::Init() noexcept macAddress = platform.GetDefaultMacAddress(); } -GCodeResult LwipEthernetInterface::EnableProtocol(NetworkProtocol protocol, int port, int secure, const StringRef& reply) noexcept +GCodeResult LwipEthernetInterface::EnableProtocol(NetworkProtocol protocol, int port, uint32_t ip, int secure, const StringRef& reply) noexcept { if (secure != 0 && secure != -1) { @@ -192,11 +192,11 @@ GCodeResult LwipEthernetInterface::EnableProtocol(NetworkProtocol protocol, int return GCodeResult::error; } -GCodeResult LwipEthernetInterface::DisableProtocol(NetworkProtocol protocol, const StringRef& reply) noexcept +GCodeResult LwipEthernetInterface::DisableProtocol(NetworkProtocol protocol, const StringRef& reply, bool shutdown) noexcept { if (protocol < NumProtocols) { - if (GetState() == NetworkState::active) + if (shutdown && GetState() == NetworkState::active) { ShutdownProtocol(protocol); } diff --git a/src/Networking/LwipEthernet/LwipEthernetInterface.h b/src/Networking/LwipEthernet/LwipEthernetInterface.h index e1a34da562..bd61618c6f 100644 --- a/src/Networking/LwipEthernet/LwipEthernetInterface.h +++ b/src/Networking/LwipEthernet/LwipEthernetInterface.h @@ -39,8 +39,8 @@ class LwipEthernetInterface : public NetworkInterface void Diagnostics(MessageType mtype) noexcept override; GCodeResult EnableInterface(int mode, const StringRef& ssid, const StringRef& reply) noexcept override; // enable or disable the network - GCodeResult EnableProtocol(NetworkProtocol protocol, int port, int secure, const StringRef& reply) noexcept override; - GCodeResult DisableProtocol(NetworkProtocol protocol, const StringRef& reply) noexcept override; + GCodeResult EnableProtocol(NetworkProtocol protocol, int port, uint32_t ip, int secure, const StringRef& reply) noexcept override; + GCodeResult DisableProtocol(NetworkProtocol protocol, const StringRef& reply, bool shutdown = true) noexcept override; GCodeResult ReportProtocols(const StringRef& reply) const noexcept override; GCodeResult GetNetworkState(const StringRef& reply) noexcept override; diff --git a/src/Networking/Network.cpp b/src/Networking/Network.cpp index 516f91d91c..e7b36ac532 100644 --- a/src/Networking/Network.cpp +++ b/src/Networking/Network.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #if HAS_NETWORKING #include "NetworkBuffer.h" @@ -82,7 +83,7 @@ void MacAddress::SetFromBytes(const uint8_t mb[6]) noexcept // Network members Network::Network(Platform& p) noexcept : platform(p) #if HAS_RESPONDERS - , responders(nullptr), nextResponderToPoll(nullptr) + , responders(nullptr), clients(nullptr), nextResponderToPoll(nullptr) #endif { #if HAS_NETWORKING @@ -214,12 +215,12 @@ void Network::CreateAdditionalInterface() noexcept #endif -GCodeResult Network::EnableProtocol(unsigned int interface, NetworkProtocol protocol, int port, int secure, const StringRef& reply) noexcept +GCodeResult Network::EnableProtocol(unsigned int interface, NetworkProtocol protocol, int port, uint32_t ip, int secure, const StringRef& reply) noexcept { #if HAS_NETWORKING if (interface < GetNumNetworkInterfaces()) { - return interfaces[interface]->EnableProtocol(protocol, port, secure, reply); + return interfaces[interface]->EnableProtocol(protocol, port, ip, secure, reply); } reply.printf("Invalid network interface '%d'\n", interface); @@ -235,14 +236,31 @@ GCodeResult Network::DisableProtocol(unsigned int interface, NetworkProtocol pro #if HAS_NETWORKING if (interface < GetNumNetworkInterfaces()) { + bool client = false; + + // Check if a client handles the protocol. If so, termination is handled + // by the client itself, after attempting to disconnect gracefully. + for (NetworkClient *c = clients; c != nullptr; c = c->GetNext()) + { + if (c->HandlesProtocol(protocol)) + { + client = true; + break; + } + } + NetworkInterface * const iface = interfaces[interface]; - const GCodeResult ret = iface->DisableProtocol(protocol, reply); + const GCodeResult ret = iface->DisableProtocol(protocol, reply, !client); + if (ret == GCodeResult::ok) { #if HAS_RESPONDERS - for (NetworkResponder *r = responders; r != nullptr; r = r->GetNext()) + if (!client) { - r->Terminate(protocol, iface); + for (NetworkResponder *r = responders; r != nullptr; r = r->GetNext()) + { + r->Terminate(protocol, iface); + } } // The following isn't quite right, because we shouldn't free up output buffers if another network interface is still serving this protocol. @@ -751,6 +769,30 @@ bool Network::FindResponder(Socket *skt, NetworkProtocol protocol) noexcept return false; } +bool Network::StartClient(NetworkInterface *interface, NetworkProtocol protocol) noexcept +{ +#if HAS_RESPONDERS + for (NetworkClient *c = clients; c != nullptr; c = c->GetNext()) + { + if (c->Start(protocol, interface)) + { + return true; + } + } +#endif + return false; +} + +void Network::StopClient(NetworkInterface *interface, NetworkProtocol protocol) noexcept +{ +#if HAS_RESPONDERS + for (NetworkClient *c = clients; c != nullptr; c = c->GetNext()) + { + c->Stop(protocol, interface); + } +#endif +} + void Network::HandleHttpGCodeReply(const char *msg) noexcept { #if SUPPORT_HTTP diff --git a/src/Networking/Network.h b/src/Networking/Network.h index 8548f2f7b6..3265d4cddf 100644 --- a/src/Networking/Network.h +++ b/src/Networking/Network.h @@ -45,6 +45,7 @@ const size_t NumFtpResponders = 1; // the number of concurrent FTP sessions we // Forward declarations class NetworkResponder; +class NetworkClient; class NetworkInterface; class Socket; class WiFiInterface; @@ -83,7 +84,7 @@ class Network INHERIT_OBJECT_MODEL #endif GCodeResult EnableInterface(unsigned int interface, int mode, const StringRef& ssid, const StringRef& reply) noexcept; - GCodeResult EnableProtocol(unsigned int interface, NetworkProtocol protocol, int port, int secure, const StringRef& reply) noexcept; + GCodeResult EnableProtocol(unsigned int interface, NetworkProtocol protocol, int port, uint32_t ip, int secure, const StringRef& reply) noexcept; GCodeResult DisableProtocol(unsigned int interface, NetworkProtocol protocol, const StringRef& reply) noexcept; GCodeResult ReportProtocols(unsigned int interface, const StringRef& reply) const noexcept; @@ -113,11 +114,14 @@ class Network INHERIT_OBJECT_MODEL #endif bool FindResponder(Socket *skt, NetworkProtocol protocol) noexcept; + bool StartClient(NetworkInterface *interface, NetworkProtocol protocol) noexcept; + void StopClient(NetworkInterface *interface, NetworkProtocol protocol) noexcept; void HandleHttpGCodeReply(const char *msg) noexcept; void HandleTelnetGCodeReply(const char *msg) noexcept; void HandleHttpGCodeReply(OutputBuffer *buf) noexcept; void HandleTelnetGCodeReply(OutputBuffer *buf) noexcept; + uint32_t GetHttpReplySeq() noexcept; protected: @@ -135,6 +139,7 @@ class Network INHERIT_OBJECT_MODEL #if HAS_RESPONDERS NetworkResponder *responders; + NetworkClient *clients; NetworkResponder *nextResponderToPoll; #endif diff --git a/src/Networking/NetworkClient.cpp b/src/Networking/NetworkClient.cpp new file mode 100644 index 0000000000..671988abb6 --- /dev/null +++ b/src/Networking/NetworkClient.cpp @@ -0,0 +1,111 @@ +/* + * MqttClient.cpp + * + * Created on: 01 Nov 2022 + * Author: rechrtb + */ + +#include "NetworkClient.h" +#include "Socket.h" +#include + +static const uint32_t connectTimeout = ConnectTimeout + 1000; // Make sure the socket, if any, is closed before attempting another connection. + +NetworkClient::NetworkClient(NetworkResponder *n, NetworkClient *c) noexcept : NetworkResponder(n), + interface(nullptr), + next(c), + whenRequest(0) +{ + clients = this; +} + +bool NetworkClient::Start(NetworkProtocol protocol, NetworkInterface *interface) noexcept +{ + if (HandlesProtocol(protocol)) + { + if (!skt) + { + if (this->interface) + { + if (this->interface == interface) + { + if (millis() - whenRequest < connectTimeout) + { + // Client is currently waiting for the previous start request to time out, + // or for a socket to be available; do not start. + return false; + } + // Else the previous start request has timed out before getting a socket; + // do it again. + } + else + { + // Already starting on another interface. + return false; + } + } + + // Enforce a single client on each interface. + for (NetworkClient *c = clients; c != nullptr; c = c->GetNext()) + { + if (c != this && c->HandlesProtocol(protocol) && c->interface == interface) + { + return false; + } + } + + // If everything passes, confirm the specific client implementation requests a start. + if (Start()) + { + this->interface = interface; + whenRequest = millis(); + return true; + } + } + } + + // Client does not handle the protocol, or has a socket already; do not start. + return false; +} + +void NetworkClient::Stop(NetworkProtocol protocol, NetworkInterface *interface) noexcept +{ + if (HandlesProtocol(protocol) && this->interface == interface) + { + Stop(); // Allow the specific client implementation to disconnect gracefully + } +} + +bool NetworkClient::Accept(Socket *s, NetworkProtocol protocol) noexcept +{ + if (HandlesProtocol(protocol) && s->GetInterface() == interface) + { + return Accept(s); + } + + return false; +} + +void NetworkClient::Terminate(NetworkProtocol protocol, NetworkInterface *interface) noexcept +{ + if ((HandlesProtocol(protocol) || protocol == AnyProtocol) && this->interface == interface) + { + Terminate(); + } +} + +bool NetworkClient::Start() noexcept +{ + // Default behavior is that the client will always request a start when it is not active. + // A specific client implementation (child class) might override this function with custom logic, + // such as starting only during certain events, etc. + return true; +} + +void NetworkClient::ConnectionLost() noexcept +{ + NetworkResponder::ConnectionLost(); + interface = nullptr; +} + +NetworkClient *NetworkClient::clients = nullptr; diff --git a/src/Networking/NetworkClient.h b/src/Networking/NetworkClient.h new file mode 100644 index 0000000000..60e55e8dcd --- /dev/null +++ b/src/Networking/NetworkClient.h @@ -0,0 +1,54 @@ +/* + * NetworkClient.h + * + * Created on: 01 Nov 2022 + * Author: rechrtb + */ + +#ifndef SRC_NETWORKING_NETWORKCLIENT_H_ +#define SRC_NETWORKING_NETWORKCLIENT_H_ + +#include +#include "NetworkResponder.h" + +// Forward declarations +class NetworkClient; +class NetworkInterface; +class Socket; + +// Base class for implementing a network client. Unlike a plain responder, +// a client requests an outgoing connection instead of just listening for incoming ones. +class NetworkClient : public NetworkResponder +{ +public: + NetworkClient(const NetworkClient&) = delete; + NetworkClient(NetworkResponder *n, NetworkClient *c) noexcept; + + bool Start(NetworkProtocol protocol, NetworkInterface *interface) noexcept; + void Stop(NetworkProtocol protocol, NetworkInterface *interface) noexcept; + bool Accept(Socket *s, NetworkProtocol protocol) noexcept override; + void Terminate(NetworkProtocol protocol, NetworkInterface *interface) noexcept override; + + NetworkInterface *GetInterface() { return interface; } + NetworkClient *GetNext() const noexcept { return next; } + + virtual bool HandlesProtocol(NetworkProtocol p) noexcept = 0; + +protected: + NetworkInterface *interface; // interface this client is associated with + + virtual bool Start() noexcept; + virtual void Stop() noexcept = 0; + virtual bool Accept(Socket *s) noexcept = 0; + virtual void Terminate() noexcept = 0; + + virtual void ConnectionLost() noexcept override; + +private: + NetworkClient *next; // Next network client in the list + uint32_t whenRequest; // Use to keep track of time spent requesting a connection + + static NetworkClient *clients; // Head of the list of all network clients +}; + +#endif /* SRC_NETWORKING_NETWORKCLIENT_H_ */ diff --git a/src/Networking/NetworkInterface.h b/src/Networking/NetworkInterface.h index b6279eef3a..3cf4f40f9d 100644 --- a/src/Networking/NetworkInterface.h +++ b/src/Networking/NetworkInterface.h @@ -28,10 +28,10 @@ class NetworkInterface INHERIT_OBJECT_MODEL virtual int EnableState() const noexcept = 0; virtual bool IsWiFiInterface() const noexcept = 0; - virtual GCodeResult EnableProtocol(NetworkProtocol protocol, int port, int secure, const StringRef& reply) noexcept = 0; + virtual GCodeResult EnableProtocol(NetworkProtocol protocol, int port, uint32_t ip, int secure, const StringRef& reply) noexcept = 0; virtual bool IsProtocolEnabled(NetworkProtocol protocol) noexcept { return protocolEnabled[protocol]; } virtual TcpPort GetProtocolPort(NetworkProtocol protocol) noexcept { return portNumbers[protocol]; } - virtual GCodeResult DisableProtocol(NetworkProtocol protocol, const StringRef& reply) noexcept = 0; + virtual GCodeResult DisableProtocol(NetworkProtocol protocol, const StringRef& reply, bool shutdown = true) noexcept = 0; virtual GCodeResult ReportProtocols(const StringRef& reply) const noexcept = 0; virtual IPAddress GetIPAddress() const noexcept = 0; diff --git a/src/Networking/Socket.h b/src/Networking/Socket.h index 672f092afd..7ae016f69a 100644 --- a/src/Networking/Socket.h +++ b/src/Networking/Socket.h @@ -12,6 +12,7 @@ #include "General/IPAddress.h" const uint32_t FindResponderTimeout = 2000; // how long we wait for a responder to become available +const uint32_t ConnectTimeout = 2000; // how long we wait for an outgoing connection attempt const uint32_t MaxAckTime = 4000; // how long we wait for a connection to acknowledge the remaining data before it is closed const uint32_t MaxWriteTime = 2000; // how long we wait for a write operation to complete before it is cancelled @@ -51,7 +52,7 @@ class Socket inactive, listening, connected, - clientDisconnecting, + peerDisconnecting, closing, aborted }; From 3215deefad7490af5ededac3dc5d3511386782e7 Mon Sep 17 00:00:00 2001 From: rechrtb Date: Wed, 14 Dec 2022 15:35:08 +0800 Subject: [PATCH 2/3] Add MQTT-C library --- .cproject | 539 ++-- .project | 38 + src/Networking/MQTT/MQTT-C/CMakeLists.txt | 145 + src/Networking/MQTT/MQTT-C/Doxyfile | 2427 +++++++++++++++++ src/Networking/MQTT/MQTT-C/LICENSE | 21 + src/Networking/MQTT/MQTT-C/README.md | 106 + src/Networking/MQTT/MQTT-C/build.zig | 71 + .../MQTT/MQTT-C/cmake/FindMbedTLS.cmake | 9 + .../MQTT/MQTT-C/docs/annotated.html | 70 + src/Networking/MQTT/MQTT-C/docs/arrowdown.png | Bin 0 -> 246 bytes .../MQTT/MQTT-C/docs/arrowright.png | Bin 0 -> 229 bytes src/Networking/MQTT/MQTT-C/docs/bc_s.png | Bin 0 -> 676 bytes src/Networking/MQTT/MQTT-C/docs/bdwn.png | Bin 0 -> 147 bytes .../MQTT-C/docs/bio_publisher_8c-example.html | 53 + src/Networking/MQTT/MQTT-C/docs/classes.html | 62 + src/Networking/MQTT/MQTT-C/docs/closed.png | Bin 0 -> 132 bytes .../MQTT/MQTT-C/docs/dir_000001_000000.html | 52 + .../dir_68267d1309a1af8e8297ef4c3efbcdba.html | 76 + ...r_68267d1309a1af8e8297ef4c3efbcdba_dep.map | 5 + ...r_68267d1309a1af8e8297ef4c3efbcdba_dep.md5 | 1 + ...r_68267d1309a1af8e8297ef4c3efbcdba_dep.png | Bin 0 -> 2242 bytes .../dir_d44c64559bbebec7f509842c48db8b23.html | 66 + src/Networking/MQTT/MQTT-C/docs/doc.png | Bin 0 -> 746 bytes src/Networking/MQTT/MQTT-C/docs/doxygen.css | 1596 +++++++++++ src/Networking/MQTT/MQTT-C/docs/doxygen.png | Bin 0 -> 3779 bytes .../MQTT/MQTT-C/docs/dynsections.js | 120 + src/Networking/MQTT/MQTT-C/docs/examples.html | 64 + src/Networking/MQTT/MQTT-C/docs/files.html | 62 + .../MQTT/MQTT-C/docs/folderclosed.png | Bin 0 -> 616 bytes .../MQTT/MQTT-C/docs/folderopen.png | Bin 0 -> 597 bytes .../MQTT/MQTT-C/docs/functions.html | 277 ++ .../MQTT/MQTT-C/docs/functions_func.html | 80 + .../MQTT/MQTT-C/docs/functions_vars.html | 247 ++ src/Networking/MQTT/MQTT-C/docs/globals.html | 210 ++ .../MQTT/MQTT-C/docs/globals_defs.html | 80 + .../MQTT/MQTT-C/docs/globals_enum.html | 71 + .../MQTT/MQTT-C/docs/globals_func.html | 155 ++ .../MQTT/MQTT-C/docs/graph_legend.html | 81 + .../MQTT/MQTT-C/docs/graph_legend.md5 | 1 + .../MQTT/MQTT-C/docs/graph_legend.png | Bin 0 -> 18535 bytes .../MQTT/MQTT-C/docs/group__api.html | 726 +++++ .../MQTT/MQTT-C/docs/group__details.html | 596 ++++ .../MQTT/MQTT-C/docs/group__packers.html | 682 +++++ .../MQTT/MQTT-C/docs/group__pal.html | 201 ++ .../MQTT/MQTT-C/docs/group__unpackers.html | 454 +++ src/Networking/MQTT/MQTT-C/docs/index.html | 75 + src/Networking/MQTT/MQTT-C/docs/jquery.js | 87 + src/Networking/MQTT/MQTT-C/docs/menu.js | 26 + src/Networking/MQTT/MQTT-C/docs/menudata.js | 51 + src/Networking/MQTT/MQTT-C/docs/modules.html | 61 + .../MQTT/MQTT-C/docs/mqtt-c-logo.png | Bin 0 -> 10200 bytes src/Networking/MQTT/MQTT-C/docs/mqtt_8c.html | 72 + .../MQTT/MQTT-C/docs/mqtt_8c__incl.map | 4 + .../MQTT/MQTT-C/docs/mqtt_8c__incl.md5 | 1 + .../MQTT/MQTT-C/docs/mqtt_8c__incl.png | Bin 0 -> 3311 bytes src/Networking/MQTT/MQTT-C/docs/mqtt_8h.html | 573 ++++ .../MQTT/MQTT-C/docs/mqtt_8h__dep__incl.map | 4 + .../MQTT/MQTT-C/docs/mqtt_8h__dep__incl.md5 | 1 + .../MQTT/MQTT-C/docs/mqtt_8h__dep__incl.png | Bin 0 -> 4697 bytes .../MQTT/MQTT-C/docs/mqtt_8h__incl.map | 3 + .../MQTT/MQTT-C/docs/mqtt_8h__incl.md5 | 1 + .../MQTT/MQTT-C/docs/mqtt_8h__incl.png | Bin 0 -> 2815 bytes .../MQTT/MQTT-C/docs/mqtt_8h_source.html | 117 + .../MQTT/MQTT-C/docs/mqtt__pal_8c.html | 71 + .../MQTT/MQTT-C/docs/mqtt__pal_8c__incl.map | 4 + .../MQTT/MQTT-C/docs/mqtt__pal_8c__incl.md5 | 1 + .../MQTT/MQTT-C/docs/mqtt__pal_8c__incl.png | Bin 0 -> 3947 bytes .../MQTT/MQTT-C/docs/mqtt__pal_8h.html | 86 + .../MQTT-C/docs/mqtt__pal_8h__dep__incl.map | 5 + .../MQTT-C/docs/mqtt__pal_8h__dep__incl.md5 | 1 + .../MQTT-C/docs/mqtt__pal_8h__dep__incl.png | Bin 0 -> 7203 bytes .../MQTT/MQTT-C/docs/mqtt__pal_8h_source.html | 58 + src/Networking/MQTT/MQTT-C/docs/nav_f.png | Bin 0 -> 153 bytes src/Networking/MQTT/MQTT-C/docs/nav_g.png | Bin 0 -> 95 bytes src/Networking/MQTT/MQTT-C/docs/nav_h.png | Bin 0 -> 98 bytes src/Networking/MQTT/MQTT-C/docs/open.png | Bin 0 -> 123 bytes .../docs/openssl_publisher_8c-example.html | 53 + .../docs/reconnect_subscriber_8c-example.html | 53 + .../docs/simple_publisher_8c-example.html | 54 + .../docs/simple_subscriber_8c-example.html | 54 + src/Networking/MQTT/MQTT-C/docs/splitbar.png | Bin 0 -> 314 bytes .../MQTT/MQTT-C/docs/structmqtt__client.html | 323 +++ .../docs/structmqtt__fixed__header.html | 121 + .../docs/structmqtt__message__queue.html | 174 ++ .../docs/structmqtt__queued__message.html | 125 + .../MQTT-C/docs/structmqtt__response.html | 130 + .../docs/structmqtt__response__connack.html | 103 + .../docs/structmqtt__response__pingresp.html | 73 + .../docs/structmqtt__response__puback.html | 82 + .../docs/structmqtt__response__pubcomp.html | 90 + .../docs/structmqtt__response__publish.html | 146 + .../docs/structmqtt__response__pubrec.html | 73 + .../docs/structmqtt__response__pubrel.html | 73 + .../docs/structmqtt__response__suback.html | 166 ++ .../docs/structmqtt__response__unsuback.html | 130 + src/Networking/MQTT/MQTT-C/docs/sync_off.png | Bin 0 -> 853 bytes src/Networking/MQTT/MQTT-C/docs/sync_on.png | Bin 0 -> 845 bytes src/Networking/MQTT/MQTT-C/docs/tab_a.png | Bin 0 -> 142 bytes src/Networking/MQTT/MQTT-C/docs/tab_b.png | Bin 0 -> 169 bytes src/Networking/MQTT/MQTT-C/docs/tab_h.png | Bin 0 -> 177 bytes src/Networking/MQTT/MQTT-C/docs/tab_s.png | Bin 0 -> 184 bytes src/Networking/MQTT/MQTT-C/docs/tabs.css | 1 + .../MQTT/MQTT-C/examples/bearssl_publisher.c | 540 ++++ .../MQTT/MQTT-C/examples/bio_publisher.c | 157 ++ .../MQTT/MQTT-C/examples/bio_publisher_win.c | 153 ++ .../MQTT/MQTT-C/examples/mbedtls_publisher.c | 163 ++ .../MQTT/MQTT-C/examples/mosquitto.org.pem | 24 + .../MQTT/MQTT-C/examples/openssl_publisher.c | 184 ++ .../MQTT-C/examples/openssl_publisher_win.c | 164 ++ .../MQTT-C/examples/reconnect_subscriber.c | 200 ++ .../MQTT/MQTT-C/examples/simple_publisher.c | 158 ++ .../MQTT/MQTT-C/examples/simple_subscriber.c | 143 + .../examples/templates/bearssl_sockets.h | 139 + .../MQTT-C/examples/templates/bio_sockets.h | 28 + .../examples/templates/mbedtls_sockets.h | 153 ++ .../examples/templates/openssl_sockets.h | 94 + .../MQTT-C/examples/templates/posix_sockets.h | 79 + src/Networking/MQTT/MQTT-C/include/mqtt.h | 1623 +++++++++++ src/Networking/MQTT/MQTT-C/include/mqtt_pal.h | 198 ++ src/Networking/MQTT/MQTT-C/makefile | 39 + src/Networking/MQTT/MQTT-C/src/mqtt.c | 1791 ++++++++++++ src/Networking/MQTT/MQTT-C/src/mqtt_pal.c | 440 +++ src/Networking/MQTT/MQTT-C/tests.c | 1031 +++++++ src/Networking/MQTT/mqtt_pal.cpp | 56 + src/Networking/MQTT/mqtt_pal.h | 88 + 125 files changed, 20149 insertions(+), 266 deletions(-) create mode 100644 src/Networking/MQTT/MQTT-C/CMakeLists.txt create mode 100644 src/Networking/MQTT/MQTT-C/Doxyfile create mode 100644 src/Networking/MQTT/MQTT-C/LICENSE create mode 100644 src/Networking/MQTT/MQTT-C/README.md create mode 100644 src/Networking/MQTT/MQTT-C/build.zig create mode 100644 src/Networking/MQTT/MQTT-C/cmake/FindMbedTLS.cmake create mode 100644 src/Networking/MQTT/MQTT-C/docs/annotated.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/arrowdown.png create mode 100644 src/Networking/MQTT/MQTT-C/docs/arrowright.png create mode 100644 src/Networking/MQTT/MQTT-C/docs/bc_s.png create mode 100644 src/Networking/MQTT/MQTT-C/docs/bdwn.png create mode 100644 src/Networking/MQTT/MQTT-C/docs/bio_publisher_8c-example.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/classes.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/closed.png create mode 100644 src/Networking/MQTT/MQTT-C/docs/dir_000001_000000.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/dir_68267d1309a1af8e8297ef4c3efbcdba_dep.map create mode 100644 src/Networking/MQTT/MQTT-C/docs/dir_68267d1309a1af8e8297ef4c3efbcdba_dep.md5 create mode 100644 src/Networking/MQTT/MQTT-C/docs/dir_68267d1309a1af8e8297ef4c3efbcdba_dep.png create mode 100644 src/Networking/MQTT/MQTT-C/docs/dir_d44c64559bbebec7f509842c48db8b23.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/doc.png create mode 100644 src/Networking/MQTT/MQTT-C/docs/doxygen.css create mode 100644 src/Networking/MQTT/MQTT-C/docs/doxygen.png create mode 100644 src/Networking/MQTT/MQTT-C/docs/dynsections.js create mode 100644 src/Networking/MQTT/MQTT-C/docs/examples.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/files.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/folderclosed.png create mode 100644 src/Networking/MQTT/MQTT-C/docs/folderopen.png create mode 100644 src/Networking/MQTT/MQTT-C/docs/functions.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/functions_func.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/functions_vars.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/globals.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/globals_defs.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/globals_enum.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/globals_func.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/graph_legend.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/graph_legend.md5 create mode 100644 src/Networking/MQTT/MQTT-C/docs/graph_legend.png create mode 100644 src/Networking/MQTT/MQTT-C/docs/group__api.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/group__details.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/group__packers.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/group__pal.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/group__unpackers.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/index.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/jquery.js create mode 100644 src/Networking/MQTT/MQTT-C/docs/menu.js create mode 100644 src/Networking/MQTT/MQTT-C/docs/menudata.js create mode 100644 src/Networking/MQTT/MQTT-C/docs/modules.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/mqtt-c-logo.png create mode 100644 src/Networking/MQTT/MQTT-C/docs/mqtt_8c.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/mqtt_8c__incl.map create mode 100644 src/Networking/MQTT/MQTT-C/docs/mqtt_8c__incl.md5 create mode 100644 src/Networking/MQTT/MQTT-C/docs/mqtt_8c__incl.png create mode 100644 src/Networking/MQTT/MQTT-C/docs/mqtt_8h.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/mqtt_8h__dep__incl.map create mode 100644 src/Networking/MQTT/MQTT-C/docs/mqtt_8h__dep__incl.md5 create mode 100644 src/Networking/MQTT/MQTT-C/docs/mqtt_8h__dep__incl.png create mode 100644 src/Networking/MQTT/MQTT-C/docs/mqtt_8h__incl.map create mode 100644 src/Networking/MQTT/MQTT-C/docs/mqtt_8h__incl.md5 create mode 100644 src/Networking/MQTT/MQTT-C/docs/mqtt_8h__incl.png create mode 100644 src/Networking/MQTT/MQTT-C/docs/mqtt_8h_source.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/mqtt__pal_8c.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/mqtt__pal_8c__incl.map create mode 100644 src/Networking/MQTT/MQTT-C/docs/mqtt__pal_8c__incl.md5 create mode 100644 src/Networking/MQTT/MQTT-C/docs/mqtt__pal_8c__incl.png create mode 100644 src/Networking/MQTT/MQTT-C/docs/mqtt__pal_8h.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/mqtt__pal_8h__dep__incl.map create mode 100644 src/Networking/MQTT/MQTT-C/docs/mqtt__pal_8h__dep__incl.md5 create mode 100644 src/Networking/MQTT/MQTT-C/docs/mqtt__pal_8h__dep__incl.png create mode 100644 src/Networking/MQTT/MQTT-C/docs/mqtt__pal_8h_source.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/nav_f.png create mode 100644 src/Networking/MQTT/MQTT-C/docs/nav_g.png create mode 100644 src/Networking/MQTT/MQTT-C/docs/nav_h.png create mode 100644 src/Networking/MQTT/MQTT-C/docs/open.png create mode 100644 src/Networking/MQTT/MQTT-C/docs/openssl_publisher_8c-example.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/reconnect_subscriber_8c-example.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/simple_publisher_8c-example.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/simple_subscriber_8c-example.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/splitbar.png create mode 100644 src/Networking/MQTT/MQTT-C/docs/structmqtt__client.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/structmqtt__fixed__header.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/structmqtt__message__queue.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/structmqtt__queued__message.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/structmqtt__response.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/structmqtt__response__connack.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/structmqtt__response__pingresp.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/structmqtt__response__puback.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/structmqtt__response__pubcomp.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/structmqtt__response__publish.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/structmqtt__response__pubrec.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/structmqtt__response__pubrel.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/structmqtt__response__suback.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/structmqtt__response__unsuback.html create mode 100644 src/Networking/MQTT/MQTT-C/docs/sync_off.png create mode 100644 src/Networking/MQTT/MQTT-C/docs/sync_on.png create mode 100644 src/Networking/MQTT/MQTT-C/docs/tab_a.png create mode 100644 src/Networking/MQTT/MQTT-C/docs/tab_b.png create mode 100644 src/Networking/MQTT/MQTT-C/docs/tab_h.png create mode 100644 src/Networking/MQTT/MQTT-C/docs/tab_s.png create mode 100644 src/Networking/MQTT/MQTT-C/docs/tabs.css create mode 100644 src/Networking/MQTT/MQTT-C/examples/bearssl_publisher.c create mode 100644 src/Networking/MQTT/MQTT-C/examples/bio_publisher.c create mode 100644 src/Networking/MQTT/MQTT-C/examples/bio_publisher_win.c create mode 100644 src/Networking/MQTT/MQTT-C/examples/mbedtls_publisher.c create mode 100644 src/Networking/MQTT/MQTT-C/examples/mosquitto.org.pem create mode 100644 src/Networking/MQTT/MQTT-C/examples/openssl_publisher.c create mode 100644 src/Networking/MQTT/MQTT-C/examples/openssl_publisher_win.c create mode 100644 src/Networking/MQTT/MQTT-C/examples/reconnect_subscriber.c create mode 100644 src/Networking/MQTT/MQTT-C/examples/simple_publisher.c create mode 100644 src/Networking/MQTT/MQTT-C/examples/simple_subscriber.c create mode 100644 src/Networking/MQTT/MQTT-C/examples/templates/bearssl_sockets.h create mode 100644 src/Networking/MQTT/MQTT-C/examples/templates/bio_sockets.h create mode 100644 src/Networking/MQTT/MQTT-C/examples/templates/mbedtls_sockets.h create mode 100644 src/Networking/MQTT/MQTT-C/examples/templates/openssl_sockets.h create mode 100644 src/Networking/MQTT/MQTT-C/examples/templates/posix_sockets.h create mode 100644 src/Networking/MQTT/MQTT-C/include/mqtt.h create mode 100644 src/Networking/MQTT/MQTT-C/include/mqtt_pal.h create mode 100644 src/Networking/MQTT/MQTT-C/makefile create mode 100644 src/Networking/MQTT/MQTT-C/src/mqtt.c create mode 100644 src/Networking/MQTT/MQTT-C/src/mqtt_pal.c create mode 100644 src/Networking/MQTT/MQTT-C/tests.c create mode 100644 src/Networking/MQTT/mqtt_pal.cpp create mode 100644 src/Networking/MQTT/mqtt_pal.h diff --git a/.cproject b/.cproject index 550b2484a6..2f91bd154d 100644 --- a/.cproject +++ b/.cproject @@ -40,25 +40,22 @@