Closed zoujixing closed 8 years ago
Oh, yes.How about this:
nRF51ServiceDiscovery::progressServiceDiscovery(void) { ......
while ((state == SERVICE_DISCOVERY_ACTIVE) && (serviceIndex < numServices)) {
if( ((matchingServiceUUID.shortOrLong() == UUID::UUID_Type_t(UUID::UUID_TYPE_SHORT)) &&
(services[serviceIndex].getUUID().shortOrLong() == UUID::UUID_Type_t(UUID::UUID_TYPE_SHORT)) &&
(matchingServiceUUID.getShortUUID() == services[serviceIndex].getUUID().getShortUUID())
) ||
((matchingServiceUUID.shortOrLong() == UUID::UUID_Type_t(UUID::UUID_TYPE_LONG)) &&
(services[serviceIndex].getUUID().shortOrLong() == UUID::UUID_Type_t(UUID::UUID_TYPE_LONG)) &&
(0x00 == memcmp(matchingServiceUUID.getBaseUUID(), services[serviceIndex].getUUID().getBaseUUID(), UUID::LENGTH_OF_LONG_UUID))
) )
{
if ( serviceCallback ){
serviceCallback(&services[serviceIndex]);
}
if( (state == SERVICE_DISCOVERY_ACTIVE) && characteristicCallback )
{
launchCharacteristicDiscovery(connHandle, services[serviceIndex].getStartHandle(), services[serviceIndex].getEndHandle());
}
else
{
serviceIndex++;
}
}
else
{
serviceIndex++;
}
}
......
}
Why are you using explicit comparisons for UUID
s? Why not just use the overloaded operator ==
?
I agree with @adfernandes. Comparison should be encapsulated in operator==
UUID::operator == now allows comparisons between long and short UUIDs. I believe this should have been addressed by now. Please re-open if necessary.
…llback.