Skip to content
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

Add support for returning TX backpack version #75

Merged
merged 3 commits into from
Feb 12, 2023
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
5 changes: 4 additions & 1 deletion lib/MSP/msp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ MSP::processReceivedByte(uint8_t c)
m_packet.flags = header->flags;
// reset the offset iterator for re-use in payload below
m_offset = 0;
m_inputState = MSP_PAYLOAD_V2_NATIVE;
if (m_packet.payloadSize == 0)
m_inputState = MSP_CHECKSUM_V2_NATIVE;
else
m_inputState = MSP_PAYLOAD_V2_NATIVE;
}
break;

Expand Down
3 changes: 3 additions & 0 deletions lib/MSP/msptypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
#define MSP_ELRS_REQU_VTX_PKT 0x0B
#define MSP_ELRS_SET_TX_BACKPACK_WIFI_MODE 0x0C
#define MSP_ELRS_SET_VRX_BACKPACK_WIFI_MODE 0x0D
#define MSP_ELRS_SET_RX_WIFI_MODE 0x0E
#define MSP_ELRS_SET_RX_LOAN_MODE 0x0F
#define MSP_ELRS_GET_BACKPACK_VERSION 0x10
#define MSP_ELRS_SET_OSD 0x00B6

// CRSF encapsulated msp defines
Expand Down
19 changes: 19 additions & 0 deletions src/Tx_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ uint8_t broadcastAddress[6] = {0, 0, 0, 0, 0, 0};
#endif
uint8_t bindingAddress[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};

const uint8_t version[] = {LATEST_VERSION};
pkendall64 marked this conversation as resolved.
Show resolved Hide resolved

connectionState_e connectionState = starting;
unsigned long rebootTime = 0;

Expand Down Expand Up @@ -116,6 +118,19 @@ void OnDataRecv(const uint8_t * mac_addr, const uint8_t *data, int data_len)
blinkLED();
}

void SendVersionResponse()
{
mspPacket_t out;
out.reset();
out.makeResponse();
out.function = MSP_ELRS_GET_BACKPACK_VERSION;
for (size_t i = 0 ; i < sizeof(version) ; i++)
{
out.addByte(version[i]);
}
msp.sendPacket(&out, &Serial);
}

void ProcessMSPPacketFromTX(mspPacket_t *packet)
{
if (packet->function == MSP_ELRS_BIND)
Expand Down Expand Up @@ -152,6 +167,10 @@ void ProcessMSPPacketFromTX(mspPacket_t *packet)
DBGLN("Processing MSP_ELRS_SET_TX_BACKPACK_WIFI_MODE...");
RebootIntoWifi();
break;
case MSP_ELRS_GET_BACKPACK_VERSION:
DBGLN("Processing MSP_ELRS_GET_BACKPACK_VERSION...");
SendVersionResponse();
break;
default:
// transparently forward MSP packets via espnow to any subscribers
sendMSPViaEspnow(packet);
Expand Down