mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-30 15:32:41 +00:00
mesh: handle foundation gatt proxy get/set
This commit is contained in:
parent
209c6904ac
commit
272abd2bfe
@ -655,10 +655,19 @@ static int mesh_access_transport_get_opcode(mesh_transport_pdu_t * transport_pdu
|
||||
|
||||
#define MESH_TTL_MAX 0x7f
|
||||
|
||||
static uint8_t mesh_foundation_gatt_proxy = 0;
|
||||
static uint8_t mesh_foundation_beacon = 0;
|
||||
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_gatt_proxy_set(uint8_t ttl){
|
||||
mesh_foundation_gatt_proxy = ttl;
|
||||
printf("MESH: GATT PROXY %x\n", mesh_foundation_gatt_proxy);
|
||||
}
|
||||
uint8_t mesh_foundation_gatt_proxy_get(void){
|
||||
return mesh_foundation_gatt_proxy;
|
||||
}
|
||||
|
||||
void mesh_foundation_beacon_set(uint8_t ttl){
|
||||
mesh_foundation_beacon = ttl;
|
||||
printf("MESH: Secure Network Beacon %x\n", mesh_foundation_beacon);
|
||||
@ -702,6 +711,7 @@ static uint16_t new_appkey_index;
|
||||
#define MESH_FOUNDATION_OPERATION_COMPOSITION_DATA_STATUS 0x02
|
||||
#define MESH_FOUNDATION_OPERATION_HEARTBEAT_PUBLICATION_STATUS 0x06
|
||||
#define MESH_FOUNDATION_OPERATION_APPKEY_STATUS 0x8003
|
||||
|
||||
#define MESH_FOUNDATION_OPERATION_COMPOSITION_DATA_GET 0x8008
|
||||
#define MESH_FOUNDATION_OPERATION_BEACON_GET 0x8009
|
||||
#define MESH_FOUNDATION_OPERATION_BEACON_SET 0x800a
|
||||
@ -709,6 +719,11 @@ static uint16_t new_appkey_index;
|
||||
#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_GATT_PROXY_GET 0x8012
|
||||
#define MESH_FOUNDATION_OPERATION_GATT_PROXY_SET 0x8013
|
||||
#define MESH_FOUNDATION_OPERATION_GATT_PROXY_STATUS 0x8014
|
||||
|
||||
#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
|
||||
@ -723,13 +738,16 @@ static uint16_t new_appkey_index;
|
||||
#define MESH_FOUNDATION_OPERATION_NETWORK_TRANSMIT_GET 0x8023
|
||||
#define MESH_FOUNDATION_OPERATION_NETWORK_TRANSMIT_SET 0x8024
|
||||
#define MESH_FOUNDATION_OPERATION_NETWORK_TRANSMIT_STATUS 0x8025
|
||||
|
||||
#define MESH_FOUNDATION_OPERATION_HEARTBEAT_PUBLICATION_GET 0x8038
|
||||
#define MESH_FOUNDATION_OPERATION_HEARTBEAT_PUBLICATION_SET 0x8039
|
||||
#define MESH_FOUNDATION_OPERATION_HEARTBEAT_SUBSCRIPTION_GET 0x803a
|
||||
#define MESH_FOUNDATION_OPERATION_HEARTBEAT_SUBSCRIPTION_SET 0x803b
|
||||
#define MESH_FOUNDATION_OPERATION_HEARTBEAT_SUBSCRIPTION_STATUS 0x803c
|
||||
#define MESH_FOUNDATION_OPERATION_MODEL_APP_BIND 0x803d
|
||||
#define MESH_FOUNDATION_OPERATION_MODEL_APP_STATUS 0x803e
|
||||
#define MESH_FOUNDATION_OPERATION_MODEL_APP_UNBIND 0x803f
|
||||
|
||||
#define MESH_FOUNDATION_OPERATION_NODE_RESET 0x8049
|
||||
#define MESH_FOUNDATION_OPERATION_NODE_RESET_STATUS 0x804a
|
||||
|
||||
@ -871,6 +889,39 @@ static void config_default_ttl_set_handler(mesh_model_t *mesh_model, mesh_transp
|
||||
config_model_default_ttl_status(mesh_model);
|
||||
}
|
||||
|
||||
static void config_model_gatt_proxy_status(mesh_model_t * mesh_model){
|
||||
uint16_t src = primary_element_address;
|
||||
uint16_t dest = 0x0001;
|
||||
uint8_t ttl = mesh_foundation_default_ttl_get();
|
||||
|
||||
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_GATT_PROXY_STATUS);
|
||||
if (!transport_pdu) return;
|
||||
|
||||
mesh_access_transport_add_uint8( transport_pdu, mesh_foundation_gatt_proxy_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_gatt_proxy_get_handler(mesh_model_t *mesh_model, mesh_transport_pdu_t *transport_pdu){
|
||||
UNUSED(transport_pdu);
|
||||
config_model_gatt_proxy_status(mesh_model);
|
||||
}
|
||||
|
||||
static void config_gatt_proxy_set_handler(mesh_model_t *mesh_model, mesh_transport_pdu_t *transport_pdu){
|
||||
uint8_t enabled = transport_pdu->data[2]; // 2-byte op
|
||||
// ttl valid
|
||||
if (enabled > 1) return;
|
||||
// store
|
||||
mesh_foundation_gatt_proxy_set(enabled);
|
||||
//
|
||||
config_model_gatt_proxy_status(mesh_model);
|
||||
}
|
||||
|
||||
static void config_model_network_transmit_status(mesh_model_t * mesh_model){
|
||||
uint16_t src = primary_element_address;
|
||||
uint16_t dest = 0x0001;
|
||||
@ -1199,6 +1250,7 @@ static void config_node_reset_status(mesh_model_t *mesh_model){
|
||||
|
||||
static void config_node_reset_handler(mesh_model_t *mesh_model, mesh_transport_pdu_t *transport_pdu) {
|
||||
UNUSED(transport_pdu);
|
||||
mesh_foundation_node_reset();
|
||||
config_node_reset_status(mesh_model);
|
||||
}
|
||||
|
||||
@ -1222,6 +1274,8 @@ static mesh_operation_t mesh_configuration_server_model_operations[] = {
|
||||
{ MESH_FOUNDATION_OPERATION_DEFAULT_TTL_SET, 1, config_default_ttl_set_handler},
|
||||
{ MESH_FOUNDATION_OPERATION_NETWORK_TRANSMIT_GET, 0, config_model_network_transmit_get_handler},
|
||||
{ MESH_FOUNDATION_OPERATION_NETWORK_TRANSMIT_SET, 1, config_model_network_transmit_set_handler},
|
||||
{ MESH_FOUNDATION_OPERATION_GATT_PROXY_GET, 0, config_gatt_proxy_get_handler},
|
||||
{ MESH_FOUNDATION_OPERATION_GATT_PROXY_SET, 1, config_gatt_proxy_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},
|
||||
|
Loading…
x
Reference in New Issue
Block a user