|
Packit |
34410b |
/*
|
|
Packit |
34410b |
*
|
|
Packit |
34410b |
* BlueZ - Bluetooth protocol stack for Linux
|
|
Packit |
34410b |
*
|
|
Packit |
34410b |
* Copyright (C) 2018 Intel Corporation. All rights reserved.
|
|
Packit |
34410b |
*
|
|
Packit |
34410b |
*
|
|
Packit |
34410b |
* This library is free software; you can redistribute it and/or
|
|
Packit |
34410b |
* modify it under the terms of the GNU Lesser General Public
|
|
Packit |
34410b |
* License as published by the Free Software Foundation; either
|
|
Packit |
34410b |
* version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
34410b |
*
|
|
Packit |
34410b |
* This library is distributed in the hope that it will be useful,
|
|
Packit |
34410b |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
34410b |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
34410b |
* Lesser General Public License for more details.
|
|
Packit |
34410b |
*
|
|
Packit |
34410b |
*/
|
|
Packit |
34410b |
|
|
Packit |
34410b |
|
|
Packit |
34410b |
/*
|
|
Packit |
34410b |
* size: hard define (mesh.conf - OOB_NUMBEROOB_NUMBER)
|
|
Packit |
34410b |
* oob size - 8 if alpha or numeric
|
|
Packit |
34410b |
* else 1 if mask is non zero
|
|
Packit |
34410b |
* else 0
|
|
Packit |
34410b |
*/
|
|
Packit |
34410b |
struct bt_mesh;
|
|
Packit |
34410b |
struct mesh_prov;
|
|
Packit |
34410b |
struct mesh_agent;
|
|
Packit |
34410b |
|
|
Packit |
34410b |
/* Provisioner Agent Response Types */
|
|
Packit |
34410b |
#define OOB_CANCEL 0x00
|
|
Packit |
34410b |
#define OOB_PRIV_KEY 0x01
|
|
Packit |
34410b |
#define OOB_PUB_KEY 0x02
|
|
Packit |
34410b |
#define OOB_NUMBER 0x03
|
|
Packit |
34410b |
#define OOB_STATIC 0x04
|
|
Packit |
34410b |
#define OOB_NUMBER_DISPLAY 0x05
|
|
Packit |
34410b |
|
|
Packit |
34410b |
/* Spec defined Provisioning message types */
|
|
Packit |
34410b |
#define PROV_INVITE 0x00
|
|
Packit |
34410b |
#define PROV_CAPS 0x01
|
|
Packit |
34410b |
#define PROV_START 0x02
|
|
Packit |
34410b |
#define PROV_PUB_KEY 0x03
|
|
Packit |
34410b |
#define PROV_INP_CMPLT 0x04
|
|
Packit |
34410b |
#define PROV_CONFIRM 0x05
|
|
Packit |
34410b |
#define PROV_RANDOM 0x06
|
|
Packit |
34410b |
#define PROV_DATA 0x07
|
|
Packit |
34410b |
#define PROV_COMPLETE 0x08
|
|
Packit |
34410b |
#define PROV_FAILED 0x09
|
|
Packit |
34410b |
|
|
Packit |
34410b |
/* Spec defined Error Codes */
|
|
Packit |
34410b |
#define PROV_ERR_SUCCESS 0x00
|
|
Packit |
34410b |
#define PROV_ERR_INVALID_PDU 0x01
|
|
Packit |
34410b |
#define PROV_ERR_INVALID_FORMAT 0x02
|
|
Packit |
34410b |
#define PROV_ERR_UNEXPECTED_PDU 0x03
|
|
Packit |
34410b |
#define PROV_ERR_CONFIRM_FAILED 0x04
|
|
Packit |
34410b |
#define PROV_ERR_INSUF_RESOURCE 0x05
|
|
Packit |
34410b |
#define PROV_ERR_DECRYPT_FAILED 0x06
|
|
Packit |
34410b |
#define PROV_ERR_UNEXPECTED_ERR 0x07
|
|
Packit |
34410b |
#define PROV_ERR_CANT_ASSIGN_ADDR 0x08
|
|
Packit |
34410b |
/* Internally generated Error Codes */
|
|
Packit |
34410b |
#define PROV_ERR_TIMEOUT 0xFF
|
|
Packit |
34410b |
|
|
Packit |
34410b |
/* Provisioner Action values */
|
|
Packit |
34410b |
/* IN */
|
|
Packit |
34410b |
#define PROV_ACTION_PUSH 0x00
|
|
Packit |
34410b |
#define PROV_ACTION_TWIST 0x01
|
|
Packit |
34410b |
#define PROV_ACTION_IN_NUMERIC 0x02
|
|
Packit |
34410b |
#define PROV_ACTION_IN_ALPHA 0x03
|
|
Packit |
34410b |
/* OUT */
|
|
Packit |
34410b |
#define PROV_ACTION_BLINK 0x00
|
|
Packit |
34410b |
#define PROV_ACTION_BEEP 0x01
|
|
Packit |
34410b |
#define PROV_ACTION_VIBRATE 0x02
|
|
Packit |
34410b |
#define PROV_ACTION_OUT_NUMERIC 0x03
|
|
Packit |
34410b |
#define PROV_ACTION_OUT_ALPHA 0x04
|
|
Packit |
34410b |
|
|
Packit |
34410b |
/* OOB_Info defines from Table 3.54 of Mesh profile Specification v1.0 */
|
|
Packit |
34410b |
#define OOB_INFO_URI_HASH 0x0002
|
|
Packit |
34410b |
|
|
Packit |
34410b |
/* PB_REMOTE not supported from unprovisioned state */
|
|
Packit |
34410b |
enum trans_type {
|
|
Packit |
34410b |
PB_ADV = 0,
|
|
Packit |
34410b |
PB_GATT,
|
|
Packit |
34410b |
};
|
|
Packit |
34410b |
|
|
Packit |
34410b |
#define PROV_FLAG_KR 0x01
|
|
Packit |
34410b |
#define PROV_FLAG_IVU 0x02
|
|
Packit |
34410b |
|
|
Packit |
34410b |
struct mesh_prov_node_info {
|
|
Packit |
34410b |
uint32_t iv_index;
|
|
Packit |
34410b |
uint16_t unicast;
|
|
Packit |
34410b |
uint16_t net_index;
|
|
Packit |
34410b |
uint8_t num_ele;
|
|
Packit |
34410b |
uint8_t net_key[16];
|
|
Packit |
34410b |
uint8_t device_key[16];
|
|
Packit |
34410b |
uint8_t flags; /* IVU and KR bits */
|
|
Packit |
34410b |
};
|
|
Packit |
34410b |
|
|
Packit |
34410b |
typedef bool (*mesh_prov_acceptor_complete_func_t)(void *user_data,
|
|
Packit |
34410b |
uint8_t status,
|
|
Packit |
34410b |
struct mesh_prov_node_info *info);
|
|
Packit |
34410b |
|
|
Packit |
34410b |
typedef bool (*mesh_prov_initiator_data_req_func_t)(void *user_data,
|
|
Packit |
34410b |
uint8_t num_elem);
|
|
Packit |
34410b |
|
|
Packit |
34410b |
typedef bool (*mesh_prov_initiator_complete_func_t)(void *user_data,
|
|
Packit |
34410b |
uint8_t status,
|
|
Packit |
34410b |
struct mesh_prov_node_info *info);
|
|
Packit |
34410b |
|
|
Packit |
34410b |
/* This starts unprovisioned device beacon */
|
|
Packit |
34410b |
bool acceptor_start(uint8_t num_ele, uint8_t uuid[16],
|
|
Packit |
34410b |
uint16_t algorithms, uint32_t timeout,
|
|
Packit |
34410b |
struct mesh_agent *agent,
|
|
Packit |
34410b |
mesh_prov_acceptor_complete_func_t complete_cb,
|
|
Packit |
34410b |
void *caller_data);
|
|
Packit |
34410b |
void acceptor_cancel(void *user_data);
|
|
Packit |
34410b |
|
|
Packit |
34410b |
bool initiator_start(enum trans_type transport,
|
|
Packit |
34410b |
uint8_t uuid[16],
|
|
Packit |
34410b |
uint16_t max_ele,
|
|
Packit |
34410b |
uint16_t server, /* Only valid for PB-Remote */
|
|
Packit |
34410b |
uint32_t timeout, /* in seconds from mesh.conf */
|
|
Packit |
34410b |
struct mesh_agent *agent,
|
|
Packit |
34410b |
mesh_prov_initiator_data_req_func_t get_prov_data,
|
|
Packit |
34410b |
mesh_prov_initiator_complete_func_t complete_cb,
|
|
Packit |
34410b |
void *node, void *caller_data);
|
|
Packit |
34410b |
void initiator_prov_data(uint16_t net_idx, uint16_t primary, void *caller_data);
|
|
Packit |
34410b |
void initiator_cancel(void *caller_data);
|