mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-26 03:35:20 +00:00
mesh: mesh_message_pdu -> mesh_segmented_pdu
This commit is contained in:
parent
04050cc707
commit
a4bbc09d8c
@ -992,48 +992,48 @@ void btstack_memory_mesh_transport_pdu_free(mesh_transport_pdu_t *mesh_transport
|
||||
#endif
|
||||
|
||||
|
||||
// MARK: mesh_message_pdu_t
|
||||
#if !defined(HAVE_MALLOC) && !defined(MAX_NR_MESH_MESSAGE_PDUS)
|
||||
#if defined(MAX_NO_MESH_MESSAGE_PDUS)
|
||||
#error "Deprecated MAX_NO_MESH_MESSAGE_PDUS defined instead of MAX_NR_MESH_MESSAGE_PDUS. Please update your btstack_config.h to use MAX_NR_MESH_MESSAGE_PDUS."
|
||||
// MARK: mesh_segmented_pdu_t
|
||||
#if !defined(HAVE_MALLOC) && !defined(MAX_NR_MESH_SEGMENTED_PDUS)
|
||||
#if defined(MAX_NO_MESH_SEGMENTED_PDUS)
|
||||
#error "Deprecated MAX_NO_MESH_SEGMENTED_PDUS defined instead of MAX_NR_MESH_SEGMENTED_PDUS. Please update your btstack_config.h to use MAX_NR_MESH_SEGMENTED_PDUS."
|
||||
#else
|
||||
#define MAX_NR_MESH_MESSAGE_PDUS 0
|
||||
#define MAX_NR_MESH_SEGMENTED_PDUS 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MAX_NR_MESH_MESSAGE_PDUS
|
||||
#if MAX_NR_MESH_MESSAGE_PDUS > 0
|
||||
static mesh_message_pdu_t mesh_message_pdu_storage[MAX_NR_MESH_MESSAGE_PDUS];
|
||||
static btstack_memory_pool_t mesh_message_pdu_pool;
|
||||
mesh_message_pdu_t * btstack_memory_mesh_message_pdu_get(void){
|
||||
void * buffer = btstack_memory_pool_get(&mesh_message_pdu_pool);
|
||||
#ifdef MAX_NR_MESH_SEGMENTED_PDUS
|
||||
#if MAX_NR_MESH_SEGMENTED_PDUS > 0
|
||||
static mesh_segmented_pdu_t mesh_segmented_pdu_storage[MAX_NR_MESH_SEGMENTED_PDUS];
|
||||
static btstack_memory_pool_t mesh_segmented_pdu_pool;
|
||||
mesh_segmented_pdu_t * btstack_memory_mesh_segmented_pdu_get(void){
|
||||
void * buffer = btstack_memory_pool_get(&mesh_segmented_pdu_pool);
|
||||
if (buffer){
|
||||
memset(buffer, 0, sizeof(mesh_message_pdu_t));
|
||||
memset(buffer, 0, sizeof(mesh_segmented_pdu_t));
|
||||
}
|
||||
return (mesh_message_pdu_t *) buffer;
|
||||
return (mesh_segmented_pdu_t *) buffer;
|
||||
}
|
||||
void btstack_memory_mesh_message_pdu_free(mesh_message_pdu_t *mesh_message_pdu){
|
||||
btstack_memory_pool_free(&mesh_message_pdu_pool, mesh_message_pdu);
|
||||
void btstack_memory_mesh_segmented_pdu_free(mesh_segmented_pdu_t *mesh_segmented_pdu){
|
||||
btstack_memory_pool_free(&mesh_segmented_pdu_pool, mesh_segmented_pdu);
|
||||
}
|
||||
#else
|
||||
mesh_message_pdu_t * btstack_memory_mesh_message_pdu_get(void){
|
||||
mesh_segmented_pdu_t * btstack_memory_mesh_segmented_pdu_get(void){
|
||||
return NULL;
|
||||
}
|
||||
void btstack_memory_mesh_message_pdu_free(mesh_message_pdu_t *mesh_message_pdu){
|
||||
void btstack_memory_mesh_segmented_pdu_free(mesh_segmented_pdu_t *mesh_segmented_pdu){
|
||||
// silence compiler warning about unused parameter in a portable way
|
||||
(void) mesh_message_pdu;
|
||||
(void) mesh_segmented_pdu;
|
||||
};
|
||||
#endif
|
||||
#elif defined(HAVE_MALLOC)
|
||||
mesh_message_pdu_t * btstack_memory_mesh_message_pdu_get(void){
|
||||
void * buffer = malloc(sizeof(mesh_message_pdu_t));
|
||||
mesh_segmented_pdu_t * btstack_memory_mesh_segmented_pdu_get(void){
|
||||
void * buffer = malloc(sizeof(mesh_segmented_pdu_t));
|
||||
if (buffer){
|
||||
memset(buffer, 0, sizeof(mesh_message_pdu_t));
|
||||
memset(buffer, 0, sizeof(mesh_segmented_pdu_t));
|
||||
}
|
||||
return (mesh_message_pdu_t *) buffer;
|
||||
return (mesh_segmented_pdu_t *) buffer;
|
||||
}
|
||||
void btstack_memory_mesh_message_pdu_free(mesh_message_pdu_t *mesh_message_pdu){
|
||||
free(mesh_message_pdu);
|
||||
void btstack_memory_mesh_segmented_pdu_free(mesh_segmented_pdu_t *mesh_segmented_pdu){
|
||||
free(mesh_segmented_pdu);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1290,8 +1290,8 @@ void btstack_memory_init(void){
|
||||
#if MAX_NR_MESH_TRANSPORT_PDUS > 0
|
||||
btstack_memory_pool_create(&mesh_transport_pdu_pool, mesh_transport_pdu_storage, MAX_NR_MESH_TRANSPORT_PDUS, sizeof(mesh_transport_pdu_t));
|
||||
#endif
|
||||
#if MAX_NR_MESH_MESSAGE_PDUS > 0
|
||||
btstack_memory_pool_create(&mesh_message_pdu_pool, mesh_message_pdu_storage, MAX_NR_MESH_MESSAGE_PDUS, sizeof(mesh_message_pdu_t));
|
||||
#if MAX_NR_MESH_SEGMENTED_PDUS > 0
|
||||
btstack_memory_pool_create(&mesh_segmented_pdu_pool, mesh_segmented_pdu_storage, MAX_NR_MESH_SEGMENTED_PDUS, sizeof(mesh_segmented_pdu_t));
|
||||
#endif
|
||||
#if MAX_NR_MESH_NETWORK_KEYS > 0
|
||||
btstack_memory_pool_create(&mesh_network_key_pool, mesh_network_key_storage, MAX_NR_MESH_NETWORK_KEYS, sizeof(mesh_network_key_t));
|
||||
|
@ -153,13 +153,13 @@ sm_lookup_entry_t * btstack_memory_sm_lookup_entry_get(void);
|
||||
void btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t *sm_lookup_entry);
|
||||
#endif
|
||||
#ifdef ENABLE_MESH
|
||||
// mesh_network_pdu, mesh_transport_pdu, mesh_message_pdu, mesh_network_key, mesh_transport_key, mesh_virtual_address, mesh_subnet
|
||||
// mesh_network_pdu, mesh_transport_pdu, mesh_segmented_pdu, mesh_network_key, mesh_transport_key, mesh_virtual_address, mesh_subnet
|
||||
mesh_network_pdu_t * btstack_memory_mesh_network_pdu_get(void);
|
||||
void btstack_memory_mesh_network_pdu_free(mesh_network_pdu_t *mesh_network_pdu);
|
||||
mesh_transport_pdu_t * btstack_memory_mesh_transport_pdu_get(void);
|
||||
void btstack_memory_mesh_transport_pdu_free(mesh_transport_pdu_t *mesh_transport_pdu);
|
||||
mesh_message_pdu_t * btstack_memory_mesh_message_pdu_get(void);
|
||||
void btstack_memory_mesh_message_pdu_free(mesh_message_pdu_t *mesh_message_pdu);
|
||||
mesh_segmented_pdu_t * btstack_memory_mesh_segmented_pdu_get(void);
|
||||
void btstack_memory_mesh_segmented_pdu_free(mesh_segmented_pdu_t *mesh_segmented_pdu);
|
||||
mesh_network_key_t * btstack_memory_mesh_network_key_get(void);
|
||||
void btstack_memory_mesh_network_key_free(mesh_network_key_t *mesh_network_key);
|
||||
mesh_transport_key_t * btstack_memory_mesh_transport_key_get(void);
|
||||
|
@ -124,8 +124,8 @@ static uint32_t mesh_access_message_ack_opcode(mesh_pdu_t * pdu){
|
||||
switch (pdu->pdu_type){
|
||||
case MESH_PDU_TYPE_TRANSPORT:
|
||||
return ((mesh_transport_pdu_t *)pdu)->ack_opcode;
|
||||
case MESH_PDU_TYPE_MESSAGE:
|
||||
return ((mesh_message_pdu_t *)pdu)->ack_opcode;
|
||||
case MESH_PDU_TYPE_SEGMENTED:
|
||||
return ((mesh_segmented_pdu_t *)pdu)->ack_opcode;
|
||||
default:
|
||||
btstack_assert(0);
|
||||
return MESH_ACCESS_OPCODE_INVALID;
|
||||
@ -137,8 +137,8 @@ static void mesh_access_message_set_ack_opcode(mesh_pdu_t * pdu, uint32_t ack_op
|
||||
case MESH_PDU_TYPE_TRANSPORT:
|
||||
((mesh_transport_pdu_t *)pdu)->ack_opcode = ack_opcode;
|
||||
break;
|
||||
case MESH_PDU_TYPE_MESSAGE:
|
||||
((mesh_message_pdu_t *)pdu)->ack_opcode = ack_opcode;
|
||||
case MESH_PDU_TYPE_SEGMENTED:
|
||||
((mesh_segmented_pdu_t *)pdu)->ack_opcode = ack_opcode;
|
||||
break;
|
||||
default:
|
||||
btstack_assert(0);
|
||||
@ -150,8 +150,8 @@ static uint8_t mesh_access_message_retransmit_count(mesh_pdu_t * pdu){
|
||||
switch (pdu->pdu_type){
|
||||
case MESH_PDU_TYPE_TRANSPORT:
|
||||
return ((mesh_transport_pdu_t *)pdu)->retransmit_count;
|
||||
case MESH_PDU_TYPE_MESSAGE:
|
||||
return ((mesh_message_pdu_t *)pdu)->retransmit_count;
|
||||
case MESH_PDU_TYPE_SEGMENTED:
|
||||
return ((mesh_segmented_pdu_t *)pdu)->retransmit_count;
|
||||
default:
|
||||
btstack_assert(0);
|
||||
return 0;
|
||||
@ -163,8 +163,8 @@ static void mesh_access_message_set_retransmit_count(mesh_pdu_t * pdu, uint8_t r
|
||||
case MESH_PDU_TYPE_TRANSPORT:
|
||||
((mesh_transport_pdu_t *)pdu)->retransmit_count = retransmit_count;
|
||||
break;
|
||||
case MESH_PDU_TYPE_MESSAGE:
|
||||
((mesh_message_pdu_t *)pdu)->retransmit_count = retransmit_count;
|
||||
case MESH_PDU_TYPE_SEGMENTED:
|
||||
((mesh_segmented_pdu_t *)pdu)->retransmit_count = retransmit_count;
|
||||
break;
|
||||
default:
|
||||
btstack_assert(0);
|
||||
@ -176,8 +176,8 @@ static uint32_t mesh_access_message_retransmit_timeout_ms(mesh_pdu_t * pdu){
|
||||
switch (pdu->pdu_type){
|
||||
case MESH_PDU_TYPE_TRANSPORT:
|
||||
return ((mesh_transport_pdu_t *)pdu)->retransmit_timeout_ms;
|
||||
case MESH_PDU_TYPE_MESSAGE:
|
||||
return ((mesh_message_pdu_t *)pdu)->retransmit_timeout_ms;
|
||||
case MESH_PDU_TYPE_SEGMENTED:
|
||||
return ((mesh_segmented_pdu_t *)pdu)->retransmit_timeout_ms;
|
||||
default:
|
||||
btstack_assert(0);
|
||||
return 0;
|
||||
@ -189,8 +189,8 @@ static void mesh_access_message_set_retransmit_timeout_ms(mesh_pdu_t * pdu, uint
|
||||
case MESH_PDU_TYPE_TRANSPORT:
|
||||
((mesh_transport_pdu_t *)pdu)->retransmit_timeout_ms = retransmit_timeout_ms;
|
||||
break;
|
||||
case MESH_PDU_TYPE_MESSAGE:
|
||||
((mesh_message_pdu_t *)pdu)->retransmit_timeout_ms = retransmit_timeout_ms;
|
||||
case MESH_PDU_TYPE_SEGMENTED:
|
||||
((mesh_segmented_pdu_t *)pdu)->retransmit_timeout_ms = retransmit_timeout_ms;
|
||||
break;
|
||||
default:
|
||||
btstack_assert(0);
|
||||
@ -735,11 +735,11 @@ void mesh_access_transport_add_model_identifier(mesh_transport_pdu_t * pdu, uint
|
||||
}
|
||||
|
||||
// mesh_message_t builder
|
||||
mesh_message_pdu_t * mesh_access_message_init(uint32_t opcode, bool segmented, uint8_t num_segments){
|
||||
mesh_segmented_pdu_t * mesh_access_message_init(uint32_t opcode, bool segmented, uint8_t num_segments){
|
||||
btstack_assert(num_segments > 0);
|
||||
btstack_assert(segmented || (num_segments == 1));
|
||||
|
||||
mesh_message_pdu_t * pdu = mesh_message_pdu_get();
|
||||
mesh_segmented_pdu_t * pdu = mesh_message_pdu_get();
|
||||
if (!pdu) return NULL;
|
||||
|
||||
// TODO: handle segmented messages
|
||||
@ -758,34 +758,34 @@ mesh_message_pdu_t * mesh_access_message_init(uint32_t opcode, bool segmented, u
|
||||
return pdu;
|
||||
}
|
||||
|
||||
void mesh_access_message_add_uint8(mesh_message_pdu_t * pdu, uint8_t value){
|
||||
void mesh_access_message_add_uint8(mesh_segmented_pdu_t * pdu, uint8_t value){
|
||||
// TODO: handle segmented messages
|
||||
mesh_network_pdu_t * segment = (mesh_network_pdu_t *) btstack_linked_list_get_first_item(&pdu->segments);
|
||||
segment->data[pdu->len++] = value;
|
||||
}
|
||||
|
||||
void mesh_access_message_add_uint16(mesh_message_pdu_t * pdu, uint16_t value){
|
||||
void mesh_access_message_add_uint16(mesh_segmented_pdu_t * pdu, uint16_t value){
|
||||
// TODO: handle segmented messages
|
||||
mesh_network_pdu_t * segment = (mesh_network_pdu_t *) btstack_linked_list_get_first_item(&pdu->segments);
|
||||
little_endian_store_16(segment->data, pdu->len, value);
|
||||
pdu->len += 2;
|
||||
}
|
||||
|
||||
void mesh_access_message_add_uint24(mesh_message_pdu_t * pdu, uint16_t value){
|
||||
void mesh_access_message_add_uint24(mesh_segmented_pdu_t * pdu, uint16_t value){
|
||||
// TODO: handle segmented messages
|
||||
mesh_network_pdu_t * segment = (mesh_network_pdu_t *) btstack_linked_list_get_first_item(&pdu->segments);
|
||||
little_endian_store_24(segment->data, pdu->len, value);
|
||||
pdu->len += 3;
|
||||
}
|
||||
|
||||
void mesh_access_message_add_uint32(mesh_message_pdu_t * pdu, uint16_t value){
|
||||
void mesh_access_message_add_uint32(mesh_segmented_pdu_t * pdu, uint16_t value){
|
||||
// TODO: handle segmented messages
|
||||
mesh_network_pdu_t * segment = (mesh_network_pdu_t *) btstack_linked_list_get_first_item(&pdu->segments);
|
||||
little_endian_store_32(segment->data, pdu->len, value);
|
||||
pdu->len += 4;
|
||||
}
|
||||
|
||||
void mesh_access_message_add_model_identifier(mesh_message_pdu_t * pdu, uint32_t model_identifier){
|
||||
void mesh_access_message_add_model_identifier(mesh_segmented_pdu_t * pdu, uint32_t model_identifier){
|
||||
if (mesh_model_is_bluetooth_sig(model_identifier)){
|
||||
mesh_access_message_add_uint16( pdu, mesh_model_get_model_id(model_identifier) );
|
||||
} else {
|
||||
@ -794,11 +794,11 @@ void mesh_access_message_add_model_identifier(mesh_message_pdu_t * pdu, uint32_t
|
||||
}
|
||||
|
||||
// access message template
|
||||
mesh_message_pdu_t * mesh_access_setup_message(bool segmented, const mesh_access_message_t *message_template, ...){
|
||||
mesh_segmented_pdu_t * mesh_access_setup_message(bool segmented, const mesh_access_message_t *message_template, ...){
|
||||
btstack_assert(segmented == false);
|
||||
|
||||
// TODO: handle segmented messages
|
||||
mesh_message_pdu_t * message_pdu = mesh_access_message_init(message_template->opcode, segmented, 1);
|
||||
mesh_segmented_pdu_t * message_pdu = mesh_access_message_init(message_template->opcode, segmented, 1);
|
||||
if (!message_pdu) return NULL;
|
||||
|
||||
va_list argptr;
|
||||
|
@ -256,16 +256,16 @@ void mesh_access_transport_add_uint32(mesh_transport_pdu_t * pdu, uint32_t value
|
||||
void mesh_access_transport_add_model_identifier(mesh_transport_pdu_t * pdu, uint32_t model_identifier);
|
||||
void mesh_access_transport_add_label_uuid(mesh_transport_pdu_t * pdu, uint8_t * value);
|
||||
|
||||
mesh_message_pdu_t * mesh_access_message_init(uint32_t opcode, bool segmented, uint8_t num_segments);
|
||||
void mesh_access_message_add_uint8(mesh_message_pdu_t * pdu, uint8_t value);
|
||||
void mesh_access_message_add_uint16(mesh_message_pdu_t * pdu, uint16_t value);
|
||||
void mesh_access_message_add_uint24(mesh_message_pdu_t * pdu, uint16_t value);
|
||||
void mesh_access_message_add_uint32(mesh_message_pdu_t * pdu, uint16_t value);
|
||||
void mesh_access_message_add_model_identifier(mesh_message_pdu_t * pdu, uint32_t model_identifier);
|
||||
mesh_segmented_pdu_t * mesh_access_message_init(uint32_t opcode, bool segmented, uint8_t num_segments);
|
||||
void mesh_access_message_add_uint8(mesh_segmented_pdu_t * pdu, uint8_t value);
|
||||
void mesh_access_message_add_uint16(mesh_segmented_pdu_t * pdu, uint16_t value);
|
||||
void mesh_access_message_add_uint24(mesh_segmented_pdu_t * pdu, uint16_t value);
|
||||
void mesh_access_message_add_uint32(mesh_segmented_pdu_t * pdu, uint16_t value);
|
||||
void mesh_access_message_add_model_identifier(mesh_segmented_pdu_t * pdu, uint32_t model_identifier);
|
||||
|
||||
// message builder using template
|
||||
mesh_transport_pdu_t * mesh_access_setup_segmented_message(const mesh_access_message_t *message_template, ...);
|
||||
mesh_message_pdu_t * mesh_access_setup_message(bool segmented, const mesh_access_message_t *message_template, ...);
|
||||
mesh_segmented_pdu_t * mesh_access_setup_message(bool segmented, const mesh_access_message_t *message_template, ...);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end of extern "C" */
|
||||
|
@ -342,7 +342,7 @@ uint8_t mesh_configuration_client_send_beacon_get(mesh_model_t * mesh_model, uin
|
||||
uint8_t status = mesh_access_validate_envelop_params(mesh_model, dest, netkey_index, appkey_index);
|
||||
if (status != ERROR_CODE_SUCCESS) return status;
|
||||
|
||||
mesh_message_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_beacon_get);
|
||||
mesh_segmented_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_beacon_get);
|
||||
if (!message_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 *) message_pdu, MESH_FOUNDATION_OPERATION_BEACON_STATUS);
|
||||
@ -355,7 +355,7 @@ uint8_t mesh_configuration_client_send_beacon_set(mesh_model_t * mesh_model, uin
|
||||
|
||||
if (beacon > 1) return ERROR_CODE_PARAMETER_OUT_OF_MANDATORY_RANGE;
|
||||
|
||||
mesh_message_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_beacon_set, beacon);
|
||||
mesh_segmented_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_beacon_set, beacon);
|
||||
if (!message_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 *) message_pdu, MESH_FOUNDATION_OPERATION_BEACON_STATUS);
|
||||
@ -366,7 +366,7 @@ uint8_t mesh_configuration_client_send_composition_data_get(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;
|
||||
|
||||
mesh_message_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_composition_data_get, page);
|
||||
mesh_segmented_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_composition_data_get, page);
|
||||
if (!message_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 *) message_pdu, MESH_FOUNDATION_OPERATION_COMPOSITION_DATA_STATUS);
|
||||
@ -377,7 +377,7 @@ uint8_t mesh_configuration_client_send_default_ttl_get(mesh_model_t * mesh_model
|
||||
uint8_t status = mesh_access_validate_envelop_params(mesh_model, dest, netkey_index, appkey_index);
|
||||
if (status != ERROR_CODE_SUCCESS) return status;
|
||||
|
||||
mesh_message_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_default_ttl_get);
|
||||
mesh_segmented_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_default_ttl_get);
|
||||
if (!message_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 *) message_pdu, MESH_FOUNDATION_OPERATION_DEFAULT_TTL_STATUS);
|
||||
@ -390,7 +390,7 @@ uint8_t mesh_configuration_client_send_default_ttl_set(mesh_model_t * mesh_model
|
||||
|
||||
if (ttl == 0x01 || ttl >= 0x80) return ERROR_CODE_PARAMETER_OUT_OF_MANDATORY_RANGE;
|
||||
|
||||
mesh_message_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_default_ttl_set, ttl);
|
||||
mesh_segmented_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_default_ttl_set, ttl);
|
||||
if (!message_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 *) message_pdu, MESH_FOUNDATION_OPERATION_DEFAULT_TTL_STATUS);
|
||||
@ -401,7 +401,7 @@ uint8_t mesh_configuration_client_send_gatt_proxy_get(mesh_model_t * mesh_model,
|
||||
uint8_t status = mesh_access_validate_envelop_params(mesh_model, dest, netkey_index, appkey_index);
|
||||
if (status != ERROR_CODE_SUCCESS) return status;
|
||||
|
||||
mesh_message_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_gatt_proxy_get);
|
||||
mesh_segmented_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_gatt_proxy_get);
|
||||
if (!message_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 *) message_pdu, MESH_FOUNDATION_OPERATION_GATT_PROXY_STATUS);
|
||||
@ -414,7 +414,7 @@ uint8_t mesh_configuration_client_send_gatt_proxy_set(mesh_model_t * mesh_model,
|
||||
|
||||
if (gatt_proxy_state > 2) return ERROR_CODE_PARAMETER_OUT_OF_MANDATORY_RANGE;
|
||||
|
||||
mesh_message_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_gatt_proxy_set, gatt_proxy_state);
|
||||
mesh_segmented_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_gatt_proxy_set, gatt_proxy_state);
|
||||
if (!message_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 *) message_pdu, MESH_FOUNDATION_OPERATION_GATT_PROXY_STATUS);
|
||||
@ -425,7 +425,7 @@ uint8_t mesh_configuration_client_send_relay_get(mesh_model_t * mesh_model, uint
|
||||
uint8_t status = mesh_access_validate_envelop_params(mesh_model, dest, netkey_index, appkey_index);
|
||||
if (status != ERROR_CODE_SUCCESS) return status;
|
||||
|
||||
mesh_message_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_relay_get);
|
||||
mesh_segmented_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_relay_get);
|
||||
if (!message_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 *) message_pdu, MESH_FOUNDATION_OPERATION_RELAY_STATUS);
|
||||
@ -439,7 +439,7 @@ uint8_t mesh_configuration_client_send_relay_set(mesh_model_t * mesh_model, uint
|
||||
if (relay_retransmit_count > 0x07) return ERROR_CODE_PARAMETER_OUT_OF_MANDATORY_RANGE;
|
||||
if (relay_retransmit_interval_steps > 0x1F) return ERROR_CODE_PARAMETER_OUT_OF_MANDATORY_RANGE;
|
||||
|
||||
mesh_message_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_relay_set, relay, (relay_retransmit_count << 5) | relay_retransmit_interval_steps);
|
||||
mesh_segmented_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_relay_set, relay, (relay_retransmit_count << 5) | relay_retransmit_interval_steps);
|
||||
if (!message_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 *) message_pdu, MESH_FOUNDATION_OPERATION_RELAY_SET);
|
||||
@ -450,7 +450,7 @@ uint8_t mesh_configuration_client_send_model_publication_get(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;
|
||||
|
||||
mesh_message_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_model_publication_get, dest, model_id);
|
||||
mesh_segmented_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_model_publication_get, dest, model_id);
|
||||
if (!message_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 *) message_pdu, MESH_FOUNDATION_OPERATION_MODEL_PUBLICATION_STATUS);
|
||||
@ -475,14 +475,14 @@ uint8_t mesh_configuration_client_send_model_publication_set(mesh_model_t * mesh
|
||||
return ERROR_CODE_PARAMETER_OUT_OF_MANDATORY_RANGE;
|
||||
}
|
||||
|
||||
mesh_message_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_model_publication_set,
|
||||
dest,
|
||||
publication_config->publish_address_unicast,
|
||||
mesh_segmented_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_model_publication_set,
|
||||
dest,
|
||||
publication_config->publish_address_unicast,
|
||||
(publication_config->credential_flag << 12) | publication_config->appkey_index,
|
||||
publication_config->publish_ttl,
|
||||
publication_config->publish_period,
|
||||
publication_config->publish_ttl,
|
||||
publication_config->publish_period,
|
||||
(publication_config->publish_retransmit_interval_steps << 3) | publication_config->publish_retransmit_count,
|
||||
model_id);
|
||||
model_id);
|
||||
if (!message_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 *) message_pdu, MESH_FOUNDATION_OPERATION_MODEL_PUBLICATION_STATUS);
|
||||
@ -518,7 +518,7 @@ uint8_t mesh_configuration_client_send_model_subscription_add(mesh_model_t * mes
|
||||
uint8_t status = mesh_access_validate_envelop_params(mesh_model, dest, netkey_index, appkey_index);
|
||||
if (status != ERROR_CODE_SUCCESS) return status;
|
||||
|
||||
mesh_message_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_model_subscription_add, dest, address, model_id);
|
||||
mesh_segmented_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_model_subscription_add, dest, address, model_id);
|
||||
if (!message_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 *) message_pdu, MESH_FOUNDATION_OPERATION_MODEL_SUBSCRIPTION_STATUS);
|
||||
@ -540,7 +540,7 @@ uint8_t mesh_configuration_client_send_model_subscription_delete(mesh_model_t *
|
||||
uint8_t status = mesh_access_validate_envelop_params(mesh_model, dest, netkey_index, appkey_index);
|
||||
if (status != ERROR_CODE_SUCCESS) return status;
|
||||
|
||||
mesh_message_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_model_subscription_delete, dest, address, model_id);
|
||||
mesh_segmented_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_model_subscription_delete, dest, address, model_id);
|
||||
if (!message_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 *) message_pdu, MESH_FOUNDATION_OPERATION_MODEL_SUBSCRIPTION_STATUS);
|
||||
@ -562,7 +562,7 @@ uint8_t mesh_configuration_client_send_model_subscription_overwrite(mesh_model_t
|
||||
uint8_t status = mesh_access_validate_envelop_params(mesh_model, dest, netkey_index, appkey_index);
|
||||
if (status != ERROR_CODE_SUCCESS) return status;
|
||||
|
||||
mesh_message_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_model_subscription_overwrite, dest, address, model_id);
|
||||
mesh_segmented_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_model_subscription_overwrite, dest, address, model_id);
|
||||
if (!message_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 *) message_pdu, MESH_FOUNDATION_OPERATION_MODEL_SUBSCRIPTION_STATUS);
|
||||
@ -584,7 +584,7 @@ uint8_t mesh_configuration_client_send_model_subscription_delete_all(mesh_model_
|
||||
uint8_t status = mesh_access_validate_envelop_params(mesh_model, dest, netkey_index, appkey_index);
|
||||
if (status != ERROR_CODE_SUCCESS) return status;
|
||||
|
||||
mesh_message_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_model_subscription_delete_all, dest, address, model_id);
|
||||
mesh_segmented_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_model_subscription_delete_all, dest, address, model_id);
|
||||
if (!message_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 *) message_pdu, MESH_FOUNDATION_OPERATION_MODEL_SUBSCRIPTION_STATUS);
|
||||
@ -595,7 +595,7 @@ uint8_t mesh_configuration_client_send_model_subscription_get(mesh_model_t * mes
|
||||
uint8_t status = mesh_access_validate_envelop_params(mesh_model, dest, netkey_index, appkey_index);
|
||||
if (status != ERROR_CODE_SUCCESS) return status;
|
||||
|
||||
mesh_message_pdu_t * message_pdu = NULL;
|
||||
mesh_segmented_pdu_t * message_pdu = NULL;
|
||||
uint32_t ack_opcode = MESH_FOUNDATION_OPERATION_SIG_MODEL_SUBSCRIPTION_LIST;
|
||||
|
||||
if (mesh_model_is_bluetooth_sig(model_id)){
|
||||
@ -736,7 +736,7 @@ uint8_t mesh_configuration_client_send_model_app_unbind_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;
|
||||
|
||||
mesh_message_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_model_app_unbind, dest, appk_index, model_identifier);
|
||||
mesh_segmented_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_model_app_unbind, dest, appk_index, model_identifier);
|
||||
if (!message_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 *) message_pdu, MESH_FOUNDATION_OPERATION_MODEL_APP_STATUS);
|
||||
@ -747,7 +747,7 @@ uint8_t mesh_configuration_client_send_model_app_get(mesh_model_t * mesh_model,
|
||||
uint8_t status = mesh_access_validate_envelop_params(mesh_model, dest, netkey_index, appkey_index);
|
||||
if (status != ERROR_CODE_SUCCESS) return status;
|
||||
|
||||
mesh_message_pdu_t * message_pdu;
|
||||
mesh_segmented_pdu_t * message_pdu;
|
||||
uint32_t ack_opcode = MESH_FOUNDATION_OPERATION_SIG_MODEL_APP_LIST;
|
||||
|
||||
if (mesh_model_is_bluetooth_sig(model_identifier)){
|
||||
@ -765,7 +765,7 @@ uint8_t mesh_configuration_client_send_node_reset(mesh_model_t * mesh_model, uin
|
||||
uint8_t status = mesh_access_validate_envelop_params(mesh_model, dest, netkey_index, appkey_index);
|
||||
if (status != ERROR_CODE_SUCCESS) return status;
|
||||
|
||||
mesh_message_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_node_reset);
|
||||
mesh_segmented_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_node_reset);
|
||||
if (message_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 *) message_pdu, MESH_FOUNDATION_OPERATION_NODE_RESET_STATUS);
|
||||
@ -776,7 +776,7 @@ uint8_t mesh_configuration_client_send_friend_get(mesh_model_t * mesh_model, uin
|
||||
uint8_t status = mesh_access_validate_envelop_params(mesh_model, dest, netkey_index, appkey_index);
|
||||
if (status != ERROR_CODE_SUCCESS) return status;
|
||||
|
||||
mesh_message_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_friend_get);
|
||||
mesh_segmented_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_friend_get);
|
||||
if (message_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 *) message_pdu, MESH_FOUNDATION_OPERATION_FRIEND_STATUS);
|
||||
@ -787,7 +787,7 @@ uint8_t mesh_configuration_client_send_friend_set(mesh_model_t * mesh_model, uin
|
||||
uint8_t status = mesh_access_validate_envelop_params(mesh_model, dest, netkey_index, appkey_index);
|
||||
if (status != ERROR_CODE_SUCCESS) return status;
|
||||
|
||||
mesh_message_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_friend_set, friend_state);
|
||||
mesh_segmented_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_friend_set, friend_state);
|
||||
if (message_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 *) message_pdu, MESH_FOUNDATION_OPERATION_FRIEND_STATUS);
|
||||
@ -798,7 +798,7 @@ uint8_t mesh_configuration_client_send_key_refresh_phase_get(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;
|
||||
|
||||
mesh_message_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_key_refresh_phase_get, netk_index);
|
||||
mesh_segmented_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_key_refresh_phase_get, netk_index);
|
||||
if (message_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 *) message_pdu, MESH_FOUNDATION_OPERATION_KEY_REFRESH_PHASE_STATUS);
|
||||
@ -809,7 +809,7 @@ uint8_t mesh_configuration_client_send_key_refresh_phase_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;
|
||||
|
||||
mesh_message_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_key_refresh_phase_set, netk_index, transition);
|
||||
mesh_segmented_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_key_refresh_phase_set, netk_index, transition);
|
||||
if (message_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 *) message_pdu, MESH_FOUNDATION_OPERATION_KEY_REFRESH_PHASE_STATUS);
|
||||
@ -820,7 +820,7 @@ uint8_t mesh_configuration_client_send_heartbeat_publication_get(mesh_model_t *
|
||||
uint8_t status = mesh_access_validate_envelop_params(mesh_model, dest, netkey_index, appkey_index);
|
||||
if (status != ERROR_CODE_SUCCESS) return status;
|
||||
|
||||
mesh_message_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_heartbeat_publication_get);
|
||||
mesh_segmented_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_heartbeat_publication_get);
|
||||
if (message_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 *) message_pdu, MESH_FOUNDATION_OPERATION_HEARTBEAT_PUBLICATION_STATUS);
|
||||
@ -831,13 +831,13 @@ uint8_t mesh_configuration_client_send_heartbeat_publication_set(mesh_model_t *
|
||||
uint8_t status = mesh_access_validate_envelop_params(mesh_model, dest, netkey_index, appkey_index);
|
||||
if (status != ERROR_CODE_SUCCESS) return status;
|
||||
|
||||
mesh_message_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_heartbeat_publication_set,
|
||||
publication_state.destination,
|
||||
mesh_heartbeat_period_log(publication_state.count),
|
||||
mesh_heartbeat_period_log(publication_state.period_s),
|
||||
publication_state.ttl,
|
||||
publication_state.features,
|
||||
publication_state.netkey_index);
|
||||
mesh_segmented_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_heartbeat_publication_set,
|
||||
publication_state.destination,
|
||||
mesh_heartbeat_period_log(publication_state.count),
|
||||
mesh_heartbeat_period_log(publication_state.period_s),
|
||||
publication_state.ttl,
|
||||
publication_state.features,
|
||||
publication_state.netkey_index);
|
||||
|
||||
if (message_pdu) return BTSTACK_MEMORY_ALLOC_FAILED;
|
||||
|
||||
@ -849,7 +849,7 @@ uint8_t mesh_configuration_client_send_heartbeat_subscription_get(mesh_model_t *
|
||||
uint8_t status = mesh_access_validate_envelop_params(mesh_model, dest, netkey_index, appkey_index);
|
||||
if (status != ERROR_CODE_SUCCESS) return status;
|
||||
|
||||
mesh_message_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_heartbeat_subscription_get);
|
||||
mesh_segmented_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_heartbeat_subscription_get);
|
||||
if (message_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 *) message_pdu, MESH_FOUNDATION_OPERATION_HEARTBEAT_SUBSCRIPTION_STATUS);
|
||||
@ -860,7 +860,7 @@ uint8_t mesh_configuration_client_send_heartbeat_subscription_set(mesh_model_t *
|
||||
uint8_t status = mesh_access_validate_envelop_params(mesh_model, dest, netkey_index, appkey_index);
|
||||
if (status != ERROR_CODE_SUCCESS) return status;
|
||||
|
||||
mesh_message_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_heartbeat_subscription_set, heartbeat_source, heartbeat_destination, mesh_heartbeat_period_log(period_s));
|
||||
mesh_segmented_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_heartbeat_subscription_set, heartbeat_source, heartbeat_destination, mesh_heartbeat_period_log(period_s));
|
||||
if (message_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 *) message_pdu, MESH_FOUNDATION_OPERATION_HEARTBEAT_SUBSCRIPTION_STATUS);
|
||||
@ -871,7 +871,7 @@ uint8_t mesh_configuration_client_send_low_power_node_poll_timeout_get(mesh_mode
|
||||
uint8_t status = mesh_access_validate_envelop_params(mesh_model, dest, netkey_index, appkey_index);
|
||||
if (status != ERROR_CODE_SUCCESS) return status;
|
||||
|
||||
mesh_message_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_low_power_node_poll_timeout_get);
|
||||
mesh_segmented_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_client_low_power_node_poll_timeout_get);
|
||||
if (message_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 *) message_pdu, MESH_FOUNDATION_OPERATION_LOW_POWER_NODE_POLL_TIMEOUT_STATUS);
|
||||
@ -882,7 +882,7 @@ uint8_t mesh_configuration_client_send_network_transmit_get(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;
|
||||
|
||||
mesh_message_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_network_transmit_get);
|
||||
mesh_segmented_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_network_transmit_get);
|
||||
if (message_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 *) message_pdu, MESH_FOUNDATION_OPERATION_NETWORK_TRANSMIT_STATUS);
|
||||
@ -898,7 +898,7 @@ uint8_t mesh_configuration_client_send_network_transmit_set(mesh_model_t * mesh_
|
||||
transmit_interval_steps_10ms -= 1;
|
||||
}
|
||||
|
||||
mesh_message_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_network_transmit_set, (transmit_count << 5) | (transmit_interval_steps_10ms & 0x1F));
|
||||
mesh_segmented_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_configuration_network_transmit_set, (transmit_count << 5) | (transmit_interval_steps_10ms & 0x1F));
|
||||
if (message_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 *) message_pdu, MESH_FOUNDATION_OPERATION_NETWORK_TRANSMIT_STATUS);
|
||||
|
@ -108,19 +108,19 @@ const mesh_access_message_t mesh_foundation_health_attention_status = {
|
||||
static mesh_pdu_t * health_period_status(mesh_model_t * mesh_model){
|
||||
mesh_health_state_t * state = (mesh_health_state_t *) mesh_model->model_data;
|
||||
// setup message
|
||||
mesh_message_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_foundation_health_period_status, state->fast_period_divisor);
|
||||
mesh_segmented_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_foundation_health_period_status, state->fast_period_divisor);
|
||||
return (mesh_pdu_t *) message_pdu;
|
||||
}
|
||||
|
||||
static mesh_pdu_t * health_attention_status(void){
|
||||
// setup message
|
||||
mesh_message_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_foundation_health_attention_status, mesh_attention_timer_get());
|
||||
mesh_segmented_pdu_t * message_pdu = mesh_access_setup_message(false, &mesh_foundation_health_attention_status, mesh_attention_timer_get());
|
||||
return (mesh_pdu_t *) message_pdu;
|
||||
}
|
||||
|
||||
// report fault status - used for both current as well as registered faults, see registered_faults param
|
||||
static mesh_pdu_t * health_fault_status(mesh_model_t * mesh_model, uint32_t opcode, uint16_t company_id, bool registered_faults){
|
||||
mesh_message_pdu_t * message_pdu = mesh_access_message_init(opcode, false, 1);
|
||||
mesh_segmented_pdu_t * message_pdu = mesh_access_message_init(opcode, false, 1);
|
||||
if (!message_pdu) return NULL;
|
||||
|
||||
mesh_health_fault_t * fault = mesh_health_server_fault_for_company_id(mesh_model, company_id);
|
||||
|
@ -65,23 +65,23 @@ static void mesh_print_hex(const char * name, const uint8_t * data, uint16_t len
|
||||
|
||||
// utility
|
||||
|
||||
mesh_message_pdu_t * mesh_message_pdu_get(void){
|
||||
mesh_message_pdu_t * message_pdu = btstack_memory_mesh_message_pdu_get();
|
||||
mesh_segmented_pdu_t * mesh_message_pdu_get(void){
|
||||
mesh_segmented_pdu_t * message_pdu = btstack_memory_mesh_segmented_pdu_get();
|
||||
if (message_pdu){
|
||||
message_pdu->pdu_header.pdu_type = MESH_PDU_TYPE_MESSAGE;
|
||||
message_pdu->pdu_header.pdu_type = MESH_PDU_TYPE_SEGMENTED;
|
||||
}
|
||||
return message_pdu;
|
||||
}
|
||||
|
||||
void mesh_message_pdu_free(mesh_message_pdu_t * message_pdu){
|
||||
void mesh_message_pdu_free(mesh_segmented_pdu_t * message_pdu){
|
||||
while (message_pdu->segments){
|
||||
mesh_network_pdu_t * segment = (mesh_network_pdu_t *) btstack_linked_list_pop(&message_pdu->segments);
|
||||
mesh_network_pdu_free(segment);
|
||||
}
|
||||
btstack_memory_mesh_message_pdu_free(message_pdu);
|
||||
btstack_memory_mesh_segmented_pdu_free(message_pdu);
|
||||
}
|
||||
|
||||
static void mesh_lower_transport_report_segments_as_processed(mesh_message_pdu_t * message_pdu) {
|
||||
static void mesh_lower_transport_report_segments_as_processed(mesh_segmented_pdu_t * message_pdu) {
|
||||
while (message_pdu->segments){
|
||||
mesh_network_pdu_t * segment = (mesh_network_pdu_t *) btstack_linked_list_pop(&message_pdu->segments);
|
||||
mesh_network_message_processed_by_higher_layer(segment);
|
||||
@ -127,25 +127,25 @@ void mesh_transport_set_dest(mesh_transport_pdu_t * transport_pdu, uint16_t dest
|
||||
big_endian_store_16(transport_pdu->network_header, 7, dest);
|
||||
}
|
||||
|
||||
uint16_t mesh_message_nid(mesh_message_pdu_t * message_pdu){
|
||||
uint16_t mesh_message_nid(mesh_segmented_pdu_t * message_pdu){
|
||||
return message_pdu->network_header[0] & 0x7f;
|
||||
}
|
||||
uint16_t mesh_message_ctl(mesh_message_pdu_t * message_pdu){
|
||||
uint16_t mesh_message_ctl(mesh_segmented_pdu_t * message_pdu){
|
||||
return message_pdu->network_header[1] >> 7;
|
||||
}
|
||||
static uint16_t mesh_message_ttl(mesh_message_pdu_t * message_pdu){
|
||||
static uint16_t mesh_message_ttl(mesh_segmented_pdu_t * message_pdu){
|
||||
return message_pdu->network_header[1] & 0x7f;
|
||||
}
|
||||
static uint32_t mesh_message_seq(mesh_message_pdu_t * message_pdu){
|
||||
static uint32_t mesh_message_seq(mesh_segmented_pdu_t * message_pdu){
|
||||
return big_endian_read_24(message_pdu->network_header, 2);
|
||||
}
|
||||
static uint16_t mesh_message_src(mesh_message_pdu_t * message_pdu){
|
||||
static uint16_t mesh_message_src(mesh_segmented_pdu_t * message_pdu){
|
||||
return big_endian_read_16(message_pdu->network_header, 5);
|
||||
}
|
||||
static uint16_t mesh_message_dest(mesh_message_pdu_t * message_pdu){
|
||||
static uint16_t mesh_message_dest(mesh_segmented_pdu_t * message_pdu){
|
||||
return big_endian_read_16(message_pdu->network_header, 7);
|
||||
}
|
||||
static uint32_t mesh_message_seq_zero(mesh_message_pdu_t * message_pdu){
|
||||
static uint32_t mesh_message_seq_zero(mesh_segmented_pdu_t * message_pdu){
|
||||
return message_pdu->seq_zero;
|
||||
}
|
||||
|
||||
@ -167,9 +167,9 @@ static btstack_linked_list_t lower_transport_outgoing;
|
||||
static mesh_network_pdu_t * lower_transport_outgoing_segment;
|
||||
static uint16_t lower_transport_outgoing_seg_o;
|
||||
|
||||
static mesh_message_pdu_t lower_transport_outgoing_segmented_message_singleton;
|
||||
static mesh_segmented_pdu_t lower_transport_outgoing_segmented_message_singleton;
|
||||
|
||||
static mesh_message_pdu_t * lower_transport_outgoing_message;
|
||||
static mesh_segmented_pdu_t * lower_transport_outgoing_message;
|
||||
|
||||
static mesh_unsegmented_pdu_t * lower_transport_outgoing_unsegmented_pdu;
|
||||
|
||||
@ -319,7 +319,7 @@ static void mesh_lower_transport_send_ack(uint16_t netkey_index, uint8_t ttl, ui
|
||||
mesh_network_send_pdu(network_pdu);
|
||||
}
|
||||
|
||||
static void mesh_lower_transport_send_ack_for_transport_pdu(mesh_message_pdu_t * message_pdu){
|
||||
static void mesh_lower_transport_send_ack_for_transport_pdu(mesh_segmented_pdu_t * message_pdu){
|
||||
uint16_t seq_zero = mesh_message_seq_zero(message_pdu);
|
||||
uint8_t ttl = mesh_message_ttl(message_pdu);
|
||||
uint16_t dest = mesh_message_src(message_pdu);
|
||||
@ -342,32 +342,32 @@ static void mesh_lower_transport_send_ack_for_network_pdu(mesh_network_pdu_t *ne
|
||||
mesh_lower_transport_send_ack(netkey_index, ttl, dest, seq_zero, block_ack);
|
||||
}
|
||||
|
||||
static void mesh_lower_transport_incoming_stop_acknowledgment_timer(mesh_message_pdu_t *message_pdu){
|
||||
static void mesh_lower_transport_incoming_stop_acknowledgment_timer(mesh_segmented_pdu_t *message_pdu){
|
||||
if (!message_pdu->acknowledgement_timer_active) return;
|
||||
message_pdu->acknowledgement_timer_active = 0;
|
||||
btstack_run_loop_remove_timer(&message_pdu->acknowledgement_timer);
|
||||
}
|
||||
|
||||
static void mesh_lower_transport_incoming_stop_incomplete_timer(mesh_message_pdu_t *message_pdu){
|
||||
static void mesh_lower_transport_incoming_stop_incomplete_timer(mesh_segmented_pdu_t *message_pdu){
|
||||
if (!message_pdu->incomplete_timer_active) return;
|
||||
message_pdu->incomplete_timer_active = 0;
|
||||
btstack_run_loop_remove_timer(&message_pdu->incomplete_timer);
|
||||
}
|
||||
|
||||
static void mesh_lower_transport_outgoing_stop_acknowledgment_timer(mesh_message_pdu_t *message_pdu){
|
||||
static void mesh_lower_transport_outgoing_stop_acknowledgment_timer(mesh_segmented_pdu_t *message_pdu){
|
||||
if (!message_pdu->acknowledgement_timer_active) return;
|
||||
message_pdu->acknowledgement_timer_active = 0;
|
||||
btstack_run_loop_remove_timer(&message_pdu->acknowledgement_timer);
|
||||
}
|
||||
|
||||
static void mesh_lower_transport_outgoing_stop_incomplete_timer(mesh_message_pdu_t *message_pdu){
|
||||
static void mesh_lower_transport_outgoing_stop_incomplete_timer(mesh_segmented_pdu_t *message_pdu){
|
||||
if (!message_pdu->incomplete_timer_active) return;
|
||||
message_pdu->incomplete_timer_active = 0;
|
||||
btstack_run_loop_remove_timer(&message_pdu->incomplete_timer);
|
||||
}
|
||||
|
||||
// stops timers and updates reassembly engine
|
||||
static void mesh_lower_transport_rx_segmented_message_complete(mesh_message_pdu_t * message_pdu){
|
||||
static void mesh_lower_transport_rx_segmented_message_complete(mesh_segmented_pdu_t * message_pdu){
|
||||
// set flag
|
||||
message_pdu->message_complete = 1;
|
||||
// stop timers
|
||||
@ -381,7 +381,7 @@ static void mesh_lower_transport_rx_segmented_message_complete(mesh_message_pdu_
|
||||
}
|
||||
|
||||
static void mesh_lower_transport_rx_ack_timeout(btstack_timer_source_t *ts){
|
||||
mesh_message_pdu_t * message_pdu = (mesh_message_pdu_t *) btstack_run_loop_get_timer_context(ts);
|
||||
mesh_segmented_pdu_t * message_pdu = (mesh_segmented_pdu_t *) btstack_run_loop_get_timer_context(ts);
|
||||
#ifdef LOG_LOWER_TRANSPORT
|
||||
printf("ACK: acknowledgement timer fired for %p, send ACK\n", message_pdu);
|
||||
#endif
|
||||
@ -390,7 +390,7 @@ static void mesh_lower_transport_rx_ack_timeout(btstack_timer_source_t *ts){
|
||||
}
|
||||
|
||||
static void mesh_lower_transport_rx_incomplete_timeout(btstack_timer_source_t *ts){
|
||||
mesh_message_pdu_t * message_pdu = (mesh_message_pdu_t *) btstack_run_loop_get_timer_context(ts);
|
||||
mesh_segmented_pdu_t * message_pdu = (mesh_segmented_pdu_t *) btstack_run_loop_get_timer_context(ts);
|
||||
#ifdef LOG_LOWER_TRANSPORT
|
||||
printf("mesh_transport_rx_incomplete_timeout for %p - give up\n", message_pdu);
|
||||
#endif
|
||||
@ -398,10 +398,10 @@ static void mesh_lower_transport_rx_incomplete_timeout(btstack_timer_source_t *t
|
||||
// free segments
|
||||
mesh_lower_transport_report_segments_as_processed(message_pdu);
|
||||
// free message
|
||||
btstack_memory_mesh_message_pdu_free(message_pdu);
|
||||
btstack_memory_mesh_segmented_pdu_free(message_pdu);
|
||||
}
|
||||
|
||||
static void mesh_lower_transport_start_rx_acknowledgment_timer(mesh_message_pdu_t * message_pdu, uint32_t timeout){
|
||||
static void mesh_lower_transport_start_rx_acknowledgment_timer(mesh_segmented_pdu_t * message_pdu, uint32_t timeout){
|
||||
#ifdef LOG_LOWER_TRANSPORT
|
||||
printf("ACK: start rx ack timer for %p, timeout %u ms\n", message_pdu, (int) timeout);
|
||||
#endif
|
||||
@ -430,8 +430,8 @@ static void mesh_lower_transport_tx_restart_segment_transmission_timer(void){
|
||||
lower_transport_outgoing_message->acknowledgement_timer_active = 1;
|
||||
}
|
||||
|
||||
static void mesh_lower_transport_incoming_restart_incomplete_timer(mesh_message_pdu_t * message_pdu, uint32_t timeout,
|
||||
void (*callback)(btstack_timer_source_t *ts)){
|
||||
static void mesh_lower_transport_incoming_restart_incomplete_timer(mesh_segmented_pdu_t * message_pdu, uint32_t timeout,
|
||||
void (*callback)(btstack_timer_source_t *ts)){
|
||||
#ifdef LOG_LOWER_TRANSPORT
|
||||
printf("RX-(re)start incomplete timer for %p, timeout %u ms\n", message_pdu, (int) timeout);
|
||||
#endif
|
||||
@ -458,12 +458,12 @@ static void mesh_lower_transport_outgoing_complete(void){
|
||||
lower_transport_outgoing_message = NULL;
|
||||
|
||||
// notify upper transport
|
||||
mesh_message_pdu_t * pdu = lower_transport_outgoing_message;
|
||||
mesh_segmented_pdu_t * pdu = lower_transport_outgoing_message;
|
||||
lower_transport_outgoing_message = NULL;
|
||||
higher_layer_handler(MESH_TRANSPORT_PDU_SENT, MESH_TRANSPORT_STATUS_SEND_ABORT_BY_REMOTE, (mesh_pdu_t *) pdu);
|
||||
}
|
||||
|
||||
static mesh_message_pdu_t * mesh_lower_transport_pdu_for_segmented_message(mesh_network_pdu_t *network_pdu){
|
||||
static mesh_segmented_pdu_t * mesh_lower_transport_pdu_for_segmented_message(mesh_network_pdu_t *network_pdu){
|
||||
uint16_t src = mesh_network_src(network_pdu);
|
||||
uint16_t seq_zero = ( big_endian_read_16(mesh_network_pdu_data(network_pdu), 1) >> 2) & 0x1fff;
|
||||
#ifdef LOG_LOWER_TRANSPORT
|
||||
@ -513,7 +513,7 @@ static mesh_message_pdu_t * mesh_lower_transport_pdu_for_segmented_message(mesh_
|
||||
|
||||
// no transport pdu active, check new message: seq auth is greater OR seq auth is same but no segments
|
||||
if (seq_auth > peer->seq_auth || (seq_auth == peer->seq_auth && peer->block_ack == 0)){
|
||||
mesh_message_pdu_t * pdu = mesh_message_pdu_get();
|
||||
mesh_segmented_pdu_t * pdu = mesh_message_pdu_get();
|
||||
if (!pdu) return NULL;
|
||||
|
||||
// cache network pdu header
|
||||
@ -547,7 +547,7 @@ static mesh_message_pdu_t * mesh_lower_transport_pdu_for_segmented_message(mesh_
|
||||
}
|
||||
}
|
||||
|
||||
static void mesh_lower_transport_process_segment( mesh_message_pdu_t * message_pdu, mesh_network_pdu_t * network_pdu){
|
||||
static void mesh_lower_transport_process_segment(mesh_segmented_pdu_t * message_pdu, mesh_network_pdu_t * network_pdu){
|
||||
|
||||
uint8_t * lower_transport_pdu = mesh_network_pdu_data(network_pdu);
|
||||
uint8_t lower_transport_pdu_len = mesh_network_pdu_len(network_pdu);
|
||||
@ -615,7 +615,7 @@ static void mesh_lower_transport_process_segment( mesh_message_pdu_t * message_p
|
||||
|
||||
static void mesh_lower_transport_process_network_pdu(mesh_network_pdu_t *network_pdu) {// segmented?
|
||||
if (mesh_network_segmented(network_pdu)){
|
||||
mesh_message_pdu_t * message_pdu = mesh_lower_transport_pdu_for_segmented_message(network_pdu);
|
||||
mesh_segmented_pdu_t * message_pdu = mesh_lower_transport_pdu_for_segmented_message(network_pdu);
|
||||
if (message_pdu) {
|
||||
// start acknowledgment timer if inactive
|
||||
if (message_pdu->acknowledgement_timer_active == 0){
|
||||
@ -647,10 +647,10 @@ void mesh_lower_transport_message_processed_by_higher_layer(mesh_pdu_t * pdu){
|
||||
mesh_unsegmented_pdu_t * unsegmented_incoming_pdu = (mesh_unsegmented_pdu_t *) pdu;
|
||||
mesh_network_pdu_t * network_pdu;
|
||||
switch (pdu->pdu_type){
|
||||
case MESH_PDU_TYPE_MESSAGE:
|
||||
case MESH_PDU_TYPE_SEGMENTED:
|
||||
// free segments
|
||||
mesh_lower_transport_report_segments_as_processed((mesh_message_pdu_t *) pdu);
|
||||
mesh_message_pdu_free((mesh_message_pdu_t *) pdu);
|
||||
mesh_lower_transport_report_segments_as_processed((mesh_segmented_pdu_t *) pdu);
|
||||
mesh_message_pdu_free((mesh_segmented_pdu_t *) pdu);
|
||||
break;
|
||||
case MESH_PDU_TYPE_UNSEGMENTED:
|
||||
network_pdu = unsegmented_incoming_pdu->segment;
|
||||
@ -699,7 +699,7 @@ void mesh_lower_transport_received_message(mesh_network_callback_type_t callback
|
||||
}
|
||||
}
|
||||
|
||||
static void mesh_lower_transport_setup_segment(mesh_message_pdu_t *message_pdu, uint8_t seg_o, mesh_network_pdu_t *network_pdu){
|
||||
static void mesh_lower_transport_setup_segment(mesh_segmented_pdu_t *message_pdu, uint8_t seg_o, mesh_network_pdu_t *network_pdu){
|
||||
|
||||
int ctl = mesh_message_ctl(message_pdu);
|
||||
uint16_t max_segment_len = ctl ? 8 : 12; // control 8 bytes (64 bit NetMic), access 12 bytes (32 bit NetMIC)
|
||||
@ -890,7 +890,7 @@ static void mesh_lower_transport_network_pdu_sent(mesh_network_pdu_t *network_pd
|
||||
higher_layer_handler(MESH_TRANSPORT_PDU_SENT, MESH_TRANSPORT_STATUS_SUCCESS, (mesh_pdu_t *) network_pdu);
|
||||
}
|
||||
|
||||
static void mesh_lower_transport_setup_block_ack(mesh_message_pdu_t *message_pdu){
|
||||
static void mesh_lower_transport_setup_block_ack(mesh_segmented_pdu_t *message_pdu){
|
||||
// setup block ack - set bit for segment to send, will be cleared on ack
|
||||
int ctl = mesh_message_ctl(message_pdu);
|
||||
uint16_t max_segment_len = ctl ? 8 : 12; // control 8 bytes (64 bit NetMic), access 12 bytes (32 bit NetMIC)
|
||||
@ -911,7 +911,7 @@ void mesh_lower_transport_send_pdu(mesh_pdu_t *pdu){
|
||||
network_pdu = unsegmented_pdu->segment;
|
||||
btstack_assert(network_pdu->len >= 9);
|
||||
break;
|
||||
case MESH_PDU_TYPE_MESSAGE:
|
||||
case MESH_PDU_TYPE_SEGMENTED:
|
||||
break;
|
||||
default:
|
||||
btstack_assert(false);
|
||||
@ -943,7 +943,7 @@ static void mesh_lower_transport_run(void){
|
||||
while(!btstack_linked_list_empty(&lower_transport_outgoing)) {
|
||||
// get next message
|
||||
mesh_network_pdu_t * network_pdu;
|
||||
mesh_message_pdu_t * message_pdu;
|
||||
mesh_segmented_pdu_t * message_pdu;
|
||||
mesh_pdu_t * pdu = (mesh_pdu_t *) btstack_linked_list_pop(&lower_transport_outgoing);
|
||||
switch (pdu->pdu_type) {
|
||||
case MESH_PDU_TYPE_UNSEGMENTED:
|
||||
@ -951,8 +951,8 @@ static void mesh_lower_transport_run(void){
|
||||
network_pdu = lower_transport_outgoing_unsegmented_pdu->segment;
|
||||
mesh_network_send_pdu(network_pdu);
|
||||
break;
|
||||
case MESH_PDU_TYPE_MESSAGE:
|
||||
message_pdu = (mesh_message_pdu_t *) pdu;
|
||||
case MESH_PDU_TYPE_SEGMENTED:
|
||||
message_pdu = (mesh_segmented_pdu_t *) pdu;
|
||||
//
|
||||
printf("[+] Lower transport, segmented pdu %p, seq %06x: run start sending now\n", message_pdu, mesh_message_seq(message_pdu));
|
||||
// start sending segmented pdu
|
||||
|
@ -79,8 +79,8 @@ typedef enum {
|
||||
mesh_transport_pdu_t * mesh_transport_pdu_get(void);
|
||||
void mesh_transport_pdu_free(mesh_transport_pdu_t * transport_pdu);
|
||||
|
||||
mesh_message_pdu_t * mesh_message_pdu_get(void);
|
||||
void mesh_message_pdu_free(mesh_message_pdu_t * message_pdu);
|
||||
mesh_segmented_pdu_t * mesh_message_pdu_get(void);
|
||||
void mesh_message_pdu_free(mesh_segmented_pdu_t * message_pdu);
|
||||
|
||||
// transport getter/setter
|
||||
uint16_t mesh_transport_nid(mesh_transport_pdu_t * transport_pdu);
|
||||
@ -98,7 +98,7 @@ void mesh_transport_set_seq(mesh_transport_pdu_t * transport_pdu, uint32_t seq);
|
||||
void mesh_transport_set_src(mesh_transport_pdu_t * transport_pdu, uint16_t src);
|
||||
void mesh_transport_set_dest(mesh_transport_pdu_t * transport_pdu, uint16_t dest);
|
||||
|
||||
uint16_t mesh_message_ctl(mesh_message_pdu_t * message_pdu);
|
||||
uint16_t mesh_message_ctl(mesh_segmented_pdu_t * message_pdu);
|
||||
|
||||
void mesh_lower_transport_init(void);
|
||||
void mesh_lower_transport_set_higher_layer_handler(void (*pdu_handler)( mesh_transport_callback_type_t callback_type, mesh_transport_status_t status, mesh_pdu_t * pdu));
|
||||
|
@ -69,7 +69,7 @@ typedef enum {
|
||||
typedef enum {
|
||||
MESH_PDU_TYPE_NETWORK = 0,
|
||||
MESH_PDU_TYPE_TRANSPORT,
|
||||
MESH_PDU_TYPE_MESSAGE,
|
||||
MESH_PDU_TYPE_SEGMENTED,
|
||||
MESH_PDU_TYPE_UNSEGMENTED,
|
||||
MESH_PDU_TYPE_ACCESS,
|
||||
} mesh_pdu_type_t;
|
||||
@ -131,6 +131,17 @@ typedef struct {
|
||||
uint8_t data[MESH_ACCESS_PAYLOAD_MAX];
|
||||
} mesh_transport_pdu_t;
|
||||
|
||||
typedef struct {
|
||||
// generic pdu header
|
||||
mesh_pdu_t pdu_header;
|
||||
// meta data transport layer
|
||||
uint16_t appkey_index;
|
||||
// MESH_TRANSPORT_FLAG
|
||||
uint16_t flags;
|
||||
// pdu segment
|
||||
mesh_network_pdu_t * segment;
|
||||
} mesh_unsegmented_pdu_t;
|
||||
|
||||
typedef struct {
|
||||
mesh_pdu_t pdu_header;
|
||||
|
||||
@ -168,18 +179,7 @@ typedef struct {
|
||||
// pdu segments
|
||||
uint16_t len;
|
||||
btstack_linked_list_t segments;
|
||||
} mesh_message_pdu_t;
|
||||
|
||||
typedef struct {
|
||||
// generic pdu header
|
||||
mesh_pdu_t pdu_header;
|
||||
// meta data transport layer
|
||||
uint16_t appkey_index;
|
||||
// MESH_TRANSPORT_FLAG
|
||||
uint16_t flags;
|
||||
// pdu segment
|
||||
mesh_network_pdu_t * segment;
|
||||
} mesh_unsegmented_pdu_t;
|
||||
} mesh_segmented_pdu_t;
|
||||
|
||||
typedef struct {
|
||||
// generic pdu header
|
||||
|
@ -52,7 +52,7 @@ typedef struct {
|
||||
uint32_t seq;
|
||||
|
||||
// segmented transport message
|
||||
mesh_message_pdu_t * message_pdu;
|
||||
mesh_segmented_pdu_t * message_pdu;
|
||||
// seq_zero
|
||||
uint16_t seq_zero;
|
||||
// seq_auth
|
||||
|
@ -82,7 +82,7 @@ static int crypto_active;
|
||||
static mesh_unsegmented_pdu_t * incoming_unsegmented_pdu_raw;
|
||||
static mesh_network_pdu_t * incoming_network_pdu_decoded;
|
||||
|
||||
static mesh_message_pdu_t incoming_message_pdu_singleton;
|
||||
static mesh_segmented_pdu_t incoming_message_pdu_singleton;
|
||||
|
||||
static mesh_access_pdu_t * incoming_access_pdu_encrypted;
|
||||
static mesh_access_pdu_t * incoming_access_pdu_decrypted;
|
||||
@ -90,7 +90,7 @@ static mesh_access_pdu_t * incoming_access_pdu_decrypted;
|
||||
static mesh_access_pdu_t incoming_access_pdu_encrypted_singleton;
|
||||
static mesh_access_pdu_t incoming_access_pdu_decrypted_singleton;
|
||||
|
||||
static mesh_message_pdu_t outgoing_segmented_message_singleton;
|
||||
static mesh_segmented_pdu_t outgoing_segmented_message_singleton;
|
||||
static mesh_transport_pdu_t * outgoing_segmented_pdu;
|
||||
static mesh_unsegmented_pdu_t outgoing_unsegmented_pdu;
|
||||
|
||||
@ -306,7 +306,7 @@ static void mesh_upper_unsegmented_control_message_received(mesh_unsegmented_pdu
|
||||
}
|
||||
}
|
||||
|
||||
static void mesh_upper_transport_process_message_done(mesh_message_pdu_t *message_pdu){
|
||||
static void mesh_upper_transport_process_message_done(mesh_segmented_pdu_t *message_pdu){
|
||||
crypto_active = 0;
|
||||
btstack_assert(message_pdu == &incoming_message_pdu_singleton);
|
||||
mesh_network_pdu_t * network_pdu = (mesh_network_pdu_t *) btstack_linked_list_pop(&incoming_message_pdu_singleton.segments);
|
||||
@ -608,7 +608,7 @@ static void mesh_upper_transport_pdu_handler(mesh_transport_callback_type_t call
|
||||
break;
|
||||
case MESH_TRANSPORT_PDU_SENT:
|
||||
switch (pdu->pdu_type){
|
||||
case MESH_PDU_TYPE_MESSAGE:
|
||||
case MESH_PDU_TYPE_SEGMENTED:
|
||||
// free chunks
|
||||
while (!btstack_linked_list_empty(&outgoing_segmented_message_singleton.segments)){
|
||||
mesh_network_pdu_t * network_pdu = (mesh_network_pdu_t *) btstack_linked_list_pop(&outgoing_segmented_message_singleton.segments);
|
||||
@ -664,10 +664,10 @@ static void mesh_upper_transport_send_unsegmented_access_pdu_ccm(void * arg){
|
||||
|
||||
static void mesh_upper_transport_send_segmented_pdu(mesh_transport_pdu_t * transport_pdu){
|
||||
outgoing_segmented_pdu = transport_pdu;
|
||||
mesh_message_pdu_t * message_pdu = &outgoing_segmented_message_singleton;
|
||||
message_pdu->pdu_header.pdu_type = MESH_PDU_TYPE_MESSAGE;
|
||||
mesh_segmented_pdu_t * message_pdu = &outgoing_segmented_message_singleton;
|
||||
message_pdu->pdu_header.pdu_type = MESH_PDU_TYPE_SEGMENTED;
|
||||
|
||||
// convert mesh_transport_pdu_t into mesh_message_pdu_t
|
||||
// convert mesh_transport_pdu_t into mesh_segmented_pdu_t
|
||||
uint16_t message_offset = 0;
|
||||
uint16_t bytes_current_segment = 0;
|
||||
mesh_network_pdu_t * network_pdu = NULL;
|
||||
@ -755,7 +755,7 @@ uint8_t mesh_upper_transport_setup_control_pdu(mesh_pdu_t * pdu, uint16_t netkey
|
||||
return mesh_upper_transport_setup_unsegmented_control_pdu((mesh_network_pdu_t *) pdu, netkey_index, ttl, src, dest, opcode, control_pdu_data, control_pdu_len);
|
||||
case MESH_PDU_TYPE_TRANSPORT:
|
||||
return mesh_upper_transport_setup_segmented_control_pdu((mesh_transport_pdu_t *) pdu, netkey_index, ttl, src, dest, opcode, control_pdu_data, control_pdu_len);
|
||||
case MESH_PDU_TYPE_MESSAGE:
|
||||
case MESH_PDU_TYPE_SEGMENTED:
|
||||
btstack_assert(0);
|
||||
break;
|
||||
default:
|
||||
@ -1087,7 +1087,7 @@ static void mesh_upper_transport_run(void){
|
||||
mesh_pdu_t * pdu = (mesh_pdu_t *) btstack_linked_list_get_first_item(&upper_transport_incoming);
|
||||
mesh_network_pdu_t * network_pdu;
|
||||
mesh_transport_pdu_t * transport_pdu;
|
||||
mesh_message_pdu_t * message_pdu;
|
||||
mesh_segmented_pdu_t * message_pdu;
|
||||
mesh_unsegmented_pdu_t * unsegmented_pdu;
|
||||
switch (pdu->pdu_type){
|
||||
case MESH_PDU_TYPE_UNSEGMENTED:
|
||||
@ -1107,13 +1107,13 @@ static void mesh_upper_transport_run(void){
|
||||
(void) btstack_linked_list_pop(&upper_transport_incoming);
|
||||
|
||||
// use pre-allocated message pdu
|
||||
incoming_message_pdu_singleton.pdu_header.pdu_type = MESH_PDU_TYPE_MESSAGE;
|
||||
incoming_message_pdu_singleton.pdu_header.pdu_type = MESH_PDU_TYPE_SEGMENTED;
|
||||
btstack_linked_list_add(&incoming_message_pdu_singleton.segments, (btstack_linked_item_t *) incoming_network_pdu_decoded);
|
||||
mesh_upper_transport_process_unsegmented_access_message();
|
||||
}
|
||||
break;
|
||||
case MESH_PDU_TYPE_MESSAGE:
|
||||
message_pdu = (mesh_message_pdu_t *) pdu;
|
||||
case MESH_PDU_TYPE_SEGMENTED:
|
||||
message_pdu = (mesh_segmented_pdu_t *) pdu;
|
||||
uint8_t ctl = mesh_message_ctl(message_pdu);
|
||||
if (ctl){
|
||||
printf("Ignoring Segmented Control Message\n");
|
||||
@ -1184,7 +1184,7 @@ static void mesh_upper_transport_run(void){
|
||||
case MESH_PDU_TYPE_NETWORK:
|
||||
mesh_upper_transport_send_unsegmented_control_pdu((mesh_network_pdu_t *) pdu);
|
||||
break;
|
||||
case MESH_PDU_TYPE_MESSAGE:
|
||||
case MESH_PDU_TYPE_SEGMENTED:
|
||||
btstack_assert(0);
|
||||
break;
|
||||
case MESH_PDU_TYPE_TRANSPORT:
|
||||
@ -1214,7 +1214,7 @@ static void mesh_upper_transport_run(void){
|
||||
void mesh_upper_transport_pdu_free(mesh_pdu_t * pdu){
|
||||
mesh_network_pdu_t * network_pdu;
|
||||
mesh_transport_pdu_t * transport_pdu;
|
||||
mesh_message_pdu_t * message_pdu;
|
||||
mesh_segmented_pdu_t * message_pdu;
|
||||
switch (pdu->pdu_type) {
|
||||
case MESH_PDU_TYPE_NETWORK:
|
||||
network_pdu = (mesh_network_pdu_t *) pdu;
|
||||
@ -1224,8 +1224,8 @@ void mesh_upper_transport_pdu_free(mesh_pdu_t * pdu){
|
||||
transport_pdu = (mesh_transport_pdu_t *) pdu;
|
||||
mesh_transport_pdu_free(transport_pdu);
|
||||
break;
|
||||
case MESH_PDU_TYPE_MESSAGE:
|
||||
message_pdu = (mesh_message_pdu_t *) pdu;
|
||||
case MESH_PDU_TYPE_SEGMENTED:
|
||||
message_pdu = (mesh_segmented_pdu_t *) pdu;
|
||||
mesh_message_pdu_free(message_pdu);
|
||||
default:
|
||||
break;
|
||||
@ -1238,8 +1238,8 @@ void mesh_upper_transport_message_processed_by_higher_layer(mesh_pdu_t * pdu){
|
||||
case MESH_PDU_TYPE_ACCESS:
|
||||
mesh_upper_transport_process_segmented_access_message_done((mesh_access_pdu_t *) pdu);
|
||||
break;
|
||||
case MESH_PDU_TYPE_MESSAGE:
|
||||
mesh_upper_transport_process_message_done((mesh_message_pdu_t *) pdu);
|
||||
case MESH_PDU_TYPE_SEGMENTED:
|
||||
mesh_upper_transport_process_message_done((mesh_segmented_pdu_t *) pdu);
|
||||
break;
|
||||
case MESH_PDU_TYPE_UNSEGMENTED:
|
||||
mesh_upper_transport_process_unsegmented_message_done(pdu);
|
||||
|
@ -261,7 +261,7 @@ static void test_proxy_server_callback_handler(mesh_network_callback_type_t call
|
||||
static void test_upper_transport_access_message_handler(mesh_pdu_t * pdu){
|
||||
mesh_access_pdu_t * access_pdu;
|
||||
mesh_network_pdu_t * network_pdu;
|
||||
mesh_message_pdu_t * message_pdu;
|
||||
mesh_segmented_pdu_t * message_pdu;
|
||||
switch(pdu->pdu_type){
|
||||
case MESH_PDU_TYPE_ACCESS:
|
||||
access_pdu = (mesh_access_pdu_t *) pdu;
|
||||
@ -270,9 +270,9 @@ static void test_upper_transport_access_message_handler(mesh_pdu_t * pdu){
|
||||
memcpy(recv_upper_transport_pdu_data, access_pdu->data, recv_upper_transport_pdu_len);
|
||||
mesh_upper_transport_message_processed_by_higher_layer(pdu);
|
||||
break;
|
||||
case MESH_PDU_TYPE_MESSAGE:
|
||||
message_pdu = (mesh_message_pdu_t *) pdu;
|
||||
printf("test access handler MESH_PDU_TYPE_MESSAGE received\n");
|
||||
case MESH_PDU_TYPE_SEGMENTED:
|
||||
message_pdu = (mesh_segmented_pdu_t *) pdu;
|
||||
printf("test access handler MESH_PDU_TYPE_SEGMENTED received\n");
|
||||
network_pdu = (mesh_network_pdu_t *) btstack_linked_list_get_first_item(&message_pdu->segments);
|
||||
recv_upper_transport_pdu_len = mesh_network_pdu_len(network_pdu) - 1;
|
||||
memcpy(recv_upper_transport_pdu_data, mesh_network_pdu_data(network_pdu) + 1, recv_upper_transport_pdu_len);
|
||||
|
@ -213,7 +213,7 @@ list_of_le_structs = [
|
||||
["gatt_client", "whitelist_entry", "sm_lookup_entry"],
|
||||
]
|
||||
list_of_mesh_structs = [
|
||||
['mesh_network_pdu', 'mesh_transport_pdu', 'mesh_message_pdu', 'mesh_network_key', 'mesh_transport_key', 'mesh_virtual_address', 'mesh_subnet']
|
||||
['mesh_network_pdu', 'mesh_transport_pdu', 'mesh_segmented_pdu', 'mesh_network_key', 'mesh_transport_key', 'mesh_virtual_address', 'mesh_subnet']
|
||||
]
|
||||
|
||||
btstack_root = os.path.abspath(os.path.dirname(sys.argv[0]) + '/..')
|
||||
|
Loading…
x
Reference in New Issue
Block a user