Skip to content

BLE: fix deprecated API calls in battery and thermometer services #10634

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
merged 1 commit into from
May 23, 2019
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
2 changes: 1 addition & 1 deletion features/FEATURE_BLE/ble/services/BatteryService.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class BatteryService {
sizeof(charTable) / sizeof(GattCharacteristic *)
);

ble.addService(batteryService);
ble.gattServer().addService(batteryService);
}

/**
Expand Down
8 changes: 3 additions & 5 deletions features/FEATURE_BLE/ble/services/HealthThermometerService.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class HealthThermometerService {
GattCharacteristic *hrmChars[] = {&tempMeasurement, &tempLocation, };
GattService hrmService(GattService::UUID_HEALTH_THERMOMETER_SERVICE, hrmChars, sizeof(hrmChars) / sizeof(GattCharacteristic *));

ble.addService(hrmService);
ble.gattServer().addService(hrmService);
}

/**
Expand All @@ -72,10 +72,8 @@ class HealthThermometerService {
*
*/
void updateTemperature(float temperature) {
if (ble.getGapState().connected) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this could be replaced by getConnectionCount()?

Copy link
Contributor Author

@LDong-Arm LDong-Arm May 22, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Unfortunately getConnectionCount() is not available anymore (reverted soon after it was first introduced), but a few deprecation notices still point to/recommend that. I guess it needs to be fixed as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one removed getConnectionCount(): 61536c3

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why it was removed. The variable backing it is still functional. @pan-?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure it was intentionally removed; just a mistake when non backward compatible changes were reverted. #8738 has been wild.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So that's actually not required and application code doesn't have to ensure that it is connected before calling updateTemperature.

valueBytes.updateTemperature(temperature);
ble.gattServer().write(tempMeasurement.getValueHandle(), valueBytes.getPointer(), sizeof(TemperatureValueBytes));
}
valueBytes.updateTemperature(temperature);
ble.gattServer().write(tempMeasurement.getValueHandle(), valueBytes.getPointer(), sizeof(TemperatureValueBytes));
}

/**
Expand Down