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

how to set only 1 advertisement channel for mesh?

Hello devzone,

There are 3 {37,28,29} channels for advertisement & i want to advertise only on 37.

Soft: Nordic mesh v1.0.0 stack & pca10040 nrf board, light switch example.

Try 1

I saw a function set_default_advertiser_configuration() (in /mesh/bearer/src/advertiser.c) which leads me to nrf_mesh_defines.h has a #define NRF_MESH_ADV_CHAN_ALL {37, 38, 39} I changed the values to 37 & servers unable to provisioned, am i missing something to configure to advertise only 1 channel? Thanks

Try 2 

mesh/core/src/core_tx_adv.c in core_tx_adv_init() i set_channels after advertiser_instance_init

set_channels.channels.count = 1;
set_channels.channels.randomize_order = 0;
set_channels.channels.channel_map[0] = 37;

advertiser_channels_set(&m_advertisers[CORE_TX_ROLE_ORIGINATOR],&set_channels); 

Unfortunately, mesh stack unable to initialize.

  • What kind of errors are you getting? Are you able to compile the light switch example client & server code? Do you have a log that you could upload? Have you tried debugging the client example? Did you remember to make the changes to both the advertiser & server? 

  • Hi Bjorn thanks for you reply.

    Yes, i am able to compile example client & server code in both trys.

    For try 1

    I see servers doesn't get always provisioned, sometimes one of the servers get provisioned ! 

    i only changes at #define NRF_MESH_ADV_CHAN_ALL {37} , would it be change client as well client settings as nrf_mesh_init() is called from nrf_mesh_node_config ref: /mesh/access/src/nrf_node_config.c line:266 if not can u please point me out where i need to make changes ?

    Try 2 code diff is also attached.

    diff --git a/mesh/core/src/core_tx_adv.c b/mesh/core/src/core_tx_adv.c
    index 29ca192..6c1dfa7 100644
    --- a/mesh/core/src/core_tx_adv.c
    +++ b/mesh/core/src/core_tx_adv.c
    @@ -108,6 +108,7 @@ static void packet_discard(const core_tx_metadata_t * p_meta                                                                                                                                                                                                         data, uint8_t * p_pa
     /*****************************************************************************
     * Interface functions
     *****************************************************************************/
    +advertiser_channels_t set_channels;
     void core_tx_adv_init(void)
     {
         m_adv_tx_count[CORE_TX_ROLE_ORIGINATOR] = CORE_TX_REPEAT_ORIGINATOR_DEFAULT                                                                                                                                                                                                         ;
    @@ -115,6 +116,10 @@ void core_tx_adv_init(void)
                                  adv_tx_complete_callback,
                                  m_originator_adv_packet_buffer,
                                  sizeof(m_originator_adv_packet_buffer));
    +    set_channels.count = 1;
    +    set_channels.randomize_order = 0;
    +    set_channels.channel_map[0] = 37;
    +    advertiser_channels_set(&m_advertisers[CORE_TX_ROLE_ORIGINATOR],&set_channe                                                                                                                                                                                                         ls);
         advertiser_enable(&m_advertisers[CORE_TX_ROLE_ORIGINATOR]);
    
         m_adv_tx_count[CORE_TX_ROLE_RELAY] = CORE_TX_REPEAT_RELAY_DEFAULT;
    @@ -122,8 +127,8 @@ void core_tx_adv_init(void)
                                  NULL,
                                  m_relay_adv_packet_buffer,
    :
     /*****************************************************************************
     * Interface functions
     *****************************************************************************/
    +advertiser_channels_t set_channels;
     void core_tx_adv_init(void)
     {
         m_adv_tx_count[CORE_TX_ROLE_ORIGINATOR] = CORE_TX_REPEAT_ORIGINATOR_DEFAULT;
    @@ -115,6 +116,10 @@ void core_tx_adv_init(void)
                                  adv_tx_complete_callback,
                                  m_originator_adv_packet_buffer,
                                  sizeof(m_originator_adv_packet_buffer));
    +    set_channels.count = 1;
    +    set_channels.randomize_order = 0;
    +    set_channels.channel_map[0] = 37;
    +    advertiser_channels_set(&m_advertisers[CORE_TX_ROLE_ORIGINATOR],&set_channe                                                                                                                                                                                                         ls);
         advertiser_enable(&m_advertisers[CORE_TX_ROLE_ORIGINATOR]);
    
         m_adv_tx_count[CORE_TX_ROLE_RELAY] = CORE_TX_REPEAT_RELAY_DEFAULT;
    @@ -122,8 +127,8 @@ void core_tx_adv_init(void)
                                  NULL,
                                  m_relay_adv_packet_buffer,
                                  sizeof(m_relay_adv_packet_buffer));
    +    advertiser_channels_set(&m_advertisers[CORE_TX_ROLE_RELAY],&set_channels);
         advertiser_enable(&m_advertisers[CORE_TX_ROLE_RELAY]);
    
         core_tx_bearer_register(CORE_TX_BEARER_ADV, &m_interface);
     }
     
     
     diff --git a/mesh/prov/src/prov_bearer_adv.c b/mesh/prov/src/prov_bearer_adv.c
    index 94f044c..dd6aa52 100755
    --- a/mesh/prov/src/prov_bearer_adv.c
    +++ b/mesh/prov/src/prov_bearer_adv.c
    @@ -343,6 +343,11 @@ static void init_bearer_structure(nrf_mesh_prov_bearer_adv_t * p_pb_adv, uint32_
                                  tx_complete_cb,
                                  p_pb_adv->tx_buffer,
                                  NRF_MESH_PROV_BEARER_ADV_TX_BUFFER_SIZE);
    +    advertiser_channels_t set_channels;
    +    set_channels.channel_map[0] = 37;
    +    set_channels.count = 1;
    +    set_channels.randomize_order = 0;
    +    advertiser_channels_set(&p_pb_adv->advertiser,&set_channels);
     }
    
    

  • Hi Beike,

    Do u have any solution/ suggestion ? this comment is not helping me much !!

    Thank you. 

  • What seems weird is that you are getting the servers provisioned on the first try. This makes me believe that everything you have done is correct. What are you doing different on the second try? Have you tried debugging the client on the second try or running two rtt viewer windows (one for client, one for server) to see where the issue lies?

Related