mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-28 19:20:54 +00:00
mesh: extract gatt_bearer_setup_advertising_with_network_id
This commit is contained in:
parent
94a4ac9a13
commit
ff1c8a81b3
@ -45,6 +45,7 @@
|
||||
#include "ble/core.h"
|
||||
#include "bluetooth.h"
|
||||
#include "bluetooth_data_types.h"
|
||||
#include "bluetooth_gatt.h"
|
||||
#include "btstack_debug.h"
|
||||
#include "btstack_util.h"
|
||||
#include "btstack_run_loop.h"
|
||||
@ -75,6 +76,17 @@ static mesh_msg_type_t msg_type;
|
||||
static uint16_t gatt_bearer_mtu;
|
||||
static hci_con_handle_t gatt_bearer_con_handle;
|
||||
|
||||
static const uint8_t adv_data_with_network_id_template[] = {
|
||||
// Flags general discoverable, BR/EDR not supported
|
||||
0x02, BLUETOOTH_DATA_TYPE_FLAGS, 0x06,
|
||||
// 16-bit Service UUIDs
|
||||
0x03, BLUETOOTH_DATA_TYPE_COMPLETE_LIST_OF_16_BIT_SERVICE_CLASS_UUIDS, ORG_BLUETOOTH_SERVICE_MESH_PROXY & 0xff, ORG_BLUETOOTH_SERVICE_MESH_PROXY >> 8,
|
||||
// Service Data
|
||||
0x0C, BLUETOOTH_DATA_TYPE_SERVICE_DATA, ORG_BLUETOOTH_SERVICE_MESH_PROXY & 0xff, ORG_BLUETOOTH_SERVICE_MESH_PROXY >> 8,
|
||||
// MESH_IDENTIFICATION_NETWORK_ID_TYPE
|
||||
MESH_IDENTIFICATION_NETWORK_ID_TYPE
|
||||
};
|
||||
|
||||
// round-robin
|
||||
static void gatt_bearer_emit_can_send_now(void){
|
||||
// if (gatt_active) return;
|
||||
@ -328,3 +340,9 @@ void gatt_bearer_send_mesh_proxy_configuration(const uint8_t * data, uint16_t da
|
||||
msg_type = MESH_MSG_TYPE_PROXY_CONFIGURATION;
|
||||
gatt_bearer_send_pdu(gatt_bearer_con_handle, data, data_len);
|
||||
}
|
||||
|
||||
uint8_t gatt_bearer_setup_advertising_with_network_id(uint8_t * buffer, uint8_t * network_id){
|
||||
memcpy(&buffer[0], adv_data_with_network_id_template, 12);
|
||||
memcpy(&buffer[12], network_id, 8);
|
||||
return 20;
|
||||
}
|
||||
|
@ -74,6 +74,14 @@ void gatt_bearer_send_mesh_network_pdu(const uint8_t * network_pdu, uint16_t siz
|
||||
void gatt_bearer_send_mesh_beacon(const uint8_t * beacon_update, uint16_t size);
|
||||
void gatt_bearer_send_mesh_proxy_configuration(const uint8_t * proxy_configuration, uint16_t size);
|
||||
|
||||
/* Utility functions */
|
||||
/**
|
||||
* Setup Proxy Advertisement for given network id
|
||||
* @param buffer (20 bytes)
|
||||
* @param network_id (8 bytes)
|
||||
*/
|
||||
uint8_t gatt_bearer_setup_advertising_with_network_id(uint8_t * buffer, uint8_t * network_id);
|
||||
|
||||
#if defined __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -212,17 +212,9 @@ static void mesh_proxy_handle_get_random(void * arg){
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef USE_ADVERTISING_WITH_NETWORK_ID
|
||||
static void setup_advertising_with_network_id(void){
|
||||
|
||||
// dynamically store network ID into adv data
|
||||
memcpy(&adv_data_with_network_id[12], network_id, sizeof(network_id));
|
||||
|
||||
// store in advertisement item
|
||||
memset(&connectable_advertisement_item, 0, sizeof(connectable_advertisement_item));
|
||||
connectable_advertisement_item.adv_length = adv_data_with_network_id_len;
|
||||
memcpy(connectable_advertisement_item.adv_data, (uint8_t*) adv_data_with_network_id, adv_data_with_network_id_len);
|
||||
connectable_advertisement_item.adv_length = gatt_bearer_setup_advertising_with_network_id(connectable_advertisement_item.adv_data, network_id);
|
||||
|
||||
// setup advertisements
|
||||
bd_addr_t null_addr;
|
||||
|
Loading…
x
Reference in New Issue
Block a user