mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-29 22:20:37 +00:00
mesh: pb_adv gets device uuid from mesh_node
This commit is contained in:
parent
54274a7650
commit
8936a14384
@ -43,6 +43,7 @@
|
||||
#include <string.h>
|
||||
#include "mesh/adv_bearer.h"
|
||||
#include "mesh/beacon.h"
|
||||
#include "mesh/mesh_node.h"
|
||||
#include "provisioning.h"
|
||||
#include "btstack_util.h"
|
||||
#include "btstack_debug.h"
|
||||
@ -84,8 +85,6 @@ typedef enum {
|
||||
} link_state_t;
|
||||
static link_state_t link_state;
|
||||
|
||||
static const uint8_t * pb_adv_own_device_uuid;
|
||||
|
||||
#ifdef ENABLE_MESH_PROVISIONER
|
||||
static const uint8_t * pb_adv_peer_device_uuid;
|
||||
#endif
|
||||
@ -154,11 +153,13 @@ static void pb_adv_emit_link_close(uint16_t pb_adv_cid, uint8_t reason){
|
||||
static void pb_adv_handle_bearer_control(uint32_t link_id, uint8_t transaction_nr, const uint8_t * pdu, uint16_t size){
|
||||
uint8_t bearer_opcode = pdu[0] >> 2;
|
||||
uint8_t reason;
|
||||
const uint8_t * own_device_uuid;
|
||||
switch (bearer_opcode){
|
||||
case MESH_GENERIC_PROVISIONING_LINK_OPEN: // Open a session on a bearer with a device
|
||||
// does it match our device_uuid?
|
||||
if (!pb_adv_own_device_uuid) break;
|
||||
if (memcmp(&pdu[1], pb_adv_own_device_uuid, 16) != 0) break;
|
||||
own_device_uuid = mesh_node_get_device_uuid();
|
||||
if (!own_device_uuid) break;
|
||||
if (memcmp(&pdu[1], own_device_uuid, 16) != 0) break;
|
||||
switch(link_state){
|
||||
case LINK_STATE_W4_OPEN:
|
||||
pb_adv_link_id = link_id;
|
||||
@ -550,8 +551,7 @@ static void pb_adv_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
||||
}
|
||||
}
|
||||
|
||||
void pb_adv_init(uint8_t * device_uuid){
|
||||
pb_adv_own_device_uuid = device_uuid;
|
||||
void pb_adv_init(void){
|
||||
adv_bearer_register_for_provisioning_pdu(&pb_adv_handler);
|
||||
pb_adv_lfsr = 0x12345678;
|
||||
pb_adv_random();
|
||||
|
@ -49,9 +49,8 @@ extern "C" {
|
||||
|
||||
/**
|
||||
* Initialize Provisioning Bearer using Advertisement Bearer
|
||||
* @param DeviceUUID
|
||||
*/
|
||||
void pb_adv_init(const uint8_t * device_uuid);
|
||||
void pb_adv_init(void);
|
||||
|
||||
/**
|
||||
* Register listener for Provisioning PDUs and MESH_PBV_ADV_SEND_COMPLETE
|
||||
|
@ -67,7 +67,7 @@ mesh_message_test: mesh_foundation.o mesh_node.o mesh_message_test.c mesh_iv_ind
|
||||
sniffer: ${CORE_OBJ} ${COMMON_OBJ} ${ATT_OBJ} ${SM_OBJ} mesh_keys.o mesh_network.o mesh_foundation.o sniffer.c
|
||||
${CC} $^ ${CFLAGS} ${LDFLAGS} -o $@
|
||||
|
||||
provisioning_device_test: provisioning_device_test.cpp uECC.o mesh_crypto.o provisioning_device.o btstack_crypto.o btstack_util.o btstack_linked_list.o mock.o rijndael.o hci_cmd.o hci_dump.o
|
||||
provisioning_device_test: provisioning_device_test.cpp uECC.o mesh_crypto.o provisioning_device.o btstack_crypto.o btstack_util.o btstack_linked_list.o mesh_node.o mock.o rijndael.o hci_cmd.o hci_dump.o
|
||||
${CC_UNIT} ${CFLAGS} ${LDFLAGS} $^ -lCppUTest -lCppUTestExt -o $@
|
||||
|
||||
provisioning_provisioner_test: provisioning_provisioner_test.cpp uECC.o mesh_crypto.o provisioning_provisioner.o btstack_crypto.o btstack_util.o btstack_linked_list.o mock.o rijndael.o hci_cmd.o hci_dump.o
|
||||
|
@ -660,7 +660,7 @@ int btstack_main(void)
|
||||
btstack_print_hex(pts_device_uuid, 16, 0);
|
||||
|
||||
// Provisioning in device role
|
||||
provisioning_device_init(mesh_node_get_device_uuid());
|
||||
provisioning_device_init();
|
||||
provisioning_device_register_packet_handler(&mesh_provisioning_message_handler);
|
||||
|
||||
// Network layer
|
||||
|
@ -821,9 +821,9 @@ static void prov_key_generated(void * arg){
|
||||
}
|
||||
}
|
||||
|
||||
void provisioning_device_init(const uint8_t * device_uuid){
|
||||
void provisioning_device_init(void){
|
||||
// setup PB ADV
|
||||
pb_adv_init(device_uuid);
|
||||
pb_adv_init();
|
||||
pb_adv_register_packet_handler(&provisioning_handle_pdu);
|
||||
// setup PB GATT
|
||||
pb_gatt_init();
|
||||
|
@ -53,9 +53,8 @@ extern "C"
|
||||
|
||||
/**
|
||||
* @brief Init Provisioning in Device Role with device UUID
|
||||
* @param device_uuid
|
||||
*/
|
||||
void provisioning_device_init(const uint8_t * device_uuid);
|
||||
void provisioning_device_init(void);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include <string.h>
|
||||
#include "mesh/pb_adv.h"
|
||||
#include "mesh/pb_gatt.h"
|
||||
#include "mesh/mesh_node.h"
|
||||
#include "ble/gatt-service/mesh_provisioning_service_server.h"
|
||||
#include "provisioning.h"
|
||||
#include "provisioning_device.h"
|
||||
@ -105,7 +106,7 @@ static uint16_t pdu_size;
|
||||
* Initialize Provisioning Bearer using Advertisement Bearer
|
||||
* @param DeviceUUID
|
||||
*/
|
||||
void pb_adv_init(const uint8_t * device_uuid){}
|
||||
void pb_adv_init(void){}
|
||||
void pb_gatt_init(void){}
|
||||
|
||||
/**
|
||||
@ -198,7 +199,8 @@ static const char * prov_static_oob_string = "00000000000000000102030405060708";
|
||||
TEST_GROUP(Provisioning){
|
||||
void setup(void){
|
||||
btstack_crypto_init();
|
||||
provisioning_device_init(device_uuid);
|
||||
provisioning_device_init();
|
||||
mesh_node_set_device_uuid(device_uuid);
|
||||
btstack_parse_hex(prov_static_oob_string, 16, prov_static_oob_data);
|
||||
provisioning_device_set_static_oob(16, prov_static_oob_data);
|
||||
provisioning_device_set_output_oob_actions(0x08, 0x08);
|
||||
|
@ -711,7 +711,7 @@ static void prov_key_generated(void * arg){
|
||||
|
||||
void provisioning_provisioner_init(void){
|
||||
pb_adv_cid = MESH_PB_TRANSPORT_INVALID_CID;
|
||||
pb_adv_init(NULL);
|
||||
pb_adv_init();
|
||||
pb_adv_register_packet_handler(&provisioning_handle_pdu);
|
||||
}
|
||||
|
||||
|
@ -111,8 +111,8 @@ static void pb_adv_emit_pdu_sent(uint8_t status){
|
||||
pb_adv_packet_handler(HCI_EVENT_PACKET, 0, event, sizeof(event));
|
||||
}
|
||||
|
||||
void pb_adv_init(const uint8_t * device_uuid){}
|
||||
void pb_gatt_init(const uint8_t * device_uuid){}
|
||||
void pb_adv_init(void){}
|
||||
void pb_gatt_init(void){}
|
||||
|
||||
void pb_adv_close_link(uint16_t pb_adv_cid, uint8_t reason){}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user