Skip to content

Commit

Permalink
AP_RCProtocol: add CRSF binding API
Browse files Browse the repository at this point in the history
  • Loading branch information
andyp1per committed Mar 10, 2024
1 parent 6287e65 commit 542e652
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions libraries/AP_RCProtocol/AP_RCProtocol_CRSF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,17 @@ int16_t AP_RCProtocol_CRSF::derive_scaled_lq_value(uint8_t uplink_lq)
return int16_t(roundf(constrain_float(uplink_lq*2.5f,0,255)));
}

// start bind
#if HAL_CRSF_TELEM_ENABLED
void AP_RCProtocol_CRSF::start_bind(void)
{
AP_CRSF_Telem* telem = AP::crsf_telem();
if (telem != nullptr) {
telem->start_bind();
}
}
#endif

namespace AP {
AP_RCProtocol_CRSF* crsf() {
return AP_RCProtocol_CRSF::get_singleton();
Expand Down
6 changes: 6 additions & 0 deletions libraries/AP_RCProtocol/AP_RCProtocol_CRSF.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#pragma once

#include "AP_RCProtocol_config.h"
#include <AP_RCTelemetry/AP_RCTelemetry_config.h>

#if AP_RCPROTOCOL_CRSF_ENABLED

Expand All @@ -43,6 +44,9 @@ class AP_RCProtocol_CRSF : public AP_RCProtocol_Backend {
void process_byte(uint8_t byte, uint32_t baudrate) override;
void process_handshake(uint32_t baudrate) override;
void update(void) override;
#if HAL_CRSF_TELEM_ENABLED
void start_bind(void) override;
#endif
// support for CRSF v3
bool change_baud_rate(uint32_t baudrate);
// bootstrap baudrate
Expand Down Expand Up @@ -149,6 +153,8 @@ class AP_RCProtocol_CRSF : public AP_RCProtocol_Backend {
// Commands for CRSF_COMMAND_RX
enum CommandRX {
CRSF_COMMAND_RX_BIND = 0x01,
CRSF_COMMAND_RX_CANCEL_BIND = 0x02,
CRSF_COMMAND_RX_SET_BIND_ID = 0x03,
};

// Commands for CRSF_COMMAND_GENERAL
Expand Down

0 comments on commit 542e652

Please sign in to comment.