move Bluetooth related types to bluetooth.h and BTstack types to btstack_defines.h

This commit is contained in:
Matthias Ringwald 2016-02-10 11:35:31 +01:00
parent ab49db6128
commit 8974fcd6cf
6 changed files with 80 additions and 62 deletions

View File

@ -38,16 +38,14 @@
#ifndef __SM_H
#define __SM_H
#include <stdint.h>
#include "btstack_util.h"
#if defined __cplusplus
#if defined __cplusplus
extern "C" {
#endif
// PTS testing
void sm_test_set_irk(sm_key_t irk);
void sm_test_use_fixed_local_csrk(void);
#include <stdint.h>
#include "btstack_util.h"
#include "btstack_defines.h"
#include "hci.h"
typedef struct {
btstack_linked_item_t item;
@ -204,6 +202,10 @@ int sm_address_resolution_lookup(uint8_t addr_type, bd_addr_t addr);
int sm_le_device_index(uint16_t handle );
/* API_END */
// PTS testing
void sm_test_set_irk(sm_key_t irk);
void sm_test_use_fixed_local_csrk(void);
#if defined __cplusplus
}
#endif

View File

@ -46,6 +46,55 @@
#include <stdint.h>
/**
* @brief hci connection handle type
*/
typedef uint16_t hci_con_handle_t;
/**
* @brief Length of a bluetooth device address.
*/
#define BD_ADDR_LEN 6
/**
* @brief Bluetooth address
*/
typedef uint8_t bd_addr_t[BD_ADDR_LEN];
/**
* Address types
* @note: BTstack uses a custom addr type to refer to classic ACL and SCO devices
*/
typedef enum {
BD_ADDR_TYPE_LE_PUBLIC = 0,
BD_ADDR_TYPE_LE_RANDOM = 1,
BD_ADDR_TYPE_SCO = 0xfe,
BD_ADDR_TYPE_CLASSIC = 0xff,
BD_ADDR_TYPE_UNKNOWN = 0xfe
} bd_addr_type_t;
/**
* @brief link key
*/
#define LINK_KEY_LEN 16
#define LINK_KEY_STR_LEN (LINK_KEY_LEN*2)
typedef uint8_t link_key_t[LINK_KEY_LEN];
/**
* @brief link key type
*/
typedef enum {
COMBINATION_KEY = 0, // standard pairing
LOCAL_UNIT_KEY, // ?
REMOTE_UNIT_KEY, // ?
DEBUG_COMBINATION_KEY, // SSP with debug
UNAUTHENTICATED_COMBINATION_KEY_GENERATED_FROM_P192, // SSP Simple Pairing
AUTHENTICATED_COMBINATION_KEY_GENERATED_FROM_P192, // SSP Passkey, Number confirm, OOB
CHANGED_COMBINATION_KEY, // Link key changed using Change Connection Lnk Key
UNAUTHENTICATED_COMBINATION_KEY_GENERATED_FROM_P256, // SSP Simpe Pairing
AUTHENTICATED_COMBINATION_KEY_GENERATED_FROM_P256, // SSP Passkey, Number confirm, OOB
} link_key_type_t;
/**
* HCI Transport
*/

View File

@ -43,17 +43,24 @@
#ifndef __BTSTACK_DEFINES_H
#define __BTSTACK_DEFINES_H
#include <stdint.h>
#include "btstack_linked_list.h"
// TYPES
// packet handler
typedef void (*btstack_packet_handler_t) (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
// packet callback supporting multiple registrations
typedef struct {
btstack_linked_item_t item;
btstack_packet_handler_t callback;
} btstack_packet_callback_registration_t;
/**
* Address types
* @note: BTstack uses a custom addr type to refer to classic ACL and SCO devices
* @brief 128 bit key used with AES128 in Security Manager
*/
typedef enum {
BD_ADDR_TYPE_LE_PUBLIC = 0,
BD_ADDR_TYPE_LE_RANDOM = 1,
BD_ADDR_TYPE_SCO = 0xfe,
BD_ADDR_TYPE_CLASSIC = 0xff,
BD_ADDR_TYPE_UNKNOWN = 0xfe
} bd_addr_type_t;
typedef uint8_t sm_key_t[16];
// DEFINES

View File

@ -52,42 +52,11 @@ extern "C" {
#endif
#include <stdint.h>
#include "bluetooth.h"
#include "btstack_defines.h"
#include "btstack_linked_list.h"
/**
* @brief hci connection handle type
*/
typedef uint16_t hci_con_handle_t;
/**
* @brief Length of a bluetooth device address.
*/
#define BD_ADDR_LEN 6
typedef uint8_t bd_addr_t[BD_ADDR_LEN];
/**
* @brief link key and its type
*/
#define LINK_KEY_LEN 16
#define LINK_KEY_STR_LEN (LINK_KEY_LEN*2)
typedef uint8_t link_key_t[LINK_KEY_LEN];
typedef enum {
COMBINATION_KEY = 0, // standard pairing
LOCAL_UNIT_KEY, // ?
REMOTE_UNIT_KEY, // ?
DEBUG_COMBINATION_KEY, // SSP with debug
UNAUTHENTICATED_COMBINATION_KEY_GENERATED_FROM_P192, // SSP Simple Pairing
AUTHENTICATED_COMBINATION_KEY_GENERATED_FROM_P192, // SSP Passkey, Number confirm, OOB
CHANGED_COMBINATION_KEY, // Link key changed using Change Connection Lnk Key
UNAUTHENTICATED_COMBINATION_KEY_GENERATED_FROM_P256, // SSP Simpe Pairing
AUTHENTICATED_COMBINATION_KEY_GENERATED_FROM_P256, // SSP Passkey, Number confirm, OOB
} link_key_type_t;
/**
* @brief 128 bit key used with AES128 in Security Manager
*/
typedef uint8_t sm_key_t[16];
// will be moved to daemon/btstack_device_name_db.h
/**
* @brief The device name type
@ -95,15 +64,6 @@ typedef uint8_t sm_key_t[16];
#define DEVICE_NAME_LEN 248
typedef uint8_t device_name_t[DEVICE_NAME_LEN+1];
// packet handler
typedef void (*btstack_packet_handler_t) (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
// packet callback supporting multiple registrations
typedef struct {
btstack_linked_item_t item;
btstack_packet_handler_t callback;
} btstack_packet_callback_registration_t;
// helper for BT little endian format
#define little_endian_read_16( buffer, pos) ( ((uint16_t) buffer[pos]) | (((uint16_t)buffer[(pos)+1]) << 8))

View File

@ -42,8 +42,7 @@
#ifndef __BTSTACK_LINK_KEY_DB_H
#define __BTSTACK_LINK_KEY_DB_H
#include "btstack_util.h"
#include "gap.h"
#include "bluetooth.h"
#if defined __cplusplus
extern "C" {

View File

@ -53,6 +53,7 @@
#include "btstack_util.h"
#include "classic/btstack_link_key_db.h"
#include "hci_cmd.h"
#include "gap.h"
#include "hci_transport.h"
#include <stdint.h>