@@ -28,7 +28,9 @@ extern "C" {
28
28
#include " libb64/cencode.h"
29
29
}
30
30
31
+ #ifdef ESP8266
31
32
#include < Hash.h>
33
+ #endif
32
34
33
35
/* *
34
36
*
@@ -284,8 +286,11 @@ void WebSockets::handleWebsocket(WSclient_t * client) {
284
286
*/
285
287
String WebSockets::acceptKey (String clientKey) {
286
288
uint8_t sha1HashBin[20 ] = { 0 };
289
+ #ifdef ESP8266
287
290
sha1 (clientKey + " 258EAFA5-E914-47DA-95CA-C5AB0DC85B11" , &sha1HashBin[0 ]);
288
-
291
+ #else
292
+ #error todo implement sha1 for AVR
293
+ #endif
289
294
String key = base64_encode (sha1HashBin, 20 );
290
295
key.trim ();
291
296
@@ -327,19 +332,20 @@ bool WebSockets::readWait(WSclient_t * client, uint8_t *out, size_t n) {
327
332
328
333
while (n > 0 ) {
329
334
if (!client->tcp .connected ()) {
330
- DEBUG_WEBSOCKETS (" [readWait] Receive not connected - 1 !\n " );
335
+ DEBUG_WEBSOCKETS (" [readWait] not connected!\n " );
331
336
return false ;
332
337
}
333
- while (!client->tcp .available ()) {
334
- if (!client->tcp .connected ()) {
335
- DEBUG_WEBSOCKETS (" [readWait] Receive not connected - 2!\n " );
336
- return false ;
337
- }
338
- if ((millis () - t) > WEBSOCKETS_TCP_TIMEOUT) {
339
- DEBUG_WEBSOCKETS (" [readWait] Receive TIMEOUT!\n " );
340
- return false ;
341
- }
338
+
339
+ if ((millis () - t) > WEBSOCKETS_TCP_TIMEOUT) {
340
+ DEBUG_WEBSOCKETS (" [readWait] receive TIMEOUT!\n " );
341
+ return false ;
342
+ }
343
+
344
+ if (!client->tcp .available ()) {
345
+ #ifdef ESP8266
342
346
delay (0 );
347
+ #endif
348
+ continue ;
343
349
}
344
350
345
351
len = client->tcp .read ((uint8_t *) out, n);
@@ -351,7 +357,9 @@ bool WebSockets::readWait(WSclient_t * client, uint8_t *out, size_t n) {
351
357
} else {
352
358
// DEBUG_WEBSOCKETS("Receive %d left %d!\n", len, n);
353
359
}
360
+ #ifdef ESP8266
354
361
delay (0 );
362
+ #endif
355
363
}
356
364
return true ;
357
365
}
0 commit comments