mesh: implement config client low power node msgs [a2582]

This commit is contained in:
Milanka Ringwald 2020-01-30 09:47:01 +01:00
parent 7d339f89ba
commit 70fcff1a97
4 changed files with 139 additions and 44 deletions

View File

@ -3143,4 +3143,15 @@ typedef uint8_t sm_key_t[16];
*/
#define MESH_SUBEVENT_CONFIGURATION_HEARTBEAT_SUBSCRIPTION 0x55
/**
* @format 12123
* @param subevent_code
* @param dest
* @param foundation_status
* @param lpn_address
* @param poll_timeout
*/
#define MESH_SUBEVENT_CONFIGURATION_LOW_POWER_NODE_POLL_TIMEOUT 0x56
#endif

View File

@ -8719,15 +8719,6 @@ static inline uint16_t mesh_subevent_configuration_heartbeat_publication_get_des
static inline uint8_t mesh_subevent_configuration_heartbeat_publication_get_foundation_status(const uint8_t * event){
return event[5];
}
/**
* @brief Get field period_log from event MESH_SUBEVENT_CONFIGURATION_HEARTBEAT_PUBLICATION
* @param event packet
* @return period_log
* @note: btstack_type 1
*/
static inline uint8_t mesh_subevent_configuration_heartbeat_publication_get_period_log(const uint8_t * event){
return event[6];
}
/**
* @brief Get field count_log from event MESH_SUBEVENT_CONFIGURATION_HEARTBEAT_PUBLICATION
* @param event packet
@ -8735,6 +8726,15 @@ static inline uint8_t mesh_subevent_configuration_heartbeat_publication_get_peri
* @note: btstack_type 1
*/
static inline uint8_t mesh_subevent_configuration_heartbeat_publication_get_count_log(const uint8_t * event){
return event[6];
}
/**
* @brief Get field period_log from event MESH_SUBEVENT_CONFIGURATION_HEARTBEAT_PUBLICATION
* @param event packet
* @return period_log
* @note: btstack_type 1
*/
static inline uint8_t mesh_subevent_configuration_heartbeat_publication_get_period_log(const uint8_t * event){
return event[7];
}
/**
@ -8792,15 +8792,6 @@ static inline uint8_t mesh_subevent_configuration_heartbeat_subscription_get_fou
static inline uint16_t mesh_subevent_configuration_heartbeat_subscription_get_source(const uint8_t * event){
return little_endian_read_16(event, 6);
}
/**
* @brief Get field period_log from event MESH_SUBEVENT_CONFIGURATION_HEARTBEAT_SUBSCRIPTION
* @param event packet
* @return period_log
* @note: btstack_type 1
*/
static inline uint8_t mesh_subevent_configuration_heartbeat_subscription_get_period_log(const uint8_t * event){
return event[8];
}
/**
* @brief Get field count_log from event MESH_SUBEVENT_CONFIGURATION_HEARTBEAT_SUBSCRIPTION
* @param event packet
@ -8808,6 +8799,15 @@ static inline uint8_t mesh_subevent_configuration_heartbeat_subscription_get_per
* @note: btstack_type 1
*/
static inline uint8_t mesh_subevent_configuration_heartbeat_subscription_get_count_log(const uint8_t * event){
return event[8];
}
/**
* @brief Get field period_log from event MESH_SUBEVENT_CONFIGURATION_HEARTBEAT_SUBSCRIPTION
* @param event packet
* @return period_log
* @note: btstack_type 1
*/
static inline uint8_t mesh_subevent_configuration_heartbeat_subscription_get_period_log(const uint8_t * event){
return event[9];
}
/**
@ -8829,6 +8829,43 @@ static inline uint8_t mesh_subevent_configuration_heartbeat_subscription_get_max
return event[11];
}
/**
* @brief Get field dest from event MESH_SUBEVENT_CONFIGURATION_LOW_POWER_NODE_POLL_TIMEOUT
* @param event packet
* @return dest
* @note: btstack_type 2
*/
static inline uint16_t mesh_subevent_configuration_low_power_node_poll_timeout_get_dest(const uint8_t * event){
return little_endian_read_16(event, 3);
}
/**
* @brief Get field foundation_status from event MESH_SUBEVENT_CONFIGURATION_LOW_POWER_NODE_POLL_TIMEOUT
* @param event packet
* @return foundation_status
* @note: btstack_type 1
*/
static inline uint8_t mesh_subevent_configuration_low_power_node_poll_timeout_get_foundation_status(const uint8_t * event){
return event[5];
}
/**
* @brief Get field lpn_address from event MESH_SUBEVENT_CONFIGURATION_LOW_POWER_NODE_POLL_TIMEOUT
* @param event packet
* @return lpn_address
* @note: btstack_type 2
*/
static inline uint16_t mesh_subevent_configuration_low_power_node_poll_timeout_get_lpn_address(const uint8_t * event){
return little_endian_read_16(event, 6);
}
/**
* @brief Get field poll_timeout from event MESH_SUBEVENT_CONFIGURATION_LOW_POWER_NODE_POLL_TIMEOUT
* @param event packet
* @return poll_timeout
* @note: btstack_type 3
*/
static inline uint32_t mesh_subevent_configuration_low_power_node_poll_timeout_get_poll_timeout(const uint8_t * event){
return little_endian_read_24(event, 8);
}
/* API_END */

View File

@ -309,6 +309,11 @@ static const mesh_access_message_t mesh_configuration_client_heartbeat_subscript
MESH_FOUNDATION_OPERATION_HEARTBEAT_SUBSCRIPTION_SET, "21"
};
static const mesh_access_message_t mesh_configuration_client_low_power_node_poll_timeout_get = {
MESH_FOUNDATION_OPERATION_LOW_POWER_NODE_POLL_TIMEOUT_GET, ""
};
static void mesh_configuration_client_send_acknowledged(uint16_t src, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index, mesh_pdu_t *pdu, uint32_t ack_opcode){
uint8_t ttl = mesh_foundation_default_ttl_get();
mesh_upper_transport_setup_access_pdu_header(pdu, netkey_index, appkey_index, ttl, src, dest, 0);
@ -854,6 +859,16 @@ uint8_t mesh_configuration_client_send_heartbeat_subscription_set(mesh_model_t *
return ERROR_CODE_SUCCESS;
}
uint8_t mesh_configuration_client_send_low_power_node_poll_timeout_get(mesh_model_t * mesh_model, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index){
uint8_t status = mesh_access_validate_envelop_params(mesh_model, dest, netkey_index, appkey_index);
if (status != ERROR_CODE_SUCCESS) return status;
mesh_network_pdu_t * transport_pdu = mesh_access_setup_unsegmented_message(&mesh_configuration_client_low_power_node_poll_timeout_get);
if (!transport_pdu) return BTSTACK_MEMORY_ALLOC_FAILED;
mesh_configuration_client_send_acknowledged(mesh_access_get_element_address(mesh_model), dest, netkey_index, appkey_index, (mesh_pdu_t *) transport_pdu, MESH_FOUNDATION_OPERATION_LOW_POWER_NODE_POLL_TIMEOUT_STATUS);
return ERROR_CODE_SUCCESS;
}
// Model Operations
static void mesh_configuration_client_composition_data_status_handler(mesh_model_t *mesh_model, mesh_pdu_t * pdu){
@ -1426,29 +1441,54 @@ static void mesh_configuration_client_heartbeat_subscription_handler(mesh_model_
mesh_access_message_processed(pdu);
}
static void mesh_configuration_client_low_power_node_poll_timeout_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 lpn_address = mesh_access_parser_get_u16(&parser);
uint32_t poll_timeout = mesh_access_parser_get_u24(&parser);
uint8_t event[8];
int pos = 0;
event[pos++] = HCI_EVENT_MESH_META;
event[pos++] = sizeof(event) - 2;
event[pos++] = MESH_SUBEVENT_CONFIGURATION_LOW_POWER_NODE_POLL_TIMEOUT;
// dest
little_endian_store_16(event, pos, mesh_pdu_src(pdu));
pos += 2;
event[pos++] = ERROR_CODE_SUCCESS;
little_endian_store_24(event, pos, poll_timeout);
pos += 3;
(*mesh_model->model_packet_handler)(HCI_EVENT_PACKET, 0, event, pos);
mesh_access_message_processed(pdu);
}
const static mesh_operation_t mesh_configuration_client_model_operations[] = {
{ MESH_FOUNDATION_OPERATION_BEACON_STATUS, 1, mesh_configuration_client_beacon_status_handler },
{ MESH_FOUNDATION_OPERATION_COMPOSITION_DATA_STATUS, 10, mesh_configuration_client_composition_data_status_handler },
{ MESH_FOUNDATION_OPERATION_DEFAULT_TTL_STATUS, 1, mesh_configuration_client_default_ttl_handler },
{ MESH_FOUNDATION_OPERATION_GATT_PROXY_STATUS, 1, mesh_configuration_client_gatt_proxy_handler },
{ MESH_FOUNDATION_OPERATION_RELAY_STATUS, 2, mesh_configuration_client_relay_handler },
{ MESH_FOUNDATION_OPERATION_MODEL_PUBLICATION_STATUS, 12, mesh_configuration_client_model_publication_handler },
{ MESH_FOUNDATION_OPERATION_MODEL_SUBSCRIPTION_STATUS, 7, mesh_configuration_client_model_subscription_handler },
{ MESH_FOUNDATION_OPERATION_SIG_MODEL_SUBSCRIPTION_LIST, 5, mesh_configuration_client_sig_model_subscription_handler},
{ MESH_FOUNDATION_OPERATION_VENDOR_MODEL_SUBSCRIPTION_LIST, 7, mesh_configuration_client_vendor_model_subscription_handler},
{ MESH_FOUNDATION_OPERATION_NETKEY_STATUS, 3, mesh_configuration_client_netkey_handler },
{ MESH_FOUNDATION_OPERATION_NETKEY_LIST, 0, mesh_configuration_client_netkey_list_handler },
{ MESH_FOUNDATION_OPERATION_APPKEY_STATUS, 4, mesh_configuration_client_appkey_handler },
{ MESH_FOUNDATION_OPERATION_APPKEY_LIST, 3, mesh_configuration_client_appkey_list_handler },
{ MESH_FOUNDATION_OPERATION_NODE_IDENTITY_STATUS, 4, mesh_configuration_client_node_identity_handler },
{ MESH_FOUNDATION_OPERATION_MODEL_APP_STATUS, 7, mesh_configuration_client_model_app_handler },
{ MESH_FOUNDATION_OPERATION_SIG_MODEL_APP_LIST, 5, mesh_configuration_client_sig_model_app_list_handler },
{ MESH_FOUNDATION_OPERATION_VENDOR_MODEL_APP_LIST, 7, mesh_configuration_client_vendor_model_app_list_handler },
{ MESH_FOUNDATION_OPERATION_NODE_RESET_STATUS, 0, mesh_configuration_client_node_reset_handler },
{ MESH_FOUNDATION_OPERATION_FRIEND_STATUS, 1, mesh_configuration_client_friend_handler },
{ MESH_FOUNDATION_OPERATION_KEY_REFRESH_PHASE_STATUS, 4, mesh_configuration_client_key_refresh_phase_handler },
{ MESH_FOUNDATION_OPERATION_HEARTBEAT_PUBLICATION_STATUS, 10, mesh_configuration_client_heartbeat_publication_handler },
{ MESH_FOUNDATION_OPERATION_HEARTBEAT_SUBSCRIPTION_STATUS, 9, mesh_configuration_client_heartbeat_subscription_handler },
{ MESH_FOUNDATION_OPERATION_BEACON_STATUS, 1, mesh_configuration_client_beacon_status_handler },
{ MESH_FOUNDATION_OPERATION_COMPOSITION_DATA_STATUS, 10, mesh_configuration_client_composition_data_status_handler },
{ MESH_FOUNDATION_OPERATION_DEFAULT_TTL_STATUS, 1, mesh_configuration_client_default_ttl_handler },
{ MESH_FOUNDATION_OPERATION_GATT_PROXY_STATUS, 1, mesh_configuration_client_gatt_proxy_handler },
{ MESH_FOUNDATION_OPERATION_RELAY_STATUS, 2, mesh_configuration_client_relay_handler },
{ MESH_FOUNDATION_OPERATION_MODEL_PUBLICATION_STATUS, 12, mesh_configuration_client_model_publication_handler },
{ MESH_FOUNDATION_OPERATION_MODEL_SUBSCRIPTION_STATUS, 7, mesh_configuration_client_model_subscription_handler },
{ MESH_FOUNDATION_OPERATION_SIG_MODEL_SUBSCRIPTION_LIST, 5, mesh_configuration_client_sig_model_subscription_handler},
{ MESH_FOUNDATION_OPERATION_VENDOR_MODEL_SUBSCRIPTION_LIST, 7, mesh_configuration_client_vendor_model_subscription_handler},
{ MESH_FOUNDATION_OPERATION_NETKEY_STATUS, 3, mesh_configuration_client_netkey_handler },
{ MESH_FOUNDATION_OPERATION_NETKEY_LIST, 0, mesh_configuration_client_netkey_list_handler },
{ MESH_FOUNDATION_OPERATION_APPKEY_STATUS, 4, mesh_configuration_client_appkey_handler },
{ MESH_FOUNDATION_OPERATION_APPKEY_LIST, 3, mesh_configuration_client_appkey_list_handler },
{ MESH_FOUNDATION_OPERATION_NODE_IDENTITY_STATUS, 4, mesh_configuration_client_node_identity_handler },
{ MESH_FOUNDATION_OPERATION_MODEL_APP_STATUS, 7, mesh_configuration_client_model_app_handler },
{ MESH_FOUNDATION_OPERATION_SIG_MODEL_APP_LIST, 5, mesh_configuration_client_sig_model_app_list_handler },
{ MESH_FOUNDATION_OPERATION_VENDOR_MODEL_APP_LIST, 7, mesh_configuration_client_vendor_model_app_list_handler },
{ MESH_FOUNDATION_OPERATION_NODE_RESET_STATUS, 0, mesh_configuration_client_node_reset_handler },
{ MESH_FOUNDATION_OPERATION_FRIEND_STATUS, 1, mesh_configuration_client_friend_handler },
{ MESH_FOUNDATION_OPERATION_KEY_REFRESH_PHASE_STATUS, 4, mesh_configuration_client_key_refresh_phase_handler },
{ MESH_FOUNDATION_OPERATION_HEARTBEAT_PUBLICATION_STATUS, 10, mesh_configuration_client_heartbeat_publication_handler },
{ MESH_FOUNDATION_OPERATION_HEARTBEAT_SUBSCRIPTION_STATUS, 9, mesh_configuration_client_heartbeat_subscription_handler },
{ MESH_FOUNDATION_OPERATION_LOW_POWER_NODE_POLL_TIMEOUT_STATUS, 5, mesh_configuration_client_low_power_node_poll_timeout_handler},
{ 0, 0, NULL }
};

View File

@ -618,7 +618,6 @@ uint8_t mesh_configuration_client_send_key_refresh_phase_set(mesh_model_t * mesh
* @param dest element_address
* @param netkey_index
* @param appkey_index
* @param netk_index
* @return status ERROR_CODE_SUCCESS if successful, otherwise BTSTACK_MEMORY_ALLOC_FAILED or ERROR_CODE_PARAMETER_OUT_OF_MANDATORY_RANGE
*/
uint8_t mesh_configuration_client_send_heartbeat_publication_get(mesh_model_t * mesh_model, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index);
@ -629,7 +628,6 @@ uint8_t mesh_configuration_client_send_heartbeat_publication_get(mesh_model_t *
* @param dest element_address
* @param netkey_index
* @param appkey_index
* @param netk_index
* @param publication_state
* @return status ERROR_CODE_SUCCESS if successful, otherwise BTSTACK_MEMORY_ALLOC_FAILED or ERROR_CODE_PARAMETER_OUT_OF_MANDATORY_RANGE
*/
@ -641,7 +639,6 @@ uint8_t mesh_configuration_client_send_heartbeat_publication_set(mesh_model_t *
* @param dest element_address
* @param netkey_index
* @param appkey_index
* @param netk_index
* @return status ERROR_CODE_SUCCESS if successful, otherwise BTSTACK_MEMORY_ALLOC_FAILED or ERROR_CODE_PARAMETER_OUT_OF_MANDATORY_RANGE
*/
uint8_t mesh_configuration_client_send_heartbeat_subscription_get(mesh_model_t * mesh_model, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index);
@ -652,13 +649,23 @@ uint8_t mesh_configuration_client_send_heartbeat_subscription_get(mesh_model_t *
* @param dest element_address
* @param netkey_index
* @param appkey_index
* @param netk_index
* @param source
* @param period_log
* @return status ERROR_CODE_SUCCESS if successful, otherwise BTSTACK_MEMORY_ALLOC_FAILED or ERROR_CODE_PARAMETER_OUT_OF_MANDATORY_RANGE
*/
uint8_t mesh_configuration_client_send_heartbeat_subscription_set(mesh_model_t * mesh_model, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index, uint16_t source, uint8_t period_log);
/**
* @brief Get the current value of PollTimeout timer of the Low Power node within a Friend node.
* @param mesh_model
* @param dest element_address
* @param netkey_index
* @param appkey_index
* @return status ERROR_CODE_SUCCESS if successful, otherwise BTSTACK_MEMORY_ALLOC_FAILED or ERROR_CODE_PARAMETER_OUT_OF_MANDATORY_RANGE
*/
uint8_t mesh_configuration_client_send_low_power_node_poll_timeout_get(mesh_model_t * mesh_model, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index);
#ifdef __cplusplus
} /* end of extern "C" */