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)
29 /*Timer Related Defination*/
32 typedef void (TIMER_CBACK)(void *p_tle);
39 TIMER_PARAM_TYPE param;
40 TIMER_PARAM_TYPE data;
45 #define alarm_timer_t uint32_t
46 #define alarm_timer_setfn(timer, cb, data) \
49 #define alarm_timer_arm(timer, to, periodic) \
52 #define alarm_timer_disarm(timer) \
55 #define alarm_timer_now() (0)
61 } __attribute__ ((__packed__)) bt_bdaddr_t;
63 /** Bluetooth 128-bit UUID */
68 /** Bluetooth Error Status */
69 /** We need to build on this */
71 /* relate to ESP_BT_STATUS_xxx in esp_bt_defs.h */
73 BT_STATUS_SUCCESS = 0,
78 BT_STATUS_DONE, /* request already completed */
79 BT_STATUS_UNSUPPORTED,
80 BT_STATUS_PARM_INVALID,
82 BT_STATUS_AUTH_FAILURE,
83 BT_STATUS_RMT_DEV_DOWN,
84 BT_STATUS_AUTH_REJECTED,
85 BT_STATUS_INVALID_STATIC_RAND_ADDR,
87 BT_STATUS_UNACCEPT_CONN_INTERVAL,
88 BT_STATUS_PARAM_OUT_OF_RANGE,
90 BT_STATUS_MEMORY_FULL,
93 #ifndef CPU_LITTLE_ENDIAN
94 #define CPU_LITTLE_ENDIAN
97 inline uint16_t swap_byte_16(uint16_t x)
99 return (((x & 0x00ffU) << 8) |
100 ((x & 0xff00U) >> 8));
103 inline uint32_t swap_byte_32(uint32_t x)
105 return (((x & 0x000000ffUL) << 24) |
106 ((x & 0x0000ff00UL) << 8) |
107 ((x & 0x00ff0000UL) >> 8) |
108 ((x & 0xff000000UL) >> 24));
112 inline uint16_t ntohs(uint16_t x)
114 #ifdef CPU_LITTLE_ENDIAN
115 return swap_byte_16(x);
120 #endif /* #ifndef ntohs */
123 inline uint16_t htons(uint16_t x)
125 #ifdef CPU_LITTLE_ENDIAN
126 return swap_byte_16(x);
131 #endif /* #ifndef htons */
134 inline uint32_t ntohl(uint32_t x)
136 #ifdef CPU_LITTLE_ENDIAN
137 return swap_byte_32(x);
142 #endif /* #ifndef ntohl*/
145 inline uint32_t htonl(uint32_t x)
147 #ifdef CPU_LITTLE_ENDIAN
148 return swap_byte_32(x);
153 #endif /* #ifndef htonl*/
155 #endif /* _BT_DEFS_H_ */