Skip to content

Commit 16e65fb

Browse files
committed
Udp bug fixing
Former-commit-id: d507597
1 parent 691283a commit 16e65fb

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

libraries/WiFiS3/examples/WiFiUdpSendReceiveString/WiFiUdpSendReceiveString.ino

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
*/
1111

1212

13-
#include <WiFi.h>
14-
#include <WiFiUdp.h>
13+
#include <WiFiS3.h>
1514

1615
int status = WL_IDLE_STATUS;
1716
#include "arduino_secrets.h"
@@ -42,7 +41,7 @@ void setup() {
4241
}
4342

4443
String fv = WiFi.firmwareVersion();
45-
if (fv < WiFi_FIRMWARE_LATEST_VERSION) {
44+
if (fv < WIFI_FIRMWARE_LATEST_VERSION) {
4645
Serial.println("Please upgrade the firmware");
4746
}
4847

libraries/WiFiS3/src/Modem.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,13 @@ bool ModemClass::buf_read(const string &prompt, string &data_res) {
183183
/* -------------------------------------------------------------------------- */
184184
bool res = false;
185185
bool found = false;
186+
186187
unsigned long start_time = millis();
187188
while((millis() - start_time < _timeout) && !found){
188189
while(_serial->available()){
189190
char c = _serial->read();
190191
data_res += c;
192+
191193
if(read_by_size) {
192194
if(read_by_size_finished(data_res)) {
193195
found = true;
@@ -248,7 +250,7 @@ bool ModemClass::buf_read(const string &prompt, string &data_res) {
248250
trim(data_res);
249251
}
250252
trim_results = true;
251-
253+
read_by_size = false;
252254
#ifdef MODEM_DEBUG
253255
Serial.print(" Write Call, response rx |>>");
254256
Serial.print(data_res.c_str());

libraries/WiFiS3/src/WiFiUdp.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,10 @@ int WiFiUDP::parsePacket() {
137137
/* -------------------------------------------------------------------------- */
138138
if(_sock >= 0) {
139139
string res = "";
140+
rx_buffer.clear();
140141
modem.begin();
141142
if(modem.write(string(PROMPT(_UDPPARSE)),res, "%s%d\r\n" , CMD_WRITE(_UDPPARSE), _sock)) {
142-
return 1;
143+
return atoi(res.c_str());
143144
}
144145
}
145146
return 0;

libraries/WiFiS3/src/WiFiUdp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#include "Modem.h"
3131
#include "FifoBuffer.h"
3232

33-
#define RX_BUFFER_DIM 64
33+
#define RX_BUFFER_DIM 1461
3434

3535
class WiFiUDP : public UDP {
3636
private:

0 commit comments

Comments
 (0)