mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-28 00:35:42 +00:00
mesh/health_server: implement clear registered faults internally, remove unused events
This commit is contained in:
parent
63ad364382
commit
204019bbbb
@ -2924,15 +2924,6 @@ typedef uint8_t sm_key_t[16];
|
||||
*/
|
||||
#define MESH_SUBEVENT_GENERIC_LEVEL_STATUS 0x32
|
||||
|
||||
|
||||
/**
|
||||
* @format 112
|
||||
* @param subevent_code
|
||||
* @param element_index
|
||||
* @param company_id
|
||||
*/
|
||||
#define MESH_SUBEVENT_HEALTH_CLEAR_REGISTERED_FAULTS 0x33
|
||||
|
||||
/**
|
||||
* @format 11422221
|
||||
* @param subevent_code
|
||||
@ -2944,21 +2935,13 @@ typedef uint8_t sm_key_t[16];
|
||||
* @param company_id
|
||||
* @param test_id
|
||||
*/
|
||||
#define MESH_SUBEVENT_HEALTH_PERFORM_TEST 0x34
|
||||
|
||||
/**
|
||||
* @format 111
|
||||
* @param subevent_code
|
||||
* @param element_index
|
||||
* @param fast_period_divisor
|
||||
*/
|
||||
#define MESH_SUBEVENT_HEALTH_FAST_PERIOD_DIVISOR_CHANGED 0x35
|
||||
#define MESH_SUBEVENT_HEALTH_PERFORM_TEST 0x33
|
||||
|
||||
/**
|
||||
* @format 11
|
||||
* @param subevent_code
|
||||
* @param element_index
|
||||
*/
|
||||
#define MESH_SUBEVENT_HEALTH_ATTENTION_TIMER_CHANGED 0x36
|
||||
#define MESH_SUBEVENT_HEALTH_ATTENTION_TIMER_CHANGED 0x34
|
||||
|
||||
#endif
|
||||
|
@ -7915,25 +7915,6 @@ static inline uint32_t mesh_subevent_generic_level_status_get_remaining_time_ms(
|
||||
return little_endian_read_32(event, 12);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get field element_index from event MESH_SUBEVENT_HEALTH_CLEAR_REGISTERED_FAULTS
|
||||
* @param event packet
|
||||
* @return element_index
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t mesh_subevent_health_clear_registered_faults_get_element_index(const uint8_t * event){
|
||||
return event[3];
|
||||
}
|
||||
/**
|
||||
* @brief Get field company_id from event MESH_SUBEVENT_HEALTH_CLEAR_REGISTERED_FAULTS
|
||||
* @param event packet
|
||||
* @return company_id
|
||||
* @note: btstack_type 2
|
||||
*/
|
||||
static inline uint16_t mesh_subevent_health_clear_registered_faults_get_company_id(const uint8_t * event){
|
||||
return little_endian_read_16(event, 4);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get field element_index from event MESH_SUBEVENT_HEALTH_PERFORM_TEST
|
||||
* @param event packet
|
||||
@ -7998,25 +7979,6 @@ static inline uint8_t mesh_subevent_health_perform_test_get_test_id(const uint8_
|
||||
return event[16];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get field element_index from event MESH_SUBEVENT_HEALTH_FAST_PERIOD_DIVISOR_CHANGED
|
||||
* @param event packet
|
||||
* @return element_index
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t mesh_subevent_health_fast_period_divisor_changed_get_element_index(const uint8_t * event){
|
||||
return event[3];
|
||||
}
|
||||
/**
|
||||
* @brief Get field fast_period_divisor from event MESH_SUBEVENT_HEALTH_FAST_PERIOD_DIVISOR_CHANGED
|
||||
* @param event packet
|
||||
* @return fast_period_divisor
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t mesh_subevent_health_fast_period_divisor_changed_get_fast_period_divisor(const uint8_t * event){
|
||||
return event[4];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get field element_index from event MESH_SUBEVENT_HEALTH_ATTENTION_TIMER_CHANGED
|
||||
* @param event packet
|
||||
|
@ -133,6 +133,16 @@ static uint16_t process_message_fault_clear(mesh_model_t *mesh_model, mesh_pdu_t
|
||||
mesh_access_parser_state_t parser;
|
||||
mesh_access_parser_init(&parser, (mesh_pdu_t*) pdu);
|
||||
uint16_t company_id = mesh_access_parser_get_u16(&parser);
|
||||
|
||||
mesh_health_state_t * state = (mesh_health_state_t *) mesh_model->model_data;
|
||||
btstack_linked_list_iterator_t it;
|
||||
btstack_linked_list_iterator_init(&it, &state->faults);
|
||||
while (btstack_linked_list_iterator_has_next(&it)){
|
||||
mesh_health_fault_t * fault = (mesh_health_fault_t *) btstack_linked_list_iterator_next(&it);
|
||||
if (fault->company_id != company_id) continue;
|
||||
fault->num_registered_faults = 0;
|
||||
memset(fault->registered_faults, 0, sizeof(fault->registered_faults));
|
||||
}
|
||||
return company_id;
|
||||
}
|
||||
|
||||
@ -146,7 +156,7 @@ static void health_fault_clear_handler(mesh_model_t * mesh_model, mesh_pdu_t * p
|
||||
}
|
||||
|
||||
static void health_fault_clear_unacknowledged_handler(mesh_model_t *mesh_model, mesh_pdu_t * pdu){
|
||||
process_message_fault_clear(mesh_model, pdu);
|
||||
(void) process_message_fault_clear(mesh_model, pdu);
|
||||
mesh_access_message_processed(pdu);
|
||||
}
|
||||
|
||||
@ -313,14 +323,3 @@ const mesh_operation_t * mesh_health_server_get_operations(void){
|
||||
void mesh_health_server_register_packet_handler(mesh_model_t *mesh_model, btstack_packet_handler_t events_packet_handler){
|
||||
mesh_model->model_packet_handler = events_packet_handler;
|
||||
}
|
||||
|
||||
void health_server_clear_faults(btstack_linked_list_t * faults, uint16_t company_id){
|
||||
btstack_linked_list_iterator_t it;
|
||||
btstack_linked_list_iterator_init(&it, faults);
|
||||
while (btstack_linked_list_iterator_has_next(&it)){
|
||||
mesh_fault_t * fault = (mesh_fault_t *) btstack_linked_list_iterator_next(&it);
|
||||
if (fault->company_id != company_id) continue;
|
||||
memset(fault->faults, 0, sizeof(fault->faults));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -56,10 +56,11 @@ const mesh_operation_t * mesh_health_server_get_operations(void);
|
||||
*/
|
||||
void mesh_health_server_register_packet_handler(mesh_model_t *mesh_model, btstack_packet_handler_t events_packet_handler);
|
||||
|
||||
/**
|
||||
* @brief Notify health server that test was perfomed
|
||||
*/
|
||||
void mesh_health_server_report_test_done(uint16_t element_index, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index, uint8_t test_id, uint16_t company_id);
|
||||
|
||||
void health_server_clear_faults(btstack_linked_list_t * faults, uint16_t company_id);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end of extern "C" */
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user