File tree 2 files changed +21
-5
lines changed
2 files changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -59,14 +59,26 @@ int WiFiUDP::beginPacket(const char *host, uint16_t port) {
59
59
}
60
60
61
61
int WiFiUDP::endPacket () {
62
+ return 0 ;
62
63
}
63
64
64
- size_t WiFiUDP::write (uint8_t ) {
65
- return 0 ;
65
+ size_t WiFiUDP::write (uint8_t byte ) {
66
+ return write (&byte, 1 ) ;
66
67
}
67
68
68
69
size_t WiFiUDP::write (const uint8_t *buffer, size_t size) {
69
- return 0 ;
70
+ size_t bytesStored = 0 ;
71
+
72
+ for (size_t i = 0 ; i < size; i++) {
73
+ if (!txBuffer.isFull ()) { // Check if the buffer is not full
74
+ txBuffer.store_char (buffer[i]);
75
+ bytesStored++;
76
+ } else {
77
+ break ; // Stop if the buffer is full
78
+ }
79
+ }
80
+
81
+ return bytesStored; // Return the number of bytes successfully stored
70
82
}
71
83
72
84
int WiFiUDP::parsePacket () {
Original file line number Diff line number Diff line change 11
11
12
12
class WiFiUDP : public arduino ::UDP {
13
13
public:
14
+
15
+ static const size_t WIFI_UDP_BUFFER_SIZE = 256 ;
16
+
14
17
WiFiUDP ();
15
18
uint8_t begin (uint16_t );
16
19
@@ -19,9 +22,8 @@ class WiFiUDP: public arduino::UDP {
19
22
int beginPacket (IPAddress ip, uint16_t port);
20
23
int beginPacket (const char *host, uint16_t port);
21
24
int endPacket ();
22
- size_t write (uint8_t );
25
+ size_t write (uint8_t byte );
23
26
size_t write (const uint8_t *buffer, size_t size);
24
-
25
27
using Print::write;
26
28
int parsePacket ();
27
29
int available ();
@@ -44,6 +46,8 @@ class WiFiUDP: public arduino::UDP {
44
46
IPAddress remote_ip;
45
47
uint16_t _port;
46
48
49
+ arduino::RingBufferN < WIFI_UDP_BUFFER_SIZE > txBuffer;
50
+
47
51
};
48
52
49
53
#endif /* WIFI_UDP_H */
You can’t perform that action at this time.
0 commit comments