Skip to content

Conversation

@AvatarSD
Copy link

@AvatarSD AvatarSD commented Jun 11, 2025

@gsuess
@EugeneSakun

Summary

This pull request enhances the TelemetryModule in the psdk_wrapper to improve battery state handling by introducing a fallback mechanism for publishing combined battery data when the primary battery info subscription fails. The changes ensure robust battery state reporting for dual-battery systems.

Changes

Header File Updates (telemetry.hpp):

  • Added member variables and a utility function for combining battery states:
    • publish_combined_battery_state() to merge and publish data from both batteries.
    • Atomic flags (battery_info_subscription_failed_, has_battery1_info_, has_battery2_info_) to track subscription status and data availability.
    • Storage for latest battery info (last_battery1_info_, last_battery2_info_) with mutex protection (battery_info_mutex_).

Source File Updates (telemetry.cpp):

  • Enhanced single_battery_index1_callback and single_battery_index2_callback:
    • Added error logging for failed publications.
    • Store latest battery info with mutex protection.
    • Trigger publish_combined_battery_state() when both batteries have data and the primary subscription has failed.
  • Modified subscribe_psdk_topics() to set battery_info_subscription_failed_ based on the success of the DJI_FC_SUBSCRIPTION_TOPIC_BATTERY_INFO subscription.
  • Implemented publish_combined_battery_state():
    • Combines data from both batteries (voltage, current, capacity, etc.) using the latest timestamp.
    • Publishes the combined state to the battery_pub_ topic.
    • Includes detailed debug logging for combined battery data.

@AvatarSD AvatarSD force-pushed the feature/compose-target branch from a1b4dc3 to f9e2ae0 Compare June 14, 2025 05:12
@AvatarSD AvatarSD changed the title Feature: Combination of single battery info event Feature: Combining of single battery info event Jun 14, 2025
@AvatarSD AvatarSD marked this pull request as ready for review June 15, 2025 18:17
@AvatarSD AvatarSD requested a review from a team as a code owner June 15, 2025 18:17
@AvatarSD AvatarSD force-pushed the feature/compose-target branch from f9e2ae0 to 4fd5996 Compare June 27, 2025 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant