mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-22 06:41:17 +00:00
mesh: add destination field to heartbeat messages of configuration client [a2591]
This commit is contained in:
parent
786ea917db
commit
4f44739eea
@ -3118,10 +3118,11 @@ typedef uint8_t sm_key_t[16];
|
||||
#define MESH_SUBEVENT_CONFIGURATION_KEY_REFRESH_PHASE 0x53
|
||||
|
||||
/**
|
||||
* @format 12111122
|
||||
* @format 121211122
|
||||
* @param subevent_code
|
||||
* @param dest
|
||||
* @param foundation_status
|
||||
* @param heartbeat_destination
|
||||
* @param count_log
|
||||
* @param period_log
|
||||
* @param ttl
|
||||
@ -3131,11 +3132,12 @@ typedef uint8_t sm_key_t[16];
|
||||
#define MESH_SUBEVENT_CONFIGURATION_HEARTBEAT_PUBLICATION 0x54
|
||||
|
||||
/**
|
||||
* @format 12121111
|
||||
* @format 121221111
|
||||
* @param subevent_code
|
||||
* @param dest
|
||||
* @param foundation_status
|
||||
* @param source
|
||||
* @param heartbeat_destination
|
||||
* @param heartbeat_source
|
||||
* @param count_log
|
||||
* @param period_log
|
||||
* @param min_hops
|
||||
|
@ -8719,6 +8719,15 @@ 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 heartbeat_destination from event MESH_SUBEVENT_CONFIGURATION_HEARTBEAT_PUBLICATION
|
||||
* @param event packet
|
||||
* @return heartbeat_destination
|
||||
* @note: btstack_type 2
|
||||
*/
|
||||
static inline uint16_t mesh_subevent_configuration_heartbeat_publication_get_heartbeat_destination(const uint8_t * event){
|
||||
return little_endian_read_16(event, 6);
|
||||
}
|
||||
/**
|
||||
* @brief Get field count_log from event MESH_SUBEVENT_CONFIGURATION_HEARTBEAT_PUBLICATION
|
||||
* @param event packet
|
||||
@ -8726,7 +8735,7 @@ static inline uint8_t mesh_subevent_configuration_heartbeat_publication_get_foun
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t mesh_subevent_configuration_heartbeat_publication_get_count_log(const uint8_t * event){
|
||||
return event[6];
|
||||
return event[8];
|
||||
}
|
||||
/**
|
||||
* @brief Get field period_log from event MESH_SUBEVENT_CONFIGURATION_HEARTBEAT_PUBLICATION
|
||||
@ -8735,7 +8744,7 @@ static inline uint8_t mesh_subevent_configuration_heartbeat_publication_get_coun
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t mesh_subevent_configuration_heartbeat_publication_get_period_log(const uint8_t * event){
|
||||
return event[7];
|
||||
return event[9];
|
||||
}
|
||||
/**
|
||||
* @brief Get field ttl from event MESH_SUBEVENT_CONFIGURATION_HEARTBEAT_PUBLICATION
|
||||
@ -8744,7 +8753,7 @@ 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_ttl(const uint8_t * event){
|
||||
return event[8];
|
||||
return event[10];
|
||||
}
|
||||
/**
|
||||
* @brief Get field features from event MESH_SUBEVENT_CONFIGURATION_HEARTBEAT_PUBLICATION
|
||||
@ -8753,7 +8762,7 @@ static inline uint8_t mesh_subevent_configuration_heartbeat_publication_get_ttl(
|
||||
* @note: btstack_type 2
|
||||
*/
|
||||
static inline uint16_t mesh_subevent_configuration_heartbeat_publication_get_features(const uint8_t * event){
|
||||
return little_endian_read_16(event, 9);
|
||||
return little_endian_read_16(event, 11);
|
||||
}
|
||||
/**
|
||||
* @brief Get field netkey_index from event MESH_SUBEVENT_CONFIGURATION_HEARTBEAT_PUBLICATION
|
||||
@ -8762,7 +8771,7 @@ static inline uint16_t mesh_subevent_configuration_heartbeat_publication_get_fea
|
||||
* @note: btstack_type 2
|
||||
*/
|
||||
static inline uint16_t mesh_subevent_configuration_heartbeat_publication_get_netkey_index(const uint8_t * event){
|
||||
return little_endian_read_16(event, 11);
|
||||
return little_endian_read_16(event, 13);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -8784,14 +8793,23 @@ static inline uint8_t mesh_subevent_configuration_heartbeat_subscription_get_fou
|
||||
return event[5];
|
||||
}
|
||||
/**
|
||||
* @brief Get field source from event MESH_SUBEVENT_CONFIGURATION_HEARTBEAT_SUBSCRIPTION
|
||||
* @brief Get field heartbeat_destination from event MESH_SUBEVENT_CONFIGURATION_HEARTBEAT_SUBSCRIPTION
|
||||
* @param event packet
|
||||
* @return source
|
||||
* @return heartbeat_destination
|
||||
* @note: btstack_type 2
|
||||
*/
|
||||
static inline uint16_t mesh_subevent_configuration_heartbeat_subscription_get_source(const uint8_t * event){
|
||||
static inline uint16_t mesh_subevent_configuration_heartbeat_subscription_get_heartbeat_destination(const uint8_t * event){
|
||||
return little_endian_read_16(event, 6);
|
||||
}
|
||||
/**
|
||||
* @brief Get field heartbeat_source from event MESH_SUBEVENT_CONFIGURATION_HEARTBEAT_SUBSCRIPTION
|
||||
* @param event packet
|
||||
* @return heartbeat_source
|
||||
* @note: btstack_type 2
|
||||
*/
|
||||
static inline uint16_t mesh_subevent_configuration_heartbeat_subscription_get_heartbeat_source(const uint8_t * event){
|
||||
return little_endian_read_16(event, 8);
|
||||
}
|
||||
/**
|
||||
* @brief Get field count_log from event MESH_SUBEVENT_CONFIGURATION_HEARTBEAT_SUBSCRIPTION
|
||||
* @param event packet
|
||||
@ -8799,7 +8817,7 @@ static inline uint16_t mesh_subevent_configuration_heartbeat_subscription_get_so
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t mesh_subevent_configuration_heartbeat_subscription_get_count_log(const uint8_t * event){
|
||||
return event[8];
|
||||
return event[10];
|
||||
}
|
||||
/**
|
||||
* @brief Get field period_log from event MESH_SUBEVENT_CONFIGURATION_HEARTBEAT_SUBSCRIPTION
|
||||
@ -8808,7 +8826,7 @@ static inline uint8_t mesh_subevent_configuration_heartbeat_subscription_get_cou
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t mesh_subevent_configuration_heartbeat_subscription_get_period_log(const uint8_t * event){
|
||||
return event[9];
|
||||
return event[11];
|
||||
}
|
||||
/**
|
||||
* @brief Get field min_hops from event MESH_SUBEVENT_CONFIGURATION_HEARTBEAT_SUBSCRIPTION
|
||||
@ -8817,7 +8835,7 @@ 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_min_hops(const uint8_t * event){
|
||||
return event[10];
|
||||
return event[12];
|
||||
}
|
||||
/**
|
||||
* @brief Get field max_hops from event MESH_SUBEVENT_CONFIGURATION_HEARTBEAT_SUBSCRIPTION
|
||||
@ -8826,7 +8844,7 @@ static inline uint8_t mesh_subevent_configuration_heartbeat_subscription_get_min
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t mesh_subevent_configuration_heartbeat_subscription_get_max_hops(const uint8_t * event){
|
||||
return event[11];
|
||||
return event[13];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -299,14 +299,14 @@ static const mesh_access_message_t mesh_configuration_client_heartbeat_publicati
|
||||
MESH_FOUNDATION_OPERATION_HEARTBEAT_PUBLICATION_GET, ""
|
||||
};
|
||||
static const mesh_access_message_t mesh_configuration_client_heartbeat_publication_set = {
|
||||
MESH_FOUNDATION_OPERATION_HEARTBEAT_PUBLICATION_SET, "11122"
|
||||
MESH_FOUNDATION_OPERATION_HEARTBEAT_PUBLICATION_SET, "211122"
|
||||
};
|
||||
|
||||
static const mesh_access_message_t mesh_configuration_client_heartbeat_subscription_get = {
|
||||
MESH_FOUNDATION_OPERATION_HEARTBEAT_SUBSCRIPTION_GET, ""
|
||||
};
|
||||
static const mesh_access_message_t mesh_configuration_client_heartbeat_subscription_set = {
|
||||
MESH_FOUNDATION_OPERATION_HEARTBEAT_SUBSCRIPTION_SET, "21"
|
||||
MESH_FOUNDATION_OPERATION_HEARTBEAT_SUBSCRIPTION_SET, "221"
|
||||
};
|
||||
|
||||
static const mesh_access_message_t mesh_configuration_client_low_power_node_poll_timeout_get = {
|
||||
@ -832,6 +832,7 @@ uint8_t mesh_configuration_client_send_heartbeat_publication_set(mesh_model_t *
|
||||
if (status != ERROR_CODE_SUCCESS) return status;
|
||||
|
||||
mesh_network_pdu_t * transport_pdu = mesh_access_setup_unsegmented_message(&mesh_configuration_client_heartbeat_publication_set,
|
||||
publication_state.destination,
|
||||
publication_state.count_log,
|
||||
publication_state.period_log,
|
||||
publication_state.ttl,
|
||||
@ -855,11 +856,11 @@ uint8_t mesh_configuration_client_send_heartbeat_subscription_get(mesh_model_t *
|
||||
return ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
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){
|
||||
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 heartbeat_source, uint16_t heartbeat_destination, uint8_t period_log){
|
||||
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_heartbeat_subscription_set, source, period_log);
|
||||
mesh_network_pdu_t * transport_pdu = mesh_access_setup_unsegmented_message(&mesh_configuration_client_heartbeat_subscription_set, heartbeat_source, heartbeat_destination, period_log);
|
||||
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_HEARTBEAT_SUBSCRIPTION_STATUS);
|
||||
@ -892,7 +893,7 @@ uint8_t mesh_configuration_client_send_network_transmit_set(mesh_model_t * mesh_
|
||||
uint8_t status = mesh_access_validate_envelop_params(mesh_model, dest, netkey_index, appkey_index);
|
||||
if (status != ERROR_CODE_SUCCESS) return status;
|
||||
|
||||
uint8_t transmit_interval_steps_10ms = (uint8_t) transmit_interval_steps_ms/10;
|
||||
uint8_t transmit_interval_steps_10ms = (uint8_t) (transmit_interval_steps_ms/10);
|
||||
if (transmit_interval_steps_10ms > 0){
|
||||
transmit_interval_steps_10ms -= 1;
|
||||
}
|
||||
@ -1416,10 +1417,7 @@ static void mesh_configuration_client_heartbeat_publication_handler(mesh_model_t
|
||||
uint16_t features = mesh_access_parser_get_u16(&parser);
|
||||
uint16_t netkey_index = mesh_access_parser_get_u16(&parser);
|
||||
|
||||
if (dest != mesh_pdu_src(pdu)){
|
||||
log_info("MESH_SUBEVENT_CONFIGURATION_HEARTBEAT_PUBLICATION event, destination differs from mesh_pdu_src");
|
||||
}
|
||||
uint8_t event[13];
|
||||
uint8_t event[15];
|
||||
int pos = 0;
|
||||
event[pos++] = HCI_EVENT_MESH_META;
|
||||
event[pos++] = sizeof(event) - 2;
|
||||
@ -1428,6 +1426,8 @@ static void mesh_configuration_client_heartbeat_publication_handler(mesh_model_t
|
||||
little_endian_store_16(event, pos, mesh_pdu_src(pdu));
|
||||
pos += 2;
|
||||
event[pos++] = status;
|
||||
little_endian_store_16(event, pos, dest);
|
||||
pos += 2;
|
||||
event[pos++] = count_log;
|
||||
event[pos++] = period_log;
|
||||
event[pos++] = ttl;
|
||||
@ -1450,11 +1450,7 @@ static void mesh_configuration_client_heartbeat_subscription_handler(mesh_model_
|
||||
uint8_t min_hops = mesh_access_parser_get_u8(&parser);
|
||||
uint8_t max_hops = mesh_access_parser_get_u8(&parser);
|
||||
|
||||
if (dest != mesh_pdu_src(pdu)){
|
||||
log_info("MESH_SUBEVENT_CONFIGURATION_HEARTBEAT_PUBLICATION event, destination differs from mesh_pdu_src");
|
||||
}
|
||||
|
||||
uint8_t event[12];
|
||||
uint8_t event[14];
|
||||
int pos = 0;
|
||||
event[pos++] = HCI_EVENT_MESH_META;
|
||||
event[pos++] = sizeof(event) - 2;
|
||||
@ -1463,7 +1459,8 @@ static void mesh_configuration_client_heartbeat_subscription_handler(mesh_model_
|
||||
little_endian_store_16(event, pos, mesh_pdu_src(pdu));
|
||||
pos += 2;
|
||||
event[pos++] = status;
|
||||
|
||||
little_endian_store_16(event, pos, dest);
|
||||
pos += 2;
|
||||
little_endian_store_16(event, pos, source);
|
||||
pos += 2;
|
||||
event[pos++] = count_log;
|
||||
@ -1547,8 +1544,8 @@ const static mesh_operation_t mesh_configuration_client_model_operations[] = {
|
||||
{ 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_HEARTBEAT_PUBLICATION_STATUS, 12, mesh_configuration_client_heartbeat_publication_handler },
|
||||
{ MESH_FOUNDATION_OPERATION_HEARTBEAT_SUBSCRIPTION_STATUS, 11, 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},
|
||||
{ MESH_FOUNDATION_OPERATION_NETWORK_TRANSMIT_STATUS, 1, mesh_configuration_client_network_transmit_handler},
|
||||
{ 0, 0, NULL }
|
||||
|
@ -649,11 +649,12 @@ uint8_t mesh_configuration_client_send_heartbeat_subscription_get(mesh_model_t *
|
||||
* @param dest element_address
|
||||
* @param netkey_index
|
||||
* @param appkey_index
|
||||
* @param source
|
||||
* @param heartbeat_source
|
||||
* @param heartbeat_destination
|
||||
* @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);
|
||||
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 heartbeat_source, uint16_t heartbeat_destination, uint8_t period_log);
|
||||
|
||||
/**
|
||||
* @brief Get the current value of PollTimeout timer of the Low Power node within a Friend node.
|
||||
|
@ -105,6 +105,7 @@ typedef struct {
|
||||
} mesh_publication_model_t;
|
||||
|
||||
typedef struct {
|
||||
uint16_t destination;
|
||||
uint8_t count_log; // Number of Heartbeat messages to be sent
|
||||
uint8_t period_log; // Period for sending Heartbeat messages
|
||||
uint8_t ttl; // TTL to be used when sending Heartbeat messages
|
||||
|
Loading…
x
Reference in New Issue
Block a user