Skip to content

Commit

Permalink
revert bad assumption about how ESP8266 handled send
Browse files Browse the repository at this point in the history
  • Loading branch information
gfwilliams committed Oct 2, 2018
1 parent 9a9b551 commit 7b4b448
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
12 changes: 8 additions & 4 deletions devices/ESP8266WiFi_0v25.js
Expand Up @@ -169,11 +169,14 @@ var netCallbacks = {
}

var cmd = 'AT+CIPSEND='+sckt+','+data.length+extra+'\r\n';
at.cmd(cmd, 2000, function cb(d) {
at.cmd(cmd, 10000, function cb(d) {
//console.log("SEND "+JSON.stringify(d));
if (d=="OK") {
} else if (d=="> ") {
at.write(data);
at.register('> ', function(l) {
at.unregister('> ');
at.write(data);
return l.substr(2);
});
} else if (d=="Recv "+data.length+" bytes" || d=="busy s...") {
// all good, we expect this
// Not sure why we get "busy s..." in this case (2 sends one after the other) but it all seems ok.
Expand All @@ -184,9 +187,10 @@ var netCallbacks = {
return;
} else {
socks[sckt]=undefined; // uh-oh. Error. If undefined it was probably a timeout
at.unregister('> ');
return;
}
return cb;
return cb
});
// if we obey the above, we shouldn't get the 'busy p...' prompt
socks[sckt]="Wait"; // wait for data to be sent
Expand Down
8 changes: 6 additions & 2 deletions devices/EspruinoWiFi.js
Expand Up @@ -159,8 +159,11 @@ var netCallbacks = {
at.cmd(cmd, 2000, function cb(d) {
//console.log("SEND "+JSON.stringify(d));
if (d=="OK") {
} else if (d=="> ") {
at.write(data);
at.register('> ', function(l) {
at.unregister('> ');
at.write(data);
return l.substr(2);
});
} else if (d=="Recv "+data.length+" bytes" || d=="busy s...") {
// all good, we expect this
// Not sure why we get "busy s..." in this case (2 sends one after the other) but it all seems ok.
Expand All @@ -171,6 +174,7 @@ var netCallbacks = {
return;
} else {
socks[sckt]=undefined; // uh-oh. Error. If undefined it was probably a timeout
at.unregister('> ');
return;
}
return cb;
Expand Down

0 comments on commit 7b4b448

Please sign in to comment.