Compare commits

...

6 Commits

Author SHA1 Message Date
Matthijs Kooijman 0251447aa2
Merge 9735e00c0c into 406f7a204c 2025-03-24 02:33:09 +01:00
Antonio Sconza 406f7a204c [PRJ] Fetch the RSSI calibration from memory before performing the LBT verification in Sigfox applications of 'B-WL5M-SUBG1' and 'NUCLEO-WL55JC1' boards 2025-03-21 15:02:06 +01:00
Matthijs Kooijman 9735e00c0c Fix signed vs unsigned comparison warning 2022-12-19 13:00:25 +01:00
Matthijs Kooijman 17482cea0d Add additional debug output
This adds some more details about RX and TX bytes and TX config. There
is also some code for RX config, but to minimize the impact on RX
timing, that is commented out.
2022-12-15 20:28:25 +01:00
Matthijs Kooijman 1c17e31589 Fix printf format warnings
These warnings are caused because frequencies are stored as `uint32_t`,
which is `unsigned long`, while the printf format expects `int`. In
practice, this does not actually cause problems, since on STM32 gcc
`long` and `int` are both 32-bits and frequencies are never large enough
to cause signed vs unsigned ambiguity.

Since printf has no format specifiers for e.g. uint32_t (libc does have
some macros for this, but those really hurt readability), this is tricky
to fix in a portable way (other architectures or compilers might have
`uint32_t` equal to `unsigned int` instead of `unsigned long`), this fix
just casts the frequency to `unsigned` before passing it to printf (and
for good measure, also convert the specifier from `%d` to `%u`). This
does mean this printing will break if `int` is not at least 32-bits
(e.g. on AVR), but given the scope of this library, that should be
acceptable.
2022-12-15 20:27:13 +01:00
Matthijs Kooijman 8372970ad4 Fix comments in LoRaMacCallback_t
It seems the comment for GetDevAddress was copied from GetUniqueId, but
not changend sufficiently to be correct.
2022-12-15 08:53:55 +01:00
12 changed files with 60 additions and 8 deletions

View File

@ -1137,6 +1137,11 @@ static void ProcessRadioRxDone( void )
#endif /* LORAMAC_VERSION */ #endif /* LORAMAC_VERSION */
Mlme_t joinType = MLME_JOIN; Mlme_t joinType = MLME_JOIN;
MW_LOG( TS_ON, VLEVEL_M, "RX: ");
for (size_t i = 0; i < RxDoneParams.Size; ++i)
MW_LOG( TS_ON, VLEVEL_M, "%02x", RxDoneParams.Payload[i]);
MW_LOG( TS_ON, VLEVEL_M, "\r\n");
#if (defined( LORAMAC_VERSION ) && (( LORAMAC_VERSION == 0x01000400 ) || ( LORAMAC_VERSION == 0x01010100 ))) #if (defined( LORAMAC_VERSION ) && (( LORAMAC_VERSION == 0x01000400 ) || ( LORAMAC_VERSION == 0x01010100 )))
LoRaMacRadioEvents.Events.RxProcessPending = 0; LoRaMacRadioEvents.Events.RxProcessPending = 0;
#endif /* LORAMAC_VERSION */ #endif /* LORAMAC_VERSION */

View File

@ -3131,15 +3131,15 @@ typedef struct sLoRaMacCallback
*/ */
int16_t ( *GetTemperatureLevel )( void ); int16_t ( *GetTemperatureLevel )( void );
/*! /*!
* \brief Get the board 64 bits unique ID * \brief Get the board 64 bits unique ID (for OTAA)
* *
* \param [out] id unique * \param [out] id unique
*/ */
void ( *GetUniqueId )(uint8_t *id); void ( *GetUniqueId )(uint8_t *id);
/*! /*!
* \brief Get the 64 bits unique Device address * \brief Get the 32 bits Device address (for ABP)
* *
* \param [out] id unique * \param [out] id devaddr
*/ */
void ( *GetDevAddress )(uint32_t *devAddr); void ( *GetDevAddress )(uint32_t *devAddr);
/*! /*!

View File

@ -656,7 +656,7 @@ void RegionCommonRxBeaconSetup( RegionCommonRxBeaconSetupParams_t* rxBeaconSetup
1, 0, 10, rxBeaconSetupParams->SymbolTimeout, true, rxBeaconSetupParams->BeaconSize, false, 0, 0, false, rxContinuous ); 1, 0, 10, rxBeaconSetupParams->SymbolTimeout, true, rxBeaconSetupParams->BeaconSize, false, 0, 0, false, rxContinuous );
Radio.Rx( rxBeaconSetupParams->RxTime ); Radio.Rx( rxBeaconSetupParams->RxTime );
MW_LOG(TS_ON, VLEVEL_M, "RX_BC on freq %d Hz at DR %d\r\n", rxBeaconSetupParams->Frequency, rxBeaconSetupParams->BeaconDatarate ); MW_LOG(TS_ON, VLEVEL_M, "RX_BC on freq %u Hz at DR %d\r\n", (unsigned)rxBeaconSetupParams->Frequency, rxBeaconSetupParams->BeaconDatarate );
} }
void RegionCommonCountNbOfEnabledChannels( RegionCommonCountNbOfEnabledChannelsParams_t* countNbOfEnabledChannelsParams, void RegionCommonCountNbOfEnabledChannels( RegionCommonCountNbOfEnabledChannelsParams_t* countNbOfEnabledChannelsParams,
@ -790,15 +790,15 @@ void RegionCommonRxConfigPrint(LoRaMacRxSlot_t rxSlot, uint32_t frequency, int8_
{ {
if ( rxSlot < RX_SLOT_NONE ) if ( rxSlot < RX_SLOT_NONE )
{ {
MW_LOG(TS_ON, VLEVEL_M, "RX_%s on freq %d Hz at DR %d\r\n", EventRXSlotStrings[rxSlot], frequency, dr ); MW_LOG(TS_ON, VLEVEL_M, "RX_%s on freq %u Hz at DR %d\r\n", EventRXSlotStrings[rxSlot], (unsigned)frequency, dr );
} }
else else
{ {
MW_LOG(TS_ON, VLEVEL_M, "RX on freq %d Hz at DR %d\r\n", frequency, dr ); MW_LOG(TS_ON, VLEVEL_M, "RX on freq %u Hz at DR %d\r\n", (unsigned)frequency, dr );
} }
} }
void RegionCommonTxConfigPrint(uint32_t frequency, int8_t dr) void RegionCommonTxConfigPrint(uint32_t frequency, int8_t dr)
{ {
MW_LOG(TS_ON, VLEVEL_M, "TX on freq %d Hz at DR %d\r\n", frequency, dr ); MW_LOG(TS_ON, VLEVEL_M, "TX on freq %u Hz at DR %d\r\n", (unsigned)frequency, dr );
} }

View File

@ -781,7 +781,7 @@ STATIC uint16_t lr_fhss_payload_interleaving( const uint8_t *data_in, uint16_t d
lr_fhss_set_bit_in_byte_vector( data_out, 0 + out_row_index, 0 ); // guard bits lr_fhss_set_bit_in_byte_vector( data_out, 0 + out_row_index, 0 ); // guard bits
lr_fhss_set_bit_in_byte_vector( data_out, 1 + out_row_index, 0 ); // guard bits lr_fhss_set_bit_in_byte_vector( data_out, 1 + out_row_index, 0 ); // guard bits
for( uint32_t j = 0; j < in_row_width; j++ ) for( int32_t j = 0; j < in_row_width; j++ )
{ {
lr_fhss_set_bit_in_byte_vector( data_out, j + 2 + out_row_index, lr_fhss_set_bit_in_byte_vector( data_out, j + 2 + out_row_index,
lr_fhss_extract_bit_in_byte_vector( data_in, pos ) ); // guard bit lr_fhss_extract_bit_in_byte_vector( data_in, pos ) ); // guard bit

View File

@ -868,6 +868,18 @@ static void RadioSetRxConfig( RadioModems_t modem, uint32_t bandwidth,
#if (RADIO_SIGFOX_ENABLE == 1) #if (RADIO_SIGFOX_ENABLE == 1)
uint8_t modReg; uint8_t modReg;
#endif #endif
//Disabled, too much influence on RX timing
/*
MW_LOG( TS_ON, VLEVEL_M,
"Setting RX Config: modem=%s, bandwidth=%u, datarate=%u, coderate=%u bandwithAfc=%u, preambleLen=%u, symbTimeout=%u, fixLen=%u, payloadLen=%u, crcOn=%u, freqHopOn=%u, hopPeriod=%u, iqInverted=%u, rxContinuous=%u\r\n",
modem == MODEM_FSK ? "MODEM_FSK" : (modem == MODEM_LORA ? "MODEM_LORA" : "?"),
(unsigned)bandwidth, (unsigned)datarate, (unsigned)coderate,
(unsigned)bandwidthAfc, (unsigned)preambleLen,
(unsigned)symbTimeout, (unsigned)fixLen, (unsigned)payloadLen,
(unsigned)crcOn, (unsigned)freqHopOn, (unsigned)hopPeriod,
(unsigned)iqInverted, (unsigned)rxContinuous
);
*/
SubgRf.RxContinuous = rxContinuous; SubgRf.RxContinuous = rxContinuous;
RFW_DeInit(); RFW_DeInit();
if( rxContinuous == true ) if( rxContinuous == true )
@ -1057,6 +1069,15 @@ static void RadioSetTxConfig( RadioModems_t modem, int8_t power, uint32_t fdev,
SubgRf.lr_fhss.is_lr_fhss_on = false; SubgRf.lr_fhss.is_lr_fhss_on = false;
#endif /* RADIO_LR_FHSS_IS_ON == 1 */ #endif /* RADIO_LR_FHSS_IS_ON == 1 */
RFW_DeInit(); RFW_DeInit();
MW_LOG( TS_ON, VLEVEL_M,
"Setting TX Config: modem=%s, power=%u, fdev=%u, bandwidth=%u, datarate=%u, coderate=%u preambleLen=%u, fixLen=%u, crcOn=%u, freqHopOn=%u, hopPeriod=%u, iqInverted=%u, timeout=%u\r\n",
modem == MODEM_FSK ? "MODEM_FSK" : (modem == MODEM_LORA ? "MODEM_LORA" : "?"),
(int)power, (unsigned)fdev, (unsigned)bandwidth,
(unsigned)datarate, (unsigned)coderate, (unsigned)preambleLen,
(unsigned)fixLen, (unsigned)crcOn, (unsigned)freqHopOn,
(unsigned)hopPeriod, (unsigned)iqInverted, (unsigned)timeout
);
switch( modem ) switch( modem )
{ {
case MODEM_FSK: case MODEM_FSK:
@ -1315,6 +1336,11 @@ static radio_status_t RadioSend( uint8_t *buffer, uint8_t size )
IRQ_RADIO_NONE, IRQ_RADIO_NONE,
IRQ_RADIO_NONE ); IRQ_RADIO_NONE );
MW_LOG( TS_ON, VLEVEL_M, "TX:");
for (size_t i = 0; i < size; ++i)
MW_LOG( TS_ON, VLEVEL_M, " %02x", buffer[i]);
MW_LOG( TS_ON, VLEVEL_M, "\r\n");
/* Set DBG pin */ /* Set DBG pin */
DBG_GPIO_RADIO_TX( SET ); DBG_GPIO_RADIO_TX( SET );

View File

@ -485,6 +485,7 @@ sfx_u8 RF_API_wait_for_clear_channel(sfx_u8 cs_min, sfx_s8 cs_threshold, sfx_rx_
{ {
sfx_u8 status = SFX_ERR_NONE; sfx_u8 status = SFX_ERR_NONE;
sfx_rx_state_enum_t cs_state = DL_TIMEOUT; sfx_rx_state_enum_t cs_state = DL_TIMEOUT;
sfx_s8 lbt_threshold_cal;
/* Starts Rx Windows to sense if channel is occupied or clear* /* Starts Rx Windows to sense if channel is occupied or clear*
* If the channel is clear during the minimum carrier sense * If the channel is clear during the minimum carrier sense
* value (cs_min), under the limit of the cs_threshold, * value (cs_min), under the limit of the cs_threshold,
@ -502,6 +503,8 @@ sfx_u8 RF_API_wait_for_clear_channel(sfx_u8 cs_min, sfx_s8 cs_threshold, sfx_rx_
HAL_Delay(Radio.GetWakeupTime()); HAL_Delay(Radio.GetWakeupTime());
lbt_threshold_cal = E2P_Read_RssiCal();
cs_threshold += lbt_threshold_cal;
APP_LOG(TS_ON, VLEVEL_M, "CS start cs_min=%dms, cs_threshold=%dBm\n\r", cs_min, cs_threshold); APP_LOG(TS_ON, VLEVEL_M, "CS start cs_min=%dms, cs_threshold=%dBm\n\r", cs_min, cs_threshold);
while (RxCarrierSenseGetStatus() == 0) while (RxCarrierSenseGetStatus() == 0)

View File

@ -485,6 +485,7 @@ sfx_u8 RF_API_wait_for_clear_channel(sfx_u8 cs_min, sfx_s8 cs_threshold, sfx_rx_
{ {
sfx_u8 status = SFX_ERR_NONE; sfx_u8 status = SFX_ERR_NONE;
sfx_rx_state_enum_t cs_state = DL_TIMEOUT; sfx_rx_state_enum_t cs_state = DL_TIMEOUT;
sfx_s8 lbt_threshold_cal;
/* Starts Rx Windows to sense if channel is occupied or clear* /* Starts Rx Windows to sense if channel is occupied or clear*
* If the channel is clear during the minimum carrier sense * If the channel is clear during the minimum carrier sense
* value (cs_min), under the limit of the cs_threshold, * value (cs_min), under the limit of the cs_threshold,
@ -502,6 +503,8 @@ sfx_u8 RF_API_wait_for_clear_channel(sfx_u8 cs_min, sfx_s8 cs_threshold, sfx_rx_
HAL_Delay(Radio.GetWakeupTime()); HAL_Delay(Radio.GetWakeupTime());
lbt_threshold_cal = E2P_Read_RssiCal();
cs_threshold += lbt_threshold_cal;
APP_LOG(TS_ON, VLEVEL_M, "CS start cs_min=%dms, cs_threshold=%dBm\n\r", cs_min, cs_threshold); APP_LOG(TS_ON, VLEVEL_M, "CS start cs_min=%dms, cs_threshold=%dBm\n\r", cs_min, cs_threshold);
while (RxCarrierSenseGetStatus() == 0) while (RxCarrierSenseGetStatus() == 0)

View File

@ -485,6 +485,7 @@ sfx_u8 RF_API_wait_for_clear_channel(sfx_u8 cs_min, sfx_s8 cs_threshold, sfx_rx_
{ {
sfx_u8 status = SFX_ERR_NONE; sfx_u8 status = SFX_ERR_NONE;
sfx_rx_state_enum_t cs_state = DL_TIMEOUT; sfx_rx_state_enum_t cs_state = DL_TIMEOUT;
sfx_s8 lbt_threshold_cal;
/* Starts Rx Windows to sense if channel is occupied or clear* /* Starts Rx Windows to sense if channel is occupied or clear*
* If the channel is clear during the minimum carrier sense * If the channel is clear during the minimum carrier sense
* value (cs_min), under the limit of the cs_threshold, * value (cs_min), under the limit of the cs_threshold,
@ -502,6 +503,8 @@ sfx_u8 RF_API_wait_for_clear_channel(sfx_u8 cs_min, sfx_s8 cs_threshold, sfx_rx_
HAL_Delay(Radio.GetWakeupTime()); HAL_Delay(Radio.GetWakeupTime());
lbt_threshold_cal = E2P_Read_RssiCal();
cs_threshold += lbt_threshold_cal;
APP_LOG(TS_ON, VLEVEL_M, "CS start cs_min=%dms, cs_threshold=%dBm\n\r", cs_min, cs_threshold); APP_LOG(TS_ON, VLEVEL_M, "CS start cs_min=%dms, cs_threshold=%dBm\n\r", cs_min, cs_threshold);
while (RxCarrierSenseGetStatus() == 0) while (RxCarrierSenseGetStatus() == 0)

View File

@ -485,6 +485,7 @@ sfx_u8 RF_API_wait_for_clear_channel(sfx_u8 cs_min, sfx_s8 cs_threshold, sfx_rx_
{ {
sfx_u8 status = SFX_ERR_NONE; sfx_u8 status = SFX_ERR_NONE;
sfx_rx_state_enum_t cs_state = DL_TIMEOUT; sfx_rx_state_enum_t cs_state = DL_TIMEOUT;
sfx_s8 lbt_threshold_cal;
/* Starts Rx Windows to sense if channel is occupied or clear* /* Starts Rx Windows to sense if channel is occupied or clear*
* If the channel is clear during the minimum carrier sense * If the channel is clear during the minimum carrier sense
* value (cs_min), under the limit of the cs_threshold, * value (cs_min), under the limit of the cs_threshold,
@ -502,6 +503,8 @@ sfx_u8 RF_API_wait_for_clear_channel(sfx_u8 cs_min, sfx_s8 cs_threshold, sfx_rx_
HAL_Delay(Radio.GetWakeupTime()); HAL_Delay(Radio.GetWakeupTime());
lbt_threshold_cal = E2P_Read_RssiCal();
cs_threshold += lbt_threshold_cal;
APP_LOG(TS_ON, VLEVEL_M, "CS start cs_min=%dms, cs_threshold=%dBm\n\r", cs_min, cs_threshold); APP_LOG(TS_ON, VLEVEL_M, "CS start cs_min=%dms, cs_threshold=%dBm\n\r", cs_min, cs_threshold);
while (RxCarrierSenseGetStatus() == 0) while (RxCarrierSenseGetStatus() == 0)

View File

@ -485,6 +485,7 @@ sfx_u8 RF_API_wait_for_clear_channel(sfx_u8 cs_min, sfx_s8 cs_threshold, sfx_rx_
{ {
sfx_u8 status = SFX_ERR_NONE; sfx_u8 status = SFX_ERR_NONE;
sfx_rx_state_enum_t cs_state = DL_TIMEOUT; sfx_rx_state_enum_t cs_state = DL_TIMEOUT;
sfx_s8 lbt_threshold_cal;
/* Starts Rx Windows to sense if channel is occupied or clear* /* Starts Rx Windows to sense if channel is occupied or clear*
* If the channel is clear during the minimum carrier sense * If the channel is clear during the minimum carrier sense
* value (cs_min), under the limit of the cs_threshold, * value (cs_min), under the limit of the cs_threshold,
@ -502,6 +503,8 @@ sfx_u8 RF_API_wait_for_clear_channel(sfx_u8 cs_min, sfx_s8 cs_threshold, sfx_rx_
HAL_Delay(Radio.GetWakeupTime()); HAL_Delay(Radio.GetWakeupTime());
lbt_threshold_cal = E2P_Read_RssiCal();
cs_threshold += lbt_threshold_cal;
APP_LOG(TS_ON, VLEVEL_M, "CS start cs_min=%dms, cs_threshold=%dBm\n\r", cs_min, cs_threshold); APP_LOG(TS_ON, VLEVEL_M, "CS start cs_min=%dms, cs_threshold=%dBm\n\r", cs_min, cs_threshold);
while (RxCarrierSenseGetStatus() == 0) while (RxCarrierSenseGetStatus() == 0)

View File

@ -485,6 +485,7 @@ sfx_u8 RF_API_wait_for_clear_channel(sfx_u8 cs_min, sfx_s8 cs_threshold, sfx_rx_
{ {
sfx_u8 status = SFX_ERR_NONE; sfx_u8 status = SFX_ERR_NONE;
sfx_rx_state_enum_t cs_state = DL_TIMEOUT; sfx_rx_state_enum_t cs_state = DL_TIMEOUT;
sfx_s8 lbt_threshold_cal;
/* Starts Rx Windows to sense if channel is occupied or clear* /* Starts Rx Windows to sense if channel is occupied or clear*
* If the channel is clear during the minimum carrier sense * If the channel is clear during the minimum carrier sense
* value (cs_min), under the limit of the cs_threshold, * value (cs_min), under the limit of the cs_threshold,
@ -502,6 +503,8 @@ sfx_u8 RF_API_wait_for_clear_channel(sfx_u8 cs_min, sfx_s8 cs_threshold, sfx_rx_
HAL_Delay(Radio.GetWakeupTime()); HAL_Delay(Radio.GetWakeupTime());
lbt_threshold_cal = E2P_Read_RssiCal();
cs_threshold += lbt_threshold_cal;
APP_LOG(TS_ON, VLEVEL_M, "CS start cs_min=%dms, cs_threshold=%dBm\n\r", cs_min, cs_threshold); APP_LOG(TS_ON, VLEVEL_M, "CS start cs_min=%dms, cs_threshold=%dBm\n\r", cs_min, cs_threshold);
while (RxCarrierSenseGetStatus() == 0) while (RxCarrierSenseGetStatus() == 0)

View File

@ -485,6 +485,7 @@ sfx_u8 RF_API_wait_for_clear_channel(sfx_u8 cs_min, sfx_s8 cs_threshold, sfx_rx_
{ {
sfx_u8 status = SFX_ERR_NONE; sfx_u8 status = SFX_ERR_NONE;
sfx_rx_state_enum_t cs_state = DL_TIMEOUT; sfx_rx_state_enum_t cs_state = DL_TIMEOUT;
sfx_s8 lbt_threshold_cal;
/* Starts Rx Windows to sense if channel is occupied or clear* /* Starts Rx Windows to sense if channel is occupied or clear*
* If the channel is clear during the minimum carrier sense * If the channel is clear during the minimum carrier sense
* value (cs_min), under the limit of the cs_threshold, * value (cs_min), under the limit of the cs_threshold,
@ -502,6 +503,8 @@ sfx_u8 RF_API_wait_for_clear_channel(sfx_u8 cs_min, sfx_s8 cs_threshold, sfx_rx_
HAL_Delay(Radio.GetWakeupTime()); HAL_Delay(Radio.GetWakeupTime());
lbt_threshold_cal = E2P_Read_RssiCal();
cs_threshold += lbt_threshold_cal;
APP_LOG(TS_ON, VLEVEL_M, "CS start cs_min=%dms, cs_threshold=%dBm\n\r", cs_min, cs_threshold); APP_LOG(TS_ON, VLEVEL_M, "CS start cs_min=%dms, cs_threshold=%dBm\n\r", cs_min, cs_threshold);
while (RxCarrierSenseGetStatus() == 0) while (RxCarrierSenseGetStatus() == 0)