Skip to content

Commit

Permalink
Fix betaflight telematry by supporting source_sysid of 0
Browse files Browse the repository at this point in the history
  • Loading branch information
peteallenm committed Oct 1, 2023
1 parent 83fb19e commit 0fd9b0c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 11 additions & 0 deletions app/telemetry/MavlinkTelemetry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,17 @@ void MavlinkTelemetry::process_mavlink_message(const mavlink_message_t& msg)
m_fc_comp_id=source_compid;
m_fc_found=true;
}
else if(source_sysid==0){
qDebug()<<"Found betaflight FC:"<<source_sysid;
FCMavlinkSystem::instance().set_system_id(source_sysid);
m_fc_sys_id=source_sysid;
m_fc_comp_id=source_compid;
m_fc_found=true;
}
else
{
qDebug()<<"Got weird system:"<<source_sysid;
}
}

}
Expand Down
4 changes: 2 additions & 2 deletions app/telemetry/models/fcmavlinksystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,13 +487,13 @@ std::optional<uint8_t> FCMavlinkSystem::get_fc_sys_id()
return std::nullopt;
}
auto sys_id=m_sys_id;
assert(sys_id>0);
assert(sys_id>=0);
return sys_id;
}

bool FCMavlinkSystem::set_system_id(int sys_id)
{
if(sys_id<=0 || sys_id >= UINT8_MAX){
if(sys_id<0 || sys_id >= UINT8_MAX){
qWarning()<<"Invalid sys id";
return false;
}
Expand Down

0 comments on commit 0fd9b0c

Please sign in to comment.