mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-27 21:40:15 +00:00
mesh: add mesh_network/transport_dump/reset
This commit is contained in:
parent
80665fb721
commit
acc9b2251c
@ -247,7 +247,7 @@ static void mesh_network_send_c(void *arg){
|
||||
network_pdu->data[1+i] ^= obfuscation_block[i];
|
||||
}
|
||||
|
||||
printf("TX-NetworkPDU: ");
|
||||
printf("TX-C-NetworkPDU: ");
|
||||
printf_hexdump(network_pdu->data, network_pdu->len);
|
||||
|
||||
// crypto done
|
||||
@ -278,6 +278,9 @@ static void mesh_network_send_b(void *arg){
|
||||
memcpy(&network_pdu->data[network_pdu->len], net_mic, net_mic_len);
|
||||
network_pdu->len += net_mic_len;
|
||||
|
||||
printf("TX-B-NetworkPDU: ");
|
||||
printf_hexdump(network_pdu->data, network_pdu->len);
|
||||
|
||||
// calc PECB
|
||||
memset(encryption_block, 0, 5);
|
||||
big_endian_store_32(encryption_block, 5, iv_index);
|
||||
@ -639,3 +642,36 @@ uint8_t * mesh_network_pdu_data(mesh_network_pdu_t * network_pdu){
|
||||
uint8_t mesh_network_pdu_len(mesh_network_pdu_t * network_pdu){
|
||||
return network_pdu->len - 9;
|
||||
}
|
||||
|
||||
static void mesh_network_dump_network_pdu(mesh_network_pdu_t * network_pdu){
|
||||
if (network_pdu){
|
||||
printf("- %p: ", network_pdu); printf_hexdump(network_pdu->data, network_pdu->len);
|
||||
}
|
||||
}
|
||||
static void mesh_network_dump_network_pdus(const char * name, btstack_linked_list_t * list){
|
||||
printf("List: %s:\n", name);
|
||||
btstack_linked_list_iterator_t it;
|
||||
btstack_linked_list_iterator_init(&it, list);
|
||||
while (btstack_linked_list_iterator_has_next(&it)){
|
||||
mesh_network_pdu_t * network_pdu = (mesh_network_pdu_t*) btstack_linked_list_iterator_next(&it);
|
||||
mesh_network_dump_network_pdu(network_pdu);
|
||||
}
|
||||
}
|
||||
static void mesh_network_reset_network_pdus(btstack_linked_list_t * list){
|
||||
while (!btstack_linked_list_empty(list)){
|
||||
mesh_network_pdu_t * pdu = (mesh_network_pdu_t *) btstack_linked_list_pop(list);
|
||||
btstack_memory_mesh_network_pdu_free(pdu);
|
||||
}
|
||||
}
|
||||
void mesh_network_dump(void){
|
||||
mesh_network_dump_network_pdus("network_pdus_received", &network_pdus_received);
|
||||
mesh_network_dump_network_pdus("network_pdus_queued", &network_pdus_queued);
|
||||
mesh_network_dump_network_pdus("network_pdus_outgoing", &network_pdus_outgoing);
|
||||
printf("network_pdu_in_validation: \n");
|
||||
mesh_network_dump_network_pdu(network_pdu_in_validation);
|
||||
}
|
||||
void mesh_network_reset(void){
|
||||
mesh_network_reset_network_pdus(&network_pdus_received);
|
||||
mesh_network_reset_network_pdus(&network_pdus_queued);
|
||||
mesh_network_reset_network_pdus(&network_pdus_outgoing);
|
||||
}
|
||||
|
@ -192,12 +192,15 @@ int mesh_network_segmented(mesh_network_pdu_t * network_pdu);
|
||||
uint8_t * mesh_network_pdu_data(mesh_network_pdu_t * network_pdu);
|
||||
uint8_t mesh_network_pdu_len(mesh_network_pdu_t * network_pdu);
|
||||
|
||||
// Testing only
|
||||
void mesh_network_received_message(const uint8_t * pdu_data, uint8_t pdu_len);
|
||||
|
||||
void mesh_set_iv_index(uint32_t iv_index);
|
||||
uint32_t mesh_get_iv_index(void);
|
||||
|
||||
// Testing only
|
||||
void mesh_network_received_message(const uint8_t * pdu_data, uint8_t pdu_len);
|
||||
void mesh_network_dump(void);
|
||||
void mesh_network_reset(void);
|
||||
|
||||
|
||||
#if defined __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -1059,3 +1059,29 @@ void mesh_upper_transport_register_unsegemented_message_handler(void (*callback)
|
||||
void mesh_upper_transport_register_segemented_message_handler(void (*callback)(mesh_transport_pdu_t * transport_pdu)){
|
||||
mesh_access_segmented_handler = callback;
|
||||
}
|
||||
|
||||
static void mesh_transport_dump_network_pdus(const char * name, btstack_linked_list_t * list){
|
||||
printf("List: %s:\n", name);
|
||||
btstack_linked_list_iterator_t it;
|
||||
btstack_linked_list_iterator_init(&it, list);
|
||||
while (btstack_linked_list_iterator_has_next(&it)){
|
||||
mesh_network_pdu_t * network_pdu = (mesh_network_pdu_t*) btstack_linked_list_iterator_next(&it);
|
||||
printf("- %p: ", network_pdu); printf_hexdump(network_pdu->data, network_pdu->len);
|
||||
}
|
||||
}
|
||||
static void mesh_transport_reset_network_pdus(btstack_linked_list_t * list){
|
||||
while (!btstack_linked_list_empty(list)){
|
||||
mesh_network_pdu_t * pdu = (mesh_network_pdu_t *) btstack_linked_list_pop(list);
|
||||
btstack_memory_mesh_network_pdu_free(pdu);
|
||||
}
|
||||
}
|
||||
void mesh_transport_dump(void){
|
||||
// static btstack_linked_list_t upper_transport_control;
|
||||
// static btstack_linked_list_t upper_transport_access;
|
||||
mesh_transport_dump_network_pdus("lower_transport_incoming", &lower_transport_incoming);
|
||||
}
|
||||
void mesh_transport_reset(void){
|
||||
// static btstack_linked_list_t upper_transport_control;
|
||||
// static btstack_linked_list_t upper_transport_access;
|
||||
mesh_transport_reset_network_pdus(&lower_transport_incoming);
|
||||
}
|
||||
|
@ -65,6 +65,10 @@ void mesh_lower_transport_received_mesage(mesh_network_callback_type_t callback_
|
||||
void mesh_upper_transport_register_unsegemented_message_handler(void (*callback)(mesh_network_pdu_t * network_pdu));
|
||||
void mesh_upper_transport_register_segemented_message_handler(void (*callback)(mesh_transport_pdu_t * transport_pdu));
|
||||
|
||||
// test
|
||||
void mesh_transport_dump(void);
|
||||
void mesh_transport_reset(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end of extern "C" */
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user