当前位置:操作系统 > 安卓/Android >>

Andorid BlueZ Debug Enable

打开Android BlueZ Debug 开关:

Enable Bluetoothd debugging
Way1:
    In file external/bluetooth/bluez/src/log.h
    Redefine DBG as follow:

1)
#define DBG(fmt, arg...) __android_log_print(ANDROID_LOG_DEBUG, "BlueZ", fmt, ## arg)
2)
add file as header in log.h:
#include <android/log.h>
3)
void __btd_toggle_debug()                                                                                                                                   
{
    struct btd_debug_desc *desc;

//  for (desc = __start___debug; desc < __stop___debug; desc++)
//      desc->flags |= BTD_DEBUG_FLAG_PRINT;
}

void __btd_log_init(const char *debug, int detach)
{
    int option = LOG_NDELAY | LOG_PID;
    struct btd_debug_desc *desc;
    const char *name = NULL, *file = NULL;

    if (debug != NULL)
        enabled = g_strsplit_set(debug, ":, ", 0);
/*
    for (desc = __start___debug; desc < __stop___debug; desc++) {
        if (file != NULL || name != NULL) {
            if (g_strcmp0(desc->file, file) == 0) {
                if (desc->name == NULL)
                    desc->name = name;
            } else
                file = NULL;
        }

        if (is_enabled(desc))
            desc->flags |= BTD_DEBUG_FLAG_PRINT;
    }
*/


Way 2:
In file external/bluetooth/bluez/src/log.h:
1.
Add
#include <cutils/logd.h>

2.
Before:
#define BTD_DEBUG_FLAG_DEFAULT (0)
#define BTD_DEBUG_FLAG_PRINT (1 << 0)
After
#define BTD_DEBUG_FLAG_DEFAULT 1
#define BTD_DEBUG_FLAG_PRINT 1

3.
Before:
#define DBG(fmt, arg...) do { \
static struct btd_debug_desc __btd_debug_desc \
__attribute__((used, section("__debug"), aligned(8))) = { \
.file = __FILE__, .flags = BTD_DEBUG_FLAG_DEFAULT, \
}; \
if (__btd_debug_desc.flags & BTD_DEBUG_FLAG_PRINT) \
btd_debug("%s:%s() " fmt, __FILE__, __FUNCTION__ , ## arg); \
} while (0)www.zzzyk.com
After:
#define DBG(fmt, arg...) do { \
static struct btd_debug_desc __btd_debug_desc \
__attribute__((used, section("__debug"), aligned(8))) = { \
.file = __FILE__, .flags = BTD_DEBUG_FLAG_DEFAULT, \
}; \
if (__btd_debug_desc.flags & BTD_DEBUG_FLAG_PRINT) \
__android_log_print(ANDROID_LOG_DEBUG, "BlueZ",fmt, ##arg); \
} while (0)

End.


作者:saturnbj
补充:移动开发 , Android ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,