OVMS3-idf/components/bt/ble_mesh/btc/include/btc_ble_mesh_prov.h
Island fc3253163e component/ble_mesh: ESP BLE Mesh release
1. BLE Mesh Core

* Provisioning: Node Role
    * Advertising and GATT bearer
    * Authentication OOB

* Provisioning: Provisioner Role
    * Advertising and GATT bearer
    * Authentication OOB

* Networking
    * Relay
    * Segmentation and Reassembly
    * Key Refresh
    * IV Update

* Proxy Support

* Multiple Client Models Run Simultaneously
    * Support multiple client models send packets to different nodes simultaneously
    * No blocking between client model and server

* NVS Storage
    * Store Provisioning Data of BLE Mesh Nodes in Flash

2. BLE Mesh Applications

* BLE Mesh Node & Provisioner
    * Node Example
    * Provisioner Example
    * Node + Generic OnOff Client Example

* Fast Provisioning
    * Vendor Fast Prov Server Model
    * Vendor Fast Prov Client Model
    * Examples

* Wi-Fi & BLE Mesh Coexistence
    * Example

* BLE Mesh Console Commands
    * Example

3. BLE Mesh Models

* Foundation Models
    * Configuration Server Model
    * Configuration Client Model
    * Health Server Model
    * Health Client Model

* Generic Client Models
    * Generic OnOff Client
    * Generic Level Client
    * Generic Location Client
    * Generic Default Transition Timer Client
    * Generic Power OnOff Client
    * Generic Power Level Client
    * Generic Battery Client
    * Generic Property Client

* Generic Server Models
    * Generic OnOff Server (Example)

* Lighting Client Models
    * Light Lightness Client
    * Light CTL Client
    * Light HSL Client
    * Light xyL Client
    * Light LC Client

* Sensor Client Model
    * Sensor Client

* Time and Scenes Client Models
    * Time Client
    * Scene Client
    * Scheduler Client
2019-06-24 11:31:24 +08:00

210 lines
6.8 KiB
C

// Copyright 2017-2018 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef _BTC_BLE_MESH_PROV_H_
#define _BTC_BLE_MESH_PROV_H_
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "freertos/semphr.h"
#include "btc/btc_task.h"
#include "esp_bt_defs.h"
#include "mesh_access.h"
#include "mesh_buf.h"
#include "mesh_main.h"
#include "provisioner_prov.h"
#include "esp_ble_mesh_defs.h"
typedef enum {
BTC_BLE_MESH_ACT_MESH_INIT = 0,
BTC_BLE_MESH_ACT_PROV_ENABLE,
BTC_BLE_MESH_ACT_PROV_DISABLE,
BTC_BLE_MESH_ACT_NODE_RESET,
BTC_BLE_MESH_ACT_SET_OOB_PUB_KEY,
BTC_BLE_MESH_ACT_INPUT_NUMBER,
BTC_BLE_MESH_ACT_INPUT_STRING,
BTC_BLE_MESH_ACT_SET_DEVICE_NAME,
BTC_BLE_MESH_ACT_PROXY_IDENTITY_ENABLE,
BTC_BLE_MESH_ACT_PROXY_GATT_ENABLE,
BTC_BLE_MESH_ACT_PROXY_GATT_DISABLE,
BTC_BLE_MESH_ACT_PROVISIONER_READ_OOB_PUB_KEY,
BTC_BLE_MESH_ACT_PROVISIONER_INPUT_STR,
BTC_BLE_MESH_ACT_PROVISIONER_INPUT_NUM,
BTC_BLE_MESH_ACT_PROVISIONER_ENABLE,
BTC_BLE_MESH_ACT_PROVISIONER_DISABLE,
BTC_BLE_MESH_ACT_PROVISIONER_DEV_ADD,
BTC_BLE_MESH_ACT_PROVISIONER_DEV_DEL,
BTC_BLE_MESH_ACT_PROVISIONER_SET_DEV_UUID_MATCH,
BTC_BLE_MESH_ACT_PROVISIONER_SET_PROV_DATA_INFO,
BTC_BLE_MESH_ACT_PROVISIONER_SET_NODE_NAME,
BTC_BLE_MESH_ACT_PROVISIONER_SET_LOCAL_APP_KEY,
BTC_BLE_MESH_ACT_PROVISIONER_BIND_LOCAL_MOD_APP,
BTC_BLE_MESH_ACT_PROVISIONER_ADD_LOCAL_NET_KEY,
BTC_BLE_MESH_ACT_SET_FAST_PROV_INFO,
BTC_BLE_MESH_ACT_SET_FAST_PROV_ACTION,
} btc_ble_mesh_prov_act_t;
typedef enum {
BTC_BLE_MESH_ACT_MODEL_PUBLISH,
BTC_BLE_MESH_ACT_SERVER_MODEL_SEND,
BTC_BLE_MESH_ACT_CLIENT_MODEL_SEND
} btc_ble_mesh_model_act_t;
typedef union {
struct ble_mesh_init_args {
esp_ble_mesh_prov_t *prov;
esp_ble_mesh_comp_t *comp;
SemaphoreHandle_t semaphore;
} mesh_init;
struct ble_mesh_node_prov_enable_args {
esp_ble_mesh_prov_bearer_t bearers;
} node_prov_enable;
struct ble_mesh_node_prov_disable_args {
esp_ble_mesh_prov_bearer_t bearers;
} node_prov_disable;
struct ble_mesh_set_oob_pub_key_args {
uint8_t pub_key_x[32];
uint8_t pub_key_y[32];
uint8_t private_key[32];
} set_oob_pub_key;
struct ble_mesh_node_input_num_args {
uint32_t number;
} input_number;
struct ble_mesh_node_input_str_args {
char string[8];
} input_string;
struct ble_mesh_set_device_name_args {
char name[ESP_BLE_MESH_DEVICE_NAME_MAX_LEN];
} set_device_name;
struct ble_mesh_provisioner_read_oob_pub_key_args {
uint8_t link_idx;
uint8_t pub_key_x[32];
uint8_t pub_key_y[32];
} provisioner_read_oob_pub_key;
struct ble_mesh_provisioner_input_str_args {
char string[8];
uint8_t link_idx;
} provisioner_input_str;
struct ble_mesh_provisioner_input_num_args {
uint32_t number;
uint8_t link_idx;
} provisioner_input_num;
struct ble_mesh_provisioner_enable_args {
esp_ble_mesh_prov_bearer_t bearers;
} provisioner_enable;
struct ble_mesh_provisioner_disable_args {
esp_ble_mesh_prov_bearer_t bearers;
} provisioner_disable;
struct ble_mesh_provisioner_dev_add_args {
esp_ble_mesh_unprov_dev_add_t add_dev;
esp_ble_mesh_dev_add_flag_t flags;
} provisioner_dev_add;
struct ble_mesh_provisioner_dev_del_args {
esp_ble_mesh_device_delete_t del_dev;
} provisioner_dev_del;
struct ble_mesh_provisioner_set_dev_uuid_match_args {
uint8_t offset;
uint8_t match_len;
uint8_t match_val[16];
bool prov_after_match;
} set_dev_uuid_match;
struct ble_mesh_provisioner_set_prov_net_idx_args {
esp_ble_mesh_prov_data_info_t prov_data;
} set_prov_data_info;
struct ble_mesh_provisioner_set_node_name_args {
int index;
char name[ESP_BLE_MESH_NODE_NAME_MAX_LEN];
} set_node_name;
struct ble_mesh_provisioner_add_local_app_key_args {
uint8_t app_key[16];
uint16_t net_idx;
uint16_t app_idx;
} add_local_app_key;
struct ble_mesh_provisioner_bind_local_mod_app_args {
uint16_t elem_addr;
uint16_t model_id;
uint16_t cid;
uint16_t app_idx;
} local_mod_app_bind;
struct ble_mesh_provisioner_add_local_net_key_args {
uint8_t net_key[16];
uint16_t net_idx;
} add_local_net_key;
struct ble_mesh_set_fast_prov_info_args {
uint16_t unicast_min;
uint16_t unicast_max;
uint16_t net_idx;
uint8_t flags;
uint32_t iv_index;
uint8_t offset;
uint8_t match_len;
uint8_t match_val[16];
} set_fast_prov_info;
struct ble_mesh_set_fast_prov_action_args {
uint8_t action;
} set_fast_prov_action;
} btc_ble_mesh_prov_args_t;
typedef union {
struct ble_mesh_model_publish_args {
esp_ble_mesh_model_t *model;
uint8_t device_role;
} model_publish;
struct ble_mesh_model_send_args {
esp_ble_mesh_model_t *model;
esp_ble_mesh_msg_ctx_t *ctx;
uint32_t opcode;
bool need_rsp;
uint16_t length;
uint8_t *data;
uint8_t device_role;
int32_t msg_timeout;
} model_send;
} btc_ble_mesh_model_args_t;
void btc_ble_mesh_prov_arg_deep_free(btc_msg_t *msg);
void btc_ble_mesh_prov_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
int btc_ble_mesh_client_init(esp_ble_mesh_model_t *model);
int32_t btc_ble_mesh_model_pub_period_get(esp_ble_mesh_model_t *mod);
uint16_t btc_ble_mesh_get_primary_addr(void);
uint16_t *btc_ble_mesh_model_find_group(esp_ble_mesh_model_t *mod, uint16_t addr);
esp_ble_mesh_elem_t *btc_ble_mesh_elem_find(u16_t addr);
uint8_t btc_ble_mesh_elem_count(void);
esp_ble_mesh_model_t *btc_ble_mesh_model_find_vnd(const esp_ble_mesh_elem_t *elem,
uint16_t company, uint16_t id);
esp_ble_mesh_model_t *btc_ble_mesh_model_find(const esp_ble_mesh_elem_t *elem,
uint16_t id);
const esp_ble_mesh_comp_t *btc_ble_mesh_comp_get(void);
void btc_mesh_model_call_handler(btc_msg_t *msg);
void btc_mesh_model_cb_handler(btc_msg_t *msg);
void btc_mesh_prov_call_handler(btc_msg_t *msg);
void btc_mesh_prov_cb_handler(btc_msg_t *msg);
#endif /* _BTC_BLE_MESH_PROV_H_ */