|
36 | 36 | class Arduino_10BASE_T1S_UDP : public UDP
|
37 | 37 | {
|
38 | 38 | public:
|
| 39 | + /** |
| 40 | + * @class Arduino_10BASE_T1S_UDP |
| 41 | + * @brief UDP communication class for Arduino 10BASE-T1S library. |
| 42 | + */ |
39 | 43 | Arduino_10BASE_T1S_UDP();
|
40 | 44 | virtual ~Arduino_10BASE_T1S_UDP();
|
41 | 45 |
|
42 | 46 |
|
43 | 47 | /* arduino:UDP */
|
| 48 | + /** |
| 49 | + * @brief Initializes the UDP instance to listen on the specified port. |
| 50 | + * |
| 51 | + * This method sets up the UDP protocol to begin listening for incoming packets |
| 52 | + * on the given port. It should be called before attempting to send or receive |
| 53 | + * UDP packets. |
| 54 | + * |
| 55 | + * @param port The local port to listen on. |
| 56 | + * @return Returns 1 if successful, 0 if there was an error. |
| 57 | + */ |
44 | 58 | virtual uint8_t begin(uint16_t port) override;
|
| 59 | + |
| 60 | + |
| 61 | + /** |
| 62 | + * @brief Stops the UDP connection and releases any associated resources. |
| 63 | + * |
| 64 | + * This method overrides the base class implementation to properly close |
| 65 | + * the UDP socket and perform necessary cleanup operations. |
| 66 | + */ |
45 | 67 | virtual void stop() override;
|
46 | 68 |
|
| 69 | + /** |
| 70 | + * @brief Begins the construction of a UDP packet to the specified IP address and port. |
| 71 | + * |
| 72 | + * Initializes the UDP packet buffer and prepares it to send data to the given destination. |
| 73 | + * |
| 74 | + * @param ip The destination IP address. |
| 75 | + * @param port The destination port number. |
| 76 | + * @return int Returns 1 on success, 0 on failure. |
| 77 | + */ |
47 | 78 | virtual int beginPacket(IPAddress ip, uint16_t port) override;
|
| 79 | + |
| 80 | + /** |
| 81 | + * @brief Begins the construction of a UDP packet to the specified host and port. |
| 82 | + * |
| 83 | + * Initializes the UDP packet buffer and prepares it to send data to the given destination. |
| 84 | + * |
| 85 | + * @param host The destination host name or IP address as a string. |
| 86 | + * @param port The destination port number. |
| 87 | + * @return int Returns 1 on success, 0 on failure. |
| 88 | + */ |
48 | 89 | virtual int beginPacket(const char *host, uint16_t port) override;
|
| 90 | + |
| 91 | + /** |
| 92 | + * @brief Finishes the construction of a UDP packet and sends it. |
| 93 | + * |
| 94 | + * This method finalizes the UDP packet and transmits it to the previously specified |
| 95 | + * destination IP address and port. |
| 96 | + * |
| 97 | + * @return int Returns 1 on success, 0 on failure. |
| 98 | + */ |
49 | 99 | virtual int endPacket() override;
|
| 100 | + |
| 101 | + /** |
| 102 | + * @brief Sends a single byte of data in the current UDP packet. |
| 103 | + * |
| 104 | + * This method appends a single byte to the current UDP packet buffer. |
| 105 | + * |
| 106 | + * @param data The byte of data to send. |
| 107 | + * @return size_t Returns the number of bytes written, which is always 1 for a single byte. |
| 108 | + */ |
50 | 109 | virtual size_t write(uint8_t data) override;
|
| 110 | + |
| 111 | + /** |
| 112 | + * @brief Sends a buffer of data in the current UDP packet. |
| 113 | + * |
| 114 | + * This method appends a specified number of bytes from the provided buffer to the |
| 115 | + * current UDP packet buffer. |
| 116 | + * |
| 117 | + * @param buffer Pointer to the data buffer to send. |
| 118 | + * @param size The number of bytes to write from the buffer. |
| 119 | + * @return size_t Returns the number of bytes written, which may be less than size if an error occurs. |
| 120 | + */ |
51 | 121 | virtual size_t write(const uint8_t * buffer, size_t size) override;
|
52 | 122 |
|
| 123 | + /** |
| 124 | + * @brief Sends a string in the current UDP packet. |
| 125 | + * |
| 126 | + * This method appends a null-terminated string to the current UDP packet buffer. |
| 127 | + * |
| 128 | + * @param str Pointer to the null-terminated string to send. |
| 129 | + * @return size_t Returns the number of bytes written, including the null terminator. |
| 130 | + */ |
53 | 131 | virtual int parsePacket() override;
|
| 132 | + |
| 133 | + /** |
| 134 | + * @brief Checks if there are any incoming UDP packets available to read. |
| 135 | + * |
| 136 | + * This method checks the internal buffer for any received UDP packets. |
| 137 | + * |
| 138 | + * @return int Returns the number of available bytes in the current packet, or 0 if no packets are available. |
| 139 | + */ |
54 | 140 | virtual int available() override;
|
| 141 | + |
| 142 | + /** |
| 143 | + * @brief Reads a single byte from the current UDP packet. |
| 144 | + * |
| 145 | + * This method retrieves the next byte from the current UDP packet buffer. |
| 146 | + * |
| 147 | + * @return int Returns the byte read, or -1 if no data is available. |
| 148 | + */ |
55 | 149 | virtual int read() override;
|
| 150 | + |
| 151 | + /** |
| 152 | + * @brief Reads a specified number of bytes from the current UDP packet into a buffer. |
| 153 | + * |
| 154 | + * This method reads data from the current UDP packet into the provided buffer. |
| 155 | + * |
| 156 | + * @param buffer Pointer to the buffer where the data will be stored. |
| 157 | + * @param len The number of bytes to read into the buffer. |
| 158 | + * @return int Returns the number of bytes read, which may be less than len if not enough data is available. |
| 159 | + */ |
56 | 160 | virtual int read(unsigned char* buffer, size_t len) override;
|
| 161 | + |
| 162 | + /** |
| 163 | + * @brief Reads a specified number of bytes from the current UDP packet into a character buffer. |
| 164 | + * |
| 165 | + * This method reads data from the current UDP packet into the provided character buffer. |
| 166 | + * |
| 167 | + * @param buffer Pointer to the character buffer where the data will be stored. |
| 168 | + * @param len The number of bytes to read into the buffer. |
| 169 | + * @return int Returns the number of bytes read, which may be less than len if not enough data is available. |
| 170 | + */ |
57 | 171 | virtual int read(char* buffer, size_t len) override;
|
| 172 | + |
| 173 | + /** |
| 174 | + * @brief Peeks at the next byte in the current UDP packet without removing it from the buffer. |
| 175 | + * |
| 176 | + * This method retrieves the next byte from the current UDP packet buffer without consuming it. |
| 177 | + * |
| 178 | + * @return int Returns the next byte, or -1 if no data is available. |
| 179 | + */ |
58 | 180 | virtual int peek() override;
|
| 181 | + |
| 182 | + /** |
| 183 | + * @brief Flushes the current UDP packet buffer. |
| 184 | + * |
| 185 | + * This method clears the current UDP packet buffer, discarding any unsent data. |
| 186 | + */ |
59 | 187 | virtual void flush() override;
|
60 | 188 |
|
| 189 | + /** |
| 190 | + * @brief Returns the IP address of the remote host that sent the last received packet. |
| 191 | + * |
| 192 | + * This method retrieves the IP address of the sender of the last received UDP packet. |
| 193 | + * |
| 194 | + * @return IPAddress Returns the IP address of the remote host. |
| 195 | + */ |
61 | 196 | virtual IPAddress remoteIP() override;
|
| 197 | + |
| 198 | + /** |
| 199 | + * @brief Returns the port number of the remote host that sent the last received packet. |
| 200 | + * |
| 201 | + * This method retrieves the port number of the sender of the last received UDP packet. |
| 202 | + * |
| 203 | + * @return uint16_t Returns the port number of the remote host. |
| 204 | + */ |
62 | 205 | virtual uint16_t remotePort() override;
|
63 | 206 |
|
64 |
| - |
65 | 207 | /* This function MUST not be called from the user of this library,
|
66 | 208 | * it's used for internal purposes only.
|
67 | 209 | */
|
|
0 commit comments