diff options
author | Alex Blasche <alexander.blasche@digia.com> | 2014-08-20 14:24:40 +0200 |
---|---|---|
committer | Alex Blasche <alexander.blasche@digia.com> | 2014-08-25 15:02:17 +0200 |
commit | 2b5027a808e4cf525926058542786167dfed24ea (patch) | |
tree | 3d2c5e25298e976ad9a62be8ad7856907af7edad /src/tools | |
parent | 0a8327d422228489a62aa8fed8bdaa9d1291c055 (diff) |
Fix Bluez5 FullDiscovery SDP scan
Several bugs prevented QBLuetoothServiceDiscoveryAgent from properly
working on Bluez5
1.) If parseSDPRecord returned an empty QByteArray we continued the
parse loop without further advancing the sdpResult list.
2.) Each sdp result was individually base64 encoded but the library
side decoded the entire list of items in one go. The item separation
gets lost during the transfer. As a result only every second item was
properly decoded. Therefore only every second sdp record was properly
recognized. Now we encode the entire result and transfer it in one go.
3.) Don't separate the xml items based on their size anymore. Although
this is possibly slower it is a lot simpler to understand
and debug. In combination with the above two problems the previous
pointer based logic was leading to crashes too.
4.) QProcess::readAll() seems to loose data when the process
finished and the output was very large. After this patch we start
reading right after the start of the sdpscanner.
Change-Id: I84a0be9d68e86c851945751c576a3ccf755db883
Reviewed-by: Aaron McCarthy <mccarthy.aaron@gmail.com>
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/sdpscanner/main.cpp | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/tools/sdpscanner/main.cpp b/src/tools/sdpscanner/main.cpp index 9b3b0757..5f2fd976 100644 --- a/src/tools/sdpscanner/main.cpp +++ b/src/tools/sdpscanner/main.cpp @@ -296,26 +296,21 @@ int main(int argc, char **argv) return RETURN_SDP_ERROR; } - char sizeField[sizeof(int)]; + QByteArray total; while (sdpResults) { sdp_record_t *record = (sdp_record_t *) sdpResults->data; - QByteArray xml = parseSdpRecord(record); - if (xml.isEmpty()) - continue; - - //endianness doesn't matter since same machine - int sz = xml.size(); - memcpy(&sizeField, &sz, sizeof(int)); - xml.prepend(QByteArray(sizeField, sizeof(int))); - - printf("%s", xml.toBase64().constData()); + const QByteArray xml = parseSdpRecord(record); + total += xml; previous = sdpResults; sdpResults = sdpResults->next; free(previous); sdp_record_free(record); + } + if (!total.isEmpty()) { + printf("%s", total.toBase64().constData()); } sdp_close(session); |