This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

ANT dynamic device ID

Dear Nordic team,

We are deveopping BLE & ANT enabled display. Because it is a mass production product we need to do an automation for asigning devices destinguesed ID. For BLE we manadge to do that, but for ANT we are struggling.

It doesn't let us use a regulart variable at the ANT initialisation stage (asigning channel, device id, type,...), but we need to use a constant variable. How can we go around that? Thank you,.

Parents
  • Hi 

    Unfortunately the ANT experts in the group are on holiday this month, but I will do my best to help you in the mean time. 

    Are you able to show me your ANT initialisation code?

    I would assume it should be possible to replace the constant values with dynamic values (or vice versa), but I am not very familiar with these API's. 

    Also can you let me know which nRF device you are using, and which SDK and SoftDevice?

    Best regards
    Torbjørn

  • Hi Torbjørn,

    first thank you for your response.

    I agree with you that it should be possible to change to regular. The simplest thing will be if we have a look in HRM example.

    We are using:
    - \nRF5_SDK_17.0.2_d674dde
    - s332 (but for simplicity sake we can test HRM with s212)
    - Dev kit, pca10040
    - example location, nRF5_SDK_17.0.2_d674dde\examples\ant\ant_plus\ant_hrm\hrm_tx\pca10040\s212\ses

    Short explanation:
    - Dev ID is in ->  sdk_config.h   ->   //#define CHAN_ID_DEV_NUM  (I think it is something around 50)
    - This number should be uint16_t  long
    -  We are using it in main.c at beginning (code bellow)

    HRM_SENS_CHANNEL_CONFIG_DEF(m_ant_hrm,
                                HRM_CHANNEL_NUM,
                                CHAN_ID_TRANS_TYPE,
                                CHAN_ID_DEV_NUM,
                                ANTPLUS_NETWORK_NUM);

    - Which is called in ant_hrm.h (code bellow)

    static const ant_channel_config_t   CONCAT_2(NAME,_channel_hrm_sens_config) =   \
        {                                                                           \
            .channel_number    = (CHANNEL_NUMBER),                                  \
            .channel_type      = HRM_SENS_CHANNEL_TYPE,                             \
            .ext_assign        = HRM_EXT_ASSIGN,                                    \
            .rf_freq           = HRM_ANTPLUS_RF_FREQ,                               \
            .transmission_type = (TRANSMISSION_TYPE),                               \
            .device_type       = HRM_DEVICE_TYPE,                                   \
            .device_number     = (DEVICE_NUMBER),                                   \
            .channel_period    = HRM_MSG_PERIOD_4Hz,                                \
            .network_number    = (NETWORK_NUMBER),                                  \
        }

    Thank you

    Regards, Ram

  • Hi Ram

    It is possible to assign the result of the HRM_SENS_CHANNEL_CONFIG makro into a variable, so that you can change the values dynamically as you want. 

    You can do this in the profile_setup() function, before the call to ant_hrm_sens_init(..), as shown here:

    // Write the static config into a variable
    ant_channel_config_t *channel_config = HRM_SENS_CHANNEL_CONFIG(m_ant_hrm);
    
    // Make your changes here
    channel_config->channel_number = 12;
    
    // Point to channel_config here
    err_code = ant_hrm_sens_init(&m_ant_hrm, channel_config,
                                 HRM_SENS_PROFILE_CONFIG(m_ant_hrm));
    APP_ERROR_CHECK(err_code);

    Best regards
    Torbjørn

  • Hi Torbjørn

    Thenx for suggestion (a small typo - .device_number, not channel). But that didn't work. I had another look in the code and managed to "solve" the problem by changing follow function:

    - in ant_channel_config.c
    - uint32_t ant_channel_init(ant_channel_config_t const * p_config)
    - change "Set Channel ID" -  "p_config->device_number" to whatever you like

    But keep in mind thatt this file is shared with other projects, so it isn't an elegant solution. I will be happy to hear from you for a better one.

    Regards, Ram

  • Hi Ram

    Why didn't it work?

    Is the device_number field overwritten by some of the ant_hrm functions?
    I tried to look through the code, but couldn't find any point where this appears to happen. 

    If you end up having no other choice than to change one of the SDK functions I recommend making a local copy of the source file, and applying the changes there. Then it will not affect any of the other projects. 

    Just make sure to remove the original file and add the local copy in your project settings. 

    Best regards
    Torbjørn

  • Hi Torbjørn,

    I'm not sure what went wrong, but when scanning with ANT display, I see same number as defined in config, without any change.

    Regards, Ram

Reply Children
Related