How to differentiate versions of modem lib for dect nr+?

Nordic has changed the API of nrfx nrf_modem_dect_phy from SDK 2.7 to SDK v2.9.

In struct nrf_modem_dect_phy_callbacks there is an additional callback member stf_cover_seq_control.

I found nrf_modem_build_version(); with that I can check the version of the modem lib which I compiled against at runtime I assume.

I also found an AT command for checking the version of the running modem firmware. I can print it via modem CONFIG_NRF_MODEM_LIB_LOG_FW_VERSION_UUID but did not compare against version of the modem lib.

But how can I differentiate at compile time which version of the struct I have to use (I want to support both).

Is there some #define to specify the version of the modem lib and/or the sdk?

  • Hi,

    But how can I differentiate at compile time which version of the struct I have to use (I want to support both).

    To make sure I understand correctly:

    You want to build with either the new or the old struct depending on which modem fw version the app is built for?

    Regards,
    Sigurd Hellesvik

  • It should select the correct initializer for the needed callbacks depending on modem lib version it is build against.
    Something like:

    static const struct nrf_modem_dect_phy_callbacks callbacks = {
    .init = radio_init_cb,
    .op_complete = op_complete_cb,
    .rssi = rssi_cb,
    .rx_stop = rx_stop_cb,
    .pcc = pcc_cb,
    .pcc_crc_err = pcc_crc_err_cb,
    .pdc = pdc_cb,
    .pdc_crc_err = pdc_crc_err_cb,
    .link_config = link_config_cb,
    .time_get = time_get_cb,
    .capability_get = capability_get_cb,
    #if defined NRF_MODEM_VERSION == "2.9"
    .stf_cover_seq_control = stf_cover_seq_control_cb,
    #endif
    .deinit = deinit_cb
    };
  • I found a solution that works when I differentiate the API of the modem lib via its related SDK version.

    Indeed there is a #define for the SDK version my code gets compiled against
    in the generated code under build/firmware/zephyr/include/generated/ncs_version.h.

    Now I can implement it like this:

    static const struct nrf_modem_dect_phy_callbacks callbacks = {
    .init = radio_init_cb,
    .op_complete = op_complete_cb,
    .rssi = rssi_cb,
    .rx_stop = rx_stop_cb,
    .pcc = pcc_cb,
    .pcc_crc_err = pcc_crc_err_cb,
    .pdc = pdc_cb,
    .pdc_crc_err = pdc_crc_err_cb,
    .link_config = link_config_cb,
    .time_get = time_get_cb,
    .capability_get = capability_get_cb,
    #if NCS_VERSION_NUMBER >= 0x20900
    .stf_cover_seq_control = stf_cover_seq_control_cb,
    #endif
    .deinit = deinit_cb
    };

  • That sounds like a good way to do it.
    Good job finding the solution yourself!

Related