1 /* 2 * Copyright (C) 2017 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. Neither the name of the copyright holders nor the names of 14 * contributors may be used to endorse or promote products derived 15 * from this software without specific prior written permission. 16 * 4. Any redistribution, use, or modification is done solely for 17 * personal benefit and not for any commercial purpose or for 18 * monetary gain. 19 * 20 * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN 24 * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 27 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 30 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * Please inquire about commercial licensing options at 34 * [email protected] 35 * 36 */ 37 38 /* 39 * provisioning.h 40 */ 41 42 #ifndef __PROVISIONING_H 43 #define __PROVISIONING_H 44 45 #include <stdint.h> 46 47 #include "btstack_defines.h" 48 #include "btstack_crypto.h" 49 50 #include "mesh/mesh_keys.h" 51 52 #ifdef __cplusplus 53 extern "C" 54 { 55 #endif 56 57 #define PROVISIONING_PROTOCOL_TIMEOUT_MS 60000 58 #define MESH_PROV_MAX_PROXY_PDU 66 59 #define MESH_PB_TRANSPORT_INVALID_CID 0xFFFF 60 61 // Provisioning Bearer Control 62 63 #define MESH_PROV_INVITE 0x00 64 #define MESH_PROV_CAPABILITIES 0x01 65 #define MESH_PROV_START 0x02 66 #define MESH_PROV_PUB_KEY 0x03 67 #define MESH_PROV_INPUT_COMPLETE 0x04 68 #define MESH_PROV_CONFIRM 0x05 69 #define MESH_PROV_RANDOM 0x06 70 #define MESH_PROV_DATA 0x07 71 #define MESH_PROV_COMPLETE 0x08 72 #define MESH_PROV_FAILED 0x09 73 74 // Provisioning Output OOB Actions 75 #define MESH_OUTPUT_OOB_BLINK 0x01 76 #define MESH_OUTPUT_OOB_BEEP 0x02 77 #define MESH_OUTPUT_OOB_VIBRATE 0x04 78 #define MESH_OUTPUT_OOB_NUMBER 0x08 79 #define MESH_OUTPUT_OOB_STRING 0x10 80 81 // Provisioning Input OOB Actions 82 #define MESH_INPUT_OOB_PUSH 0x01 83 #define MESH_INPUT_OOB_TWIST 0x02 84 #define MESH_INPUT_OOB_NUMBER 0x04 85 #define MESH_INPUT_OOB_STRING 0x08 86 87 typedef enum { 88 MESH_PB_TYPE_ADV = 0, 89 MESH_PB_TYPE_GATT 90 } mesh_pb_type_t; 91 92 typedef enum { 93 MESH_OOB_INFORMATION_INDEX_OTHER = 0, 94 MESH_OOB_INFORMATION_INDEX_ELECTRONIC_OR_URI, 95 MESH_OOB_INFORMATION_INDEX_2D_MACHINE_READABLE_CODE, 96 MESH_OOB_INFORMATION_INDEX_BAR_CODE, 97 MESH_OOB_INFORMATION_INDEX_NEAR_FIELD_COMMUNICATION, 98 MESH_OOB_INFORMATION_INDEX_NUMBER, 99 MESH_OOB_INFORMATION_INDEX_STRING, 100 MESH_OOB_INFORMATION_INDEX_RESERVED_7, 101 MESH_OOB_INFORMATION_INDEX_RESERVED_8, 102 MESH_OOB_INFORMATION_INDEX_RESERVED_9, 103 MESH_OOB_INFORMATION_INDEX_RESERVED_10, 104 MESH_OOB_INFORMATION_INDEX_ON_BOX, 105 MESH_OOB_INFORMATION_INDEX_INSIDE_BOX, 106 MESH_OOB_INFORMATION_INDEX_ON_PIECE_OF_PAPER, 107 MESH_OOB_INFORMATION_INDEX_INSIDE_MANUAL, 108 MESH_OOB_INFORMATION_INDEX_ON_DEVICE 109 } mesh_oob_information_index_t; 110 111 typedef enum { 112 MESH_MSG_SAR_FIELD_COMPLETE_MSG = 0, 113 MESH_MSG_SAR_FIELD_FIRST_SEGMENT, 114 MESH_MSG_SAR_FIELD_CONTINUE, 115 MESH_MSG_SAR_FIELD_LAST_SEGMENT 116 } mesh_msg_sar_field_t; // Message segmentation and reassembly information 117 118 typedef enum { 119 MESH_MSG_TYPE_NETWORK_PDU = 0, 120 MESH_MSG_TYPE_BEACON, 121 MESH_MSG_TYPE_PROXY_CONFIGURATION, 122 MESH_MSG_TYPE_PROVISIONING_PDU 123 } mesh_msg_type_t; 124 125 typedef enum { 126 MESH_IDENTIFICATION_NETWORK_ID_TYPE = 0, 127 MESH_IDENTIFICATION_NODE_IDENTIFY_TYPE 128 } mesh_identification_type_t; 129 130 typedef struct { 131 // DevKey = k1(ECDHSecret, ProvisioningSalt, “prdk”) 132 uint8_t device_key[16]; 133 134 // Unicast Address 135 uint16_t unicast_address; 136 137 // Key Refresh Phase 0 vs. 2, IV Update Active 138 uint8_t flags; 139 140 // IV Index 141 uint32_t iv_index; 142 143 // Network Key (pass by reference) 144 mesh_network_key_t * network_key; 145 146 } mesh_provisioning_data_t; 147 148 #ifdef __cplusplus 149 } /* end of extern "C" */ 150 #endif 151 152 #endif 153