2016-11-24 12:58:26 -05:00
|
|
|
// Copyright 2015-2016 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.
|
|
|
|
|
2016-09-26 09:37:39 -04:00
|
|
|
/**
|
|
|
|
* bt_defs.h Defines useful API for whole Bluedroid
|
2016-11-24 13:10:15 -05:00
|
|
|
*
|
2016-09-26 09:37:39 -04:00
|
|
|
*/
|
|
|
|
#ifndef _BT_DEFS_H_
|
|
|
|
#define _BT_DEFS_H_
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include "bt_trace.h"
|
2017-08-17 09:13:45 -04:00
|
|
|
#include "bt_target.h"
|
2016-09-26 09:37:39 -04:00
|
|
|
|
|
|
|
#define UNUSED(x) (void)(x)
|
|
|
|
|
|
|
|
#ifndef SIZE_MAX
|
2016-10-15 05:46:10 -04:00
|
|
|
#define SIZE_MAX 254
|
2016-09-26 09:37:39 -04:00
|
|
|
#endif
|
|
|
|
/*Timer Related Defination*/
|
|
|
|
|
2017-08-17 09:13:45 -04:00
|
|
|
//by Snake.T
|
|
|
|
typedef void (TIMER_CBACK)(void *p_tle);
|
|
|
|
typedef struct _tle {
|
|
|
|
struct _tle *p_next;
|
|
|
|
struct _tle *p_prev;
|
|
|
|
TIMER_CBACK *p_cback;
|
|
|
|
INT32 ticks;
|
|
|
|
INT32 ticks_initial;
|
|
|
|
TIMER_PARAM_TYPE param;
|
|
|
|
TIMER_PARAM_TYPE data;
|
|
|
|
UINT16 event;
|
|
|
|
UINT8 in_use;
|
|
|
|
} TIMER_LIST_ENT;
|
|
|
|
|
2016-09-26 09:37:39 -04:00
|
|
|
#define alarm_timer_t uint32_t
|
|
|
|
#define alarm_timer_setfn(timer, cb, data) \
|
|
|
|
do { \
|
|
|
|
} while (0)
|
|
|
|
#define alarm_timer_arm(timer, to, periodic) \
|
|
|
|
do { \
|
|
|
|
} while (0)
|
|
|
|
#define alarm_timer_disarm(timer) \
|
|
|
|
do { \
|
|
|
|
} while (0)
|
|
|
|
#define alarm_timer_now() (0)
|
|
|
|
|
|
|
|
|
|
|
|
/*Bluetooth Address*/
|
|
|
|
typedef struct {
|
2016-11-24 13:10:15 -05:00
|
|
|
uint8_t address[6];
|
2016-09-26 09:37:39 -04:00
|
|
|
} __attribute__ ((__packed__)) bt_bdaddr_t;
|
|
|
|
|
2016-10-21 03:12:22 -04:00
|
|
|
/** Bluetooth 128-bit UUID */
|
|
|
|
typedef struct {
|
2016-11-24 13:10:15 -05:00
|
|
|
uint8_t uu[16];
|
2016-10-21 03:12:22 -04:00
|
|
|
} bt_uuid_t;
|
|
|
|
|
|
|
|
/** Bluetooth Error Status */
|
|
|
|
/** We need to build on this */
|
|
|
|
|
2017-05-31 05:20:29 -04:00
|
|
|
/* relate to ESP_BT_STATUS_xxx in esp_bt_defs.h */
|
2016-10-21 03:12:22 -04:00
|
|
|
typedef enum {
|
2017-05-31 05:20:29 -04:00
|
|
|
BT_STATUS_SUCCESS = 0,
|
2016-10-21 03:12:22 -04:00
|
|
|
BT_STATUS_FAIL,
|
|
|
|
BT_STATUS_NOT_READY,
|
|
|
|
BT_STATUS_NOMEM,
|
|
|
|
BT_STATUS_BUSY,
|
|
|
|
BT_STATUS_DONE, /* request already completed */
|
|
|
|
BT_STATUS_UNSUPPORTED,
|
|
|
|
BT_STATUS_PARM_INVALID,
|
|
|
|
BT_STATUS_UNHANDLED,
|
|
|
|
BT_STATUS_AUTH_FAILURE,
|
|
|
|
BT_STATUS_RMT_DEV_DOWN,
|
2017-05-19 05:23:00 -04:00
|
|
|
BT_STATUS_AUTH_REJECTED,
|
2017-05-31 05:20:29 -04:00
|
|
|
BT_STATUS_INVALID_STATIC_RAND_ADDR,
|
2017-06-02 01:09:23 -04:00
|
|
|
BT_STATUS_PENDING,
|
|
|
|
BT_STATUS_UNACCEPT_CONN_INTERVAL,
|
|
|
|
BT_STATUS_PARAM_OUT_OF_RANGE,
|
|
|
|
BT_STATUS_TIMEOUT,
|
2017-12-19 03:41:07 -05:00
|
|
|
BT_STATUS_MEMORY_FULL,
|
2016-10-21 03:12:22 -04:00
|
|
|
} bt_status_t;
|
2016-09-26 09:37:39 -04:00
|
|
|
|
|
|
|
#ifndef CPU_LITTLE_ENDIAN
|
|
|
|
#define CPU_LITTLE_ENDIAN
|
|
|
|
#endif
|
|
|
|
|
2016-11-24 13:10:15 -05:00
|
|
|
inline uint16_t swap_byte_16(uint16_t x)
|
|
|
|
{
|
|
|
|
return (((x & 0x00ffU) << 8) |
|
|
|
|
((x & 0xff00U) >> 8));
|
2016-09-26 09:37:39 -04:00
|
|
|
}
|
|
|
|
|
2016-11-24 13:10:15 -05:00
|
|
|
inline uint32_t swap_byte_32(uint32_t x)
|
|
|
|
{
|
|
|
|
return (((x & 0x000000ffUL) << 24) |
|
|
|
|
((x & 0x0000ff00UL) << 8) |
|
|
|
|
((x & 0x00ff0000UL) >> 8) |
|
|
|
|
((x & 0xff000000UL) >> 24));
|
2016-09-26 09:37:39 -04:00
|
|
|
}
|
2016-10-25 23:25:24 -04:00
|
|
|
|
2016-10-06 22:47:25 -04:00
|
|
|
#ifndef ntohs
|
2016-11-24 13:10:15 -05:00
|
|
|
inline uint16_t ntohs(uint16_t x)
|
|
|
|
{
|
2016-09-26 09:37:39 -04:00
|
|
|
#ifdef CPU_LITTLE_ENDIAN
|
2016-11-24 13:10:15 -05:00
|
|
|
return swap_byte_16(x);
|
2016-09-26 09:37:39 -04:00
|
|
|
#else
|
2016-11-24 13:10:15 -05:00
|
|
|
return x;
|
2016-09-26 09:37:39 -04:00
|
|
|
#endif
|
|
|
|
}
|
2016-10-21 03:12:22 -04:00
|
|
|
#endif /* #ifndef ntohs */
|
|
|
|
|
2016-10-25 23:25:24 -04:00
|
|
|
#ifndef htons
|
2016-11-24 13:10:15 -05:00
|
|
|
inline uint16_t htons(uint16_t x)
|
|
|
|
{
|
2016-10-25 23:25:24 -04:00
|
|
|
#ifdef CPU_LITTLE_ENDIAN
|
2016-11-24 13:10:15 -05:00
|
|
|
return swap_byte_16(x);
|
2016-10-25 23:25:24 -04:00
|
|
|
#else
|
2016-11-24 13:10:15 -05:00
|
|
|
return x;
|
2016-10-25 23:25:24 -04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#endif /* #ifndef htons */
|
|
|
|
|
2016-10-21 03:12:22 -04:00
|
|
|
#ifndef ntohl
|
2016-11-24 13:10:15 -05:00
|
|
|
inline uint32_t ntohl(uint32_t x)
|
|
|
|
{
|
2016-10-21 03:12:22 -04:00
|
|
|
#ifdef CPU_LITTLE_ENDIAN
|
2016-11-24 13:10:15 -05:00
|
|
|
return swap_byte_32(x);
|
2016-10-21 03:12:22 -04:00
|
|
|
#else
|
2016-11-24 13:10:15 -05:00
|
|
|
return x;
|
2016-10-06 22:47:25 -04:00
|
|
|
#endif
|
2016-10-21 03:12:22 -04:00
|
|
|
}
|
|
|
|
#endif /* #ifndef ntohl*/
|
2016-09-26 09:37:39 -04:00
|
|
|
|
2016-10-25 23:25:24 -04:00
|
|
|
#ifndef htonl
|
2016-11-24 13:10:15 -05:00
|
|
|
inline uint32_t htonl(uint32_t x)
|
|
|
|
{
|
2016-10-25 23:25:24 -04:00
|
|
|
#ifdef CPU_LITTLE_ENDIAN
|
2016-11-24 13:10:15 -05:00
|
|
|
return swap_byte_32(x);
|
2016-10-25 23:25:24 -04:00
|
|
|
#else
|
2016-11-24 13:10:15 -05:00
|
|
|
return x;
|
2016-10-25 23:25:24 -04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#endif /* #ifndef htonl*/
|
|
|
|
|
2016-09-26 09:37:39 -04:00
|
|
|
#endif /* _BT_DEFS_H_ */
|