Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of WebSocketClient by
Revision 30:0b5a84149a79, committed 2017-08-23
- Comitter:
- defrost
- Date:
- Wed Aug 23 10:59:19 2017 +0000
- Parent:
- 29:33d77a538611
- Commit message:
- - Fixed bug in receiveBytes, it now works
Changed in this revision
Websocket.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/Websocket.cpp Tue Aug 22 11:04:31 2017 +0000 +++ b/Websocket.cpp Wed Aug 23 10:59:19 2017 +0000 @@ -282,8 +282,9 @@ } socket.set_blocking(false, 1); - if (socket.receive(&opcode, 1) != 2) { + if (socket.receive(&opcode, 1) != 1) { socket.set_blocking(false, 2000); + DBG(SerialCommPort, "opcode: %d", opcode); return 0; } @@ -325,15 +326,21 @@ int nb = read(bytes, len_msg, len_msg); + DBG(SerialCommPort, "Done read(), nb = %d", nb); + if (nb != len_msg){ ERR(SerialCommPort, "Unexpected number of bytes read: %d, expected: %d", nb, len_msg); return 0; } - + + DBG(SerialCommPort, "Masking..."); + for (i = 0; i < len_msg; i++) { bytes[i] = bytes[i] ^ mask[i % 4]; } + DBG(SerialCommPort, "Returning nb = %d", nb); + // Return the number of bytes read: return nb; } @@ -469,7 +476,7 @@ if ((res = socket.receive_all(str + idx, len - idx)) == -1) continue; idx += res; - DBG(SerialCommPort, "In read(* str, len, min_len), res = %d, idx = %d", res, idx); + DBG(SerialCommPort, "In read(* str, len = %d, min_len = %d), res = %d, idx = %d", len, min_len, res, idx); if (idx == len || (min_len != -1 && idx > min_len)) return idx; }