-
Notifications
You must be signed in to change notification settings - Fork 1.7k
MSP: Add minimum power index to MSP_VTX_CONFIG #11190
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
base: maintenance-9.x
Are you sure you want to change the base?
MSP: Add minimum power index to MSP_VTX_CONFIG #11190
Conversation
Adds minPowerIndex (byte 12) to MSP_VTX_CONFIG response to indicate the minimum valid power index for the VTX device. - MSP VTX: minPowerIndex = 0 (supports power off at index 0) - SmartAudio/Tramp: minPowerIndex = 1 (power off not supported) This allows configurator to correctly display all available power levels without hardcoding device-specific logic. Backward compatible: old configurators will ignore the extra byte. Related: iNavFlight/inav-configurator#2486 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
PR Compliance Guide 🔍All compliance sections have been disabled in the configurations. |
| sbufWriteU8(dst, vtxDevice->capability.powerCount); | ||
|
|
||
| uint8_t minPowerIndex = 1; | ||
| if (deviceType == VTXDEV_MSP) { | ||
| minPowerIndex = 0; | ||
| } | ||
| sbufWriteU8(dst, minPowerIndex); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Adding a new byte to the MSP reply increases the payload size; ensure the destination buffer has room (or update the reply-size calculation) before writing to avoid overruns. [Learned best practice, importance: 6]
| sbufWriteU8(dst, vtxDevice->capability.powerCount); | |
| uint8_t minPowerIndex = 1; | |
| if (deviceType == VTXDEV_MSP) { | |
| minPowerIndex = 0; | |
| } | |
| sbufWriteU8(dst, minPowerIndex); | |
| sbufWriteU8(dst, vtxDevice->capability.powerCount); | |
| const uint8_t minPowerIndex = (deviceType == VTXDEV_MSP) ? 0 : 1; | |
| if (sbufBytesRemaining(dst) < 1) { | |
| return false; | |
| } | |
| sbufWriteU8(dst, minPowerIndex); |
User description
Summary
Adds
minPowerIndex(byte 12) toMSP_VTX_CONFIGresponse to indicate the minimum valid power index for VTX devices.This complements the existing
powerCountfield and enables configurator to display all available power levels without hardcoding device-specific logic.Related Configurator PR: iNavFlight/inav-configurator#2486
Changes
File:
src/main/fc/fc_msp.cAdded single byte to
MSP_VTX_CONFIGresponse afterpowerCount:Values:
minPowerIndex = 0(supports power off at index 0)minPowerIndex = 1(power off not supported)Protocol Change
Before (11 bytes):
After (12 bytes):
1-11. (same as above)
12. minPowerIndex (NEW)
Compatibility
✅ Backward Compatible
MSP Power Level Examples
MSP VTX (minPowerIndex=0, powerCount=4):
SmartAudio (minPowerIndex=1, powerCount=8):
Rationale
Current firmware sends
powerCount(maximum valid index) but not the minimum. This works for most VTX devices which start at index 1, but MSP VTX devices support power off at index 0.Without this change, configurators must hardcode device-type-specific logic:
With this change, configurator gets complete info from firmware:
Testing
Related
Description
Adds minPowerIndex field to MSP_VTX_CONFIG response
Enables configurators to display power levels dynamically
MSP VTX devices report minPowerIndex=0, others report 1
Maintains backward compatibility with older configurators
Diagram Walkthrough
flowchart LR A["MSP_VTX_CONFIG Request"] --> B["Check Device Type"] B --> C{"Is MSP VTX?"} C -->|Yes| D["minPowerIndex = 0"] C -->|No| E["minPowerIndex = 1"] D --> F["Send 12-byte Response"] E --> F F --> G["Configurator Receives Complete Power Range Info"]File Walkthrough
fc_msp.c
Add minPowerIndex to VTX config responsesrc/main/fc/fc_msp.c
logic