OVMS3-idf/examples/bluetooth/esp_ble_mesh/components/fast_prov_vendor_model/esp_fast_prov_common.h

121 lines
4.8 KiB
C
Raw Normal View History

ble_mesh: Add ESP BLE Mesh implementation 1. BLE Mesh Core * Provisioning: Node Role * PB-ADV and PB-GATT * Authentication OOB * Provisioning: Provisioner Role * PB-ADV and PB-GATT * 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 BLE Mesh node related information in flash * Store BLE Mesh Provisioner related information in flash 2. BLE Mesh Models * Foundation Models * Configuration Server Model * Configuration Client Model * Health Server Model * Health Client Model * Generic * Generic OnOff Server * Generic OnOff Client * Generic Level Server * Generic Level Client * Generic Default Transition Time Server * Generic Default Transition Time Client * Generic Power OnOff Server * Generic Power OnOff Setup Server * Generic Power OnOff Client * Generic Power Level Server * Generic Power Level Setup Server * Generic Power Level Client * Generic Battery Server * Generic Battery Client * Generic Location Server * Generic Location Setup Server * Generic Location Client * Generic Admin Property Server * Generic Manufacturer Property Server * Generic User Property Server * Generic Client Property Server * Generic Property Client * Sensor Server Model * Sensor Server * Sensor Setup Server * Sensor Client * Time and Scenes * Time Server * Time Setup Server * Time Client * Scene Server * Scene Setup Server * Scene Client * Scheduler Server * Scheduler Setup Server * Scheduler Client * Lighting * Light Lightness Server * Light Lightness Setup Server * Light Lightness Client * Light CTL Server * Light CTL Setup Server * Light CTL Client * Light CTL Temperature Server * Light HSL Server * Light HSL Setup Server * Light HSL Client * Light HSL Hue Server * Light HSL Saturation Server * Light xyL Server * Light xyL Setup Server * Light xyL Client * Light LC Server * Light LC Setup Server * Light LC Client 3. BLE Mesh Applications * BLE Mesh Node * OnOff Client Example * OnOff Server Example * BLE Mesh Provisioner * Example * Fast Provisioning * Vendor Fast Prov Server Model * Vendor Fast Prov Client Model * Examples * Wi-Fi & BLE Mesh Coexistence * Example * BLE Mesh Console Commands * Examples
2019-11-01 08:08:47 +00:00
// Copyright 2017-2019 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 _ESP_FAST_PROV_COMMON_H
#define _ESP_FAST_PROV_COMMON_H
#include "esp_ble_mesh_defs.h"
#include "esp_ble_mesh_config_model_api.h"
#define LED_OFF 0x00
#define LED_ON 0x01
#define CID_ESP 0x02E5
#define CID_NVAL 0xFFFF
/* Fast Prov Model ID */
#define ESP_BLE_MESH_VND_MODEL_ID_FAST_PROV_CLI 0x0000
#define ESP_BLE_MESH_VND_MODEL_ID_FAST_PROV_SRV 0x0001
/* Fast Prov Message Opcode */
#define ESP_BLE_MESH_VND_MODEL_OP_FAST_PROV_INFO_SET ESP_BLE_MESH_MODEL_OP_3(0x00, CID_ESP)
#define ESP_BLE_MESH_VND_MODEL_OP_FAST_PROV_INFO_STATUS ESP_BLE_MESH_MODEL_OP_3(0x01, CID_ESP)
#define ESP_BLE_MESH_VND_MODEL_OP_FAST_PROV_NET_KEY_ADD ESP_BLE_MESH_MODEL_OP_3(0x02, CID_ESP)
#define ESP_BLE_MESH_VND_MODEL_OP_FAST_PROV_NET_KEY_STATUS ESP_BLE_MESH_MODEL_OP_3(0x03, CID_ESP)
#define ESP_BLE_MESH_VND_MODEL_OP_FAST_PROV_NODE_ADDR ESP_BLE_MESH_MODEL_OP_3(0x04, CID_ESP)
#define ESP_BLE_MESH_VND_MODEL_OP_FAST_PROV_NODE_ADDR_ACK ESP_BLE_MESH_MODEL_OP_3(0x05, CID_ESP)
#define ESP_BLE_MESH_VND_MODEL_OP_FAST_PROV_NODE_ADDR_GET ESP_BLE_MESH_MODEL_OP_3(0x06, CID_ESP)
#define ESP_BLE_MESH_VND_MODEL_OP_FAST_PROV_NODE_ADDR_STATUS ESP_BLE_MESH_MODEL_OP_3(0x07, CID_ESP)
#define ESP_BLE_MESH_VND_MODEL_OP_FAST_PROV_NODE_GROUP_ADD ESP_BLE_MESH_MODEL_OP_3(0x08, CID_ESP)
#define ESP_BLE_MESH_VND_MODEL_OP_FAST_PROV_NODE_GROUP_DELETE ESP_BLE_MESH_MODEL_OP_3(0x09, CID_ESP)
typedef struct {
uint16_t net_idx;
uint16_t app_idx;
uint16_t dst;
int32_t timeout;
esp_ble_mesh_dev_role_t role;
} example_msg_common_info_t;
typedef struct {
uint16_t net_idx;
uint16_t app_idx;
uint8_t app_key[16];
uint16_t node_addr_cnt; /* Number of BLE Mesh nodes in the network */
uint16_t unicast_min; /* Minimum unicast address to be assigned to the nodes in the network */
uint16_t unicast_max; /* Maximum unicast address to be assigned to the nodes in the network */
uint16_t group_addr; /* Group address which will be subscribed by the nodes in the network */
uint8_t match_val[16]; /* Match value used by Fast Provisoning Provisioner */
uint8_t match_len;
uint8_t max_node_num; /* Maximum number of nodes can be provisioned by the client */
} __attribute__((packed)) example_prov_info_t;
/* Fast Prov Info Set Message Context */
typedef struct {
uint16_t ctx_flags; /* Flags indicate which part of context exists */
uint16_t node_addr_cnt; /* Number of the nodes going to be provisioned */
uint16_t unicast_min; /* Assigned minimum unicast address */
uint16_t unicast_max; /* Assigned maximum unicast address */
uint8_t flags; /* Flags used for provisioning data */
uint32_t iv_index; /* IV_index used for provisioning data */
uint16_t net_idx; /* Netkey index used for provisioning data */
uint16_t group_addr; /* Group address going to be added to model */
uint16_t prov_addr; /* Primary Provisioner address */
uint8_t match_val[16]; /* Match value used for provisioning */
uint8_t match_len;
uint8_t action; /* Action used to enbale/disable Provisioner functionality */
} __attribute__((packed)) example_fast_prov_info_set_t;
typedef struct {
/* The following is the basic information of a node */
bool reprov;
uint8_t uuid[16];
uint16_t unicast_addr;
uint8_t element_num;
uint16_t net_idx;
uint16_t app_idx;
uint8_t onoff;
/* The following is the information which will be/has been sent to the node */
bool lack_of_addr;
uint16_t node_addr_cnt;
uint16_t unicast_min;
uint16_t unicast_max;
uint8_t flags;
uint32_t iv_index;
uint16_t fp_net_idx;
uint16_t group_addr;
uint16_t prov_addr;
uint8_t match_val[16];
uint8_t match_len;
uint8_t action;
} __attribute__((packed)) example_node_info_t;
typedef struct {
uint8_t net_key[16]; /* Network key going to be added */
} example_fast_prov_net_key_add_t;
typedef struct {
uint8_t status_key; /* Indicate the result of adding network key */
uint8_t status_act; /* Indicate the result of action */
} example_fast_prov_net_key_status_t;
#endif /* _ESP_FAST_PROV_COMMON_H */