mesh: foundation config message sig and vendor model subscription get

This commit is contained in:
Milanka Ringwald 2019-06-07 10:26:17 +02:00 committed by Matthias Ringwald
parent 5f6e8f7ce0
commit 667063f1a7

View File

@ -2411,7 +2411,7 @@ static void config_model_subscription_add_handler(mesh_model_t *mesh_model, mesh
status = mesh_model_add_subscription(target_model, address);
}
config_model_subscription_status(mesh_model, mesh_pdu_netkey_index(pdu), mesh_pdu_src(pdu), status, element_address, address, model_identifier);
config_model_subscription_status(target_model, mesh_pdu_netkey_index(pdu), mesh_pdu_src(pdu), status, element_address, address, model_identifier);
mesh_access_message_processed(pdu);
}
@ -2435,7 +2435,7 @@ static void config_model_subscription_delete_handler(mesh_model_t *mesh_model, m
mesh_model_delete_subscription(target_model, address);
}
config_model_subscription_status(mesh_model, mesh_pdu_netkey_index(pdu), mesh_pdu_src(pdu), status, element_address, address, model_identifier);
config_model_subscription_status(target_model, mesh_pdu_netkey_index(pdu), mesh_pdu_src(pdu), status, element_address, address, model_identifier);
mesh_access_message_processed(pdu);
}
@ -2453,7 +2453,48 @@ static void config_model_subscription_delete_all_handler(mesh_model_t *mesh_mode
mesh_model_deleteall_subscription(target_model);
}
config_model_subscription_status(mesh_model, mesh_pdu_netkey_index(pdu), mesh_pdu_src(pdu), status, element_address, MESH_ADDRESS_UNSASSIGNED, model_identifier);
config_model_subscription_status(target_model, mesh_pdu_netkey_index(pdu), mesh_pdu_src(pdu), status, element_address, MESH_ADDRESS_UNSASSIGNED, model_identifier);
mesh_access_message_processed(pdu);
}
static void config_model_subscription_list_status(mesh_model_t * mesh_model, uint16_t netkey_index, uint16_t dest, uint8_t status, uint16_t element_address, uint32_t model_identifier){
uint16_t opcode;
if (mesh_model_is_bluetooth_sig(model_identifier)){
opcode = MESH_FOUNDATION_OPERATION_SIG_MODEL_SUBSCRIPTION_LIST;
} else {
opcode = MESH_FOUNDATION_OPERATION_VENDOR_MODEL_SUBSCRIPTION_LIST;
}
mesh_transport_pdu_t * transport_pdu = mesh_access_transport_init(opcode);
if (!transport_pdu) return;
// setup segmented message
mesh_access_transport_add_uint8(transport_pdu, status);
mesh_access_transport_add_uint16(transport_pdu, element_address);
mesh_access_transport_add_model_identifier(transport_pdu, model_identifier);
if (mesh_model != NULL){
int i;
for (i = 0; i < MAX_NR_MESH_SUBSCRIPTION_PER_MODEL; i++){
if (mesh_model->subscriptions[i] != MESH_ADDRESS_UNSASSIGNED){
mesh_access_transport_add_uint16(transport_pdu, mesh_model->subscriptions[i]);
}
}
}
config_server_send_message(mesh_model, netkey_index, dest, (mesh_pdu_t *) transport_pdu);
}
static void config_model_subscription_get_handler(mesh_model_t *mesh_model, mesh_pdu_t * pdu){
mesh_access_parser_state_t parser;
mesh_access_parser_init(&parser, (mesh_pdu_t*) pdu);
uint16_t element_address = mesh_access_parser_get_u16(&parser);
uint32_t model_identifier = mesh_access_parser_get_model_identifier(&parser);
uint8_t status = MESH_FOUNDATION_STATUS_SUCCESS;
mesh_model_t * target_model = mesh_access_model_for_address_and_model_identifier(element_address, model_identifier, &status);
config_model_subscription_list_status(target_model, mesh_pdu_netkey_index(pdu), mesh_pdu_src(pdu), status, element_address, model_identifier);
mesh_access_message_processed(pdu);
}
@ -3094,8 +3135,8 @@ static mesh_operation_t mesh_configuration_server_model_operations[] = {
{ MESH_FOUNDATION_OPERATION_MODEL_SUBSCRIPTION_OVERWRITE, 6, config_model_subscription_delete_all_handler },
// { MESH_FOUNDATION_OPERATION_MODEL_SUBSCRIPTION_VIRTUAL_ADDRESS_OVERWRITE,20, config_model_subscription_virtual_address_overwrite_handler },
{ MESH_FOUNDATION_OPERATION_MODEL_SUBSCRIPTION_DELETE_ALL, 4, config_model_subscription_delete_all_handler },
// { MESH_FOUNDATION_OPERATION_SIG_MODEL_SUBSCRIPTION_GET, 4, config_sig_model_subscription_get_handler },
// { MESH_FOUNDATION_OPERATION_VENDOR_MODEL_SUBSCRIPTION_GET, 6, config_vendor_model_subscription_get_handler },
{ MESH_FOUNDATION_OPERATION_SIG_MODEL_SUBSCRIPTION_GET, 4, config_model_subscription_get_handler },
{ MESH_FOUNDATION_OPERATION_VENDOR_MODEL_SUBSCRIPTION_GET, 6, config_model_subscription_get_handler },
{ MESH_FOUNDATION_OPERATION_SIG_MODEL_APP_GET, 4, config_sig_model_app_get_handler },
{ MESH_FOUNDATION_OPERATION_VENDOR_MODEL_APP_GET, 6, config_vendor_model_app_get_handler },
{ MESH_FOUNDATION_OPERATION_MODEL_PUBLICATION_SET, 11, config_model_publication_set_handler },