1 /* 2 * Copyright (c) 2022 Winner Microelectronics Co., Ltd. All rights reserved. 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 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 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. 14 */ 15 16 #ifndef __BLE_UTIL_H__ 17 #define __BLE_UTIL_H__ 18 #include <stdio.h> 19 #include <stdint.h> 20 21 #define BLE_IF_DBG 1 22 23 #ifndef BLE_IF_DBG 24 #define BLE_IF_DBG 0 25 #endif 26 27 #if BLE_IF_DBG 28 #define BLE_IF_DEBUG(fmt, ...) \ 29 do { \ 30 if (1) \ 31 printf("%s(L%d): " fmt, __FUNCTION__, __LINE__, ## __VA_ARGS__); \ 32 } while (0) 33 #define BLE_IF_PRINTF(fmt, ...) \ 34 do { \ 35 if (1) \ 36 printf(fmt, ## __VA_ARGS__); \ 37 } while (0) 38 #else 39 #define BLE_IF_DEBUG(param, ...) 40 #define BLE_IF_PRINTF(param, ...) 41 #endif 42 43 #ifndef MIN 44 #define MIN(a, b) (((a) < (b)) ? (a) : (b)) 45 #endif 46 extern const char *tls_bt_gap_evt_2_str(uint32_t event); 47 extern void tls_bt_dump_hexstring(const char *info, uint8_t *p, int length); 48 49 #endif 50