mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-26 21:35:16 +00:00
mesh: fix callbacks to model packet handler, fix access message dispatching
This commit is contained in:
parent
5f84574095
commit
8ef657c601
@ -94,10 +94,10 @@ void mesh_access_init(void){
|
||||
mesh_sequence_number_set_update_callback(&mesh_persist_iv_index_and_sequence_number);
|
||||
}
|
||||
|
||||
void mesh_access_emit_state_update_bool(btstack_packet_handler_t * event_handler, uint8_t element_index, uint32_t model_identifier,
|
||||
void mesh_access_emit_state_update_bool(btstack_packet_handler_t event_handler, uint8_t element_index, uint32_t model_identifier,
|
||||
model_state_id_t state_identifier, model_state_update_reason_t reason, uint8_t value){
|
||||
if (event_handler == NULL) return;
|
||||
uint8_t event[14] = {HCI_EVENT_MESH_META, 13, MESH_SUBEVENT_STATE_UPDATE_BOOL};
|
||||
uint8_t event[14] = {HCI_EVENT_MESH_META, 12, MESH_SUBEVENT_STATE_UPDATE_BOOL};
|
||||
int pos = 3;
|
||||
event[pos++] = element_index;
|
||||
little_endian_store_32(event, pos, model_identifier);
|
||||
@ -109,10 +109,10 @@ void mesh_access_emit_state_update_bool(btstack_packet_handler_t * event_handler
|
||||
(*event_handler)(HCI_EVENT_PACKET, 0, event, sizeof(event));
|
||||
}
|
||||
|
||||
void mesh_access_emit_state_update_int16(btstack_packet_handler_t * event_handler, uint8_t element_index, uint32_t model_identifier,
|
||||
void mesh_access_emit_state_update_int16(btstack_packet_handler_t event_handler, uint8_t element_index, uint32_t model_identifier,
|
||||
model_state_id_t state_identifier, model_state_update_reason_t reason, int16_t value){
|
||||
if (event_handler == NULL) return;
|
||||
uint8_t event[14] = {HCI_EVENT_MESH_META, 13, MESH_SUBEVENT_STATE_UPDATE_BOOL};
|
||||
uint8_t event[15] = {HCI_EVENT_MESH_META, 13, MESH_SUBEVENT_STATE_UPDATE_BOOL};
|
||||
int pos = 3;
|
||||
event[pos++] = element_index;
|
||||
little_endian_store_32(event, pos, model_identifier);
|
||||
@ -887,16 +887,7 @@ static void mesh_access_message_process_handler(mesh_pdu_t * pdu){
|
||||
|
||||
uint16_t len = mesh_pdu_len(pdu);
|
||||
printf("MESH Access Message, Opcode = %x: ", opcode);
|
||||
switch (pdu->pdu_type){
|
||||
case MESH_PDU_TYPE_NETWORK:
|
||||
printf_hexdump(&((mesh_network_pdu_t *) pdu)->data[10], len);
|
||||
break;
|
||||
case MESH_PDU_TYPE_TRANSPORT:
|
||||
printf_hexdump(((mesh_transport_pdu_t *) pdu)->data, len);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
printf_hexdump(mesh_pdu_data(pdu), len);
|
||||
|
||||
uint16_t src = mesh_pdu_src(pdu);
|
||||
uint16_t dst = mesh_pdu_dst(pdu);
|
||||
@ -912,8 +903,8 @@ static void mesh_access_message_process_handler(mesh_pdu_t * pdu){
|
||||
mesh_model_t * model = mesh_model_iterator_next(&model_it);
|
||||
// find opcode in table
|
||||
const mesh_operation_t * operation = mesh_model_lookup_operation(model, pdu);
|
||||
if (operation == NULL) break;
|
||||
if (mesh_access_validate_appkey_index(model, appkey_index) == 0) break;
|
||||
if (operation == NULL) continue;
|
||||
if (mesh_access_validate_appkey_index(model, appkey_index) == 0) continue;
|
||||
mesh_access_acknowledged_received(src, opcode);
|
||||
operation->handler(model, pdu);
|
||||
return;
|
||||
|
@ -162,7 +162,7 @@ typedef struct mesh_model {
|
||||
uint16_t subscriptions[MAX_NR_MESH_SUBSCRIPTION_PER_MODEL];
|
||||
|
||||
// packet handler for transition events in server, event callback handler in client
|
||||
btstack_packet_handler_t * model_packet_handler;
|
||||
btstack_packet_handler_t model_packet_handler;
|
||||
} mesh_model_t;
|
||||
|
||||
typedef struct {
|
||||
@ -301,9 +301,9 @@ mesh_model_t * mesh_access_model_for_address_and_model_identifier(uint16_t eleme
|
||||
uint8_t mesh_access_transitions_num_steps_from_gdtt(uint8_t time_gdtt);
|
||||
uint32_t mesh_access_time_gdtt2ms(uint8_t time_gdtt);
|
||||
|
||||
void mesh_access_emit_state_update_bool(btstack_packet_handler_t * event_handler, uint8_t element_index, uint32_t model_identifier,
|
||||
void mesh_access_emit_state_update_bool(btstack_packet_handler_t event_handler, uint8_t element_index, uint32_t model_identifier,
|
||||
model_state_id_t state_identifier, model_state_update_reason_t reason, uint8_t value);
|
||||
void mesh_access_emit_state_update_int16(btstack_packet_handler_t * event_handler, uint8_t element_index, uint32_t model_identifier,
|
||||
void mesh_access_emit_state_update_int16(btstack_packet_handler_t event_handler, uint8_t element_index, uint32_t model_identifier,
|
||||
model_state_id_t state_identifier, model_state_update_reason_t reason, int16_t value);
|
||||
|
||||
// Mesh Model Transitions
|
||||
|
@ -178,7 +178,7 @@ void mesh_generic_on_off_server_register_packet_handler(mesh_model_t *generic_on
|
||||
log_error("mesh_generic_on_off_server_register_packet_handler called with NULL generic_on_off_server_model");
|
||||
return;
|
||||
}
|
||||
generic_on_off_server_model->model_packet_handler = &transition_events_packet_handler;
|
||||
generic_on_off_server_model->model_packet_handler = transition_events_packet_handler;
|
||||
}
|
||||
|
||||
const mesh_access_message_t mesh_generic_on_off_status_transition = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user