<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Simple_On_Off_Model callbacks are called multiple times each message</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/50897/simple_on_off_model-callbacks-are-called-multiple-times-each-message</link><description>Hi , so I witnessed this weird phenomenon: 
 When I use the simple On-Off-Model (as a base for a custom vendor model) in the switch application, the handle_set function in simple on_off_server. and therefore the callback function in main.c are called</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 10 Oct 2019 14:04:29 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/50897/simple_on_off_model-callbacks-are-called-multiple-times-each-message" /><item><title>RE: Simple_On_Off_Model callbacks are called multiple times each message</title><link>https://devzone.nordicsemi.com/thread/214415?ContentTypeID=1</link><pubDate>Thu, 10 Oct 2019 14:04:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b926b5bc-cce1-4498-8dae-5543caf1b306</guid><dc:creator>Joakim Jakobsen</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;Sorry, I think I misread the documentation so you can disregard my last answer.&lt;/p&gt;
&lt;p&gt;Could you try changing part of the code you added in your previous answer(from server.c):&lt;/p&gt;
&lt;p&gt;From:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;for (uint8_t i = 0; i &amp;lt; repeats; ++i)
{
    message.access_token = nrf_mesh_unique_token_get();
    status = access_model_publish(p_client-&amp;gt;model_handle, &amp;amp;message);

    if (status != NRF_SUCCESS)
    {
    break;
    }

}

return status;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;to:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;for (uint8_t i = 0; i &amp;lt;= repeats; ++i)
{
    message.access_token = nrf_mesh_unique_token_get();
    status = access_model_publish(p_client-&amp;gt;model_handle, &amp;amp;message);

    if (status != NRF_SUCCESS)
    {
    break;
    }

}

return status;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Best regards, &lt;br /&gt;Joakim Jakobsen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Simple_On_Off_Model callbacks are called multiple times each message</title><link>https://devzone.nordicsemi.com/thread/212341?ContentTypeID=1</link><pubDate>Fri, 27 Sep 2019 15:09:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:11d080c0-bea5-4686-98e5-2e26f9187885</guid><dc:creator>Heiner</dc:creator><description>&lt;p&gt;Hi Joakim,&lt;/p&gt;
&lt;p&gt;sorry for the long delay.&lt;/p&gt;
&lt;p&gt;I actually couldn&amp;#39;t find&amp;nbsp;&lt;span&gt;the&amp;nbsp;&lt;/span&gt;&lt;span&gt;Public Retransmit Count&lt;/span&gt;&lt;span&gt;&amp;nbsp;in my project. Could you please&amp;nbsp;specify further where to find this parameter?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Heiner&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Simple_On_Off_Model callbacks are called multiple times each message</title><link>https://devzone.nordicsemi.com/thread/208948?ContentTypeID=1</link><pubDate>Tue, 10 Sep 2019 12:42:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:af601c11-2472-4b26-912a-2e816d186a0a</guid><dc:creator>Joakim Jakobsen</dc:creator><description>&lt;p&gt;Hi.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks for the detailed response and the code-upload.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I can&amp;#39;t seem to find the root cause for this.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Could you double check that the&amp;nbsp;&lt;span&gt;Public Retransmit Count&lt;/span&gt;&lt;span&gt;&amp;nbsp;(&lt;/span&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.meshsdk.v3.1.0/structconfig__publication__state__t.html#a78ca10d553d26efd2f13c2ee04bfd91e"&gt;config_publication_state_t::retransmit_count&lt;/a&gt;) is set to zero?&lt;/p&gt;
&lt;p&gt;Regards,&amp;nbsp;&lt;br /&gt;Joakim&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Simple_On_Off_Model callbacks are called multiple times each message</title><link>https://devzone.nordicsemi.com/thread/208947?ContentTypeID=1</link><pubDate>Tue, 10 Sep 2019 12:41:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:109a3d7d-5437-411e-80f9-dc07c2a56ae5</guid><dc:creator>Joakim Jakobsen</dc:creator><description>&lt;p&gt;Hi.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks for the detailed response and the code-upload.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I can&amp;#39;t seem to find the root cause for this.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Could you double check that the&amp;nbsp;&lt;span&gt;Public Retransmit Count&lt;/span&gt;&lt;span&gt;&amp;nbsp;(&lt;/span&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.meshsdk.v3.1.0/structconfig__publication__state__t.html#a78ca10d553d26efd2f13c2ee04bfd91e"&gt;config_publication_state_t::retransmit_count&lt;/a&gt;) is set to zero?&lt;/p&gt;
&lt;p&gt;Regards,&amp;nbsp;&lt;br /&gt;Joakim&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Simple_On_Off_Model callbacks are called multiple times each message</title><link>https://devzone.nordicsemi.com/thread/207871?ContentTypeID=1</link><pubDate>Wed, 04 Sep 2019 09:39:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cbf68913-85de-4ead-b82d-2bbd0258f73a</guid><dc:creator>Heiner</dc:creator><description>&lt;p&gt;Hi Joakim,&lt;/p&gt;
&lt;p&gt;I followed your guide and&amp;nbsp;tried to stick as close as possible to it.&lt;/p&gt;
[quote userid="20690" url="~/f/nordic-q-a/50897/simple_on_off_model-callbacks-are-called-multiple-times-each-message/207664"]If you don&amp;#39;t want to share your code in the public forum, we can turn the ticket private first.&amp;nbsp;[/quote]
&lt;p&gt;&lt;span&gt;There aren&amp;#39;t too many&amp;nbsp;changes, at least not yet. So I think it should be fine if we leave it in the public forum for now.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;As mentioned I used your simple_on_off model as a base for my code.&lt;/p&gt;
&lt;p&gt;model common.h&lt;pre class="ui-code" data-mode="c_cpp"&gt;/* Copyright (c) 2010 - 2018, Nordic Semiconductor ASA
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice, this
 * list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form, except as embedded into a Nordic
 *    Semiconductor ASA integrated circuit in a product or a software update for
 *    such product, must reproduce the above copyright notice, this list of
 *    conditions and the following disclaimer in the documentation and/or other
 *    materials provided with the distribution.
 *
 * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
 *    contributors may be used to endorse or promote products derived from this
 *    software without specific prior written permission.
 *
 * 4. This software, with or without modification, must only be used with a
 *    Nordic Semiconductor ASA integrated circuit.
 *
 * 5. Any software provided in binary form under this license must not be reverse
 *    engineered, decompiled, modified and/or disassembled.
 *
 * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA &amp;quot;AS IS&amp;quot; AND ANY EXPRESS
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef SIMPLE_ON_OFF_COMMON_H__
#define SIMPLE_ON_OFF_COMMON_H__

#include &amp;lt;stdint.h&amp;gt;
#include &amp;quot;access.h&amp;quot;

/**
 * @defgroup SIMPLE_ON_OFF_MODEL Simple OnOff model
 * This model implements the message based interface required to
 * set the 1 bit value on the server.
 *
 * This implementation of a simple OnOff model can be used to switch things
 * on or off by manipulating a single on/off state. The intention of this model
 * is to have a simple example model that can be used as a baseline for constructing
 * your own model.
 *
 * Do not confuse the simple OnOff model with the Generic OnOff Model specified
 * in the Mesh Model Specification v1.0. The Generic OnOff Model provides additional
 * features such as control over when and for how long the transition between
 * the on/off state should be performed.
 *
 * @note When the server has a publish address set (as in the light switch example),
 * the server will publish its state to its publish address every time its state changes.
 *
 * For more information about creating models, see
 * @ref md_doc_getting_started_how_to_models.
 *
 * Model Identification
 * @par
 * Company ID: @ref SIMPLE_ON_OFF_COMPANY_ID
 * @par
 * Simple OnOff Client Model ID: @ref SIMPLE_ON_OFF_CLIENT_MODEL_ID
 * @par
 * Simple OnOff Server Model ID: @ref SIMPLE_ON_OFF_SERVER_MODEL_ID
 *
 * List of supported messages:
 * @par
 * @copydoc SIMPLE_ON_OFF_OPCODE_SET
 * @par
 * @copydoc SIMPLE_ON_OFF_OPCODE_GET
 * @par
 * @copydoc SIMPLE_ON_OFF_OPCODE_SET_UNRELIABLE
 * @par
 * @copydoc SIMPLE_ON_OFF_OPCODE_STATUS
 *
 * @ingroup MESH_API_GROUP_VENDOR_MODELS
 * @{
 * @defgroup SIMPLE_ON_OFF_COMMON Common Simple OnOff definitions
 * Types and definitions shared between the two Simple OnOff models.
 * @{
 */


/** Vendor specific company ID for Simple OnOff model */
#define SIMPLE_ON_OFF_COMPANY_ID    (ACCESS_COMPANY_ID_NORDIC)

/** Simple OnOff opcodes. */
typedef enum
{
    SIMPLE_ON_OFF_OPCODE_SET = 0xC1,            /**&amp;lt; Simple OnOff Acknowledged Set. */
    SIMPLE_ON_OFF_OPCODE_GET = 0xC2,            /**&amp;lt; Simple OnOff Get. */
    SIMPLE_ON_OFF_OPCODE_SET_UNRELIABLE = 0xC3, /**&amp;lt; Simple OnOff Set Unreliable. */
    SIMPLE_ON_OFF_OPCODE_STATUS = 0xC4,         /**&amp;lt; Simple OnOff Status. */
	SIMPLE_ON_OFF_OPCODE_SET_FRIEND = 0xC5,		/** Heiner Set Adress of Friend Node */
} simple_on_off_opcode_t;

/** Message format for the Simple OnOff Set message. */
typedef struct __attribute((packed))
{
    uint8_t state; /** Heiner: State 1 */
		/** Heiner: State 2 hier hinzuf&amp;#252;gen*/
    uint8_t tid;    /**&amp;lt; Transaction number. */
} simple_on_off_msg_set_t;

/** Message format for th Simple OnOff Set Unreliable message. */
typedef struct __attribute((packed))
{
    uint8_t state; /** Heiner: State 1  */
		/** Heiner: State 2 hier hinzuf&amp;#252;gen*/
	uint8_t tid;    /**&amp;lt; Transaction number. */
} simple_on_off_msg_set_unreliable_t;

/** Message format for the Simple OnOff Status message. */
typedef struct __attribute((packed))
{
    uint8_t present_state; /**&amp;lt; Current state. */ // Heiner
} simple_on_off_msg_status_t;

//** Heiner: format for Simple OnOff Friend message */
typedef struct __attribute((packed))
{
    uint16_t address; /** Heiner: Adresse des FRND Knoten */
    uint8_t tid;    /**&amp;lt; Transaction number. */
} simple_on_off_msg_set_friend_t;


/** @} end of SIMPLE_ON_OFF_COMMON */
/** @} end of SIMPLE_ON_OFF_MODEL */
#endif /* SIMPLE_ON_OFF_COMMON_H__ */
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;model server.c&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/* Copyright (c) 2010 - 2018, Nordic Semiconductor ASA
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice, this
 * list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form, except as embedded into a Nordic
 *    Semiconductor ASA integrated circuit in a product or a software update for
 *    such product, must reproduce the above copyright notice, this list of
 *    conditions and the following disclaimer in the documentation and/or other
 *    materials provided with the distribution.
 *
 * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
 *    contributors may be used to endorse or promote products derived from this
 *    software without specific prior written permission.
 *
 * 4. This software, with or without modification, must only be used with a
 *    Nordic Semiconductor ASA integrated circuit.
 *
 * 5. Any software provided in binary form under this license must not be reverse
 *    engineered, decompiled, modified and/or disassembled.
 *
 * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA &amp;quot;AS IS&amp;quot; AND ANY EXPRESS
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include &amp;quot;simple_on_off_server.h&amp;quot;
#include &amp;quot;simple_on_off_common.h&amp;quot;

#include &amp;lt;stdint.h&amp;gt;
#include &amp;lt;stddef.h&amp;gt;

#include &amp;quot;access.h&amp;quot;
#include &amp;quot;nrf_mesh_assert.h&amp;quot;
#include &amp;quot;log.h&amp;quot;

/*****************************************************************************
 * Static functions
 *****************************************************************************/

static void reply_status(const simple_on_off_server_t * p_server,
                         const access_message_rx_t * p_message,
//                         bool present_on_off) 
                         uint8_t present_state)
{
    simple_on_off_msg_status_t status;
//    status.present_on_off = present_on_off ? 1 : 0;
    status.present_state; // Heiner
    access_message_tx_t reply;
    reply.opcode.opcode = SIMPLE_ON_OFF_OPCODE_STATUS;
    reply.opcode.company_id = SIMPLE_ON_OFF_COMPANY_ID;
    reply.p_buffer = (const uint8_t *) &amp;amp;status;
    reply.length = sizeof(status);
    reply.force_segmented = false;
    reply.transmic_size = NRF_MESH_TRANSMIC_SIZE_DEFAULT;
    reply.access_token = nrf_mesh_unique_token_get();

    (void) access_model_reply(p_server-&amp;gt;model_handle, p_message, &amp;amp;reply);
}

/*****************************************************************************
 * Opcode handler callbacks
 *****************************************************************************/

static void handle_set_cb(access_model_handle_t handle, const access_message_rx_t * p_message, void * p_args)
{
    simple_on_off_server_t * p_server = p_args;
    NRF_MESH_ASSERT(p_server-&amp;gt;set_cb != NULL);

    // bool value = (((simple_on_off_msg_set_t*) p_message-&amp;gt;p_data)-&amp;gt;on_off) &amp;gt; 0; 
    uint8_t value = (((simple_on_off_msg_set_t*) p_message-&amp;gt;p_data)-&amp;gt;state);//Heiner value -&amp;gt; uint8
    value = p_server-&amp;gt;set_cb(p_server, value);
    reply_status(p_server, p_message, value);
    (void) simple_on_off_server_status_publish(p_server, value); /* We don&amp;#39;t care about status */
}

static void handle_get_cb(access_model_handle_t handle, const access_message_rx_t * p_message, void * p_args)
{
    simple_on_off_server_t * p_server = p_args;
    NRF_MESH_ASSERT(p_server-&amp;gt;get_cb != NULL);
    reply_status(p_server, p_message, p_server-&amp;gt;get_cb(p_server));
}

static void handle_set_unreliable_cb(access_model_handle_t handle, const access_message_rx_t * p_message, void * p_args)
{
    simple_on_off_server_t * p_server = p_args;
    NRF_MESH_ASSERT(p_server-&amp;gt;set_cb != NULL);
//    bool value = (((simple_on_off_msg_set_unreliable_t*) p_message-&amp;gt;p_data)-&amp;gt;on_off) &amp;gt; 0;
	uint8_t value = (((simple_on_off_msg_set_unreliable_t*) p_message-&amp;gt;p_data)-&amp;gt;state);//Heiner value -&amp;gt; uint8
    value = p_server-&amp;gt;set_cb(p_server, value);
    (void) simple_on_off_server_status_publish(p_server, value);
}

// Heiner
static void handle_set_friend_cb(access_model_handle_t handle, const access_message_rx_t * p_message, void * p_args)
{
    simple_on_off_server_t * p_server = p_args;
    NRF_MESH_ASSERT(p_server-&amp;gt;friend_cb != NULL);
	uint16_t value = (((simple_on_off_msg_set_friend_t*) p_message-&amp;gt;p_data)-&amp;gt;address);
    value = p_server-&amp;gt;friend_cb(p_server, value);
    //(void) simple_on_off_server_status_publish(p_server, value); // Heiner publish Friend Adress if necessary
}

static const access_opcode_handler_t m_opcode_handlers[] =
{
    {ACCESS_OPCODE_VENDOR(SIMPLE_ON_OFF_OPCODE_SET,            SIMPLE_ON_OFF_COMPANY_ID), handle_set_cb},
    {ACCESS_OPCODE_VENDOR(SIMPLE_ON_OFF_OPCODE_GET,            SIMPLE_ON_OFF_COMPANY_ID), handle_get_cb},
    {ACCESS_OPCODE_VENDOR(SIMPLE_ON_OFF_OPCODE_SET_UNRELIABLE, SIMPLE_ON_OFF_COMPANY_ID), handle_set_unreliable_cb},
    {ACCESS_OPCODE_VENDOR(SIMPLE_ON_OFF_OPCODE_SET_FRIEND,     SIMPLE_ON_OFF_COMPANY_ID), handle_set_friend_cb}
};

/*****************************************************************************
 * Public API
 *****************************************************************************/

uint32_t simple_on_off_server_init(simple_on_off_server_t * p_server, uint16_t element_index)
{
    if (p_server == NULL ||
        p_server-&amp;gt;get_cb == NULL ||
        p_server-&amp;gt;set_cb == NULL)
    {
        return NRF_ERROR_NULL;
    }

    access_model_add_params_t init_params;
    init_params.element_index =  element_index;
    init_params.model_id.model_id = SIMPLE_ON_OFF_SERVER_MODEL_ID;
    init_params.model_id.company_id = SIMPLE_ON_OFF_COMPANY_ID;
    init_params.p_opcode_handlers = &amp;amp;m_opcode_handlers[0];
    init_params.opcode_count = sizeof(m_opcode_handlers) / sizeof(m_opcode_handlers[0]);
    init_params.p_args = p_server;
    init_params.publish_timeout_cb = NULL;
    return access_model_add(&amp;amp;init_params, &amp;amp;p_server-&amp;gt;model_handle);
}

//Heiner value -&amp;gt; uint8
uint32_t simple_on_off_server_status_publish(simple_on_off_server_t * p_server, uint8_t value) 
{
    simple_on_off_msg_status_t status;
//    status.present_on_off = value ? 1 : 0;
    status.present_state = value; // Heiner
    access_message_tx_t msg;
    msg.opcode.opcode = SIMPLE_ON_OFF_OPCODE_STATUS;
    msg.opcode.company_id = SIMPLE_ON_OFF_COMPANY_ID;
    msg.p_buffer = (const uint8_t *) &amp;amp;status;
    msg.length = sizeof(status);
    msg.force_segmented = false;
    msg.transmic_size = NRF_MESH_TRANSMIC_SIZE_DEFAULT;
    msg.access_token = nrf_mesh_unique_token_get();
    return access_model_publish(p_server-&amp;gt;model_handle, &amp;amp;msg);
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;While uploading the code I took a closer look at the set_unreliable function from server.c&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;uint32_t simple_on_off_client_set_unreliable(simple_on_off_client_t * p_client, uint8_t state, uint8_t repeats) // Heiner
{
    simple_on_off_msg_set_unreliable_t set_unreliable;
//    set_unreliable.on_off = on_off ? 1 : 0;
    set_unreliable.state = state; // Heiner
    set_unreliable.tid = m_tid++;

    access_message_tx_t message;
    message.opcode.opcode = SIMPLE_ON_OFF_OPCODE_SET_UNRELIABLE;
    message.opcode.company_id = SIMPLE_ON_OFF_COMPANY_ID;
    message.p_buffer = (const uint8_t*) &amp;amp;set_unreliable;
    message.length = sizeof(set_unreliable);
    message.force_segmented = false;
    message.transmic_size = NRF_MESH_TRANSMIC_SIZE_DEFAULT;

    uint32_t status = NRF_SUCCESS;
    for (uint8_t i = 0; i &amp;lt; repeats; ++i)
    {
        message.access_token = nrf_mesh_unique_token_get();
        status = access_model_publish(p_client-&amp;gt;model_handle, &amp;amp;message);
        if (status != NRF_SUCCESS)
        {
            break;
        }
    }
    return status;
}&lt;/pre&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;This explains why I couldn&amp;#39;t get&amp;nbsp;&lt;/span&gt;any message through before.&lt;/p&gt;
[quote userid="80745" url="~/f/nordic-q-a/50897/simple_on_off_model-callbacks-are-called-multiple-times-each-message/206850"]if I set the repeat counter to 0 I cannot seem to transmit any message. [/quote]
&lt;p&gt;&lt;span&gt;However if set the repeat counter to&amp;nbsp;&lt;/span&gt;&lt;span&gt;1 the message should be transmitted just once, but the callback is still&amp;nbsp;being called twice. So the root of the problem must be somewhere else.&lt;/span&gt;&lt;/p&gt;
[quote userid="80745" url="~/f/nordic-q-a/50897/simple_on_off_model-callbacks-are-called-multiple-times-each-message/206850"]When&amp;nbsp;&lt;span&gt;I set repeats to 1 the handler is called two times&amp;nbsp;&lt;/span&gt;&lt;span&gt;instead of tree times.&lt;/span&gt;[/quote]
&lt;p&gt;&lt;span&gt;Best,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Heiner&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Simple_On_Off_Model callbacks are called multiple times each message</title><link>https://devzone.nordicsemi.com/thread/207664?ContentTypeID=1</link><pubDate>Tue, 03 Sep 2019 11:46:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9d2d382a-3d41-4ad8-9714-124b22674cf2</guid><dc:creator>Joakim Jakobsen</dc:creator><description>&lt;p&gt;Ok, then I don&amp;#39; think it&amp;#39;s related to my previous answer.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;When you added the simple on-off model, did you follow our guide in the infocenter?&lt;br /&gt;(&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.meshsdk.v3.1.0/md_doc_getting_started_how_to_models.html?cp=5_6_0_1_6"&gt;Creating new models&lt;/a&gt;)&lt;/p&gt;
&lt;p&gt;Could it be possible for you to upload your project so that I can look at your code?&lt;br /&gt;If you don&amp;#39;t want to share your code in the public forum, we can turn the ticket private first.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&amp;nbsp;&lt;br /&gt;Joakim&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Simple_On_Off_Model callbacks are called multiple times each message</title><link>https://devzone.nordicsemi.com/thread/206850?ContentTypeID=1</link><pubDate>Thu, 29 Aug 2019 11:47:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fc9949d5-9476-4be6-b542-b1739e3cc29d</guid><dc:creator>Heiner</dc:creator><description>&lt;p&gt;Hi Joakim,&lt;/p&gt;
[quote userid="20690" url="~/f/nordic-q-a/50897/simple_on_off_model-callbacks-are-called-multiple-times-each-message/205588"]You could try to use set_unack instead[/quote]
&lt;p&gt;this is weird, because I actually used simple_on_off_client_set_unreliable for my messages.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The differences I could find so far, where that&amp;nbsp;&lt;span&gt;simple_on_off_client_set_unreliable uses an argument called repeats.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;It&amp;nbsp;would make sense if that is the cause, because repeats is set to 2.&lt;/span&gt;&amp;nbsp;However if I set the repeat counter to 0 I cannot seem to transmit any message. (When&amp;nbsp;&lt;span&gt;I set repeats to 1 the handler is called two times&amp;nbsp;&lt;/span&gt;&lt;span&gt;instead of tree times.&lt;/span&gt;)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;From my point of view the function handle_set_unreliable_cb, unlike handle_set_cb, does not send a reply status to the access_model.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Which makes sense, since it&amp;#39;s set unacknowledged.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;But this leaves me with new questions, like:&lt;/p&gt;
&lt;p&gt;How can I set&amp;nbsp;&lt;span&gt;simple_on_off_client_set_unreliable to send the message only once?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Or is there maybe&amp;nbsp;something&amp;nbsp;that needs to be&amp;nbsp;acknowledged with handle_set_unreliable_cb&amp;nbsp;(at least on a lower level)?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;It would be great if you could look into that again.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Heiner&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Simple_On_Off_Model callbacks are called multiple times each message</title><link>https://devzone.nordicsemi.com/thread/205588?ContentTypeID=1</link><pubDate>Thu, 22 Aug 2019 12:10:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:afdaf3bc-746f-4380-886c-368bba56ba6c</guid><dc:creator>Joakim Jakobsen</dc:creator><description>&lt;p&gt;Hi.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Talked to one of my colleagues about this.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The reason that the command is sent three times is could be because you don&amp;#39;t reply to the client. The client expects that the set command is ACKED, otherwise it will retry 3 times.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You could try to use set_unack instead, that way the client won&amp;#39;t retry three times when it doesn&amp;#39;t receive an ACK.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Cheers,&amp;nbsp;&lt;br /&gt;Joakim&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Simple_On_Off_Model callbacks are called multiple times each message</title><link>https://devzone.nordicsemi.com/thread/204516?ContentTypeID=1</link><pubDate>Fri, 16 Aug 2019 13:02:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c09816b9-b373-447b-a576-7f32e445086c</guid><dc:creator>Joakim Jakobsen</dc:creator><description>&lt;p&gt;Hi.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Can&amp;#39;t see by first look what is causing this.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I&amp;#39;ll closer into it and discuss with our Mesh developers what might be causing this.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&amp;nbsp;&lt;br /&gt;Joakim&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>