1 // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
16 * common/bt_defs.h Defines useful API for whole Bluedroid
24 #include "common/bt_trace.h"
25 #include "common/bt_target.h"
27 #define UNUSED(x) (void)(x)
32 /*Timer Related Defination*/
35 typedef void (TIMER_CBACK)(void *p_tle);
42 TIMER_PARAM_TYPE param;
43 TIMER_PARAM_TYPE data;
48 #define alarm_timer_t uint32_t
49 #define alarm_timer_setfn(timer, cb, data) \
52 #define alarm_timer_arm(timer, to, periodic) \
55 #define alarm_timer_disarm(timer) \
58 #define alarm_timer_now() (0)
64 } __attribute__ ((__packed__)) bt_bdaddr_t;
66 /** Bluetooth 128-bit UUID */
71 /** Bluetooth Error Status */
72 /** We need to build on this */
74 /* relate to ESP_BT_STATUS_xxx in esp_bt_defs.h */
76 BT_STATUS_SUCCESS = 0,
81 BT_STATUS_DONE, /* request already completed */
82 BT_STATUS_UNSUPPORTED,
83 BT_STATUS_PARM_INVALID,
85 BT_STATUS_AUTH_FAILURE,
86 BT_STATUS_RMT_DEV_DOWN,
87 BT_STATUS_AUTH_REJECTED,
88 BT_STATUS_INVALID_STATIC_RAND_ADDR,
90 BT_STATUS_UNACCEPT_CONN_INTERVAL,
91 BT_STATUS_PARAM_OUT_OF_RANGE,
93 BT_STATUS_MEMORY_FULL,
96 #ifndef CPU_LITTLE_ENDIAN
97 #define CPU_LITTLE_ENDIAN
100 inline uint16_t swap_byte_16(uint16_t x)
102 return (((x & 0x00ffU) << 8) |
103 ((x & 0xff00U) >> 8));
106 inline uint32_t swap_byte_32(uint32_t x)
108 return (((x & 0x000000ffUL) << 24) |
109 ((x & 0x0000ff00UL) << 8) |
110 ((x & 0x00ff0000UL) >> 8) |
111 ((x & 0xff000000UL) >> 24));
115 inline uint16_t ntohs(uint16_t x)
117 #ifdef CPU_LITTLE_ENDIAN
118 return swap_byte_16(x);
123 #endif /* #ifndef ntohs */
126 inline uint16_t htons(uint16_t x)
128 #ifdef CPU_LITTLE_ENDIAN
129 return swap_byte_16(x);
134 #endif /* #ifndef htons */
137 inline uint32_t ntohl(uint32_t x)
139 #ifdef CPU_LITTLE_ENDIAN
140 return swap_byte_32(x);
145 #endif /* #ifndef ntohl*/
148 inline uint32_t htonl(uint32_t x)
150 #ifdef CPU_LITTLE_ENDIAN
151 return swap_byte_32(x);
156 #endif /* #ifndef htonl*/
158 #endif /* _BT_DEFS_H_ */