mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-18 14:42:33 +00:00
mesh: fix appkey index in generic_server_send_message, define two sepparate access messages for submitting generic on off status message
This commit is contained in:
parent
68bd3dd63e
commit
27c4ce3264
@ -53,15 +53,7 @@
|
|||||||
// TODO handler in model?
|
// TODO handler in model?
|
||||||
static btstack_packet_handler_t mesh_packet_handler;
|
static btstack_packet_handler_t mesh_packet_handler;
|
||||||
|
|
||||||
static void generic_server_send_message(mesh_model_t *mesh_model, uint16_t netkey_index, uint16_t dest, mesh_pdu_t *pdu){
|
static void generic_server_send_message(uint16_t src, uint16_t dest, uint16_t netkey_index, uint16_t appkey_index, mesh_pdu_t *pdu){
|
||||||
if (mesh_model == NULL){
|
|
||||||
log_error("mesh_model == NULL");
|
|
||||||
}
|
|
||||||
if (mesh_model->element == NULL){
|
|
||||||
log_error("mesh_model->element == NULL");
|
|
||||||
}
|
|
||||||
uint16_t src = mesh_model->element->unicast_address;
|
|
||||||
uint16_t appkey_index = MESH_DEVICE_KEY_INDEX;
|
|
||||||
uint8_t ttl = mesh_foundation_default_ttl_get();
|
uint8_t ttl = mesh_foundation_default_ttl_get();
|
||||||
mesh_upper_transport_setup_access_pdu_header(pdu, netkey_index, appkey_index, ttl, src, dest, 0);
|
mesh_upper_transport_setup_access_pdu_header(pdu, netkey_index, appkey_index, ttl, src, dest, 0);
|
||||||
mesh_upper_transport_send_access_pdu(pdu);
|
mesh_upper_transport_send_access_pdu(pdu);
|
||||||
@ -73,14 +65,19 @@ void mesh_generic_on_off_server_register_packet_handler(btstack_packet_handler_t
|
|||||||
mesh_packet_handler = packet_handler;
|
mesh_packet_handler = packet_handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
const mesh_access_message_t mesh_generic_on_off_status = {
|
const mesh_access_message_t mesh_generic_on_off_status_transition = {
|
||||||
MESH_GENERIC_ON_OFF_STATUS, "111"
|
MESH_GENERIC_ON_OFF_STATUS, "111"
|
||||||
};
|
};
|
||||||
|
|
||||||
static void mesh_generic_on_off_status_message(mesh_model_t *generic_on_off_server_model, uint16_t netkey_index, uint16_t dest){
|
const mesh_access_message_t mesh_generic_on_off_status_instantaneous = {
|
||||||
if (generic_on_off_server_model == NULL){
|
MESH_GENERIC_ON_OFF_STATUS, "1"
|
||||||
log_error("generic_on_off_server_model == NULL");
|
};
|
||||||
|
|
||||||
|
static void mesh_generic_on_off_status_message(mesh_model_t *generic_on_off_server_model, uint16_t netkey_index, uint16_t dest, uint16_t appkey_index){
|
||||||
|
if (generic_on_off_server_model->element == NULL){
|
||||||
|
log_error("generic_on_off_server_model->element == NULL");
|
||||||
}
|
}
|
||||||
|
|
||||||
mesh_generic_on_off_state_t * state = (mesh_generic_on_off_state_t *) generic_on_off_server_model->model_data;
|
mesh_generic_on_off_state_t * state = (mesh_generic_on_off_state_t *) generic_on_off_server_model->model_data;
|
||||||
if (state == NULL){
|
if (state == NULL){
|
||||||
log_error("generic_on_off_status == NULL");
|
log_error("generic_on_off_status == NULL");
|
||||||
@ -89,19 +86,19 @@ static void mesh_generic_on_off_status_message(mesh_model_t *generic_on_off_serv
|
|||||||
mesh_transport_pdu_t * transport_pdu = NULL;
|
mesh_transport_pdu_t * transport_pdu = NULL;
|
||||||
|
|
||||||
if (state->remaining_time_ms != 0) {
|
if (state->remaining_time_ms != 0) {
|
||||||
transport_pdu = mesh_access_setup_segmented_message(&mesh_generic_on_off_status, state->current_on_off_value,
|
transport_pdu = mesh_access_setup_segmented_message(&mesh_generic_on_off_status_transition, state->current_on_off_value,
|
||||||
state->target_on_off_value, state->remaining_time_ms);
|
state->target_on_off_value, state->remaining_time_ms);
|
||||||
} else {
|
} else {
|
||||||
transport_pdu = mesh_access_setup_segmented_message(&mesh_generic_on_off_status, state->current_on_off_value);
|
transport_pdu = mesh_access_setup_segmented_message(&mesh_generic_on_off_status_instantaneous, state->current_on_off_value);
|
||||||
}
|
}
|
||||||
if (!transport_pdu) return;
|
if (!transport_pdu) return;
|
||||||
|
|
||||||
// send as segmented access pdu
|
// send as segmented access pdu
|
||||||
generic_server_send_message(generic_on_off_server_model, netkey_index, dest, (mesh_pdu_t *) transport_pdu);
|
generic_server_send_message(generic_on_off_server_model->element->unicast_address, dest, netkey_index, appkey_index, (mesh_pdu_t *) transport_pdu);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void generic_on_off_get_handler(mesh_model_t *generic_on_off_server_model, mesh_pdu_t * pdu){
|
static void generic_on_off_get_handler(mesh_model_t *generic_on_off_server_model, mesh_pdu_t * pdu){
|
||||||
mesh_generic_on_off_status_message(generic_on_off_server_model, mesh_pdu_netkey_index(pdu), mesh_pdu_src(pdu));
|
mesh_generic_on_off_status_message(generic_on_off_server_model, mesh_pdu_netkey_index(pdu), mesh_pdu_src(pdu), mesh_pdu_appkey_index(pdu));
|
||||||
mesh_access_message_processed(pdu);
|
mesh_access_message_processed(pdu);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,8 +141,6 @@ static void generic_on_off_set_handler(mesh_model_t *generic_on_off_server_model
|
|||||||
log_error("generic_on_off_server_state == NULL");
|
log_error("generic_on_off_server_state == NULL");
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t status = MESH_FOUNDATION_STATUS_SUCCESS;
|
|
||||||
|
|
||||||
mesh_access_parser_state_t parser;
|
mesh_access_parser_state_t parser;
|
||||||
mesh_access_parser_init(&parser, (mesh_pdu_t*) pdu);
|
mesh_access_parser_init(&parser, (mesh_pdu_t*) pdu);
|
||||||
uint8_t on_off_value = mesh_access_parser_get_u8(&parser);
|
uint8_t on_off_value = mesh_access_parser_get_u8(&parser);
|
||||||
@ -158,7 +153,7 @@ static void generic_on_off_set_handler(mesh_model_t *generic_on_off_server_model
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mesh_access_parser_available(&parser) == 4){
|
if (mesh_access_parser_available(&parser) == 2){
|
||||||
// Generic Default Transition Time format - num_steps (higher 6 bits), step_resolution (lower 2 bits)
|
// Generic Default Transition Time format - num_steps (higher 6 bits), step_resolution (lower 2 bits)
|
||||||
uint8_t transition_time_gdtt = mesh_access_parser_get_u8(&parser);
|
uint8_t transition_time_gdtt = mesh_access_parser_get_u8(&parser);
|
||||||
// Only values of 0x00 through 0x3E shall be used to specify the value of the Transition Number of Steps field
|
// Only values of 0x00 through 0x3E shall be used to specify the value of the Transition Number of Steps field
|
||||||
@ -179,7 +174,7 @@ static void generic_on_off_set_handler(mesh_model_t *generic_on_off_server_model
|
|||||||
generic_on_off_server_state->transaction_identifier = tid;
|
generic_on_off_server_state->transaction_identifier = tid;
|
||||||
generic_on_off_server_state->transition_time_ms = 0;
|
generic_on_off_server_state->transition_time_ms = 0;
|
||||||
generic_on_off_server_state->delay_ms = 0;
|
generic_on_off_server_state->delay_ms = 0;
|
||||||
mesh_generic_on_off_status_message(generic_on_off_server_model, mesh_pdu_netkey_index(pdu), mesh_pdu_src(pdu));
|
mesh_generic_on_off_status_message(generic_on_off_server_model, mesh_pdu_netkey_index(pdu), mesh_pdu_src(pdu), mesh_pdu_appkey_index(pdu));
|
||||||
mesh_access_message_processed(pdu);
|
mesh_access_message_processed(pdu);
|
||||||
// TODO
|
// TODO
|
||||||
uint8_t reason = 0;
|
uint8_t reason = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user