mesh: responsability for transaction id control moved to client code

This commit is contained in:
Milanka Ringwald 2019-07-08 22:53:37 +02:00 committed by Matthias Ringwald
parent c27802bef0
commit 82ed29d491
4 changed files with 76 additions and 57 deletions

View File

@ -144,66 +144,67 @@ const mesh_operation_t * mesh_generic_on_off_client_get_operations(void){
static uint8_t mesh_generic_on_off_client_set_with_transition_message(mesh_model_t *mesh_model, const mesh_access_message_t * message_template, static uint8_t mesh_generic_on_off_client_set_with_transition_message(mesh_model_t *mesh_model, const mesh_access_message_t * message_template,
uint16_t dest, uint16_t netkey_index, uint16_t appkey_index, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index,
uint8_t on_off_value, uint8_t transition_time_gdtt, uint8_t delay_time_gdtt){ uint8_t on_off_value, uint8_t transition_time_gdtt, uint8_t delay_time_gdtt, uint8_t transaction_id){
if (mesh_model->element == NULL){ if (mesh_model->element == NULL){
log_error("mesh_model->element == NULL"); log_error("mesh_model->element == NULL");
} }
// setup message // setup message
uint8_t transaction_id = mesh_access_transactions_get_next_transaction_id();
mesh_transport_pdu_t * transport_pdu = mesh_access_setup_segmented_message(message_template, on_off_value, transaction_id, transition_time_gdtt, delay_time_gdtt); mesh_transport_pdu_t * transport_pdu = mesh_access_setup_segmented_message(message_template, on_off_value, transaction_id, transition_time_gdtt, delay_time_gdtt);
if (!transport_pdu) return 0; if (!transport_pdu) return BTSTACK_MEMORY_ALLOC_FAILED;
// send as segmented access pdu // send as segmented access pdu
generic_client_send_message(mesh_access_get_element_address(mesh_model), dest, netkey_index, appkey_index, (mesh_pdu_t *) transport_pdu); generic_client_send_message(mesh_access_get_element_address(mesh_model), dest, netkey_index, appkey_index, (mesh_pdu_t *) transport_pdu);
return transaction_id; return ERROR_CODE_SUCCESS;
} }
static uint8_t mesh_generic_on_off_client_set_instantaneous_message(mesh_model_t *mesh_model, const mesh_access_message_t * message_template, static uint8_t mesh_generic_on_off_client_set_instantaneous_message(mesh_model_t *mesh_model, const mesh_access_message_t * message_template,
uint16_t dest, uint16_t netkey_index, uint16_t appkey_index, uint8_t on_off_value){ uint16_t dest, uint16_t netkey_index, uint16_t appkey_index, uint8_t on_off_value, uint8_t transaction_id){
if (mesh_model->element == NULL){ if (mesh_model->element == NULL){
log_error("mesh_model->element == NULL"); log_error("mesh_model->element == NULL");
} }
// setup message // setup message
uint8_t transaction_id = mesh_access_transactions_get_next_transaction_id();
mesh_transport_pdu_t * transport_pdu = mesh_access_setup_segmented_message(message_template, on_off_value, transaction_id); mesh_transport_pdu_t * transport_pdu = mesh_access_setup_segmented_message(message_template, on_off_value, transaction_id);
if (!transport_pdu) return 0; if (!transport_pdu) return BTSTACK_MEMORY_ALLOC_FAILED;
generic_client_send_message(mesh_access_get_element_address(mesh_model), dest, netkey_index, appkey_index, (mesh_pdu_t *) transport_pdu); generic_client_send_message(mesh_access_get_element_address(mesh_model), dest, netkey_index, appkey_index, (mesh_pdu_t *) transport_pdu);
return transaction_id; return ERROR_CODE_SUCCESS;
} }
uint8_t mesh_generic_on_off_client_set_value(mesh_model_t * mesh_model, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index, uint8_t on_off_value, uint8_t transition_time_gdtt, uint8_t delay_time_gdtt){ uint8_t mesh_generic_on_off_client_set_value(mesh_model_t * mesh_model, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index,
uint8_t on_off_value, uint8_t transition_time_gdtt, uint8_t delay_time_gdtt, uint8_t transaction_id){
if (transition_time_gdtt != 0) { if (transition_time_gdtt != 0) {
return mesh_generic_on_off_client_set_with_transition_message(mesh_model, &mesh_generic_on_off_set_with_transition, dest, netkey_index, appkey_index, on_off_value, transition_time_gdtt, delay_time_gdtt); return mesh_generic_on_off_client_set_with_transition_message(mesh_model, &mesh_generic_on_off_set_with_transition, dest, netkey_index, appkey_index, on_off_value, transition_time_gdtt, delay_time_gdtt, transaction_id);
} else { } else {
return mesh_generic_on_off_client_set_instantaneous_message(mesh_model, &mesh_generic_on_off_set_instantaneous, dest, netkey_index, appkey_index, on_off_value); return mesh_generic_on_off_client_set_instantaneous_message(mesh_model, &mesh_generic_on_off_set_instantaneous, dest, netkey_index, appkey_index, on_off_value, transaction_id);
} }
} }
uint8_t mesh_generic_on_off_client_set_value_unacknowledged(mesh_model_t * mesh_model, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index, uint8_t on_off_value, uint8_t transition_time_gdtt, uint8_t delay_time_gdtt){ uint8_t mesh_generic_on_off_client_set_value_unacknowledged(mesh_model_t * mesh_model, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index,
uint8_t on_off_value, uint8_t transition_time_gdtt, uint8_t delay_time_gdtt, uint8_t transaction_id){
if (transition_time_gdtt != 0) { if (transition_time_gdtt != 0) {
return mesh_generic_on_off_client_set_with_transition_message(mesh_model, &mesh_generic_on_off_set_unacknowledged_with_transition, dest, netkey_index, appkey_index, on_off_value, transition_time_gdtt, delay_time_gdtt); return mesh_generic_on_off_client_set_with_transition_message(mesh_model, &mesh_generic_on_off_set_unacknowledged_with_transition, dest, netkey_index, appkey_index, on_off_value, transition_time_gdtt, delay_time_gdtt, transaction_id);
} else { } else {
return mesh_generic_on_off_client_set_instantaneous_message(mesh_model, &mesh_generic_on_off_set_unacknowledged_instantaneous, dest, netkey_index, appkey_index, on_off_value); return mesh_generic_on_off_client_set_instantaneous_message(mesh_model, &mesh_generic_on_off_set_unacknowledged_instantaneous, dest, netkey_index, appkey_index, on_off_value, transaction_id);
} }
} }
void mesh_generic_on_off_client_get_value(mesh_model_t *mesh_model, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index){ uint8_t mesh_generic_on_off_client_get_value(mesh_model_t *mesh_model, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index){
if (mesh_model->element == NULL){ if (mesh_model->element == NULL){
log_error("mesh_model->element == NULL"); log_error("mesh_model->element == NULL");
} }
// setup message // setup message
mesh_transport_pdu_t * transport_pdu = mesh_access_setup_segmented_message(&mesh_generic_on_off_get); mesh_transport_pdu_t * transport_pdu = mesh_access_setup_segmented_message(&mesh_generic_on_off_get);
if (!transport_pdu) return; if (!transport_pdu) return BTSTACK_MEMORY_ALLOC_FAILED;
// send as segmented access pdu // send as segmented access pdu
generic_client_send_message(mesh_access_get_element_address(mesh_model), dest, netkey_index, appkey_index, (mesh_pdu_t *) transport_pdu); generic_client_send_message(mesh_access_get_element_address(mesh_model), dest, netkey_index, appkey_index, (mesh_pdu_t *) transport_pdu);
return ERROR_CODE_SUCCESS;
} }
void mesh_generic_on_off_client_publish_value(mesh_model_t * mesh_model, uint8_t on_off_value){ uint8_t mesh_generic_on_off_client_publish_value(mesh_model_t * mesh_model, uint8_t on_off_value, uint8_t transaction_id){
mesh_publication_model_t * publication_model = mesh_model->publication_model; mesh_publication_model_t * publication_model = mesh_model->publication_model;
uint16_t appkey_index = publication_model->appkey_index; uint16_t appkey_index = publication_model->appkey_index;
mesh_transport_key_t * app_key = mesh_transport_key_get(appkey_index); mesh_transport_key_t * app_key = mesh_transport_key_get(appkey_index);
if (app_key == NULL) return; if (app_key == NULL) return MESH_ERROR_APPKEY_INDEX_INVALID;
mesh_generic_on_off_client_set_value_unacknowledged(mesh_model, publication_model->address, app_key->netkey_index, appkey_index, on_off_value, 0, 0); return mesh_generic_on_off_client_set_value_unacknowledged(mesh_model, publication_model->address, app_key->netkey_index, appkey_index, on_off_value, 0, 0, transaction_id);
} }

View File

@ -63,9 +63,11 @@ void mesh_generic_on_off_client_register_packet_handler(mesh_model_t *mesh_model
* @param on_off_value * @param on_off_value
* @param transition_time_gdtt * @param transition_time_gdtt
* @param delay_time_gdtt * @param delay_time_gdtt
* @return transaction_id if transaction_id == 0, it is invalid * @param transaction_id
* @return status 0 if successful
*/ */
uint8_t mesh_generic_on_off_client_set_value(mesh_model_t * mesh_model, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index, uint8_t on_off_value, uint8_t transition_time_gdtt, uint8_t delay_time_gdtt); uint8_t mesh_generic_on_off_client_set_value(mesh_model_t * mesh_model, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index,
uint8_t on_off_value, uint8_t transition_time_gdtt, uint8_t delay_time_gdtt, uint8_t transaction_id);
/** /**
* @brief Set ON/OFF value unacknowledged * @brief Set ON/OFF value unacknowledged
@ -76,9 +78,11 @@ uint8_t mesh_generic_on_off_client_set_value(mesh_model_t * mesh_model, uint16_t
* @param on_off_value * @param on_off_value
* @param transition_time_gdtt * @param transition_time_gdtt
* @param delay_time_gdtt * @param delay_time_gdtt
* @return transaction_id if transaction_id == 0, it is invalid * @param transaction_id
* @return status 0 if successful
*/ */
uint8_t mesh_generic_on_off_client_set_value_unacknowledged(mesh_model_t * mesh_model, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index, uint8_t on_off_value, uint8_t transition_time_gdtt, uint8_t delay_time_gdtt); uint8_t mesh_generic_on_off_client_set_value_unacknowledged(mesh_model_t * mesh_model, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index,
uint8_t on_off_value, uint8_t transition_time_gdtt, uint8_t delay_time_gdtt, uint8_t transaction_id);
/** /**
* @brief Get present ON/OFF value * @brief Get present ON/OFF value
@ -86,15 +90,18 @@ uint8_t mesh_generic_on_off_client_set_value_unacknowledged(mesh_model_t * mesh_
* @param dest * @param dest
* @param netkey_index * @param netkey_index
* @param appkey_index * @param appkey_index
* @return status 0 if successful
*/ */
void mesh_generic_on_off_client_get_value(mesh_model_t *mesh_model, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index); uint8_t mesh_generic_on_off_client_get_value(mesh_model_t *mesh_model, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index);
/** /**
* @brief Publish on_off value by sending an unacknowledged set message to the publish destination * @brief Publish on_off value by sending an unacknowledged set message to the publish destination
* @param mesh_model * @param mesh_model
* @param on_off_value * @param on_off_value
* @param transaction_id
* @return status 0 if successful
*/ */
void mesh_generic_on_off_client_publish_value(mesh_model_t * mesh_model, uint8_t on_off_value); uint8_t mesh_generic_on_off_client_publish_value(mesh_model_t * mesh_model, uint8_t on_off_value, uint8_t transaction_id);
#ifdef __cplusplus #ifdef __cplusplus
} /* end of extern "C" */ } /* end of extern "C" */

View File

@ -51,10 +51,11 @@
#include "btstack_memory.h" #include "btstack_memory.h"
#include "btstack_debug.h" #include "btstack_debug.h"
static void generic_client_send_message(uint16_t src, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index, mesh_pdu_t *pdu){ static uint8_t generic_client_send_message(uint16_t src, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index, mesh_pdu_t *pdu){
uint8_t ttl = mesh_foundation_default_ttl_get(); uint8_t ttl = mesh_foundation_default_ttl_get();
mesh_upper_transport_setup_access_pdu_header(pdu, netkey_index, appkey_index, ttl, src, dest, 0); mesh_upper_transport_setup_access_pdu_header(pdu, netkey_index, appkey_index, ttl, src, dest, 0);
mesh_upper_transport_send_access_pdu(pdu); mesh_upper_transport_send_access_pdu(pdu);
return ERROR_CODE_SUCCESS;
} }
void mesh_generic_level_client_register_packet_handler(mesh_model_t *mesh_model, btstack_packet_handler_t transition_events_packet_handler){ void mesh_generic_level_client_register_packet_handler(mesh_model_t *mesh_model, btstack_packet_handler_t transition_events_packet_handler){
@ -182,79 +183,81 @@ const mesh_operation_t * mesh_generic_level_client_get_operations(void){
static uint8_t mesh_generic_level_client_set_with_transition_message(mesh_model_t *mesh_model, const mesh_access_message_t * message_template, static uint8_t mesh_generic_level_client_set_with_transition_message(mesh_model_t *mesh_model, const mesh_access_message_t * message_template,
uint16_t dest, uint16_t netkey_index, uint16_t appkey_index, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index,
int16_t level_value, uint8_t transition_time_gdtt, uint8_t delay_time_gdtt){ int16_t level_value, uint8_t transition_time_gdtt, uint8_t delay_time_gdtt, uint8_t transaction_id){
if (mesh_model->element == NULL){ if (mesh_model->element == NULL){
log_error("mesh_model->element == NULL"); log_error("mesh_model->element == NULL");
} }
// setup message // setup message
uint8_t transaction_id = mesh_access_transactions_get_next_transaction_id();
mesh_transport_pdu_t * transport_pdu = mesh_access_setup_segmented_message(message_template, level_value, transaction_id, transition_time_gdtt, delay_time_gdtt); mesh_transport_pdu_t * transport_pdu = mesh_access_setup_segmented_message(message_template, level_value, transaction_id, transition_time_gdtt, delay_time_gdtt);
if (!transport_pdu) return 0; if (!transport_pdu) return BTSTACK_MEMORY_ALLOC_FAILED;
// send as segmented access pdu // send as segmented access pdu
generic_client_send_message(mesh_access_get_element_address(mesh_model), dest, netkey_index, appkey_index, (mesh_pdu_t *) transport_pdu); generic_client_send_message(mesh_access_get_element_address(mesh_model), dest, netkey_index, appkey_index, (mesh_pdu_t *) transport_pdu);
return transaction_id; return ERROR_CODE_SUCCESS;
} }
static uint8_t mesh_generic_level_client_set_instantaneous_message(mesh_model_t *mesh_model, const mesh_access_message_t * message_template, static uint8_t mesh_generic_level_client_set_instantaneous_message(mesh_model_t *mesh_model, const mesh_access_message_t * message_template,
uint16_t dest, uint16_t netkey_index, uint16_t appkey_index, int16_t level_value){ uint16_t dest, uint16_t netkey_index, uint16_t appkey_index, int16_t level_value, uint8_t transaction_id){
if (mesh_model->element == NULL){ if (mesh_model->element == NULL){
log_error("mesh_model->element == NULL"); log_error("mesh_model->element == NULL");
return 0; return 0;
} }
// setup message // setup message
uint8_t transaction_id = mesh_access_transactions_get_next_transaction_id();
mesh_transport_pdu_t * transport_pdu = mesh_access_setup_segmented_message(message_template, level_value, transaction_id); mesh_transport_pdu_t * transport_pdu = mesh_access_setup_segmented_message(message_template, level_value, transaction_id);
if (!transport_pdu) return 0; if (!transport_pdu) return BTSTACK_MEMORY_ALLOC_FAILED;
// send as segmented access pdu // send as segmented access pdu
generic_client_send_message(mesh_access_get_element_address(mesh_model), dest, netkey_index, appkey_index, (mesh_pdu_t *) transport_pdu); generic_client_send_message(mesh_access_get_element_address(mesh_model), dest, netkey_index, appkey_index, (mesh_pdu_t *) transport_pdu);
return transaction_id; return ERROR_CODE_SUCCESS;
} }
uint8_t mesh_generic_level_client_set_value(mesh_model_t * mesh_model, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index, int16_t level_value, uint8_t transition_time_gdtt, uint8_t delay_time_gdtt){ uint8_t mesh_generic_level_client_set_value(mesh_model_t * mesh_model, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index,
int16_t level_value, uint8_t transition_time_gdtt, uint8_t delay_time_gdtt, uint8_t transaction_id){
if (transition_time_gdtt != 0) { if (transition_time_gdtt != 0) {
return mesh_generic_level_client_set_with_transition_message(mesh_model, &mesh_generic_level_set_with_transition, dest, netkey_index, appkey_index, level_value, transition_time_gdtt, delay_time_gdtt); return mesh_generic_level_client_set_with_transition_message(mesh_model, &mesh_generic_level_set_with_transition, dest, netkey_index, appkey_index, level_value, transition_time_gdtt, delay_time_gdtt, transaction_id);
} else { } else {
return mesh_generic_level_client_set_instantaneous_message(mesh_model, &mesh_generic_level_set_instantaneous, dest, netkey_index, appkey_index, level_value); return mesh_generic_level_client_set_instantaneous_message(mesh_model, &mesh_generic_level_set_instantaneous, dest, netkey_index, appkey_index, level_value, transaction_id);
} }
} }
uint8_t mesh_generic_level_client_set_value_unacknowledged(mesh_model_t * mesh_model, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index, int16_t level_value, uint8_t transition_time_gdtt, uint8_t delay_time_gdtt){ uint8_t mesh_generic_level_client_set_value_unacknowledged(mesh_model_t * mesh_model, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index,
int16_t level_value, uint8_t transition_time_gdtt, uint8_t delay_time_gdtt, uint8_t transaction_id){
if (transition_time_gdtt != 0) { if (transition_time_gdtt != 0) {
return mesh_generic_level_client_set_with_transition_message(mesh_model, &mesh_generic_level_set_unacknowledged_with_transition, dest, netkey_index, appkey_index, level_value, transition_time_gdtt, delay_time_gdtt); return mesh_generic_level_client_set_with_transition_message(mesh_model, &mesh_generic_level_set_unacknowledged_with_transition, dest, netkey_index, appkey_index, level_value, transition_time_gdtt, delay_time_gdtt, transaction_id);
} else { } else {
return mesh_generic_level_client_set_instantaneous_message(mesh_model, &mesh_generic_level_set_unacknowledged_instantaneous, dest, netkey_index, appkey_index, level_value); return mesh_generic_level_client_set_instantaneous_message(mesh_model, &mesh_generic_level_set_unacknowledged_instantaneous, dest, netkey_index, appkey_index, level_value, transaction_id);
} }
} }
void mesh_generic_level_client_get_value(mesh_model_t *mesh_model, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index){ uint8_t mesh_generic_level_client_get_value(mesh_model_t *mesh_model, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index){
if (mesh_model->element == NULL){ if (mesh_model->element == NULL){
log_error("mesh_model->element == NULL"); log_error("mesh_model->element == NULL");
} }
// setup message // setup message
mesh_transport_pdu_t * transport_pdu = mesh_access_setup_segmented_message(&mesh_generic_level_get); mesh_transport_pdu_t * transport_pdu = mesh_access_setup_segmented_message(&mesh_generic_level_get);
if (!transport_pdu) return; if (!transport_pdu) return BTSTACK_MEMORY_ALLOC_FAILED;
// send as segmented access pdu // send as segmented access pdu
generic_client_send_message(mesh_access_get_element_address(mesh_model), dest, netkey_index, appkey_index, (mesh_pdu_t *) transport_pdu); return generic_client_send_message(mesh_access_get_element_address(mesh_model), dest, netkey_index, appkey_index, (mesh_pdu_t *) transport_pdu);
} }
// // Delta // // Delta
// uint8_t mesh_generic_level_client_set_delta_value(mesh_model_t * mesh_model, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index, uint16_t delta_value, uint8_t transition_time_gdtt, uint8_t delay_time_gdtt){ // uint8_t mesh_generic_level_client_set_delta_value(mesh_model_t * mesh_model, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index,
// uint16_t delta_value, uint8_t transition_time_gdtt, uint8_t delay_time_gdtt, uint8_t transaction_id){
// if (transition_time_gdtt != 0) { // if (transition_time_gdtt != 0) {
// return mesh_generic_level_client_set_with_transition_message(mesh_model, &mesh_generic_delta_set_with_transition, dest, netkey_index, appkey_index, delta_value, transition_time_gdtt, delay_time_gdtt); // return mesh_generic_level_client_set_with_transition_message(mesh_model, &mesh_generic_delta_set_with_transition, dest, netkey_index, appkey_index, delta_value, transition_time_gdtt, delay_time_gdtt, transaction_id);
// } else { // } else {
// return mesh_generic_level_client_set_delta_instantaneous_message(mesh_model, &mesh_generic_delta_set_instantaneous, dest, netkey_index, appkey_index, delta_value); // return mesh_generic_level_client_set_delta_instantaneous_message(mesh_model, &mesh_generic_delta_set_instantaneous, dest, netkey_index, appkey_index, delta_value, transaction_id);
// } // }
// } // }
// uint8_t mesh_generic_level_client_set_delta_value_unacknowledged(mesh_model_t * mesh_model, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index, uint16_t delta_value, uint8_t transition_time_gdtt, uint8_t delay_time_gdtt){ // uint8_t mesh_generic_level_client_set_delta_value_unacknowledged(mesh_model_t * mesh_model, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index,
// uint16_t delta_value, uint8_t transition_time_gdtt, uint8_t delay_time_gdtt, uint8_t transaction_id){
// if (transition_time_gdtt != 0) { // if (transition_time_gdtt != 0) {
// return mesh_generic_level_client_set_with_transition_message(mesh_model, &mesh_generic_delta_set_unacknowledged_with_transition, dest, netkey_index, appkey_index, delta_value, transition_time_gdtt, delay_time_gdtt); // return mesh_generic_level_client_set_with_transition_message(mesh_model, &mesh_generic_delta_set_unacknowledged_with_transition, dest, netkey_index, appkey_index, delta_value, transition_time_gdtt, delay_time_gdtt, transaction_id);
// } else { // } else {
// return mesh_generic_level_client_set_delta_instantaneous_message(mesh_model, &mesh_generic_delta_set_unacknowledged_instantaneous, dest, netkey_index, appkey_index, delta_value); // return mesh_generic_level_client_set_delta_instantaneous_message(mesh_model, &mesh_generic_delta_set_unacknowledged_instantaneous, dest, netkey_index, appkey_index, delta_value, transaction_id);
// } // }
// } // }
@ -276,10 +279,11 @@ void mesh_generic_level_client_get_value(mesh_model_t *mesh_model, uint16_t dest
// } // }
// } // }
uint8_t mesh_generic_level_client_publish_value(mesh_model_t * mesh_model, int16_t level_value, uint8_t transaction_id){
void mesh_generic_level_client_publish_value(mesh_model_t * mesh_model, int16_t level_value){
mesh_publication_model_t * publication_model = mesh_model->publication_model; mesh_publication_model_t * publication_model = mesh_model->publication_model;
uint16_t appkey_index = publication_model->appkey_index; uint16_t appkey_index = publication_model->appkey_index;
mesh_transport_key_t * app_key = mesh_transport_key_get(appkey_index); mesh_transport_key_t * app_key = mesh_transport_key_get(appkey_index);
mesh_generic_level_client_set_value_unacknowledged(mesh_model, publication_model->address, app_key->netkey_index, appkey_index, level_value, 0, 0); if (app_key == NULL) return MESH_ERROR_APPKEY_INDEX_INVALID;
return mesh_generic_level_client_set_value_unacknowledged(mesh_model, publication_model->address, app_key->netkey_index, appkey_index, level_value, 0, 0, transaction_id);
} }

View File

@ -63,9 +63,11 @@ void mesh_generic_level_client_register_packet_handler(mesh_model_t *mesh_model,
* @param on_off_value * @param on_off_value
* @param transition_time_gdtt * @param transition_time_gdtt
* @param delay_time_gdtt * @param delay_time_gdtt
* @return transaction_id if transaction_id == 0, it is invalid * @param transaction_id
* @return status 0 if successful
*/ */
uint8_t mesh_generic_level_client_set_value(mesh_model_t * mesh_model, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index, int16_t level_value, uint8_t transition_time_gdtt, uint8_t delay_time_gdtt); uint8_t mesh_generic_level_client_set_value(mesh_model_t * mesh_model, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index,
int16_t level_value, uint8_t transition_time_gdtt, uint8_t delay_time_gdtt, uint8_t transaction_id);
/** /**
* @brief Get present Level value * @brief Get present Level value
@ -76,9 +78,11 @@ uint8_t mesh_generic_level_client_set_value(mesh_model_t * mesh_model, uint16_t
* @param on_off_value * @param on_off_value
* @param transition_time_gdtt * @param transition_time_gdtt
* @param delay_time_gdtt * @param delay_time_gdtt
* @param transaction_id
* @return transaction_id if transaction_id == 0, it is invalid * @return transaction_id if transaction_id == 0, it is invalid
*/ */
uint8_t mesh_generic_level_client_set_value_unacknowledged(mesh_model_t * mesh_model, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index, int16_t level_value, uint8_t transition_time_gdtt, uint8_t delay_time_gdtt); uint8_t mesh_generic_level_client_set_value_unacknowledged(mesh_model_t * mesh_model, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index,
int16_t level_value, uint8_t transition_time_gdtt, uint8_t delay_time_gdtt, uint8_t transaction_id);
/** /**
* @brief Get present Level value * @brief Get present Level value
@ -86,15 +90,18 @@ uint8_t mesh_generic_level_client_set_value_unacknowledged(mesh_model_t * mesh_m
* @param dest * @param dest
* @param netkey_index * @param netkey_index
* @param appkey_index * @param appkey_index
* @return status 0 if successful
*/ */
void mesh_generic_level_client_get_value(mesh_model_t *mesh_model, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index); uint8_t mesh_generic_level_client_get_value(mesh_model_t *mesh_model, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index);
/** /**
* @brief Publish level value by sending an unacknowledged set message to the publish destination * @brief Publish level value by sending an unacknowledged set message to the publish destination
* @param mesh_model * @param mesh_model
* @param level_value * @param level_value
* @param transaction_id
* @return status 0 if successful
*/ */
void mesh_generic_level_client_publish_value(mesh_model_t * mesh_model, int16_t level_value); void mesh_generic_level_client_publish_value(mesh_model_t * mesh_model, int16_t level_value, uint8_t transaction_id);
#ifdef __cplusplus #ifdef __cplusplus
} /* end of extern "C" */ } /* end of extern "C" */