NordicPlayground / nRF51-ble-bcast-mesh

Other
323 stars 121 forks source link

rbc_mesh_value_enable doesn't initiate trickle #166

Open thedjnK opened 7 years ago

thedjnK commented 7 years ago

I'm not sure if this is present in your tree's build but in a modified source tree I've been hunting down an issue whereby using rbc_mesh_value_enable() to enable a handle for updates doesn't send anything and have found the solution is to call vh_order_update(timer_now()); after the bottom trickle_enable() in the handle_storage.c function handle_storage_flag_set()

If this problem exists in the default code then this or similar code will fix the problem.

thedjnK commented 7 years ago

Better fix: inside handle_storage_flag_set(), update the code after mesh_packet_build() to:

            if (handle_index == HANDLE_CACHE_ENTRY_INVALID)
            {
                /* may safely run this function inline, as we're already in event handler */
                local_packet_push(p_packet);

                handle_index = handle_entry_get(handle, true);
                if (handle_index != HANDLE_CACHE_ENTRY_INVALID)
                {
                    trickle_enable(&m_data_cache[m_handle_cache[handle_index].data_entry].trickle);
                    vh_order_update(timer_now());
                }

                return NRF_SUCCESS;
            }