Skip to content

Use case insensitive comparison for UUID or address string inputs #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/BLECharacteristic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ bool BLECharacteristic::hasDescriptor(const char* uuid, int index) const
for (int i = 0; i < numDescriptors; i++) {
BLERemoteDescriptor* d = _remote->descriptor(i);

if (strcmp(uuid, d->uuid()) == 0) {
if (strcasecmp(uuid, d->uuid()) == 0) {
if (count == index) {
return true;
}
Expand Down Expand Up @@ -419,7 +419,7 @@ BLEDescriptor BLECharacteristic::descriptor(const char * uuid, int index) const
for (int i = 0; i < numDescriptors; i++) {
BLERemoteDescriptor* d = _remote->descriptor(i);

if (strcmp(uuid, d->uuid()) == 0) {
if (strcasecmp(uuid, d->uuid()) == 0) {
if (count == index) {
return BLEDescriptor(d);
}
Expand Down
8 changes: 4 additions & 4 deletions src/BLEDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ bool BLEDevice::hasService(const char* uuid, int index) const
for (int i = 0; i < numServices; i++) {
BLERemoteService* s = device->service(i);

if (strcmp(uuid, s->uuid()) == 0) {
if (strcasecmp(uuid, s->uuid()) == 0) {
if (count == index) {
return true;
}
Expand Down Expand Up @@ -352,7 +352,7 @@ BLEService BLEDevice::service(const char * uuid, int index) const
for (int i = 0; i < numServices; i++) {
BLERemoteService* s = device->service(i);

if (strcmp(uuid, s->uuid()) == 0) {
if (strcasecmp(uuid, s->uuid()) == 0) {
if (count == index) {
return BLEService(s);
}
Expand Down Expand Up @@ -405,7 +405,7 @@ bool BLEDevice::hasCharacteristic(const char* uuid, int index) const
BLERemoteCharacteristic* c = s->characteristic(j);


if (strcmp(c->uuid(), uuid) == 0) {
if (strcasecmp(c->uuid(), uuid) == 0) {
if (count == index) {
return true;
}
Expand Down Expand Up @@ -468,7 +468,7 @@ BLECharacteristic BLEDevice::characteristic(const char * uuid, int index) const
for (int j = 0; j < numCharacteristics; j++) {
BLERemoteCharacteristic* c = s->characteristic(j);

if (strcmp(c->uuid(), uuid) == 0) {
if (strcasecmp(c->uuid(), uuid) == 0) {
if (count == index) {

return BLECharacteristic(c);
Expand Down
4 changes: 2 additions & 2 deletions src/BLEService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ bool BLEService::hasCharacteristic(const char* uuid, int index) const
for (int i = 0; i < numCharacteristics; i++) {
BLERemoteCharacteristic* c = _remote->characteristic(i);

if (strcmp(uuid, c->uuid()) == 0) {
if (strcasecmp(uuid, c->uuid()) == 0) {
if (count == index) {
return true;
}
Expand Down Expand Up @@ -158,7 +158,7 @@ BLECharacteristic BLEService::characteristic(const char * uuid, int index) const
for (int i = 0; i < numCharacteristics; i++) {
BLERemoteCharacteristic* c = _remote->characteristic(i);

if (strcmp(uuid, c->uuid()) == 0) {
if (strcasecmp(uuid, c->uuid()) == 0) {
if (count == index) {
return BLECharacteristic(c);
}
Expand Down
2 changes: 1 addition & 1 deletion src/utility/ATT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ bool ATTClass::discoverAttributes(uint8_t peerBdaddrType, uint8_t peerBdaddr[6],
for (int i = 0; i < serviceCount; i++) {
BLERemoteService* service = device->service(i);

if (strcmp(service->uuid(), serviceUuidFilter) == 0) {
if (strcasecmp(service->uuid(), serviceUuidFilter) == 0) {
// found an existing service with same UUID
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/utility/GAP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,11 @@ void GAPClass::handleLeAdvertisingReport(uint8_t type, uint8_t addressType, uint

bool GAPClass::matchesScanFilter(const BLEDevice& device)
{
if (_scanAddressFilter.length() > 0 && _scanAddressFilter != device.address()) {
if (_scanAddressFilter.length() > 0 && !(_scanAddressFilter.equalsIgnoreCase(device.address()))) {
return false; // drop doesn't match
} else if (_scanNameFilter.length() > 0 && _scanNameFilter != device.localName()) {
return false; // drop doesn't match
} else if (_scanUuidFilter.length() > 0 && _scanUuidFilter != device.advertisedServiceUuid()) {
} else if (_scanUuidFilter.length() > 0 && !(_scanUuidFilter.equalsIgnoreCase(device.advertisedServiceUuid()))) {
return false; // drop doesn't match
}

Expand Down