mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-01 01:13:23 +00:00
mesh: handle config server default ttl message
This commit is contained in:
parent
668b49bfd4
commit
19e2fc873c
@ -650,7 +650,19 @@ static int mesh_access_transport_get_opcode(mesh_transport_pdu_t * transport_pdu
|
||||
}
|
||||
|
||||
|
||||
// Foundatiopn
|
||||
|
||||
#define MESH_TTL_MAX 0x7f
|
||||
|
||||
static uint8_t mesh_foundation_default_ttl = 7;
|
||||
static uint8_t mesh_foundation_network_transmit = (10 << 3) | 2; // step 300 ms, send 3 times
|
||||
|
||||
void mesh_foundation_default_ttl_set(uint8_t ttl){
|
||||
mesh_foundation_default_ttl = ttl;
|
||||
}
|
||||
uint8_t mesh_foundation_default_ttl_get(void){
|
||||
return mesh_foundation_default_ttl;
|
||||
}
|
||||
|
||||
// to sort
|
||||
|
||||
@ -665,11 +677,11 @@ static uint16_t new_appkey_index;
|
||||
#define MESH_FOUNDATION_OPERATION_APPKEY_ADD 0x00
|
||||
#define MESH_FOUNDATION_OPERATION_COMPOSITION_DATA_STATUS 0x02
|
||||
#define MESH_FOUNDATION_OPERATION_HEARTBEAT_PUBLICATION_STATUS 0x06
|
||||
#define MESH_FOUNDATION_OPERATION_APPKEY_DEL 0x8000
|
||||
#define MESH_FOUNDATION_OPERATION_APPKEY_GET 0x8001
|
||||
#define MESH_FOUNDATION_OPERATION_APPKEY_LIST 0x8002
|
||||
#define MESH_FOUNDATION_OPERATION_APPKEY_STATUS 0x8003
|
||||
#define MESH_FOUNDATION_OPERATION_COMPOSITION_DATA_GET 0x8008
|
||||
#define MESH_FOUNDATION_OPERATION_DEFAULT_TTL_GET 0x800c
|
||||
#define MESH_FOUNDATION_OPERATION_DEFAULT_TTL_SET 0x800d
|
||||
#define MESH_FOUNDATION_OPERATION_DEFAULT_TTL_STATUS 0x800e
|
||||
#define MESH_FOUNDATION_OPERATION_MODEL_PUBLICATION_GET 0x8018
|
||||
#define MESH_FOUNDATION_OPERATION_MODEL_PUBLICATION_STATUS 0x8019
|
||||
#define MESH_FOUNDATION_OPERATION_MODEL_PUBLICATION_VIRTUAL_ADDRESS_SET 0x801a
|
||||
@ -760,6 +772,39 @@ static void config_composition_data_get_handler(mesh_model_t *mesh_model, mesh_t
|
||||
config_composition_data_status();
|
||||
}
|
||||
|
||||
static void config_model_default_ttl_status(mesh_model_t * mesh_model){
|
||||
uint16_t src = primary_element_address;
|
||||
uint16_t dest = 0x0001;
|
||||
uint8_t ttl = 10;
|
||||
|
||||
uint16_t netkey_index = 0;
|
||||
uint16_t appkey_index = MESH_DEVICE_KEY_INDEX;
|
||||
|
||||
mesh_transport_pdu_t * transport_pdu = mesh_access_transport_init(MESH_FOUNDATION_OPERATION_DEFAULT_TTL_STATUS);
|
||||
if (!transport_pdu) return;
|
||||
|
||||
mesh_access_transport_add_uint8( transport_pdu, mesh_foundation_default_ttl_get());
|
||||
|
||||
// send as segmented access pdu
|
||||
mesh_upper_transport_setup_segmented_access_pdu_header(transport_pdu, netkey_index, appkey_index, ttl, src, dest, 0);
|
||||
mesh_upper_transport_send_segmented_access_pdu(transport_pdu);
|
||||
}
|
||||
|
||||
static void config_model_default_ttl_get_handler(mesh_model_t * mesh_model, mesh_transport_pdu_t * transport_pdu){
|
||||
UNUSED(transport_pdu);
|
||||
config_model_default_ttl_status(mesh_model);
|
||||
}
|
||||
|
||||
static void config_model_default_ttl_set_handler(mesh_model_t * mesh_model, mesh_transport_pdu_t * transport_pdu){
|
||||
uint8_t new_ttl = transport_pdu->data[2]; // 2-byte op
|
||||
// ttl valid
|
||||
if (new_ttl > 0x7f || new_ttl == 0x01) return;
|
||||
// store
|
||||
mesh_foundation_default_ttl_set(new_ttl);
|
||||
//
|
||||
config_model_default_ttl_status(mesh_model);
|
||||
}
|
||||
|
||||
static void config_appkey_status(uint32_t netkey_and_appkey_index, uint8_t status){
|
||||
uint16_t src = primary_element_address;
|
||||
uint16_t dest = 0x0001;
|
||||
@ -1053,6 +1098,8 @@ static mesh_operation_t mesh_configuration_server_model_operations[] = {
|
||||
{ MESH_FOUNDATION_OPERATION_APPKEY_ADD, 19, config_appkey_add_handler },
|
||||
{ MESH_FOUNDATION_OPERATION_COMPOSITION_DATA_GET, 1, config_composition_data_get_handler },
|
||||
{ MESH_FOUNDATION_OPERATION_MODEL_SUBSCRIPTION_ADD, 6, config_model_subscription_add_handler},
|
||||
{ MESH_FOUNDATION_OPERATION_DEFAULT_TTL_GET, 0, config_model_default_ttl_get_handler},
|
||||
{ MESH_FOUNDATION_OPERATION_DEFAULT_TTL_SET, 1, config_model_default_ttl_set_handler},
|
||||
{ MESH_FOUNDATION_OPERATION_MODEL_SUBSCRIPTION_VIRTUAL_ADDRESS_ADD, 20, config_model_subscription_virtual_address_add_handler},
|
||||
{ MESH_FOUNDATION_OPERATION_MODEL_PUBLICATION_VIRTUAL_ADDRESS_SET, 24, config_model_publication_virtual_address_add_handler},
|
||||
{ MESH_FOUNDATION_OPERATION_MODEL_APP_BIND, 6, config_model_app_bind_handler},
|
||||
@ -1068,7 +1115,7 @@ static void mesh_segmented_message_handler(mesh_transport_pdu_t *transport_pdu){
|
||||
int ok = mesh_access_transport_get_opcode(transport_pdu, &opcode, &opcode_size);
|
||||
if (!ok) return;
|
||||
|
||||
printf("MESH Access Message, Opcode = %x:", opcode);
|
||||
printf("MESH Access Message, Opcode = %x: ", opcode);
|
||||
printf_hexdump(transport_pdu->data, transport_pdu->len);
|
||||
|
||||
// find opcode in table
|
||||
|
Loading…
x
Reference in New Issue
Block a user