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

Mesh Model Client Callback Function Signatures

Hello,

I am trying to make my own model and I'm using the simple on-off model as a guide, but,

I have some confusion for the function signatures of the callbacks for the client part of a model. In the simple on-off model simple_on_off_client.h file, you have

typedef void (*simple_on_off_status_cb_t)(const simple_on_off_client_t * p_self, simple_on_off_status_t status, uint16_t src);

typedef void (*simple_on_off_timeout_cb_t)(access_model_handle_t handle, void * p_self);

However, in main.c for the light switch client example, the following functions are registered for the above callbacks.

static void client_publish_timeout_cb(access_model_handle_t handle, void * p_self)
{
     __LOG(LOG_SRC_APP, LOG_LEVEL_ERROR, "Acknowledged send timedout\n");
}

static void client_status_cb(const simple_on_off_client_t * p_self, simple_on_off_status_t status, uint16_t src)
{
    uint32_t server_index = server_index_get(p_self);

    switch (status)
    {
        case SIMPLE_ON_OFF_STATUS_ON:
            hal_led_pin_set(BSP_LED_0 + server_index, true);
            __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "OnOff server %u status ON\n", server_index);
            break;

        case SIMPLE_ON_OFF_STATUS_OFF:
            hal_led_pin_set(BSP_LED_0 + server_index, false);
            __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "OnOff server %u status OFF\n", server_index);
            break;

        case SIMPLE_ON_OFF_STATUS_ERROR_NO_REPLY:
            hal_led_blink_ms(LEDS_MASK, LED_BLINK_SHORT_INTERVAL_MS, LED_BLINK_CNT_NO_REPLY);
            __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "No reply from OnOff server %u\n", server_index);
            break;

        case SIMPLE_ON_OFF_STATUS_CANCELLED:
            __LOG(LOG_SRC_APP, LOG_LEVEL_WARN, "Message to server %u cancelled\n", server_index);
            break;
        default:
            __LOG(LOG_SRC_APP, LOG_LEVEL_ERROR, "Unknown status \n");
            break;
    }
}

I am confused because in the timeout callback, neither argument is used, and in the status callback, src isn't used.

Why does the timeout callback have an access_model_handle_t argument while the status callback doesn't, when it's not even used?

Also, why are the callback function signatures defined like that when the callback functions that are registered don't use some/any of the arguments?

Thanks

Related