Source

Target

Commits (4)
Showing with 34 additions and 7 deletions
......@@ -478,7 +478,7 @@ QLowEnergyHandle parseReadByTypeCharDiscovery(
QLowEnergyHandle attributeHandle = bt_get_le16(&data[0]);
charData->properties =
(QLowEnergyCharacteristic::PropertyTypes)data[2];
(QLowEnergyCharacteristic::PropertyTypes)(data[2] & 0xff);
charData->valueHandle = bt_get_le16(&data[3]);
if (elementLength == 7) // 16 bit uuid
......@@ -672,6 +672,7 @@ void QLowEnergyControllerPrivate::processReply(
lastHandle = parseReadByTypeCharDiscovery(
&characteristic, &data[offset], elementLength);
p->characteristicList[lastHandle] = characteristic;
offset += elementLength;
} else if (attributeType == GATT_INCLUDED_SERVICE) {
QList<QBluetoothUuid> includedServices;
lastHandle = parseReadByTypeIncludeDiscovery(
......@@ -1222,7 +1223,7 @@ void QLowEnergyControllerPrivate::readServiceValues(
starting the next read request.
*/
void QLowEnergyControllerPrivate::readServiceValuesByOffset(
quint16 handleData, quint16 offset, bool isLastValue)
uint handleData, quint16 offset, bool isLastValue)
{
const QLowEnergyHandle charHandle = (handleData & 0xffff);
const QLowEnergyHandle descriptorHandle = ((handleData >> 16) & 0xffff);
......
......@@ -173,7 +173,7 @@ private:
void sendReadValueRequest(QLowEnergyHandle attributeHandle, bool isDescriptor);
void readServiceValues(const QBluetoothUuid &service,
bool readCharacteristics);
void readServiceValuesByOffset(quint16 handleData, quint16 offset,
void readServiceValuesByOffset(uint handleData, quint16 offset,
bool isLastValue);
void discoverServiceDescriptors(const QBluetoothUuid &serviceUuid);
......
......@@ -46,9 +46,11 @@
void usage()
{
fprintf(stderr, "Usage:\n");
fprintf(stderr, "\tsdpscanner <remote bdaddr> <local bdaddr>\n\n");
fprintf(stderr, "\tsdpscanner <remote bdaddr> <local bdaddr> [Options]\n\n");
fprintf(stderr, "Performs an SDP scan on remote device, using the SDP server\n"
"represented by the local Bluetooth device.\n");
"represented by the local Bluetooth device.\n\n"
"Options:\n"
" -p Show scan results in human-readable form\n");
}
#define BUFFER_SIZE 1024
......@@ -245,7 +247,7 @@ QByteArray parseSdpRecord(sdp_record_t *record)
int main(int argc, char **argv)
{
if (argc != 3) {
if (argc < 3) {
usage();
return RETURN_USAGE;
}
......@@ -266,6 +268,27 @@ int main(int argc, char **argv)
return RETURN_INVALPARAM;
}
bool showHumanReadable = false;
for (int i = 3; i < argc; i++) {
if (argv[i][0] != '-') {
usage();
return RETURN_USAGE;
}
switch (argv[i][1])
{
case 'p':
showHumanReadable = true;
break;
default:
fprintf(stderr, "Wrong argument: %s\n", argv[i]);
usage();
return RETURN_USAGE;
}
}
sdp_session_t *session = sdp_connect( &local, &remote, SDP_RETRY_IF_BUSY);
if (!session) {
//try one more time if first time failed
......@@ -314,7 +337,10 @@ int main(int argc, char **argv)
}
if (!total.isEmpty()) {
printf("%s", total.toBase64().constData());
if (showHumanReadable)
printf("%s", total.constData());
else
printf("%s", total.toBase64().constData());
}
sdp_close(session);
......