mirror of
https://github.com/espressif/esp-idf
synced 2025-04-13 10:10:09 -04:00
ble_mesh: Move the example init to the common_components
This commit is contained in:
parent
2eadacbf29
commit
74056dea91
@ -2,7 +2,8 @@
|
|||||||
# in this exact order for cmake to work correctly
|
# in this exact order for cmake to work correctly
|
||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/bluetooth/esp_ble_mesh/common_components/fast_prov_vendor_model)
|
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/bluetooth/esp_ble_mesh/common_components/example_init
|
||||||
|
$ENV{IDF_PATH}/examples/bluetooth/esp_ble_mesh/common_components/fast_prov_vendor_model)
|
||||||
|
|
||||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
set(SUPPORTED_TARGETS esp32)
|
set(SUPPORTED_TARGETS esp32)
|
||||||
|
@ -5,8 +5,7 @@
|
|||||||
|
|
||||||
PROJECT_NAME := ble_mesh_fast_prov_client
|
PROJECT_NAME := ble_mesh_fast_prov_client
|
||||||
|
|
||||||
COMPONENT_ADD_INCLUDEDIRS := components/include
|
EXTRA_COMPONENT_DIRS := $(IDF_PATH)/examples/bluetooth/esp_ble_mesh/common_components/example_init \
|
||||||
|
$(IDF_PATH)/examples/bluetooth/esp_ble_mesh/common_components/fast_prov_vendor_model
|
||||||
EXTRA_COMPONENT_DIRS := $(IDF_PATH)/examples/bluetooth/esp_ble_mesh/common_components/fast_prov_vendor_model
|
|
||||||
|
|
||||||
include $(IDF_PATH)/make/project.mk
|
include $(IDF_PATH)/make/project.mk
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
set(COMPONENT_SRCS "ble_mesh_demo_main.c"
|
set(COMPONENT_SRCS "ble_mesh_demo_main.c")
|
||||||
"ble_mesh_demo_init.c")
|
|
||||||
|
|
||||||
set(COMPONENT_ADD_INCLUDEDIRS ".")
|
set(COMPONENT_ADD_INCLUDEDIRS ".")
|
||||||
|
|
||||||
register_component()
|
register_component()
|
@ -1,143 +0,0 @@
|
|||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2017 Intel Corporation
|
|
||||||
* Additional Copyright (c) 2018 Espressif Systems (Shanghai) PTE LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <sdkconfig.h>
|
|
||||||
/* BLE */
|
|
||||||
#ifdef CONFIG_BT_BLUEDROID_ENABLED
|
|
||||||
#include "esp_bt.h"
|
|
||||||
#include "esp_bt_main.h"
|
|
||||||
#include "esp_bt_device.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_BT_NIMBLE_ENABLED
|
|
||||||
#include "esp_nimble_hci.h"
|
|
||||||
#include "nimble/nimble_port.h"
|
|
||||||
#include "nimble/nimble_port_freertos.h"
|
|
||||||
#include "host/ble_hs.h"
|
|
||||||
#include "host/util/util.h"
|
|
||||||
#include "console/console.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "esp_ble_mesh_defs.h"
|
|
||||||
#include "ble_mesh_demo_init.h"
|
|
||||||
#include "esp_ble_mesh_common_api.h"
|
|
||||||
|
|
||||||
#ifdef CONFIG_BT_BLUEDROID_ENABLED
|
|
||||||
|
|
||||||
void ble_mesh_get_dev_uuid(uint8_t *dev_uuid)
|
|
||||||
{
|
|
||||||
memcpy(dev_uuid, esp_bt_dev_get_address(), BD_ADDR_LEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_err_t bluetooth_init(void)
|
|
||||||
{
|
|
||||||
esp_err_t ret;
|
|
||||||
|
|
||||||
|
|
||||||
ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT));
|
|
||||||
|
|
||||||
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
|
||||||
ret = esp_bt_controller_init(&bt_cfg);
|
|
||||||
if (ret) {
|
|
||||||
ESP_LOGE(TAG, "%s initialize controller failed", __func__);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = esp_bt_controller_enable(ESP_BT_MODE_BLE);
|
|
||||||
if (ret) {
|
|
||||||
ESP_LOGE(TAG, "%s enable controller failed", __func__);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
ret = esp_bluedroid_init();
|
|
||||||
if (ret) {
|
|
||||||
ESP_LOGE(TAG, "%s init bluetooth failed", __func__);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
ret = esp_bluedroid_enable();
|
|
||||||
if (ret) {
|
|
||||||
ESP_LOGE(TAG, "%s enable bluetooth failed", __func__);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_BT_NIMBLE_ENABLED
|
|
||||||
static SemaphoreHandle_t mesh_sem;
|
|
||||||
static uint8_t own_addr_type;
|
|
||||||
void ble_store_config_init(void);
|
|
||||||
static uint8_t addr_val[6] = {0};
|
|
||||||
|
|
||||||
void ble_mesh_get_dev_uuid(uint8_t *dev_uuid)
|
|
||||||
{
|
|
||||||
memcpy(dev_uuid + 2, addr_val, BD_ADDR_LEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void mesh_on_reset(int reason)
|
|
||||||
{
|
|
||||||
ESP_LOGI(TAG, "Resetting state; reason=%d", reason);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void mesh_on_sync(void)
|
|
||||||
{
|
|
||||||
int rc;
|
|
||||||
|
|
||||||
rc = ble_hs_util_ensure_addr(0);
|
|
||||||
assert(rc == 0);
|
|
||||||
|
|
||||||
/* Figure out address to use while advertising (no privacy for now) */
|
|
||||||
rc = ble_hs_id_infer_auto(0, &own_addr_type);
|
|
||||||
if (rc != 0) {
|
|
||||||
ESP_LOGI(TAG, "error determining address type; rc=%d", rc);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = ble_hs_id_copy_addr(own_addr_type, addr_val, NULL);
|
|
||||||
|
|
||||||
xSemaphoreGive(mesh_sem);
|
|
||||||
}
|
|
||||||
|
|
||||||
void mesh_host_task(void *param)
|
|
||||||
{
|
|
||||||
ESP_LOGI(TAG, "BLE Host Task Started");
|
|
||||||
/* This function will return only when nimble_port_stop() is executed */
|
|
||||||
nimble_port_run();
|
|
||||||
|
|
||||||
nimble_port_freertos_deinit();
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_err_t bluetooth_init(void)
|
|
||||||
{
|
|
||||||
mesh_sem = xSemaphoreCreateBinary();
|
|
||||||
if (mesh_sem == NULL) {
|
|
||||||
ESP_LOGE(TAG, "Failed to create mesh semaphore");
|
|
||||||
return ESP_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ESP_ERROR_CHECK(esp_nimble_hci_and_controller_init());
|
|
||||||
|
|
||||||
nimble_port_init();
|
|
||||||
/* Initialize the NimBLE host configuration. */
|
|
||||||
ble_hs_cfg.reset_cb = mesh_on_reset;
|
|
||||||
ble_hs_cfg.sync_cb = mesh_on_sync;
|
|
||||||
ble_hs_cfg.store_status_cb = ble_store_util_status_rr;
|
|
||||||
|
|
||||||
/* XXX Need to have template for store */
|
|
||||||
ble_store_config_init();
|
|
||||||
|
|
||||||
nimble_port_freertos_init(mesh_host_task);
|
|
||||||
|
|
||||||
xSemaphoreTake(mesh_sem, portMAX_DELAY);
|
|
||||||
|
|
||||||
return ESP_OK;
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -1,18 +0,0 @@
|
|||||||
/*
|
|
||||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, this
|
|
||||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
||||||
CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _BLE_MESH_DEMO_INIT_H_
|
|
||||||
#define _BLE_MESH_DEMO_INIT_H_
|
|
||||||
|
|
||||||
#define TAG "FAST_PROV_CLIENT_DEMO"
|
|
||||||
|
|
||||||
void ble_mesh_get_dev_uuid(uint8_t *dev_uuid);
|
|
||||||
|
|
||||||
esp_err_t bluetooth_init(void);
|
|
||||||
|
|
||||||
#endif
|
|
@ -2,7 +2,8 @@
|
|||||||
# in this exact order for cmake to work correctly
|
# in this exact order for cmake to work correctly
|
||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/bluetooth/esp_ble_mesh/common_components/fast_prov_vendor_model)
|
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/bluetooth/esp_ble_mesh/common_components/example_init
|
||||||
|
$ENV{IDF_PATH}/examples/bluetooth/esp_ble_mesh/common_components/fast_prov_vendor_model)
|
||||||
|
|
||||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
set(SUPPORTED_TARGETS esp32)
|
set(SUPPORTED_TARGETS esp32)
|
||||||
|
@ -5,8 +5,7 @@
|
|||||||
|
|
||||||
PROJECT_NAME := ble_mesh_fast_prov_server
|
PROJECT_NAME := ble_mesh_fast_prov_server
|
||||||
|
|
||||||
COMPONENT_ADD_INCLUDEDIRS := components/include
|
EXTRA_COMPONENT_DIRS := $(IDF_PATH)/examples/bluetooth/esp_ble_mesh/common_components/example_init \
|
||||||
|
$(IDF_PATH)/examples/bluetooth/esp_ble_mesh/common_components/fast_prov_vendor_model
|
||||||
EXTRA_COMPONENT_DIRS := $(IDF_PATH)/examples/bluetooth/esp_ble_mesh/common_components/fast_prov_vendor_model
|
|
||||||
|
|
||||||
include $(IDF_PATH)/make/project.mk
|
include $(IDF_PATH)/make/project.mk
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
set(COMPONENT_SRCS "ble_mesh_demo_main.c"
|
set(COMPONENT_SRCS "ble_mesh_demo_main.c"
|
||||||
"ble_mesh_demo_init.c"
|
|
||||||
"board.c")
|
"board.c")
|
||||||
|
|
||||||
set(COMPONENT_ADD_INCLUDEDIRS ".")
|
set(COMPONENT_ADD_INCLUDEDIRS ".")
|
||||||
|
@ -1,143 +0,0 @@
|
|||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2017 Intel Corporation
|
|
||||||
* Additional Copyright (c) 2018 Espressif Systems (Shanghai) PTE LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <sdkconfig.h>
|
|
||||||
/* BLE */
|
|
||||||
#ifdef CONFIG_BT_BLUEDROID_ENABLED
|
|
||||||
#include "esp_bt.h"
|
|
||||||
#include "esp_bt_main.h"
|
|
||||||
#include "esp_bt_device.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_BT_NIMBLE_ENABLED
|
|
||||||
#include "esp_nimble_hci.h"
|
|
||||||
#include "nimble/nimble_port.h"
|
|
||||||
#include "nimble/nimble_port_freertos.h"
|
|
||||||
#include "host/ble_hs.h"
|
|
||||||
#include "host/util/util.h"
|
|
||||||
#include "console/console.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "esp_ble_mesh_defs.h"
|
|
||||||
#include "ble_mesh_demo_init.h"
|
|
||||||
#include "esp_ble_mesh_common_api.h"
|
|
||||||
|
|
||||||
#ifdef CONFIG_BT_BLUEDROID_ENABLED
|
|
||||||
|
|
||||||
void ble_mesh_get_dev_uuid(uint8_t *dev_uuid)
|
|
||||||
{
|
|
||||||
memcpy(dev_uuid + 2, esp_bt_dev_get_address(), BD_ADDR_LEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_err_t bluetooth_init(void)
|
|
||||||
{
|
|
||||||
esp_err_t ret;
|
|
||||||
|
|
||||||
|
|
||||||
ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT));
|
|
||||||
|
|
||||||
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
|
||||||
ret = esp_bt_controller_init(&bt_cfg);
|
|
||||||
if (ret) {
|
|
||||||
ESP_LOGE(TAG, "%s initialize controller failed", __func__);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = esp_bt_controller_enable(ESP_BT_MODE_BLE);
|
|
||||||
if (ret) {
|
|
||||||
ESP_LOGE(TAG, "%s enable controller failed", __func__);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
ret = esp_bluedroid_init();
|
|
||||||
if (ret) {
|
|
||||||
ESP_LOGE(TAG, "%s init bluetooth failed", __func__);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
ret = esp_bluedroid_enable();
|
|
||||||
if (ret) {
|
|
||||||
ESP_LOGE(TAG, "%s enable bluetooth failed", __func__);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_BT_NIMBLE_ENABLED
|
|
||||||
static SemaphoreHandle_t mesh_sem;
|
|
||||||
static uint8_t own_addr_type;
|
|
||||||
void ble_store_config_init(void);
|
|
||||||
static uint8_t addr_val[6] = {0};
|
|
||||||
|
|
||||||
void ble_mesh_get_dev_uuid(uint8_t *dev_uuid)
|
|
||||||
{
|
|
||||||
memcpy(dev_uuid + 2, addr_val, BD_ADDR_LEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void mesh_on_reset(int reason)
|
|
||||||
{
|
|
||||||
ESP_LOGI(TAG, "Resetting state; reason=%d", reason);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void mesh_on_sync(void)
|
|
||||||
{
|
|
||||||
int rc;
|
|
||||||
|
|
||||||
rc = ble_hs_util_ensure_addr(0);
|
|
||||||
assert(rc == 0);
|
|
||||||
|
|
||||||
/* Figure out address to use while advertising (no privacy for now) */
|
|
||||||
rc = ble_hs_id_infer_auto(0, &own_addr_type);
|
|
||||||
if (rc != 0) {
|
|
||||||
ESP_LOGI(TAG, "error determining address type; rc=%d", rc);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = ble_hs_id_copy_addr(own_addr_type, addr_val, NULL);
|
|
||||||
|
|
||||||
xSemaphoreGive(mesh_sem);
|
|
||||||
}
|
|
||||||
|
|
||||||
void mesh_host_task(void *param)
|
|
||||||
{
|
|
||||||
ESP_LOGI(TAG, "BLE Host Task Started");
|
|
||||||
/* This function will return only when nimble_port_stop() is executed */
|
|
||||||
nimble_port_run();
|
|
||||||
|
|
||||||
nimble_port_freertos_deinit();
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_err_t bluetooth_init(void)
|
|
||||||
{
|
|
||||||
mesh_sem = xSemaphoreCreateBinary();
|
|
||||||
if (mesh_sem == NULL) {
|
|
||||||
ESP_LOGE(TAG, "Failed to create mesh semaphore");
|
|
||||||
return ESP_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ESP_ERROR_CHECK(esp_nimble_hci_and_controller_init());
|
|
||||||
|
|
||||||
nimble_port_init();
|
|
||||||
/* Initialize the NimBLE host configuration. */
|
|
||||||
ble_hs_cfg.reset_cb = mesh_on_reset;
|
|
||||||
ble_hs_cfg.sync_cb = mesh_on_sync;
|
|
||||||
ble_hs_cfg.store_status_cb = ble_store_util_status_rr;
|
|
||||||
|
|
||||||
/* XXX Need to have template for store */
|
|
||||||
ble_store_config_init();
|
|
||||||
|
|
||||||
nimble_port_freertos_init(mesh_host_task);
|
|
||||||
|
|
||||||
xSemaphoreTake(mesh_sem, portMAX_DELAY);
|
|
||||||
|
|
||||||
return ESP_OK;
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -1,18 +0,0 @@
|
|||||||
/*
|
|
||||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, this
|
|
||||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
||||||
CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _BLE_MESH_DEMO_INIT_H_
|
|
||||||
#define _BLE_MESH_DEMO_INIT_H_
|
|
||||||
|
|
||||||
#define TAG "FAST_PROV_SERVER_DEMO"
|
|
||||||
|
|
||||||
void ble_mesh_get_dev_uuid(uint8_t *dev_uuid);
|
|
||||||
|
|
||||||
esp_err_t bluetooth_init(void);
|
|
||||||
|
|
||||||
#endif
|
|
@ -0,0 +1,6 @@
|
|||||||
|
set(COMPONENT_SRCS "main.c"
|
||||||
|
"board.c")
|
||||||
|
|
||||||
|
set(COMPONENT_ADD_INCLUDEDIRS ".")
|
||||||
|
|
||||||
|
register_component()
|
@ -2,7 +2,8 @@
|
|||||||
# in this exact order for cmake to work correctly
|
# in this exact order for cmake to work correctly
|
||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/bluetooth/esp_ble_mesh/common_components/button)
|
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/bluetooth/esp_ble_mesh/common_components/button
|
||||||
|
$ENV{IDF_PATH}/examples/bluetooth/esp_ble_mesh/common_components/example_init)
|
||||||
|
|
||||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
set(SUPPORTED_TARGETS esp32)
|
set(SUPPORTED_TARGETS esp32)
|
||||||
|
@ -5,8 +5,7 @@
|
|||||||
|
|
||||||
PROJECT_NAME := onoff_client
|
PROJECT_NAME := onoff_client
|
||||||
|
|
||||||
COMPONENT_ADD_INCLUDEDIRS := components/include
|
EXTRA_COMPONENT_DIRS := $(IDF_PATH)/examples/bluetooth/esp_ble_mesh/common_components/button \
|
||||||
|
$(IDF_PATH)/examples/bluetooth/esp_ble_mesh/common_components/example_init
|
||||||
EXTRA_COMPONENT_DIRS := $(IDF_PATH)/examples/bluetooth/esp_ble_mesh/common_components/button
|
|
||||||
|
|
||||||
include $(IDF_PATH)/make/project.mk
|
include $(IDF_PATH)/make/project.mk
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
set(COMPONENT_SRCS "ble_mesh_demo_main.c"
|
set(COMPONENT_SRCS "ble_mesh_demo_main.c"
|
||||||
"ble_mesh_demo_init.c"
|
|
||||||
"board.c")
|
"board.c")
|
||||||
|
|
||||||
set(COMPONENT_ADD_INCLUDEDIRS ".")
|
set(COMPONENT_ADD_INCLUDEDIRS ".")
|
||||||
|
@ -1,143 +0,0 @@
|
|||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2017 Intel Corporation
|
|
||||||
* Additional Copyright (c) 2018 Espressif Systems (Shanghai) PTE LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <sdkconfig.h>
|
|
||||||
/* BLE */
|
|
||||||
#ifdef CONFIG_BT_BLUEDROID_ENABLED
|
|
||||||
#include "esp_bt.h"
|
|
||||||
#include "esp_bt_main.h"
|
|
||||||
#include "esp_bt_device.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_BT_NIMBLE_ENABLED
|
|
||||||
#include "esp_nimble_hci.h"
|
|
||||||
#include "nimble/nimble_port.h"
|
|
||||||
#include "nimble/nimble_port_freertos.h"
|
|
||||||
#include "host/ble_hs.h"
|
|
||||||
#include "host/util/util.h"
|
|
||||||
#include "console/console.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "esp_ble_mesh_defs.h"
|
|
||||||
#include "ble_mesh_demo_init.h"
|
|
||||||
#include "esp_ble_mesh_common_api.h"
|
|
||||||
|
|
||||||
#ifdef CONFIG_BT_BLUEDROID_ENABLED
|
|
||||||
|
|
||||||
void ble_mesh_get_dev_uuid(uint8_t *dev_uuid)
|
|
||||||
{
|
|
||||||
memcpy(dev_uuid + 2, esp_bt_dev_get_address(), BD_ADDR_LEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_err_t bluetooth_init(void)
|
|
||||||
{
|
|
||||||
esp_err_t ret;
|
|
||||||
|
|
||||||
|
|
||||||
ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT));
|
|
||||||
|
|
||||||
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
|
||||||
ret = esp_bt_controller_init(&bt_cfg);
|
|
||||||
if (ret) {
|
|
||||||
ESP_LOGE(TAG, "%s initialize controller failed", __func__);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = esp_bt_controller_enable(ESP_BT_MODE_BLE);
|
|
||||||
if (ret) {
|
|
||||||
ESP_LOGE(TAG, "%s enable controller failed", __func__);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
ret = esp_bluedroid_init();
|
|
||||||
if (ret) {
|
|
||||||
ESP_LOGE(TAG, "%s init bluetooth failed", __func__);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
ret = esp_bluedroid_enable();
|
|
||||||
if (ret) {
|
|
||||||
ESP_LOGE(TAG, "%s enable bluetooth failed", __func__);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_BT_NIMBLE_ENABLED
|
|
||||||
static SemaphoreHandle_t mesh_sem;
|
|
||||||
static uint8_t own_addr_type;
|
|
||||||
void ble_store_config_init(void);
|
|
||||||
static uint8_t addr_val[6] = {0};
|
|
||||||
|
|
||||||
void ble_mesh_get_dev_uuid(uint8_t *dev_uuid)
|
|
||||||
{
|
|
||||||
memcpy(dev_uuid + 2, addr_val, BD_ADDR_LEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void mesh_on_reset(int reason)
|
|
||||||
{
|
|
||||||
ESP_LOGI(TAG, "Resetting state; reason=%d", reason);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void mesh_on_sync(void)
|
|
||||||
{
|
|
||||||
int rc;
|
|
||||||
|
|
||||||
rc = ble_hs_util_ensure_addr(0);
|
|
||||||
assert(rc == 0);
|
|
||||||
|
|
||||||
/* Figure out address to use while advertising (no privacy for now) */
|
|
||||||
rc = ble_hs_id_infer_auto(0, &own_addr_type);
|
|
||||||
if (rc != 0) {
|
|
||||||
ESP_LOGI(TAG, "error determining address type; rc=%d", rc);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = ble_hs_id_copy_addr(own_addr_type, addr_val, NULL);
|
|
||||||
|
|
||||||
xSemaphoreGive(mesh_sem);
|
|
||||||
}
|
|
||||||
|
|
||||||
void mesh_host_task(void *param)
|
|
||||||
{
|
|
||||||
ESP_LOGI(TAG, "BLE Host Task Started");
|
|
||||||
/* This function will return only when nimble_port_stop() is executed */
|
|
||||||
nimble_port_run();
|
|
||||||
|
|
||||||
nimble_port_freertos_deinit();
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_err_t bluetooth_init(void)
|
|
||||||
{
|
|
||||||
mesh_sem = xSemaphoreCreateBinary();
|
|
||||||
if (mesh_sem == NULL) {
|
|
||||||
ESP_LOGE(TAG, "Failed to create mesh semaphore");
|
|
||||||
return ESP_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ESP_ERROR_CHECK(esp_nimble_hci_and_controller_init());
|
|
||||||
|
|
||||||
nimble_port_init();
|
|
||||||
/* Initialize the NimBLE host configuration. */
|
|
||||||
ble_hs_cfg.reset_cb = mesh_on_reset;
|
|
||||||
ble_hs_cfg.sync_cb = mesh_on_sync;
|
|
||||||
ble_hs_cfg.store_status_cb = ble_store_util_status_rr;
|
|
||||||
|
|
||||||
/* XXX Need to have template for store */
|
|
||||||
ble_store_config_init();
|
|
||||||
|
|
||||||
nimble_port_freertos_init(mesh_host_task);
|
|
||||||
|
|
||||||
xSemaphoreTake(mesh_sem, portMAX_DELAY);
|
|
||||||
|
|
||||||
return ESP_OK;
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -2,6 +2,8 @@
|
|||||||
# in this exact order for cmake to work correctly
|
# in this exact order for cmake to work correctly
|
||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
|
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/bluetooth/esp_ble_mesh/common_components/example_init)
|
||||||
|
|
||||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
set(SUPPORTED_TARGETS esp32)
|
set(SUPPORTED_TARGETS esp32)
|
||||||
project(onoff_server)
|
project(onoff_server)
|
||||||
|
@ -5,6 +5,6 @@
|
|||||||
|
|
||||||
PROJECT_NAME := onoff_server
|
PROJECT_NAME := onoff_server
|
||||||
|
|
||||||
COMPONENT_ADD_INCLUDEDIRS := components/include
|
EXTRA_COMPONENT_DIRS := $(IDF_PATH)/examples/bluetooth/esp_ble_mesh/common_components/example_init
|
||||||
|
|
||||||
include $(IDF_PATH)/make/project.mk
|
include $(IDF_PATH)/make/project.mk
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
set(COMPONENT_SRCS "ble_mesh_demo_main.c"
|
set(COMPONENT_SRCS "ble_mesh_demo_main.c"
|
||||||
"ble_mesh_demo_init.c"
|
|
||||||
"board.c")
|
"board.c")
|
||||||
|
|
||||||
set(COMPONENT_ADD_INCLUDEDIRS ".")
|
set(COMPONENT_ADD_INCLUDEDIRS ".")
|
||||||
|
@ -1,143 +0,0 @@
|
|||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2017 Intel Corporation
|
|
||||||
* Additional Copyright (c) 2018 Espressif Systems (Shanghai) PTE LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <sdkconfig.h>
|
|
||||||
/* BLE */
|
|
||||||
#ifdef CONFIG_BT_BLUEDROID_ENABLED
|
|
||||||
#include "esp_bt.h"
|
|
||||||
#include "esp_bt_main.h"
|
|
||||||
#include "esp_bt_device.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_BT_NIMBLE_ENABLED
|
|
||||||
#include "esp_nimble_hci.h"
|
|
||||||
#include "nimble/nimble_port.h"
|
|
||||||
#include "nimble/nimble_port_freertos.h"
|
|
||||||
#include "host/ble_hs.h"
|
|
||||||
#include "host/util/util.h"
|
|
||||||
#include "console/console.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "esp_ble_mesh_defs.h"
|
|
||||||
#include "ble_mesh_demo_init.h"
|
|
||||||
#include "esp_ble_mesh_common_api.h"
|
|
||||||
|
|
||||||
#ifdef CONFIG_BT_BLUEDROID_ENABLED
|
|
||||||
|
|
||||||
void ble_mesh_get_dev_uuid(uint8_t *dev_uuid)
|
|
||||||
{
|
|
||||||
memcpy(dev_uuid + 2, esp_bt_dev_get_address(), BD_ADDR_LEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_err_t bluetooth_init(void)
|
|
||||||
{
|
|
||||||
esp_err_t ret;
|
|
||||||
|
|
||||||
|
|
||||||
ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT));
|
|
||||||
|
|
||||||
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
|
||||||
ret = esp_bt_controller_init(&bt_cfg);
|
|
||||||
if (ret) {
|
|
||||||
ESP_LOGE(TAG, "%s initialize controller failed", __func__);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = esp_bt_controller_enable(ESP_BT_MODE_BLE);
|
|
||||||
if (ret) {
|
|
||||||
ESP_LOGE(TAG, "%s enable controller failed", __func__);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
ret = esp_bluedroid_init();
|
|
||||||
if (ret) {
|
|
||||||
ESP_LOGE(TAG, "%s init bluetooth failed", __func__);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
ret = esp_bluedroid_enable();
|
|
||||||
if (ret) {
|
|
||||||
ESP_LOGE(TAG, "%s enable bluetooth failed", __func__);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_BT_NIMBLE_ENABLED
|
|
||||||
static SemaphoreHandle_t mesh_sem;
|
|
||||||
static uint8_t own_addr_type;
|
|
||||||
void ble_store_config_init(void);
|
|
||||||
static uint8_t addr_val[6] = {0};
|
|
||||||
|
|
||||||
void ble_mesh_get_dev_uuid(uint8_t *dev_uuid)
|
|
||||||
{
|
|
||||||
memcpy(dev_uuid + 2, addr_val, BD_ADDR_LEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void mesh_on_reset(int reason)
|
|
||||||
{
|
|
||||||
ESP_LOGI(TAG, "Resetting state; reason=%d", reason);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void mesh_on_sync(void)
|
|
||||||
{
|
|
||||||
int rc;
|
|
||||||
|
|
||||||
rc = ble_hs_util_ensure_addr(0);
|
|
||||||
assert(rc == 0);
|
|
||||||
|
|
||||||
/* Figure out address to use while advertising (no privacy for now) */
|
|
||||||
rc = ble_hs_id_infer_auto(0, &own_addr_type);
|
|
||||||
if (rc != 0) {
|
|
||||||
ESP_LOGI(TAG, "error determining address type; rc=%d", rc);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = ble_hs_id_copy_addr(own_addr_type, addr_val, NULL);
|
|
||||||
|
|
||||||
xSemaphoreGive(mesh_sem);
|
|
||||||
}
|
|
||||||
|
|
||||||
void mesh_host_task(void *param)
|
|
||||||
{
|
|
||||||
ESP_LOGI(TAG, "BLE Host Task Started");
|
|
||||||
/* This function will return only when nimble_port_stop() is executed */
|
|
||||||
nimble_port_run();
|
|
||||||
|
|
||||||
nimble_port_freertos_deinit();
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_err_t bluetooth_init(void)
|
|
||||||
{
|
|
||||||
mesh_sem = xSemaphoreCreateBinary();
|
|
||||||
if (mesh_sem == NULL) {
|
|
||||||
ESP_LOGE(TAG, "Failed to create mesh semaphore");
|
|
||||||
return ESP_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ESP_ERROR_CHECK(esp_nimble_hci_and_controller_init());
|
|
||||||
|
|
||||||
nimble_port_init();
|
|
||||||
/* Initialize the NimBLE host configuration. */
|
|
||||||
ble_hs_cfg.reset_cb = mesh_on_reset;
|
|
||||||
ble_hs_cfg.sync_cb = mesh_on_sync;
|
|
||||||
ble_hs_cfg.store_status_cb = ble_store_util_status_rr;
|
|
||||||
|
|
||||||
/* XXX Need to have template for store */
|
|
||||||
ble_store_config_init();
|
|
||||||
|
|
||||||
nimble_port_freertos_init(mesh_host_task);
|
|
||||||
|
|
||||||
xSemaphoreTake(mesh_sem, portMAX_DELAY);
|
|
||||||
|
|
||||||
return ESP_OK;
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -1,18 +0,0 @@
|
|||||||
/*
|
|
||||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, this
|
|
||||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
||||||
CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _BLE_MESH_DEMO_INIT_H_
|
|
||||||
#define _BLE_MESH_DEMO_INIT_H_
|
|
||||||
|
|
||||||
#define TAG "onoff_server"
|
|
||||||
|
|
||||||
void ble_mesh_get_dev_uuid(uint8_t *dev_uuid);
|
|
||||||
|
|
||||||
esp_err_t bluetooth_init(void);
|
|
||||||
|
|
||||||
#endif
|
|
@ -2,6 +2,8 @@
|
|||||||
# in this exact order for cmake to work correctly
|
# in this exact order for cmake to work correctly
|
||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
|
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/bluetooth/esp_ble_mesh/common_components/example_init)
|
||||||
|
|
||||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
set(SUPPORTED_TARGETS esp32)
|
set(SUPPORTED_TARGETS esp32)
|
||||||
project(ble_mesh_provisioner)
|
project(ble_mesh_provisioner)
|
||||||
|
@ -5,6 +5,6 @@
|
|||||||
|
|
||||||
PROJECT_NAME := ble_mesh_provisioner
|
PROJECT_NAME := ble_mesh_provisioner
|
||||||
|
|
||||||
COMPONENT_ADD_INCLUDEDIRS := components/include
|
EXTRA_COMPONENT_DIRS := $(IDF_PATH)/examples/bluetooth/esp_ble_mesh/common_components/example_init
|
||||||
|
|
||||||
include $(IDF_PATH)/make/project.mk
|
include $(IDF_PATH)/make/project.mk
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
set(COMPONENT_SRCS "ble_mesh_demo_main.c"
|
set(COMPONENT_SRCS "ble_mesh_demo_main.c")
|
||||||
"ble_mesh_demo_init.c")
|
|
||||||
|
|
||||||
set(COMPONENT_ADD_INCLUDEDIRS ".")
|
set(COMPONENT_ADD_INCLUDEDIRS ".")
|
||||||
|
|
||||||
|
@ -1,143 +0,0 @@
|
|||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2017 Intel Corporation
|
|
||||||
* Additional Copyright (c) 2018 Espressif Systems (Shanghai) PTE LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <sdkconfig.h>
|
|
||||||
/* BLE */
|
|
||||||
#ifdef CONFIG_BT_BLUEDROID_ENABLED
|
|
||||||
#include "esp_bt.h"
|
|
||||||
#include "esp_bt_main.h"
|
|
||||||
#include "esp_bt_device.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_BT_NIMBLE_ENABLED
|
|
||||||
#include "esp_nimble_hci.h"
|
|
||||||
#include "nimble/nimble_port.h"
|
|
||||||
#include "nimble/nimble_port_freertos.h"
|
|
||||||
#include "host/ble_hs.h"
|
|
||||||
#include "host/util/util.h"
|
|
||||||
#include "console/console.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "esp_ble_mesh_defs.h"
|
|
||||||
#include "ble_mesh_demo_init.h"
|
|
||||||
#include "esp_ble_mesh_common_api.h"
|
|
||||||
|
|
||||||
#ifdef CONFIG_BT_BLUEDROID_ENABLED
|
|
||||||
|
|
||||||
void ble_mesh_get_dev_uuid(uint8_t *dev_uuid)
|
|
||||||
{
|
|
||||||
memcpy(dev_uuid + 2, esp_bt_dev_get_address(), BD_ADDR_LEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_err_t bluetooth_init(void)
|
|
||||||
{
|
|
||||||
esp_err_t ret;
|
|
||||||
|
|
||||||
|
|
||||||
ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT));
|
|
||||||
|
|
||||||
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
|
||||||
ret = esp_bt_controller_init(&bt_cfg);
|
|
||||||
if (ret) {
|
|
||||||
ESP_LOGE(TAG, "%s initialize controller failed", __func__);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = esp_bt_controller_enable(ESP_BT_MODE_BLE);
|
|
||||||
if (ret) {
|
|
||||||
ESP_LOGE(TAG, "%s enable controller failed", __func__);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
ret = esp_bluedroid_init();
|
|
||||||
if (ret) {
|
|
||||||
ESP_LOGE(TAG, "%s init bluetooth failed", __func__);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
ret = esp_bluedroid_enable();
|
|
||||||
if (ret) {
|
|
||||||
ESP_LOGE(TAG, "%s enable bluetooth failed", __func__);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_BT_NIMBLE_ENABLED
|
|
||||||
static SemaphoreHandle_t mesh_sem;
|
|
||||||
static uint8_t own_addr_type;
|
|
||||||
void ble_store_config_init(void);
|
|
||||||
static uint8_t addr_val[6] = {0};
|
|
||||||
|
|
||||||
void ble_mesh_get_dev_uuid(uint8_t *dev_uuid)
|
|
||||||
{
|
|
||||||
memcpy(dev_uuid + 2, addr_val, BD_ADDR_LEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void mesh_on_reset(int reason)
|
|
||||||
{
|
|
||||||
ESP_LOGI(TAG, "Resetting state; reason=%d", reason);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void mesh_on_sync(void)
|
|
||||||
{
|
|
||||||
int rc;
|
|
||||||
|
|
||||||
rc = ble_hs_util_ensure_addr(0);
|
|
||||||
assert(rc == 0);
|
|
||||||
|
|
||||||
/* Figure out address to use while advertising (no privacy for now) */
|
|
||||||
rc = ble_hs_id_infer_auto(0, &own_addr_type);
|
|
||||||
if (rc != 0) {
|
|
||||||
ESP_LOGI(TAG, "error determining address type; rc=%d", rc);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = ble_hs_id_copy_addr(own_addr_type, addr_val, NULL);
|
|
||||||
|
|
||||||
xSemaphoreGive(mesh_sem);
|
|
||||||
}
|
|
||||||
|
|
||||||
void mesh_host_task(void *param)
|
|
||||||
{
|
|
||||||
ESP_LOGI(TAG, "BLE Host Task Started");
|
|
||||||
/* This function will return only when nimble_port_stop() is executed */
|
|
||||||
nimble_port_run();
|
|
||||||
|
|
||||||
nimble_port_freertos_deinit();
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_err_t bluetooth_init(void)
|
|
||||||
{
|
|
||||||
mesh_sem = xSemaphoreCreateBinary();
|
|
||||||
if (mesh_sem == NULL) {
|
|
||||||
ESP_LOGE(TAG, "Failed to create mesh semaphore");
|
|
||||||
return ESP_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ESP_ERROR_CHECK(esp_nimble_hci_and_controller_init());
|
|
||||||
|
|
||||||
nimble_port_init();
|
|
||||||
/* Initialize the NimBLE host configuration. */
|
|
||||||
ble_hs_cfg.reset_cb = mesh_on_reset;
|
|
||||||
ble_hs_cfg.sync_cb = mesh_on_sync;
|
|
||||||
ble_hs_cfg.store_status_cb = ble_store_util_status_rr;
|
|
||||||
|
|
||||||
/* XXX Need to have template for store */
|
|
||||||
ble_store_config_init();
|
|
||||||
|
|
||||||
nimble_port_freertos_init(mesh_host_task);
|
|
||||||
|
|
||||||
xSemaphoreTake(mesh_sem, portMAX_DELAY);
|
|
||||||
|
|
||||||
return ESP_OK;
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -1,18 +0,0 @@
|
|||||||
/*
|
|
||||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, this
|
|
||||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
||||||
CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _BLE_MESH_DEMO_INIT_H_
|
|
||||||
#define _BLE_MESH_DEMO_INIT_H_
|
|
||||||
|
|
||||||
#define TAG "ble_mesh_provisioner"
|
|
||||||
|
|
||||||
void ble_mesh_get_dev_uuid(uint8_t *dev_uuid);
|
|
||||||
|
|
||||||
esp_err_t bluetooth_init(void);
|
|
||||||
|
|
||||||
#endif
|
|
@ -2,7 +2,8 @@
|
|||||||
# in this exact order for cmake to work correctly
|
# in this exact order for cmake to work correctly
|
||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/bluetooth/esp_ble_mesh/common_components/button)
|
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/bluetooth/esp_ble_mesh/common_components/button
|
||||||
|
$ENV{IDF_PATH}/examples/bluetooth/esp_ble_mesh/common_components/example_init)
|
||||||
|
|
||||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
set(SUPPORTED_TARGETS esp32)
|
set(SUPPORTED_TARGETS esp32)
|
||||||
|
@ -5,8 +5,7 @@
|
|||||||
|
|
||||||
PROJECT_NAME := sensor_client
|
PROJECT_NAME := sensor_client
|
||||||
|
|
||||||
COMPONENT_ADD_INCLUDEDIRS := components/include
|
EXTRA_COMPONENT_DIRS := $(IDF_PATH)/examples/bluetooth/esp_ble_mesh/common_components/button \
|
||||||
|
$(IDF_PATH)/examples/bluetooth/esp_ble_mesh/common_components/example_init
|
||||||
EXTRA_COMPONENT_DIRS := $(IDF_PATH)/examples/bluetooth/esp_ble_mesh/common_components/button
|
|
||||||
|
|
||||||
include $(IDF_PATH)/make/project.mk
|
include $(IDF_PATH)/make/project.mk
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
set(srcs "ble_mesh_demo_main.c"
|
set(srcs "ble_mesh_demo_main.c"
|
||||||
"ble_mesh_demo_init.c"
|
|
||||||
"board.c")
|
"board.c")
|
||||||
|
|
||||||
idf_component_register(SRCS "${srcs}"
|
idf_component_register(SRCS "${srcs}"
|
||||||
|
@ -1,152 +0,0 @@
|
|||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2017 Intel Corporation
|
|
||||||
* Additional Copyright (c) 2018 Espressif Systems (Shanghai) PTE LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <sdkconfig.h>
|
|
||||||
/* BLE */
|
|
||||||
#ifdef CONFIG_BT_BLUEDROID_ENABLED
|
|
||||||
#include "esp_bt.h"
|
|
||||||
#include "esp_bt_main.h"
|
|
||||||
#include "esp_bt_device.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_BT_NIMBLE_ENABLED
|
|
||||||
#include "esp_nimble_hci.h"
|
|
||||||
#include "nimble/nimble_port.h"
|
|
||||||
#include "nimble/nimble_port_freertos.h"
|
|
||||||
#include "host/ble_hs.h"
|
|
||||||
#include "host/util/util.h"
|
|
||||||
#include "console/console.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "esp_ble_mesh_defs.h"
|
|
||||||
#include "ble_mesh_demo_init.h"
|
|
||||||
#include "esp_ble_mesh_common_api.h"
|
|
||||||
|
|
||||||
#ifdef CONFIG_BT_BLUEDROID_ENABLED
|
|
||||||
|
|
||||||
void ble_mesh_get_dev_uuid(uint8_t *dev_uuid)
|
|
||||||
{
|
|
||||||
if (dev_uuid == NULL) {
|
|
||||||
ESP_LOGE(TAG, "%s, Invalid device uuid", __func__);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Copy device address to the device uuid with offset equals to 2 here.
|
|
||||||
* The first two bytes is used for matching device uuid by Provisioner.
|
|
||||||
* And using device address here is to avoid using the same device uuid
|
|
||||||
* by different unprovisioned devices.
|
|
||||||
*/
|
|
||||||
memcpy(dev_uuid + 2, esp_bt_dev_get_address(), BD_ADDR_LEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_err_t bluetooth_init(void)
|
|
||||||
{
|
|
||||||
esp_err_t ret;
|
|
||||||
|
|
||||||
ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT));
|
|
||||||
|
|
||||||
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
|
||||||
ret = esp_bt_controller_init(&bt_cfg);
|
|
||||||
if (ret) {
|
|
||||||
ESP_LOGE(TAG, "%s initialize controller failed", __func__);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = esp_bt_controller_enable(ESP_BT_MODE_BLE);
|
|
||||||
if (ret) {
|
|
||||||
ESP_LOGE(TAG, "%s enable controller failed", __func__);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
ret = esp_bluedroid_init();
|
|
||||||
if (ret) {
|
|
||||||
ESP_LOGE(TAG, "%s init bluetooth failed", __func__);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
ret = esp_bluedroid_enable();
|
|
||||||
if (ret) {
|
|
||||||
ESP_LOGE(TAG, "%s enable bluetooth failed", __func__);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_BT_NIMBLE_ENABLED
|
|
||||||
static SemaphoreHandle_t mesh_sem;
|
|
||||||
static uint8_t own_addr_type;
|
|
||||||
void ble_store_config_init(void);
|
|
||||||
static uint8_t addr_val[BD_ADDR_LEN] = {0};
|
|
||||||
|
|
||||||
void ble_mesh_get_dev_uuid(uint8_t *dev_uuid)
|
|
||||||
{
|
|
||||||
memcpy(dev_uuid + 2, addr_val, BD_ADDR_LEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void mesh_on_reset(int reason)
|
|
||||||
{
|
|
||||||
ESP_LOGI(TAG, "Resetting state; reason=%d", reason);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void mesh_on_sync(void)
|
|
||||||
{
|
|
||||||
int rc;
|
|
||||||
|
|
||||||
rc = ble_hs_util_ensure_addr(0);
|
|
||||||
assert(rc == 0);
|
|
||||||
|
|
||||||
/* Figure out address to use while advertising (no privacy for now) */
|
|
||||||
rc = ble_hs_id_infer_auto(0, &own_addr_type);
|
|
||||||
if (rc != 0) {
|
|
||||||
ESP_LOGI(TAG, "error determining address type; rc=%d", rc);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = ble_hs_id_copy_addr(own_addr_type, addr_val, NULL);
|
|
||||||
|
|
||||||
xSemaphoreGive(mesh_sem);
|
|
||||||
}
|
|
||||||
|
|
||||||
void mesh_host_task(void *param)
|
|
||||||
{
|
|
||||||
ESP_LOGI(TAG, "BLE Host Task Started");
|
|
||||||
/* This function will return only when nimble_port_stop() is executed */
|
|
||||||
nimble_port_run();
|
|
||||||
|
|
||||||
nimble_port_freertos_deinit();
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_err_t bluetooth_init(void)
|
|
||||||
{
|
|
||||||
mesh_sem = xSemaphoreCreateBinary();
|
|
||||||
if (mesh_sem == NULL) {
|
|
||||||
ESP_LOGE(TAG, "Failed to create mesh semaphore");
|
|
||||||
return ESP_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ESP_ERROR_CHECK(esp_nimble_hci_and_controller_init());
|
|
||||||
|
|
||||||
nimble_port_init();
|
|
||||||
/* Initialize the NimBLE host configuration. */
|
|
||||||
ble_hs_cfg.reset_cb = mesh_on_reset;
|
|
||||||
ble_hs_cfg.sync_cb = mesh_on_sync;
|
|
||||||
ble_hs_cfg.store_status_cb = ble_store_util_status_rr;
|
|
||||||
|
|
||||||
/* XXX Need to have template for store */
|
|
||||||
ble_store_config_init();
|
|
||||||
|
|
||||||
nimble_port_freertos_init(mesh_host_task);
|
|
||||||
|
|
||||||
xSemaphoreTake(mesh_sem, portMAX_DELAY);
|
|
||||||
|
|
||||||
return ESP_OK;
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -1,18 +0,0 @@
|
|||||||
/*
|
|
||||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, this
|
|
||||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
||||||
CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _BLE_MESH_DEMO_INIT_H_
|
|
||||||
#define _BLE_MESH_DEMO_INIT_H_
|
|
||||||
|
|
||||||
#define TAG "Client"
|
|
||||||
|
|
||||||
void ble_mesh_get_dev_uuid(uint8_t *dev_uuid);
|
|
||||||
|
|
||||||
esp_err_t bluetooth_init(void);
|
|
||||||
|
|
||||||
#endif
|
|
@ -2,6 +2,8 @@
|
|||||||
# in this exact order for cmake to work correctly
|
# in this exact order for cmake to work correctly
|
||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
|
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/bluetooth/esp_ble_mesh/common_components/example_init)
|
||||||
|
|
||||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
set(SUPPORTED_TARGETS esp32)
|
set(SUPPORTED_TARGETS esp32)
|
||||||
project(sensor_server)
|
project(sensor_server)
|
||||||
|
@ -5,6 +5,6 @@
|
|||||||
|
|
||||||
PROJECT_NAME := sensor_server
|
PROJECT_NAME := sensor_server
|
||||||
|
|
||||||
COMPONENT_ADD_INCLUDEDIRS := components/include
|
EXTRA_COMPONENT_DIRS := $(IDF_PATH)/examples/bluetooth/esp_ble_mesh/common_components/example_init
|
||||||
|
|
||||||
include $(IDF_PATH)/make/project.mk
|
include $(IDF_PATH)/make/project.mk
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
set(srcs "ble_mesh_demo_main.c"
|
set(srcs "ble_mesh_demo_main.c"
|
||||||
"ble_mesh_demo_init.c"
|
|
||||||
"board.c")
|
"board.c")
|
||||||
|
|
||||||
idf_component_register(SRCS "${srcs}"
|
idf_component_register(SRCS "${srcs}"
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
/*
|
|
||||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, this
|
|
||||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
||||||
CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _BLE_MESH_DEMO_INIT_H_
|
|
||||||
#define _BLE_MESH_DEMO_INIT_H_
|
|
||||||
|
|
||||||
#define TAG "Server"
|
|
||||||
|
|
||||||
void ble_mesh_get_dev_uuid(uint8_t *dev_uuid);
|
|
||||||
|
|
||||||
esp_err_t bluetooth_init(void);
|
|
||||||
|
|
||||||
#endif
|
|
@ -2,7 +2,8 @@
|
|||||||
# in this exact order for cmake to work correctly
|
# in this exact order for cmake to work correctly
|
||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/bluetooth/esp_ble_mesh/common_components/button)
|
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/bluetooth/esp_ble_mesh/common_components/button
|
||||||
|
$ENV{IDF_PATH}/examples/bluetooth/esp_ble_mesh/common_components/example_init)
|
||||||
|
|
||||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
set(SUPPORTED_TARGETS esp32)
|
set(SUPPORTED_TARGETS esp32)
|
||||||
|
@ -5,8 +5,7 @@
|
|||||||
|
|
||||||
PROJECT_NAME := vendor_client
|
PROJECT_NAME := vendor_client
|
||||||
|
|
||||||
COMPONENT_ADD_INCLUDEDIRS := components/include
|
EXTRA_COMPONENT_DIRS := $(IDF_PATH)/examples/bluetooth/esp_ble_mesh/common_components/button \
|
||||||
|
$(IDF_PATH)/examples/bluetooth/esp_ble_mesh/common_components/example_init
|
||||||
EXTRA_COMPONENT_DIRS := $(IDF_PATH)/examples/bluetooth/esp_ble_mesh/common_components/button
|
|
||||||
|
|
||||||
include $(IDF_PATH)/make/project.mk
|
include $(IDF_PATH)/make/project.mk
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
set(COMPONENT_SRCS "ble_mesh_demo_main.c"
|
set(COMPONENT_SRCS "ble_mesh_demo_main.c"
|
||||||
"ble_mesh_demo_init.c"
|
|
||||||
"board.c")
|
"board.c")
|
||||||
|
|
||||||
set(COMPONENT_ADD_INCLUDEDIRS ".")
|
set(COMPONENT_ADD_INCLUDEDIRS ".")
|
||||||
|
@ -1,152 +0,0 @@
|
|||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2017 Intel Corporation
|
|
||||||
* Additional Copyright (c) 2018 Espressif Systems (Shanghai) PTE LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <sdkconfig.h>
|
|
||||||
/* BLE */
|
|
||||||
#ifdef CONFIG_BT_BLUEDROID_ENABLED
|
|
||||||
#include "esp_bt.h"
|
|
||||||
#include "esp_bt_main.h"
|
|
||||||
#include "esp_bt_device.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_BT_NIMBLE_ENABLED
|
|
||||||
#include "esp_nimble_hci.h"
|
|
||||||
#include "nimble/nimble_port.h"
|
|
||||||
#include "nimble/nimble_port_freertos.h"
|
|
||||||
#include "host/ble_hs.h"
|
|
||||||
#include "host/util/util.h"
|
|
||||||
#include "console/console.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "esp_ble_mesh_defs.h"
|
|
||||||
#include "ble_mesh_demo_init.h"
|
|
||||||
#include "esp_ble_mesh_common_api.h"
|
|
||||||
|
|
||||||
#ifdef CONFIG_BT_BLUEDROID_ENABLED
|
|
||||||
|
|
||||||
void ble_mesh_get_dev_uuid(uint8_t *dev_uuid)
|
|
||||||
{
|
|
||||||
if (dev_uuid == NULL) {
|
|
||||||
ESP_LOGE(TAG, "%s, Invalid device uuid", __func__);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Copy device address to the device uuid with offset equals to 2 here.
|
|
||||||
* The first two bytes is used for matching device uuid by Provisioner.
|
|
||||||
* And using device address here is to avoid using the same device uuid
|
|
||||||
* by different unprovisioned devices.
|
|
||||||
*/
|
|
||||||
memcpy(dev_uuid + 2, esp_bt_dev_get_address(), BD_ADDR_LEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_err_t bluetooth_init(void)
|
|
||||||
{
|
|
||||||
esp_err_t ret;
|
|
||||||
|
|
||||||
ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT));
|
|
||||||
|
|
||||||
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
|
||||||
ret = esp_bt_controller_init(&bt_cfg);
|
|
||||||
if (ret) {
|
|
||||||
ESP_LOGE(TAG, "%s initialize controller failed", __func__);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = esp_bt_controller_enable(ESP_BT_MODE_BLE);
|
|
||||||
if (ret) {
|
|
||||||
ESP_LOGE(TAG, "%s enable controller failed", __func__);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
ret = esp_bluedroid_init();
|
|
||||||
if (ret) {
|
|
||||||
ESP_LOGE(TAG, "%s init bluetooth failed", __func__);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
ret = esp_bluedroid_enable();
|
|
||||||
if (ret) {
|
|
||||||
ESP_LOGE(TAG, "%s enable bluetooth failed", __func__);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_BT_NIMBLE_ENABLED
|
|
||||||
static SemaphoreHandle_t mesh_sem;
|
|
||||||
static uint8_t own_addr_type;
|
|
||||||
void ble_store_config_init(void);
|
|
||||||
static uint8_t addr_val[BD_ADDR_LEN] = {0};
|
|
||||||
|
|
||||||
void ble_mesh_get_dev_uuid(uint8_t *dev_uuid)
|
|
||||||
{
|
|
||||||
memcpy(dev_uuid + 2, addr_val, BD_ADDR_LEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void mesh_on_reset(int reason)
|
|
||||||
{
|
|
||||||
ESP_LOGI(TAG, "Resetting state; reason=%d", reason);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void mesh_on_sync(void)
|
|
||||||
{
|
|
||||||
int rc;
|
|
||||||
|
|
||||||
rc = ble_hs_util_ensure_addr(0);
|
|
||||||
assert(rc == 0);
|
|
||||||
|
|
||||||
/* Figure out address to use while advertising (no privacy for now) */
|
|
||||||
rc = ble_hs_id_infer_auto(0, &own_addr_type);
|
|
||||||
if (rc != 0) {
|
|
||||||
ESP_LOGI(TAG, "error determining address type; rc=%d", rc);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = ble_hs_id_copy_addr(own_addr_type, addr_val, NULL);
|
|
||||||
|
|
||||||
xSemaphoreGive(mesh_sem);
|
|
||||||
}
|
|
||||||
|
|
||||||
void mesh_host_task(void *param)
|
|
||||||
{
|
|
||||||
ESP_LOGI(TAG, "BLE Host Task Started");
|
|
||||||
/* This function will return only when nimble_port_stop() is executed */
|
|
||||||
nimble_port_run();
|
|
||||||
|
|
||||||
nimble_port_freertos_deinit();
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_err_t bluetooth_init(void)
|
|
||||||
{
|
|
||||||
mesh_sem = xSemaphoreCreateBinary();
|
|
||||||
if (mesh_sem == NULL) {
|
|
||||||
ESP_LOGE(TAG, "Failed to create mesh semaphore");
|
|
||||||
return ESP_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ESP_ERROR_CHECK(esp_nimble_hci_and_controller_init());
|
|
||||||
|
|
||||||
nimble_port_init();
|
|
||||||
/* Initialize the NimBLE host configuration. */
|
|
||||||
ble_hs_cfg.reset_cb = mesh_on_reset;
|
|
||||||
ble_hs_cfg.sync_cb = mesh_on_sync;
|
|
||||||
ble_hs_cfg.store_status_cb = ble_store_util_status_rr;
|
|
||||||
|
|
||||||
/* XXX Need to have template for store */
|
|
||||||
ble_store_config_init();
|
|
||||||
|
|
||||||
nimble_port_freertos_init(mesh_host_task);
|
|
||||||
|
|
||||||
xSemaphoreTake(mesh_sem, portMAX_DELAY);
|
|
||||||
|
|
||||||
return ESP_OK;
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -1,18 +0,0 @@
|
|||||||
/*
|
|
||||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, this
|
|
||||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
||||||
CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _BLE_MESH_DEMO_INIT_H_
|
|
||||||
#define _BLE_MESH_DEMO_INIT_H_
|
|
||||||
|
|
||||||
#define TAG "Client"
|
|
||||||
|
|
||||||
void ble_mesh_get_dev_uuid(uint8_t *dev_uuid);
|
|
||||||
|
|
||||||
esp_err_t bluetooth_init(void);
|
|
||||||
|
|
||||||
#endif
|
|
@ -2,6 +2,8 @@
|
|||||||
# in this exact order for cmake to work correctly
|
# in this exact order for cmake to work correctly
|
||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
|
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/bluetooth/esp_ble_mesh/common_components/example_init)
|
||||||
|
|
||||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
set(SUPPORTED_TARGETS esp32)
|
set(SUPPORTED_TARGETS esp32)
|
||||||
project(vendor_server)
|
project(vendor_server)
|
||||||
|
@ -5,6 +5,6 @@
|
|||||||
|
|
||||||
PROJECT_NAME := vendor_server
|
PROJECT_NAME := vendor_server
|
||||||
|
|
||||||
COMPONENT_ADD_INCLUDEDIRS := components/include
|
EXTRA_COMPONENT_DIRS := $(IDF_PATH)/examples/bluetooth/esp_ble_mesh/common_components/example_init
|
||||||
|
|
||||||
include $(IDF_PATH)/make/project.mk
|
include $(IDF_PATH)/make/project.mk
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
set(COMPONENT_SRCS "ble_mesh_demo_main.c"
|
set(COMPONENT_SRCS "ble_mesh_demo_main.c"
|
||||||
"ble_mesh_demo_init.c"
|
|
||||||
"board.c")
|
"board.c")
|
||||||
|
|
||||||
set(COMPONENT_ADD_INCLUDEDIRS ".")
|
set(COMPONENT_ADD_INCLUDEDIRS ".")
|
||||||
|
@ -1,153 +0,0 @@
|
|||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2017 Intel Corporation
|
|
||||||
* Additional Copyright (c) 2018 Espressif Systems (Shanghai) PTE LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <sdkconfig.h>
|
|
||||||
/* BLE */
|
|
||||||
#ifdef CONFIG_BT_BLUEDROID_ENABLED
|
|
||||||
#include "esp_bt.h"
|
|
||||||
#include "esp_bt_main.h"
|
|
||||||
#include "esp_bt_device.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_BT_NIMBLE_ENABLED
|
|
||||||
#include "esp_nimble_hci.h"
|
|
||||||
#include "nimble/nimble_port.h"
|
|
||||||
#include "nimble/nimble_port_freertos.h"
|
|
||||||
#include "host/ble_hs.h"
|
|
||||||
#include "host/util/util.h"
|
|
||||||
#include "console/console.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "esp_ble_mesh_defs.h"
|
|
||||||
#include "ble_mesh_demo_init.h"
|
|
||||||
#include "esp_ble_mesh_common_api.h"
|
|
||||||
|
|
||||||
#ifdef CONFIG_BT_BLUEDROID_ENABLED
|
|
||||||
|
|
||||||
void ble_mesh_get_dev_uuid(uint8_t *dev_uuid)
|
|
||||||
{
|
|
||||||
if (dev_uuid == NULL) {
|
|
||||||
ESP_LOGE(TAG, "%s, Invalid device uuid", __func__);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Copy device address to the device uuid with offset equals to 2 here.
|
|
||||||
* The first two bytes is used for matching device uuid by Provisioner.
|
|
||||||
* And using device address here is to avoid using the same device uuid
|
|
||||||
* by different unprovisioned devices.
|
|
||||||
*/
|
|
||||||
memcpy(dev_uuid + 2, esp_bt_dev_get_address(), BD_ADDR_LEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_err_t bluetooth_init(void)
|
|
||||||
{
|
|
||||||
esp_err_t ret;
|
|
||||||
|
|
||||||
|
|
||||||
ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT));
|
|
||||||
|
|
||||||
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
|
||||||
ret = esp_bt_controller_init(&bt_cfg);
|
|
||||||
if (ret) {
|
|
||||||
ESP_LOGE(TAG, "%s initialize controller failed", __func__);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = esp_bt_controller_enable(ESP_BT_MODE_BLE);
|
|
||||||
if (ret) {
|
|
||||||
ESP_LOGE(TAG, "%s enable controller failed", __func__);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
ret = esp_bluedroid_init();
|
|
||||||
if (ret) {
|
|
||||||
ESP_LOGE(TAG, "%s init bluetooth failed", __func__);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
ret = esp_bluedroid_enable();
|
|
||||||
if (ret) {
|
|
||||||
ESP_LOGE(TAG, "%s enable bluetooth failed", __func__);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_BT_NIMBLE_ENABLED
|
|
||||||
static SemaphoreHandle_t mesh_sem;
|
|
||||||
static uint8_t own_addr_type;
|
|
||||||
void ble_store_config_init(void);
|
|
||||||
static uint8_t addr_val[BD_ADDR_LEN] = {0};
|
|
||||||
|
|
||||||
void ble_mesh_get_dev_uuid(uint8_t *dev_uuid)
|
|
||||||
{
|
|
||||||
memcpy(dev_uuid + 2, addr_val, BD_ADDR_LEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void mesh_on_reset(int reason)
|
|
||||||
{
|
|
||||||
ESP_LOGI(TAG, "Resetting state; reason=%d", reason);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void mesh_on_sync(void)
|
|
||||||
{
|
|
||||||
int rc;
|
|
||||||
|
|
||||||
rc = ble_hs_util_ensure_addr(0);
|
|
||||||
assert(rc == 0);
|
|
||||||
|
|
||||||
/* Figure out address to use while advertising (no privacy for now) */
|
|
||||||
rc = ble_hs_id_infer_auto(0, &own_addr_type);
|
|
||||||
if (rc != 0) {
|
|
||||||
ESP_LOGI(TAG, "error determining address type; rc=%d", rc);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = ble_hs_id_copy_addr(own_addr_type, addr_val, NULL);
|
|
||||||
|
|
||||||
xSemaphoreGive(mesh_sem);
|
|
||||||
}
|
|
||||||
|
|
||||||
void mesh_host_task(void *param)
|
|
||||||
{
|
|
||||||
ESP_LOGI(TAG, "BLE Host Task Started");
|
|
||||||
/* This function will return only when nimble_port_stop() is executed */
|
|
||||||
nimble_port_run();
|
|
||||||
|
|
||||||
nimble_port_freertos_deinit();
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_err_t bluetooth_init(void)
|
|
||||||
{
|
|
||||||
mesh_sem = xSemaphoreCreateBinary();
|
|
||||||
if (mesh_sem == NULL) {
|
|
||||||
ESP_LOGE(TAG, "Failed to create mesh semaphore");
|
|
||||||
return ESP_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ESP_ERROR_CHECK(esp_nimble_hci_and_controller_init());
|
|
||||||
|
|
||||||
nimble_port_init();
|
|
||||||
/* Initialize the NimBLE host configuration. */
|
|
||||||
ble_hs_cfg.reset_cb = mesh_on_reset;
|
|
||||||
ble_hs_cfg.sync_cb = mesh_on_sync;
|
|
||||||
ble_hs_cfg.store_status_cb = ble_store_util_status_rr;
|
|
||||||
|
|
||||||
/* XXX Need to have template for store */
|
|
||||||
ble_store_config_init();
|
|
||||||
|
|
||||||
nimble_port_freertos_init(mesh_host_task);
|
|
||||||
|
|
||||||
xSemaphoreTake(mesh_sem, portMAX_DELAY);
|
|
||||||
|
|
||||||
return ESP_OK;
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -1,18 +0,0 @@
|
|||||||
/*
|
|
||||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, this
|
|
||||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
||||||
CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _BLE_MESH_DEMO_INIT_H_
|
|
||||||
#define _BLE_MESH_DEMO_INIT_H_
|
|
||||||
|
|
||||||
#define TAG "Server"
|
|
||||||
|
|
||||||
void ble_mesh_get_dev_uuid(uint8_t *dev_uuid);
|
|
||||||
|
|
||||||
esp_err_t bluetooth_init(void);
|
|
||||||
|
|
||||||
#endif
|
|
@ -2,7 +2,8 @@
|
|||||||
# in this exact order for cmake to work correctly
|
# in this exact order for cmake to work correctly
|
||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/bluetooth/esp_ble_mesh/common_components/fast_prov_vendor_model)
|
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/bluetooth/esp_ble_mesh/common_components/example_init
|
||||||
|
$ENV{IDF_PATH}/examples/bluetooth/esp_ble_mesh/common_components/fast_prov_vendor_model)
|
||||||
|
|
||||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
set(SUPPORTED_TARGETS esp32)
|
set(SUPPORTED_TARGETS esp32)
|
||||||
|
@ -5,8 +5,7 @@
|
|||||||
|
|
||||||
PROJECT_NAME := ble_mesh_wifi_coexist
|
PROJECT_NAME := ble_mesh_wifi_coexist
|
||||||
|
|
||||||
COMPONENT_ADD_INCLUDEDIRS := components/include
|
EXTRA_COMPONENT_DIRS := $(IDF_PATH)/examples/bluetooth/esp_ble_mesh/common_components/example_init \
|
||||||
|
$(IDF_PATH)/examples/bluetooth/esp_ble_mesh/common_components/fast_prov_vendor_model
|
||||||
EXTRA_COMPONENT_DIRS := $(IDF_PATH)/examples/bluetooth/esp_ble_mesh/common_components/fast_prov_vendor_model
|
|
||||||
|
|
||||||
include $(IDF_PATH)/make/project.mk
|
include $(IDF_PATH)/make/project.mk
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
set(COMPONENT_SRCS "ble_mesh_demo_main.c"
|
set(COMPONENT_SRCS "ble_mesh_demo_main.c"
|
||||||
"ble_mesh_demo_init.c"
|
|
||||||
"board.c")
|
"board.c")
|
||||||
|
|
||||||
set(COMPONENT_ADD_INCLUDEDIRS ".")
|
set(COMPONENT_ADD_INCLUDEDIRS ".")
|
||||||
|
@ -1,143 +0,0 @@
|
|||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2017 Intel Corporation
|
|
||||||
* Additional Copyright (c) 2018 Espressif Systems (Shanghai) PTE LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <sdkconfig.h>
|
|
||||||
/* BLE */
|
|
||||||
#ifdef CONFIG_BT_BLUEDROID_ENABLED
|
|
||||||
#include "esp_bt.h"
|
|
||||||
#include "esp_bt_main.h"
|
|
||||||
#include "esp_bt_device.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_BT_NIMBLE_ENABLED
|
|
||||||
#include "esp_nimble_hci.h"
|
|
||||||
#include "nimble/nimble_port.h"
|
|
||||||
#include "nimble/nimble_port_freertos.h"
|
|
||||||
#include "host/ble_hs.h"
|
|
||||||
#include "host/util/util.h"
|
|
||||||
#include "console/console.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "esp_ble_mesh_defs.h"
|
|
||||||
#include "ble_mesh_demo_init.h"
|
|
||||||
#include "esp_ble_mesh_common_api.h"
|
|
||||||
|
|
||||||
#ifdef CONFIG_BT_BLUEDROID_ENABLED
|
|
||||||
|
|
||||||
void ble_mesh_get_dev_uuid(uint8_t *dev_uuid)
|
|
||||||
{
|
|
||||||
memcpy(dev_uuid + 2, esp_bt_dev_get_address(), BD_ADDR_LEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_err_t bluetooth_init(void)
|
|
||||||
{
|
|
||||||
esp_err_t ret;
|
|
||||||
|
|
||||||
|
|
||||||
ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT));
|
|
||||||
|
|
||||||
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
|
||||||
ret = esp_bt_controller_init(&bt_cfg);
|
|
||||||
if (ret) {
|
|
||||||
ESP_LOGE(TAG, "%s initialize controller failed", __func__);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = esp_bt_controller_enable(ESP_BT_MODE_BLE);
|
|
||||||
if (ret) {
|
|
||||||
ESP_LOGE(TAG, "%s enable controller failed", __func__);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
ret = esp_bluedroid_init();
|
|
||||||
if (ret) {
|
|
||||||
ESP_LOGE(TAG, "%s init bluetooth failed", __func__);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
ret = esp_bluedroid_enable();
|
|
||||||
if (ret) {
|
|
||||||
ESP_LOGE(TAG, "%s enable bluetooth failed", __func__);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_BT_NIMBLE_ENABLED
|
|
||||||
static SemaphoreHandle_t mesh_sem;
|
|
||||||
static uint8_t own_addr_type;
|
|
||||||
void ble_store_config_init(void);
|
|
||||||
static uint8_t addr_val[6] = {0};
|
|
||||||
|
|
||||||
void ble_mesh_get_dev_uuid(uint8_t *dev_uuid)
|
|
||||||
{
|
|
||||||
memcpy(dev_uuid + 2, addr_val, BD_ADDR_LEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void mesh_on_reset(int reason)
|
|
||||||
{
|
|
||||||
ESP_LOGI(TAG, "Resetting state; reason=%d", reason);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void mesh_on_sync(void)
|
|
||||||
{
|
|
||||||
int rc;
|
|
||||||
|
|
||||||
rc = ble_hs_util_ensure_addr(0);
|
|
||||||
assert(rc == 0);
|
|
||||||
|
|
||||||
/* Figure out address to use while advertising (no privacy for now) */
|
|
||||||
rc = ble_hs_id_infer_auto(0, &own_addr_type);
|
|
||||||
if (rc != 0) {
|
|
||||||
ESP_LOGI(TAG, "error determining address type; rc=%d", rc);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = ble_hs_id_copy_addr(own_addr_type, addr_val, NULL);
|
|
||||||
|
|
||||||
xSemaphoreGive(mesh_sem);
|
|
||||||
}
|
|
||||||
|
|
||||||
void mesh_host_task(void *param)
|
|
||||||
{
|
|
||||||
ESP_LOGI(TAG, "BLE Host Task Started");
|
|
||||||
/* This function will return only when nimble_port_stop() is executed */
|
|
||||||
nimble_port_run();
|
|
||||||
|
|
||||||
nimble_port_freertos_deinit();
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_err_t bluetooth_init(void)
|
|
||||||
{
|
|
||||||
mesh_sem = xSemaphoreCreateBinary();
|
|
||||||
if (mesh_sem == NULL) {
|
|
||||||
ESP_LOGE(TAG, "Failed to create mesh semaphore");
|
|
||||||
return ESP_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ESP_ERROR_CHECK(esp_nimble_hci_and_controller_init());
|
|
||||||
|
|
||||||
nimble_port_init();
|
|
||||||
/* Initialize the NimBLE host configuration. */
|
|
||||||
ble_hs_cfg.reset_cb = mesh_on_reset;
|
|
||||||
ble_hs_cfg.sync_cb = mesh_on_sync;
|
|
||||||
ble_hs_cfg.store_status_cb = ble_store_util_status_rr;
|
|
||||||
|
|
||||||
/* XXX Need to have template for store */
|
|
||||||
ble_store_config_init();
|
|
||||||
|
|
||||||
nimble_port_freertos_init(mesh_host_task);
|
|
||||||
|
|
||||||
xSemaphoreTake(mesh_sem, portMAX_DELAY);
|
|
||||||
|
|
||||||
return ESP_OK;
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -1,18 +0,0 @@
|
|||||||
/*
|
|
||||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, this
|
|
||||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
||||||
CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _BLE_MESH_DEMO_INIT_H_
|
|
||||||
#define _BLE_MESH_DEMO_INIT_H_
|
|
||||||
|
|
||||||
#define TAG "BLE_MESH_WIFI_COEXIST_DEMO"
|
|
||||||
|
|
||||||
void ble_mesh_get_dev_uuid(uint8_t *dev_uuid);
|
|
||||||
|
|
||||||
esp_err_t bluetooth_init(void);
|
|
||||||
|
|
||||||
#endif
|
|
@ -0,0 +1,3 @@
|
|||||||
|
idf_component_register(SRCS "ble_mesh_demo_init.c"
|
||||||
|
INCLUDE_DIRS "."
|
||||||
|
REQUIRES bt)
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2017 Intel Corporation
|
* Copyright (c) 2017 Intel Corporation
|
||||||
* Additional Copyright (c) 2018 Espressif Systems (Shanghai) PTE LTD
|
* Additional Copyright (c) 2020 Espressif Systems (Shanghai) PTE LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -9,7 +9,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sdkconfig.h>
|
#include <sdkconfig.h>
|
||||||
/* BLE */
|
|
||||||
#ifdef CONFIG_BT_BLUEDROID_ENABLED
|
#ifdef CONFIG_BT_BLUEDROID_ENABLED
|
||||||
#include "esp_bt.h"
|
#include "esp_bt.h"
|
||||||
#include "esp_bt_main.h"
|
#include "esp_bt_main.h"
|
||||||
@ -27,10 +27,8 @@
|
|||||||
|
|
||||||
#include "esp_ble_mesh_defs.h"
|
#include "esp_ble_mesh_defs.h"
|
||||||
#include "ble_mesh_demo_init.h"
|
#include "ble_mesh_demo_init.h"
|
||||||
#include "esp_ble_mesh_common_api.h"
|
|
||||||
|
|
||||||
#ifdef CONFIG_BT_BLUEDROID_ENABLED
|
#ifdef CONFIG_BT_BLUEDROID_ENABLED
|
||||||
|
|
||||||
void ble_mesh_get_dev_uuid(uint8_t *dev_uuid)
|
void ble_mesh_get_dev_uuid(uint8_t *dev_uuid)
|
||||||
{
|
{
|
||||||
if (dev_uuid == NULL) {
|
if (dev_uuid == NULL) {
|
||||||
@ -50,7 +48,6 @@ esp_err_t bluetooth_init(void)
|
|||||||
{
|
{
|
||||||
esp_err_t ret;
|
esp_err_t ret;
|
||||||
|
|
||||||
|
|
||||||
ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT));
|
ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT));
|
||||||
|
|
||||||
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
||||||
@ -78,17 +75,26 @@ esp_err_t bluetooth_init(void)
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#endif /* CONFIG_BT_BLUEDROID_ENABLED */
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_BT_NIMBLE_ENABLED
|
#ifdef CONFIG_BT_NIMBLE_ENABLED
|
||||||
static SemaphoreHandle_t mesh_sem;
|
static SemaphoreHandle_t mesh_sem;
|
||||||
static uint8_t own_addr_type;
|
static uint8_t own_addr_type;
|
||||||
void ble_store_config_init(void);
|
void ble_store_config_init(void);
|
||||||
static uint8_t addr_val[BD_ADDR_LEN] = {0};
|
static uint8_t addr_val[6] = {0};
|
||||||
|
|
||||||
void ble_mesh_get_dev_uuid(uint8_t *dev_uuid)
|
void ble_mesh_get_dev_uuid(uint8_t *dev_uuid)
|
||||||
{
|
{
|
||||||
|
if (dev_uuid == NULL) {
|
||||||
|
ESP_LOGE(TAG, "%s, Invalid device uuid", __func__);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Copy device address to the device uuid with offset equals to 2 here.
|
||||||
|
* The first two bytes is used for matching device uuid by Provisioner.
|
||||||
|
* And using device address here is to avoid using the same device uuid
|
||||||
|
* by different unprovisioned devices.
|
||||||
|
*/
|
||||||
memcpy(dev_uuid + 2, addr_val, BD_ADDR_LEN);
|
memcpy(dev_uuid + 2, addr_val, BD_ADDR_LEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,4 +156,4 @@ esp_err_t bluetooth_init(void)
|
|||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* CONFIG_BT_NIMBLE_ENABLED */
|
@ -9,10 +9,12 @@
|
|||||||
#ifndef _BLE_MESH_DEMO_INIT_H_
|
#ifndef _BLE_MESH_DEMO_INIT_H_
|
||||||
#define _BLE_MESH_DEMO_INIT_H_
|
#define _BLE_MESH_DEMO_INIT_H_
|
||||||
|
|
||||||
#define TAG "onoff_client"
|
#include "esp_err.h"
|
||||||
|
|
||||||
|
#define TAG "EXAMPLE"
|
||||||
|
|
||||||
void ble_mesh_get_dev_uuid(uint8_t *dev_uuid);
|
void ble_mesh_get_dev_uuid(uint8_t *dev_uuid);
|
||||||
|
|
||||||
esp_err_t bluetooth_init(void);
|
esp_err_t bluetooth_init(void);
|
||||||
|
|
||||||
#endif
|
#endif /* _BLE_MESH_DEMO_INIT_H_ */
|
@ -0,0 +1,6 @@
|
|||||||
|
#
|
||||||
|
# "main" pseudo-component makefile.
|
||||||
|
#
|
||||||
|
# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.)
|
||||||
|
#
|
||||||
|
COMPONENT_ADD_INCLUDEDIRS := .
|
Loading…
x
Reference in New Issue
Block a user