Skip to content
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
* Add user access to the `lorawan_api_set_no_rx_packet_threshold` function.
* Add user access to the beacon statistics data with `smtc_modem_class_b_beacon_get_statistics` function.
* Add user access to the `smtc_modem_factory_reset` function.
* Add multi-radio support. NOTE: not fully tested. Samples are not updated or tested.

## [v4.9.0] 2025-10-15

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
*/

/**
* Stack id value (multistacks modem is not yet available)
* Stack id value (multistacks modem is not yet available) - EvaTODO: Not yet supported
*/
#define STACK_ID ( 0 )

Expand Down Expand Up @@ -240,13 +240,13 @@ static bool check_lr11xx_fw_version( void )
lr11xx_system_version_t lr11xx_fw_version;

/* suspend modem to get access to the radio */
smtc_modem_suspend_radio_communications( true );
smtc_modem_suspend_radio_communications( STACK_ID, true );

status = lr11xx_system_get_version( NULL, &lr11xx_fw_version );
if( status != LR11XX_STATUS_OK )
{
SMTC_HAL_TRACE_ERROR( "Failed to get LR11XX firmware version\n" );
smtc_modem_suspend_radio_communications( false );
smtc_modem_suspend_radio_communications( STACK_ID, false );
return false;
}

Expand All @@ -255,20 +255,20 @@ static bool check_lr11xx_fw_version( void )
{
SMTC_HAL_TRACE_ERROR( "Wrong LR1110 firmware version, expected 0x%04X, got 0x%04X\n", LR1110_FW_VERSION,
lr11xx_fw_version.fw );
smtc_modem_suspend_radio_communications( false );
smtc_modem_suspend_radio_communications( STACK_ID, false );
return false;
}
if( ( lr11xx_fw_version.type == LR11XX_SYSTEM_VERSION_TYPE_LR1120 ) &&
( lr11xx_fw_version.fw < LR1120_FW_VERSION ) )
{
SMTC_HAL_TRACE_ERROR( "Wrong LR1120 firmware version, expected 0x%04X, got 0x%04X\n", LR1120_FW_VERSION,
lr11xx_fw_version.fw );
smtc_modem_suspend_radio_communications( false );
smtc_modem_suspend_radio_communications( STACK_ID, false );
return false;
}

/* release radio to the modem */
smtc_modem_suspend_radio_communications( false );
smtc_modem_suspend_radio_communications( STACK_ID, false );
SMTC_HAL_TRACE_INFO( "LR11XX FW: 0x%04X, type: 0x%02X\n", lr11xx_fw_version.fw, lr11xx_fw_version.type );
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
*/

/**
* Stack id value (multistacks modem is not yet available)
* Stack id value (multistacks modem is not yet available) - EvaTODO: Not yet supported
*/
#define STACK_ID 0

Expand Down Expand Up @@ -451,13 +451,13 @@ static bool check_lr11xx_fw_version( void )
lr11xx_system_version_t lr11xx_fw_version;

/* suspend modem to get access to the radio */
smtc_modem_suspend_radio_communications( true );
smtc_modem_suspend_radio_communications( STACK_ID, true );

status = lr11xx_system_get_version( NULL, &lr11xx_fw_version );
if( status != LR11XX_STATUS_OK )
{
SMTC_HAL_TRACE_ERROR( "Failed to get LR11XX firmware version\n" );
smtc_modem_suspend_radio_communications( false );
smtc_modem_suspend_radio_communications( STACK_ID, false );
return false;
}

Expand All @@ -466,20 +466,20 @@ static bool check_lr11xx_fw_version( void )
{
SMTC_HAL_TRACE_ERROR( "Wrong LR1110 firmware version, expected 0x%04X, got 0x%04X\n", LR1110_FW_VERSION,
lr11xx_fw_version.fw );
smtc_modem_suspend_radio_communications( false );
smtc_modem_suspend_radio_communications( STACK_ID, false );
return false;
}
if( ( lr11xx_fw_version.type == LR11XX_SYSTEM_VERSION_TYPE_LR1120 ) &&
( lr11xx_fw_version.fw < LR1120_FW_VERSION ) )
{
SMTC_HAL_TRACE_ERROR( "Wrong LR1120 firmware version, expected 0x%04X, got 0x%04X\n", LR1120_FW_VERSION,
lr11xx_fw_version.fw );
smtc_modem_suspend_radio_communications( false );
smtc_modem_suspend_radio_communications( STACK_ID, false );
return false;
}

/* release radio to the modem */
smtc_modem_suspend_radio_communications( false );
smtc_modem_suspend_radio_communications( STACK_ID, false );
SMTC_HAL_TRACE_INFO( "LR11XX FW: 0x%04X, type: 0x%02X\n", lr11xx_fw_version.fw, lr11xx_fw_version.type );
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
*/

/**
* Stack id value (multistacks modem is not yet available)
* Stack id value (multistacks modem is not yet available) - EvaTODO: Not yet supported
*/
#define STACK_ID 0

Expand Down Expand Up @@ -364,13 +364,13 @@ static bool check_lr11xx_fw_version( void )
lr11xx_system_version_t lr11xx_fw_version;

/* suspend modem to get access to the radio */
smtc_modem_suspend_radio_communications( true );
smtc_modem_suspend_radio_communications( STACK_ID, true );

status = lr11xx_system_get_version( NULL, &lr11xx_fw_version );
if( status != LR11XX_STATUS_OK )
{
SMTC_HAL_TRACE_ERROR( "Failed to get LR11XX firmware version\n" );
smtc_modem_suspend_radio_communications( false );
smtc_modem_suspend_radio_communications( STACK_ID, false );
return false;
}

Expand All @@ -379,20 +379,20 @@ static bool check_lr11xx_fw_version( void )
{
SMTC_HAL_TRACE_ERROR( "Wrong LR1110 firmware version, expected 0x%04X, got 0x%04X\n", LR1110_FW_VERSION,
lr11xx_fw_version.fw );
smtc_modem_suspend_radio_communications( false );
smtc_modem_suspend_radio_communications( STACK_ID, false );
return false;
}
if( ( lr11xx_fw_version.type == LR11XX_SYSTEM_VERSION_TYPE_LR1120 ) &&
( lr11xx_fw_version.fw < LR1120_FW_VERSION ) )
{
SMTC_HAL_TRACE_ERROR( "Wrong LR1120 firmware version, expected 0x%04X, got 0x%04X\n", LR1120_FW_VERSION,
lr11xx_fw_version.fw );
smtc_modem_suspend_radio_communications( false );
smtc_modem_suspend_radio_communications( STACK_ID, false );
return false;
}

/* release radio to the modem */
smtc_modem_suspend_radio_communications( false );
smtc_modem_suspend_radio_communications( STACK_ID, false );
SMTC_HAL_TRACE_INFO( "LR11XX FW: 0x%04X, type: 0x%02X\n", lr11xx_fw_version.fw, lr11xx_fw_version.type );
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions lbm_examples/hw_modem/cmd_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
* --- PRIVATE CONSTANTS -------------------------------------------------------
*/

#define STACK_ID 0
#define STACK_ID 0 // EvaTODO: Not yet supported
#if defined( STM32L073xx )
#define FILE_UPLOAD_MAX_SIZE 4096
#else
Expand Down Expand Up @@ -1824,7 +1824,7 @@ cmd_parse_status_t parse_cmd( cmd_input_t* cmd_input, cmd_response_t* cmd_output
}
case CMD_SUSPEND_RADIO_COMMUNICATIONS:
{
cmd_output->return_code = rc_lut[smtc_modem_suspend_radio_communications( cmd_input->buffer[0] )];
cmd_output->return_code = rc_lut[smtc_modem_suspend_radio_communications( STACK_ID, cmd_input->buffer[0] )];
break;
}
case CMD_DM_HANDLE_ALCSYNC:
Expand Down
26 changes: 17 additions & 9 deletions lbm_lib/smtc_modem_api/smtc_modem_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -1060,27 +1060,29 @@ smtc_modem_return_code_t smtc_modem_get_suspend_radio_communications( uint8_t st
/**
* @brief Suspend the radio communications initiated by the modem
*
* @param [in] suspend The configuration to be applied (true: suspend communications / false: resume communications)
* @param [in] stack_id Stack identifier
* @param [in] suspend The configuration to be applied (true: suspend communications / false: resume communications)
*
* @return Modem return code as defined in @ref smtc_modem_return_code_t
* @retval SMTC_MODEM_RC_OK Command executed without errors
* @retval SMTC_MODEM_RC_BUSY Modem is currently in test mode
*/
smtc_modem_return_code_t smtc_modem_suspend_radio_communications( bool suspend );
smtc_modem_return_code_t smtc_modem_suspend_radio_communications( uint8_t stack_id, bool suspend );

/**
* @brief Set and start the alarm timer (up to 864000s ie 10 days)
*
* @remark When the timer expires, an alarm event is generated
*
* @param [in] stack_id Stack identifier
* @param [in] alarm_timer_in_s Alarm timer in second
*
* @return Modem return code as defined in @ref smtc_modem_return_code_t
* @retval SMTC_MODEM_RC_OK Command executed without errors
* @retval SMTC_MODEM_RC_INVALID \p alarm_timer_in_s exceed max value of 864000s (10 days)
* @retval SMTC_MODEM_RC_BUSY Modem is currently in test mode
*/
smtc_modem_return_code_t smtc_modem_alarm_start_timer( uint32_t alarm_timer_in_s );
smtc_modem_return_code_t smtc_modem_alarm_start_timer( uint8_t stack_id, uint32_t alarm_timer_in_s );

/**
* @brief Stop and clear the alarm timer
Expand All @@ -1090,11 +1092,12 @@ smtc_modem_return_code_t smtc_modem_alarm_start_timer( uint32_t alarm_timer_in_s
* @retval SMTC_MODEM_RC_NOT_INIT No alarm timer currently running
* @retval SMTC_MODEM_RC_BUSY Modem is currently in test mode
*/
smtc_modem_return_code_t smtc_modem_alarm_clear_timer( void );
smtc_modem_return_code_t smtc_modem_alarm_clear_timer( uint8_t stack_id );

/**
* @brief Get the number of seconds remaining before the alarm triggers an event
*
* @param [in] stack_id Stack identifier
* @param [out] remaining_time_in_s Number of seconds remaining before the alarm triggers an event
*
* @return Modem return code as defined in @ref smtc_modem_return_code_t
Expand All @@ -1103,7 +1106,7 @@ smtc_modem_return_code_t smtc_modem_alarm_clear_timer( void );
* @retval SMTC_MODEM_RC_INVALID \p remaining_time_in_s is NULL
* @retval SMTC_MODEM_RC_BUSY Modem is currently in test mode
*/
smtc_modem_return_code_t smtc_modem_alarm_get_remaining_time( uint32_t* remaining_time_in_s );
smtc_modem_return_code_t smtc_modem_alarm_get_remaining_time( uint8_t stack_id, uint32_t* remaining_time_in_s );

/*
* -----------------------------------------------------------------------------
Expand Down Expand Up @@ -1489,32 +1492,36 @@ smtc_modem_return_code_t smtc_modem_csma_get_parameters( uint8_t stack_id, uint8
/**
* @brief Get the total charge counter of the modem in mAh
*
* @param [in] stack_id Stack identifier
* @param [out] charge_mah Accumulated charge in mAh
*
* @return Modem return code as defined in @ref smtc_modem_return_code_t
* @retval SMTC_MODEM_RC_OK Command executed without errors
* @retval SMTC_MODEM_RC_INVALID Parameter \p charge_mah is NULL
* @retval SMTC_MODEM_RC_BUSY Modem is currently in test mode
*/
smtc_modem_return_code_t smtc_modem_get_charge( uint32_t* charge_mah );
smtc_modem_return_code_t smtc_modem_get_charge( uint8_t stack_id, uint32_t* charge_mah );

/**
* @brief Get the Radio Planner statistics in array
*
* @param stack_id
* @param stats_array
* @param stats_array_length
* @return smtc_modem_return_code_t
*/
smtc_modem_return_code_t smtc_modem_get_rp_stats_to_array( uint8_t* stats_array, uint16_t* stats_array_length );
smtc_modem_return_code_t smtc_modem_get_rp_stats_to_array( uint8_t stack_id, uint8_t* stats_array, uint16_t* stats_array_length );

/**
* @brief Reset the total charge counter of the modem
*
* @param [in] stack_id Stack identifier
*
* @return Modem return code as defined in @ref smtc_modem_return_code_t
* @retval SMTC_MODEM_RC_OK Command executed without errors
* @retval SMTC_MODEM_RC_BUSY Modem is currently in test mode
*/
smtc_modem_return_code_t smtc_modem_reset_charge( void );
smtc_modem_return_code_t smtc_modem_reset_charge( uint8_t stack_id );

/*
* -----------------------------------------------------------------------------
Expand Down Expand Up @@ -2279,14 +2286,15 @@ smtc_modem_return_code_t smtc_modem_store_and_forward_flash_get_number_of_free_s
/**
* @brief Enable or disable duty cycle feature
*
* @param [in] stack_id Stack identifier
* @param [in] enable Status of the duty cycle feature to set (true: enable, false: disable)
*
* @return Modem return code as defined in @ref smtc_modem_return_code_t
* @retval SMTC_MODEM_RC_OK Command executed without errors
* @retval SMTC_MODEM_RC_BUSY Modem is currently in test mode
* @retval SMTC_MODEM_RC_FAIL Duty cycle feature is not ready
*/
smtc_modem_return_code_t smtc_modem_debug_set_duty_cycle_state( bool enable );
smtc_modem_return_code_t smtc_modem_debug_set_duty_cycle_state( uint8_t stack_id, bool enable );

/**
* @brief join network in ABP
Expand Down
45 changes: 39 additions & 6 deletions lbm_lib/smtc_modem_api/smtc_modem_utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,36 @@ extern "C" {
* --- PUBLIC TYPES ------------------------------------------------------------
*/

/* HW type */
typedef enum
{
SMTC_MODEM_RADIO_NONE = 0,
SMTC_MODEM_RADIO_LR11XX,
SMTC_MODEM_RADIO_LR20XX,
SMTC_MODEM_RADIO_SX126X,
SMTC_MODEM_RADIO_SX127X,
SMTC_MODEM_RADIO_SX128X
} smtc_modem_radio_type_t;

/*
* -----------------------------------------------------------------------------
* --- PUBLIC FUNCTIONS PROTOTYPES ---------------------------------------------
*/

/**
* @brief Init the soft modem and set the modem event chosen callback
* @remark The callback will be called each time an modem event is raised internally
* @remark The callback will be called each time an modem event is raised internally - for all stacks
*
* @param [in] event_callback User event callback prototype
*/
void smtc_modem_init( void ( *event_callback )( void ) );
void smtc_modem_init_common( void ( *event_callback )( void ) );

/**
* @brief Init the soft modem for a given stack and radio
*
* @param [in] stack_id stack identifier
*/
void smtc_modem_init( uint8_t stack_id );

/**
* @brief Run the modem engine
Expand All @@ -89,29 +107,44 @@ uint32_t smtc_modem_run_engine( void );
/**
* @brief Check if some modem irq flags are pending
*
* @param [in] stack_id stack identifier
*
* @return true if some flags are pending, false otherwise
*/
bool smtc_modem_is_irq_flag_pending( void );
bool smtc_modem_is_irq_flag_pending( uint8_t stack_id );

/**
* @brief Set optional user radio context that can be retrieved in radio drivers hal calls
*
* @param [in] stack_id stack identifier
* @param [in] radio_type type of the radio
* @param [in] radio_ctx pointer on context
*/
void smtc_modem_set_radio_context( const void* radio_ctx );
void smtc_modem_set_radio_context( uint8_t stack_id, smtc_modem_radio_type_t radio_type, const void* radio_ctx );

/**
* @brief Get optional user radio context
*
* @returns Radio context reference
*/
const void* smtc_modem_get_radio_context( void );
const void* smtc_modem_get_radio_context( uint8_t stack_id );

/**
* @brief Get the radio type for a given stack
*
* @param[in] stack_id
* @return
*/
smtc_modem_radio_type_t smtc_modem_get_radio_type( uint8_t stack_id );

/**
* @brief Check if the radio is used by the radio planner
*
* @param [in] stack_id stack identifier
*
* @returns true if the radio isn't used by the radio planner, false otherwise
*/
bool smtc_modem_radio_is_free(void);
bool smtc_modem_radio_is_free(uint8_t stack_id);
#ifdef __cplusplus
}
#endif
Expand Down
Loading