mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-17 05:15:25 +03:00
Protect VTC api against NULL vtxDevice
This commit is contained in:
parent
0c84506336
commit
498042db47
1 changed files with 9 additions and 20 deletions
|
@ -56,7 +56,7 @@ vtxDevType_e vtxCommonGetDeviceType(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
void vtxCommonProcess(timeUs_t currentTimeUs) {
|
void vtxCommonProcess(timeUs_t currentTimeUs) {
|
||||||
if (vtxDevice->vTable->process) {
|
if (vtxDevice && vtxDevice->vTable->process) {
|
||||||
vtxDevice->vTable->process(currentTimeUs);
|
vtxDevice->vTable->process(currentTimeUs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ void vtxCommonProcess(timeUs_t currentTimeUs) {
|
||||||
// band and channel are 1 origin
|
// band and channel are 1 origin
|
||||||
void vtxCommonSetBandAndChannel(uint8_t band, uint8_t channel)
|
void vtxCommonSetBandAndChannel(uint8_t band, uint8_t channel)
|
||||||
{
|
{
|
||||||
if ((band <= vtxDevice->capability.bandCount) && (channel <= vtxDevice->capability.channelCount)) {
|
if (vtxDevice && (band <= vtxDevice->capability.bandCount) && (channel <= vtxDevice->capability.channelCount)) {
|
||||||
if (vtxDevice->vTable->setBandAndChannel) {
|
if (vtxDevice->vTable->setBandAndChannel) {
|
||||||
vtxDevice->vTable->setBandAndChannel(band, channel);
|
vtxDevice->vTable->setBandAndChannel(band, channel);
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ void vtxCommonSetBandAndChannel(uint8_t band, uint8_t channel)
|
||||||
// index is zero origin, zero = power off completely
|
// index is zero origin, zero = power off completely
|
||||||
void vtxCommonSetPowerByIndex(uint8_t index)
|
void vtxCommonSetPowerByIndex(uint8_t index)
|
||||||
{
|
{
|
||||||
if (index <= vtxDevice->capability.powerCount) {
|
if (vtxDevice && (index <= vtxDevice->capability.powerCount)) {
|
||||||
if (vtxDevice->vTable->setPowerByIndex) {
|
if (vtxDevice->vTable->setPowerByIndex) {
|
||||||
vtxDevice->vTable->setPowerByIndex(index);
|
vtxDevice->vTable->setPowerByIndex(index);
|
||||||
}
|
}
|
||||||
|
@ -84,21 +84,21 @@ void vtxCommonSetPowerByIndex(uint8_t index)
|
||||||
// on = 1, off = 0
|
// on = 1, off = 0
|
||||||
void vtxCommonSetPitMode(uint8_t onoff)
|
void vtxCommonSetPitMode(uint8_t onoff)
|
||||||
{
|
{
|
||||||
if (vtxDevice->vTable->setPitMode) {
|
if (vtxDevice && vtxDevice->vTable->setPitMode) {
|
||||||
vtxDevice->vTable->setPitMode(onoff);
|
vtxDevice->vTable->setPitMode(onoff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void vtxCommonSetFrequency(uint16_t freq)
|
void vtxCommonSetFrequency(uint16_t freq)
|
||||||
{
|
{
|
||||||
if (vtxDevice->vTable->setFrequency) {
|
if (vtxDevice && vtxDevice->vTable->setFrequency) {
|
||||||
vtxDevice->vTable->setFrequency(freq);
|
vtxDevice->vTable->setFrequency(freq);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool vtxCommonGetBandAndChannel(uint8_t *pBand, uint8_t *pChannel)
|
bool vtxCommonGetBandAndChannel(uint8_t *pBand, uint8_t *pChannel)
|
||||||
{
|
{
|
||||||
if (vtxDevice->vTable->getBandAndChannel) {
|
if (vtxDevice && vtxDevice->vTable->getBandAndChannel) {
|
||||||
return vtxDevice->vTable->getBandAndChannel(pBand, pChannel);
|
return vtxDevice->vTable->getBandAndChannel(pBand, pChannel);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -107,11 +107,7 @@ bool vtxCommonGetBandAndChannel(uint8_t *pBand, uint8_t *pChannel)
|
||||||
|
|
||||||
bool vtxCommonGetPowerIndex(uint8_t *pIndex)
|
bool vtxCommonGetPowerIndex(uint8_t *pIndex)
|
||||||
{
|
{
|
||||||
if (!vtxDevice) {
|
if (vtxDevice && vtxDevice->vTable->getPowerIndex) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vtxDevice->vTable->getPowerIndex) {
|
|
||||||
return vtxDevice->vTable->getPowerIndex(pIndex);
|
return vtxDevice->vTable->getPowerIndex(pIndex);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -120,11 +116,7 @@ bool vtxCommonGetPowerIndex(uint8_t *pIndex)
|
||||||
|
|
||||||
bool vtxCommonGetPitMode(uint8_t *pOnOff)
|
bool vtxCommonGetPitMode(uint8_t *pOnOff)
|
||||||
{
|
{
|
||||||
if (!vtxDevice) {
|
if (vtxDevice && vtxDevice->vTable->getPitMode) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vtxDevice->vTable->getPitMode) {
|
|
||||||
return vtxDevice->vTable->getPitMode(pOnOff);
|
return vtxDevice->vTable->getPitMode(pOnOff);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -133,10 +125,7 @@ bool vtxCommonGetPitMode(uint8_t *pOnOff)
|
||||||
|
|
||||||
bool vtxCommonGetFrequency(uint16_t *pFreq)
|
bool vtxCommonGetFrequency(uint16_t *pFreq)
|
||||||
{
|
{
|
||||||
if (!vtxDevice) {
|
if (vtxDevice && vtxDevice->vTable->getFrequency) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (vtxDevice->vTable->getFrequency) {
|
|
||||||
return vtxDevice->vTable->getFrequency(pFreq);
|
return vtxDevice->vTable->getFrequency(pFreq);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue