119e95205Sopenharmony_ci/* 219e95205Sopenharmony_ci * Copyright (C) 2021 Huawei Device Co., Ltd. 319e95205Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 419e95205Sopenharmony_ci * you may not use this file except in compliance with the License. 519e95205Sopenharmony_ci * You may obtain a copy of the License at 619e95205Sopenharmony_ci * 719e95205Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 819e95205Sopenharmony_ci * 919e95205Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1019e95205Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1119e95205Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1219e95205Sopenharmony_ci * See the License for the specific language governing permissions and 1319e95205Sopenharmony_ci * limitations under the License. 1419e95205Sopenharmony_ci */ 1519e95205Sopenharmony_ci 1619e95205Sopenharmony_ci#ifndef GAP_COMM_DEF_H 1719e95205Sopenharmony_ci#define GAP_COMM_DEF_H 1819e95205Sopenharmony_ci 1919e95205Sopenharmony_ci#include <stdlib.h> 2019e95205Sopenharmony_ci#include <stdbool.h> 2119e95205Sopenharmony_ci#include <stddef.h> 2219e95205Sopenharmony_ci#include "btstack.h" 2319e95205Sopenharmony_ci 2419e95205Sopenharmony_ci#ifdef __cplusplus 2519e95205Sopenharmony_ciextern "C" { 2619e95205Sopenharmony_ci#endif 2719e95205Sopenharmony_ci 2819e95205Sopenharmony_ci#define GAP_SUCCESS BT_SUCCESS /// GAP error code success 2919e95205Sopenharmony_ci#define GAP_ERR_NOT_ENABLE BT_BAD_STATUS /// GAP error code module not initialize 3019e95205Sopenharmony_ci#define GAP_ERR_INVAL_PARAM BT_BAD_PARAM /// GAP error code invalid parameter 3119e95205Sopenharmony_ci#define GAP_ERR_INVAL_STATE BT_BAD_STATUS /// GAP error code invalid state 3219e95205Sopenharmony_ci#define GAP_ERR_REPEATED BT_ALREADY /// GAP error code repeated action 3319e95205Sopenharmony_ci#define GAP_ERR_OUT_OF_RES BT_NO_MEMORY /// GAP error code out of resource 3419e95205Sopenharmony_ci#define GAP_ERR_REMOTE_ACTION BT_OPERATION_FAILED /// GAP error code communication failed 3519e95205Sopenharmony_ci#define GAP_ERR_NOT_SUPPORT BT_NOT_SUPPORT /// GAP error code not support 3619e95205Sopenharmony_ci 3719e95205Sopenharmony_ci#define GAP_STATUS_SUCCESS 0x00 /// GAP success status 3819e95205Sopenharmony_ci#define GAP_STATUS_FAILED 0xFF /// GAP internal error status 3919e95205Sopenharmony_ci 4019e95205Sopenharmony_ci#define GAP_NOT_ACCEPT 0 /// reject 4119e95205Sopenharmony_ci#define GAP_ACCEPT 1 /// accept 4219e95205Sopenharmony_ci 4319e95205Sopenharmony_ci#define GAP_LINKKEY_SIZE 0x10 /// bluetooth link key size 4419e95205Sopenharmony_ci#define GAP_PINCODE_SIZE 0x10 /// bluetooth pin code size 4519e95205Sopenharmony_ci#define GAP_OOB_DATA_CONFIRM_SIZE 0x10 /// bluetooth OOB data confirm size 4619e95205Sopenharmony_ci#define GAP_OOB_DATA_RANDOM_SIZE 0x10 /// bluetooth OOB data random size 4719e95205Sopenharmony_ci#define GAP_OOB_DATA_SIZE 0x10 /// bluetooth OOB data size 4819e95205Sopenharmony_ci#define GAP_EIR_SIZE_MAX 240 /// bluetooth extended inquiry response max size 4919e95205Sopenharmony_ci#define GAP_NAME_SIZE_MAX 248 /// bluetooth device name max size 5019e95205Sopenharmony_ci 5119e95205Sopenharmony_ci#define GAP_DISCOVERABLE_MODE_NON 0x00 /// Non-discoverable Mode 5219e95205Sopenharmony_ci#define GAP_DISCOVERABLE_MODE_LIMITED 0x01 /// Limited Discoverable Mode 5319e95205Sopenharmony_ci#define GAP_DISCOVERABLE_MODE_GENERAL 0x02 /// General Discoverable Mode 5419e95205Sopenharmony_ci 5519e95205Sopenharmony_ci#define GAP_INQUIRY_SCAN_TYPE_GENERAL 0x00 /// Standard Scan 5619e95205Sopenharmony_ci#define GAP_INQUIRY_SCAN_TYPE_INTERLACED 0x01 /// Interlaced Scan 5719e95205Sopenharmony_ci 5819e95205Sopenharmony_ci#define GAP_CONNECTABLE_MODE_NON 0x00 /// Non-connectable Mode 5919e95205Sopenharmony_ci#define GAP_CONNECTABLE_MODE 0x01 /// Connectable Mode 6019e95205Sopenharmony_ci 6119e95205Sopenharmony_ci#define GAP_PAGE_SCAN_TYPE_GENERAL 0x00 /// Standard Scan 6219e95205Sopenharmony_ci#define GAP_PAGE_SCAN_TYPE_INTERLACED 0x01 /// Interlaced Scan 6319e95205Sopenharmony_ci 6419e95205Sopenharmony_ci#define GAP_SCAN_INTERVAL_RANGE_MIN 0x0012 /// Minimum Scan Interval 6519e95205Sopenharmony_ci#define GAP_SCAN_INTERVAL_RANGE_MAX 0x1000 /// Maximum Scan Interval 6619e95205Sopenharmony_ci#define GAP_SCAN_WINDOW_RANGE_MIN 0x0011 /// Minimum Scan Window 6719e95205Sopenharmony_ci#define GAP_SCAN_WINDOW_RANGE_MAX 0x1000 /// Maximum Scan Window 6819e95205Sopenharmony_ci 6919e95205Sopenharmony_ci#define GAP_INQUIRY_SCAN_INTERVAL_DEFAULT 0x1000 /// Controller default inquiry scan interval value 7019e95205Sopenharmony_ci#define GAP_INQUIRY_SCAN_WINDOW_DEFAULT 0x0012 /// Controller default inquiry scan window value 7119e95205Sopenharmony_ci#define GAP_PAGE_SCAN_INTERVAL_DEFAULT 0x0800 /// Controller default page scan interval value 7219e95205Sopenharmony_ci#define GAP_PAGE_SCAN_WINDOW_DEFAULT 0x0012 /// Controller default page scan window value 7319e95205Sopenharmony_ci 7419e95205Sopenharmony_ci#define GAP_BONDABLE_MODE_NON 0x00 /// Non-bondable Mode 7519e95205Sopenharmony_ci#define GAP_BONDABLE_MODE 0x01 /// Boneable Mode 7619e95205Sopenharmony_ci 7719e95205Sopenharmony_ci/// IO capabilities 7819e95205Sopenharmony_ci#define GAP_IO_DISPLAYONLY 0x00 7919e95205Sopenharmony_ci#define GAP_IO_DISPLAYYESNO 0x01 8019e95205Sopenharmony_ci#define GAP_IO_KEYBOARDONLY 0x02 8119e95205Sopenharmony_ci#define GAP_IO_NOINPUTNOOUTPUT 0x03 8219e95205Sopenharmony_ci#define GAP_IO_KEYBOARDDISPLAY 0x04 8319e95205Sopenharmony_ci 8419e95205Sopenharmony_ci/// Link key type of BR/EDR 8519e95205Sopenharmony_ci#define GAP_LKEY_TYPE_COMBINATION 0x00 8619e95205Sopenharmony_ci#define GAP_LKEY_TYPE_LOCAL_UNIT 0x01 8719e95205Sopenharmony_ci#define GAP_LKEY_TYPE_REMOTE_UNIT 0x02 8819e95205Sopenharmony_ci#define GAP_LKEY_TYPE_DEBUG_COMB 0x03 8919e95205Sopenharmony_ci#define GAP_LKEY_TYPE_UNAUTH_COMB_P192 0x04 9019e95205Sopenharmony_ci#define GAP_LKEY_TYPE_AUTH_COMB_P192 0x05 9119e95205Sopenharmony_ci#define GAP_LKEY_TYPE_CHANGED_COMB 0x06 9219e95205Sopenharmony_ci#define GAP_LKEY_TYPE_UNAUTH_COMB_P256 0x07 9319e95205Sopenharmony_ci#define GAP_LKEY_TYPE_AUTH_COMB_P256 0x08 9419e95205Sopenharmony_ci 9519e95205Sopenharmony_ci/// OOB authentication data from remote device present 9619e95205Sopenharmony_ci#define GAP_OOB_DATA_NOT_PRESENT 0x00 9719e95205Sopenharmony_ci#define GAP_OOB_DATA_PRESENT_P192 0x01 9819e95205Sopenharmony_ci#define GAP_OOB_DATA_PRESENT_P256 0x02 9919e95205Sopenharmony_ci#define GAP_OOB_DATA_PRESENT_P192_P256 0x03 10019e95205Sopenharmony_ci 10119e95205Sopenharmony_ci/// MITM protection 10219e95205Sopenharmony_ci#define GAP_MITM_NOT_REQUIRED 0x00 10319e95205Sopenharmony_ci#define GAP_MITM_REQUIRED 0x01 10419e95205Sopenharmony_ci 10519e95205Sopenharmony_ci/// Encryption status 10619e95205Sopenharmony_ci#define GAP_ENCRYPTION_OFF 0x00 10719e95205Sopenharmony_ci#define GAP_ENCRYPTION_ON 0x01 10819e95205Sopenharmony_ci 10919e95205Sopenharmony_ci/// Key press type 11019e95205Sopenharmony_ci#define GAP_KEY_PRESS_ENTRY_STARTED 0x00 11119e95205Sopenharmony_ci#define GAP_KEY_PRESS_DIGIT_ENTERED 0x01 11219e95205Sopenharmony_ci#define GAP_KEY_PRESS_DIGIT_ERASED 0x02 11319e95205Sopenharmony_ci#define GAP_KEY_PRESS_CLEARED 0x03 11419e95205Sopenharmony_ci#define GAP_KEY_PRESS_ENTRY_COMPLETED 0x04 11519e95205Sopenharmony_ci 11619e95205Sopenharmony_ci/** 11719e95205Sopenharmony_ci * @brief OOB data structure. 11819e95205Sopenharmony_ci */ 11919e95205Sopenharmony_citypedef struct { 12019e95205Sopenharmony_ci uint8_t C[GAP_OOB_DATA_CONFIRM_SIZE]; 12119e95205Sopenharmony_ci uint8_t R[GAP_OOB_DATA_RANDOM_SIZE]; 12219e95205Sopenharmony_ci} GapOOBData; 12319e95205Sopenharmony_ci 12419e95205Sopenharmony_ci#ifdef __cplusplus 12519e95205Sopenharmony_ci} 12619e95205Sopenharmony_ci#endif 12719e95205Sopenharmony_ci 12819e95205Sopenharmony_ci#endif /* GAP_COMM_DEF_H */