@@ -809,9 +809,12 @@ static bool ValidateDatarate( int8_t datarate, uint16_t* channelsMask );
809809/*!
810810 * \brief Limits the Tx power according to the number of enabled channels
811811 *
812+ * \param [IN] txPower txPower to limit
813+ * \param [IN] maxBandTxPower Maximum band allowed TxPower
814+ *
812815 * \retval Returns the maximum valid tx power
813816 */
814- static int8_t LimitTxPower ( int8_t txPower );
817+ static int8_t LimitTxPower ( int8_t txPower , int8_t maxBandTxPower );
815818
816819/*!
817820 * \brief Verifies, if a value is in a given range.
@@ -2220,9 +2223,13 @@ static bool ValidateDatarate( int8_t datarate, uint16_t* channelsMask )
22202223 return false;
22212224}
22222225
2223- static int8_t LimitTxPower ( int8_t txPower )
2226+ static int8_t LimitTxPower ( int8_t txPower , int8_t maxBandTxPower )
22242227{
22252228 int8_t resultTxPower = txPower ;
2229+
2230+ // Limit tx power to the band max
2231+ resultTxPower = MAX ( txPower , maxBandTxPower );
2232+
22262233#if defined( USE_BAND_915 ) || defined( USE_BAND_915_HYBRID )
22272234 if ( ( LoRaMacParams .ChannelsDatarate == DR_4 ) ||
22282235 ( ( LoRaMacParams .ChannelsDatarate >= DR_8 ) && ( LoRaMacParams .ChannelsDatarate <= DR_13 ) ) )
@@ -3231,7 +3238,7 @@ LoRaMacStatus_t SendFrameOnChannel( ChannelParams_t channel )
32313238 int8_t txPowerIndex = 0 ;
32323239 int8_t txPower = 0 ;
32333240
3234- txPowerIndex = LimitTxPower ( LoRaMacParams .ChannelsTxPower );
3241+ txPowerIndex = LimitTxPower ( LoRaMacParams .ChannelsTxPower , Bands [ channel . Band ]. TxMaxPower );
32353242 txPower = TxPowers [txPowerIndex ];
32363243
32373244 MlmeConfirm .Status = LORAMAC_EVENT_INFO_STATUS_ERROR ;
@@ -3308,7 +3315,7 @@ LoRaMacStatus_t SetTxContinuousWave( uint16_t timeout )
33083315 int8_t txPowerIndex = 0 ;
33093316 int8_t txPower = 0 ;
33103317
3311- txPowerIndex = LimitTxPower ( LoRaMacParams .ChannelsTxPower );
3318+ txPowerIndex = LimitTxPower ( LoRaMacParams .ChannelsTxPower , Bands [ Channels [ Channel ]. Band ]. TxMaxPower );
33123319 txPower = TxPowers [txPowerIndex ];
33133320
33143321 // Starts the MAC layer status check timer
0 commit comments