Skip to content

Commit

Permalink
chore: Update esp-nimble-cpp submodule to latest (#335)
Browse files Browse the repository at this point in the history
* Update to latest esp-nimble-cpp submodule
* Update ble gatt server callback implementation to remove const from parameters
* Update to use setValue methods which accept std::string and std::string_view (since they have .data() and .size())
  • Loading branch information
finger563 authored Oct 15, 2024
1 parent 904df10 commit 81ca8cd
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ class BleGattServerCallbacks : public NimBLEServerCallbacks {
public:
virtual void onConnect(NimBLEServer *server, NimBLEConnInfo &conn_info) override;
virtual void onDisconnect(NimBLEServer *server, NimBLEConnInfo &conn_info, int reason) override;
virtual void onAuthenticationComplete(const NimBLEConnInfo &conn_info) override;
virtual void onAuthenticationComplete(NimBLEConnInfo &conn_info) override;
virtual uint32_t onPassKeyDisplay() override;
virtual void onConfirmPIN(const NimBLEConnInfo &conn_info, uint32_t pass_key) override;
virtual void onConfirmPIN(NimBLEConnInfo &conn_info, uint32_t pass_key) override;

protected:
friend class BleGattServer;
Expand Down
12 changes: 6 additions & 6 deletions components/ble_gatt_server/include/device_info_service.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class DeviceInfoService : public BaseComponent {
logger_.error("Characteristic not created");
return;
}
manufacturer_name_->setValue(reinterpret_cast<const uint8_t *>(name.data()), name.size());
manufacturer_name_->setValue(name);
}

/// Set the model number
Expand All @@ -177,7 +177,7 @@ class DeviceInfoService : public BaseComponent {
logger_.error("Characteristic not created");
return;
}
model_number_->setValue(reinterpret_cast<const uint8_t *>(number.data()), number.size());
model_number_->setValue(number);
}

/// Set the serial number
Expand All @@ -187,7 +187,7 @@ class DeviceInfoService : public BaseComponent {
logger_.error("Characteristic not created");
return;
}
serial_number_->setValue(reinterpret_cast<const uint8_t *>(number.data()), number.size());
serial_number_->setValue(number);
}

/// Set the software version
Expand All @@ -197,7 +197,7 @@ class DeviceInfoService : public BaseComponent {
logger_.error("Characteristic not created");
return;
}
software_version_->setValue(reinterpret_cast<const uint8_t *>(version.data()), version.size());
software_version_->setValue(version);
}

/// Set the firmware version
Expand All @@ -207,7 +207,7 @@ class DeviceInfoService : public BaseComponent {
logger_.error("Characteristic not created");
return;
}
firmware_version_->setValue(reinterpret_cast<const uint8_t *>(version.data()), version.size());
firmware_version_->setValue(version);
}

/// Set the hardware version
Expand All @@ -217,7 +217,7 @@ class DeviceInfoService : public BaseComponent {
logger_.error("Characteristic not created");
return;
}
hardware_version_->setValue(reinterpret_cast<const uint8_t *>(version.data()), version.size());
hardware_version_->setValue(version);
}

protected:
Expand Down
4 changes: 2 additions & 2 deletions components/ble_gatt_server/src/ble_gatt_server_callbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void BleGattServerCallbacks::onDisconnect(NimBLEServer *server, NimBLEConnInfo &
}
}

void BleGattServerCallbacks::onAuthenticationComplete(const NimBLEConnInfo &conn_info) {
void BleGattServerCallbacks::onAuthenticationComplete(NimBLEConnInfo &conn_info) {
if (server_ && server_->callbacks_.authentication_complete_callback) {
server_->callbacks_.authentication_complete_callback(conn_info);
}
Expand All @@ -64,7 +64,7 @@ uint32_t BleGattServerCallbacks::onPassKeyDisplay() {
return NimBLEDevice::getSecurityPasskey();
}
}
void BleGattServerCallbacks::onConfirmPIN(const NimBLEConnInfo &conn_info, uint32_t pass_key) {
void BleGattServerCallbacks::onConfirmPIN(NimBLEConnInfo &conn_info, uint32_t pass_key) {
if (server_ && server_->callbacks_.confirm_passkey_callback) {
server_->callbacks_.confirm_passkey_callback(conn_info, pass_key);
} else {
Expand Down
2 changes: 1 addition & 1 deletion components/esp-nimble-cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ extern "C" void app_main(void) {
auto input_report = hid_service.input_report(input_report_id);

// use the HID service to make an output report characteristic
auto output_report = hid_service.output_report(output_report_id);
[[maybe_unused]] auto output_report = hid_service.output_report(output_report_id);

// now that we've made the input characteristic, we can start the service
hid_service.start();
Expand Down
3 changes: 1 addition & 2 deletions components/hid_service/include/hid_service.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ class HidService : public espp::BaseComponent {
/// @param report_map The report map as a string view.
void set_report_map(std::string_view report_map) {
if (report_map_) {
report_map_->setValue(reinterpret_cast<const uint8_t *>(report_map.data()),
report_map.size());
report_map_->setValue(report_map);
} else {
logger_.error("Report map characteristic not created");
}
Expand Down

0 comments on commit 81ca8cd

Please sign in to comment.