现在的位置: 首页 > 综合 > 正文

Andorid BlueZ Debug Enable

2013年12月02日 ⁄ 综合 ⁄ 共 1866字 ⁄ 字号 评论关闭

打开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)
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.

抱歉!评论已关闭.