mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-30 07:21:20 +00:00
mesh: add mesh_proxy_get_advertising_with_node_id_status to call from configuration server
This commit is contained in:
parent
fcf3eb548f
commit
af6e0db766
@ -52,15 +52,11 @@
|
||||
#include "mesh_virtual_addresses.h"
|
||||
#include "btstack_debug.h"
|
||||
#include "btstack_tlv.h"
|
||||
#include "mesh_proxy.h"
|
||||
#include "ble/mesh/gatt_bearer.h"
|
||||
|
||||
#define MESH_HEARTBEAT_FEATURES_SUPPORTED_MASK 0x000f
|
||||
|
||||
typedef enum {
|
||||
MESH_NODE_IDENTITY_STATE_ADVERTISING_STOPPED = 0,
|
||||
MESH_NODE_IDENTITY_STATE_ADVERTISING_RUNNING,
|
||||
MESH_NODE_IDENTITY_STATE_ADVERTISING_NOT_SUPPORTED
|
||||
} mesh_node_identity_state_t;
|
||||
|
||||
typedef struct {
|
||||
btstack_timer_source_t timer;
|
||||
uint16_t destination;
|
||||
@ -2045,23 +2041,10 @@ static void config_node_identity_get_handler(mesh_model_t *mesh_model, mesh_pdu_
|
||||
mesh_access_parser_state_t parser;
|
||||
mesh_access_parser_init(&parser, (mesh_pdu_t*) pdu);
|
||||
uint16_t netkey_index = mesh_access_parser_get_u16(&parser);
|
||||
mesh_network_key_t * network_key = mesh_network_key_list_get(netkey_index);
|
||||
|
||||
uint8_t status = MESH_FOUNDATION_STATUS_SUCCESS;
|
||||
mesh_node_identity_state_t node_identity_state = MESH_NODE_IDENTITY_STATE_ADVERTISING_NOT_SUPPORTED;
|
||||
|
||||
if (network_key == NULL){
|
||||
status = MESH_FOUNDATION_STATUS_INVALID_NETKEY_INDEX;
|
||||
} else {
|
||||
#ifdef ENABLE_MESH_PROXY_SERVER
|
||||
if (network_key->node_id_advertisement_running == 0){
|
||||
node_identity_state = MESH_NODE_IDENTITY_STATE_ADVERTISING_STOPPED;
|
||||
} else {
|
||||
node_identity_state = MESH_NODE_IDENTITY_STATE_ADVERTISING_RUNNING;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
mesh_node_identity_state_t node_identity_state = MESH_NODE_IDENTITY_STATE_ADVERTISING_NOT_SUPPORTED;
|
||||
uint8_t status = mesh_proxy_get_advertising_with_node_id_status(netkey_index, &node_identity_state);
|
||||
|
||||
config_node_identity_status(mesh_model, mesh_pdu_netkey_index(pdu), mesh_pdu_src(pdu), status, netkey_index, node_identity_state);
|
||||
mesh_access_message_processed(pdu);
|
||||
}
|
||||
@ -2081,11 +2064,11 @@ static void config_node_identity_set_handler(mesh_model_t *mesh_model, mesh_pdu_
|
||||
#ifdef ENABLE_MESH_PROXY_SERVER
|
||||
switch (node_identity_state){
|
||||
case MESH_NODE_IDENTITY_STATE_ADVERTISING_STOPPED:
|
||||
network_key->node_id_advertisement_running = 0;
|
||||
mesh_proxy_stop_advertising_with_node_id(netkey_index);
|
||||
status = MESH_FOUNDATION_STATUS_SUCCESS;
|
||||
break;
|
||||
case MESH_NODE_IDENTITY_STATE_ADVERTISING_RUNNING:
|
||||
network_key->node_id_advertisement_running = 1;
|
||||
mesh_proxy_start_advertising_with_node_id(netkey_index);
|
||||
status = MESH_FOUNDATION_STATUS_SUCCESS;
|
||||
break;
|
||||
default:
|
||||
|
@ -50,25 +50,7 @@
|
||||
#include "btstack_run_loop.h"
|
||||
#include "btstack_util.h"
|
||||
#include "mesh_proxy.h"
|
||||
|
||||
#if 0
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "ble/mesh/gatt_bearer.h"
|
||||
#include "ble/mesh/beacon.h"
|
||||
#include "ble/mesh/mesh_lower_transport.h"
|
||||
#include "ble/mesh/pb_adv.h"
|
||||
#include "ble/mesh/pb_gatt.h"
|
||||
#include "provisioning.h"
|
||||
#include "provisioning_device.h"
|
||||
#include "mesh_transport.h"
|
||||
#include "mesh_foundation.h"
|
||||
#include "mesh_access.h"
|
||||
#include "mesh_virtual_addresses.h"
|
||||
#include "mesh.h"
|
||||
#include "btstack.h"
|
||||
#include "btstack_tlv.h"
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_MESH_PROXY_SERVER
|
||||
|
||||
@ -162,6 +144,28 @@ void mesh_proxy_stop_advertising_with_node_id(uint16_t netkey_index){
|
||||
mesh_proxy_stop_all_advertising_with_node_id();
|
||||
}
|
||||
|
||||
uint8_t mesh_proxy_get_advertising_with_node_id_status(uint16_t netkey_index, mesh_node_identity_state_t * out_state ){
|
||||
|
||||
mesh_network_key_t * network_key = mesh_network_key_list_get(netkey_index);
|
||||
if (network_key == NULL){
|
||||
*out_state = MESH_NODE_IDENTITY_STATE_ADVERTISING_NOT_SUPPORTED;
|
||||
return MESH_FOUNDATION_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_MESH_PROXY_SERVER
|
||||
if (network_key->node_id_advertisement_running == 0){
|
||||
*out_state = MESH_NODE_IDENTITY_STATE_ADVERTISING_STOPPED;
|
||||
} else {
|
||||
*out_state = MESH_NODE_IDENTITY_STATE_ADVERTISING_RUNNING;
|
||||
}
|
||||
#else
|
||||
*out_state = MESH_NODE_IDENTITY_STATE_ADVERTISING_NOT_SUPPORTED;
|
||||
#endif
|
||||
|
||||
return MESH_FOUNDATION_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
void mesh_proxy_start_advertising_with_network_id(void){
|
||||
mesh_network_key_iterator_t it;
|
||||
mesh_network_key_iterator_init(&it);
|
||||
|
@ -45,6 +45,12 @@ extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
MESH_NODE_IDENTITY_STATE_ADVERTISING_STOPPED = 0,
|
||||
MESH_NODE_IDENTITY_STATE_ADVERTISING_RUNNING,
|
||||
MESH_NODE_IDENTITY_STATE_ADVERTISING_NOT_SUPPORTED
|
||||
} mesh_node_identity_state_t;
|
||||
|
||||
/**
|
||||
* @brief Init Mesh Proxy
|
||||
*/
|
||||
@ -63,6 +69,14 @@ void mesh_proxy_start_advertising_with_node_id(uint16_t netkey_index);
|
||||
*/
|
||||
void mesh_proxy_stop_advertising_with_node_id(uint16_t netkey_index);
|
||||
|
||||
/**
|
||||
* @brief Check if Advertising with Node ID is active
|
||||
* @param netey_index of subnet
|
||||
* @param out_state current state
|
||||
* @returns MESH_FOUNDATION_STATUS_SUCCESS or MESH_FOUNDATION_STATUS_INVALID_NETKEY_INDEX
|
||||
*/
|
||||
uint8_t mesh_proxy_get_advertising_with_node_id_status(uint16_t netkey_index, mesh_node_identity_state_t * out_state );
|
||||
|
||||
/**
|
||||
* @brief Start Advertising with Network ID (on all subnets)
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user