Skip to content
Permalink
Browse files

Bluetooth: Host: Print error codes in hex

Error codes are listed in header files and in the core spec as hex
values. Always print them in hex in debug for easier error code
checking.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
  • Loading branch information...
joerchan authored and carlescufi committed Aug 5, 2019
1 parent 67c66bd commit c1a754f6654701488150570d8f235e11573db1c8
@@ -81,7 +81,7 @@ static void disconnected(struct bt_conn *conn, u8_t reason)

bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));

printk("Disconnected: %s (reason %u)\n", addr, reason);
printk("Disconnected: %s (reason 0x%02x)\n", addr, reason);

bt_conn_unref(default_conn);
default_conn = NULL;
@@ -187,7 +187,7 @@ static void disconnected(struct bt_conn *conn, u8_t reason)

bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));

printk("Disconnected: %s (reason %u)\n", addr, reason);
printk("Disconnected: %s (reason 0x%02x)\n", addr, reason);

if (default_conn != conn) {
return;
@@ -649,7 +649,7 @@ static void idle_timeout(struct k_work *work)
static void connected(struct bt_conn *conn, u8_t err)
{
if (err) {
printk("Connection failed (err %u)\n", err);
printk("Connection failed (err 0x%02x)\n", err);
} else {
printk("Connected\n");
k_delayed_work_cancel(&idle_work);
@@ -660,7 +660,7 @@ static void disconnected(struct bt_conn *conn, u8_t reason)
{
struct eds_slot *slot = &eds_slots[eds_active_slot];

printk("Disconnected (reason %u)\n", reason);
printk("Disconnected (reason 0x%02x)\n", reason);

if (!slot->connectable) {
k_delayed_work_submit(&idle_work, 0);
@@ -229,15 +229,15 @@ static const struct bt_data ad[] = {
static void connected(struct bt_conn *conn, u8_t err)
{
if (err) {
printk("Connection failed (err %u)\n", err);
printk("Connection failed (err 0x%02x)\n", err);
} else {
printk("Connected\n");
}
}

static void disconnected(struct bt_conn *conn, u8_t reason)
{
printk("Disconnected (reason %u)\n", reason);
printk("Disconnected (reason 0x%02x)\n", reason);
}

static struct bt_conn_cb conn_callbacks = {
@@ -344,15 +344,15 @@ static void csc_simulation(void)
static void connected(struct bt_conn *conn, u8_t err)
{
if (err) {
printk("Connection failed (err %u)\n", err);
printk("Connection failed (err 0x%02x)\n", err);
} else {
printk("Connected\n");
}
}

static void disconnected(struct bt_conn *conn, u8_t reason)
{
printk("Disconnected (reason %u)\n", reason);
printk("Disconnected (reason 0x%02x)\n", reason);
}

static struct bt_conn_cb conn_callbacks = {
@@ -29,15 +29,15 @@ static const struct bt_data ad[] = {
static void connected(struct bt_conn *conn, u8_t err)
{
if (err) {
printk("Connection failed (err %u)\n", err);
printk("Connection failed (err 0x%02x)\n", err);
} else {
printk("Connected\n");
}
}

static void disconnected(struct bt_conn *conn, u8_t reason)
{
printk("Disconnected (reason %u)\n", reason);
printk("Disconnected (reason 0x%02x)\n", reason);
}

static struct bt_conn_cb conn_callbacks = {
@@ -361,15 +361,15 @@ static const struct bt_data ad[] = {
static void connected(struct bt_conn *conn, u8_t err)
{
if (err) {
printk("Connection failed (err %u)\n", err);
printk("Connection failed (err 0x%02x)\n", err);
} else {
printk("Connected\n");
}
}

static void disconnected(struct bt_conn *conn, u8_t reason)
{
printk("Disconnected (reason %u)\n", reason);
printk("Disconnected (reason 0x%02x)\n", reason);
}

static struct bt_conn_cb conn_callbacks = {
@@ -55,7 +55,7 @@ static void disconnected(struct bt_conn *conn, u8_t reason)

bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));

printk("Disconnected from %s (reason %u)\n", addr, reason);
printk("Disconnected from %s (reason 0x%02x)\n", addr, reason);
}

static void security_changed(struct bt_conn *conn, bt_security_t level)
@@ -32,7 +32,7 @@ static const struct bt_data ad[] = {
static void connected(struct bt_conn *conn, u8_t err)
{
if (err) {
printk("Connection failed (err %u)\n", err);
printk("Connection failed (err 0x%02x)\n", err);
} else {
default_conn = bt_conn_ref(conn);
printk("Connected\n");
@@ -41,7 +41,7 @@ static void connected(struct bt_conn *conn, u8_t err)

static void disconnected(struct bt_conn *conn, u8_t reason)
{
printk("Disconnected (reason %u)\n", reason);
printk("Disconnected (reason 0x%02x)\n", reason);

if (default_conn) {
bt_conn_unref(default_conn);
@@ -36,7 +36,7 @@ static const struct bt_data ad[] = {
static void connected(struct bt_conn *conn, u8_t err)
{
if (err) {
printk("Connection failed (err %u)\n", err);
printk("Connection failed (err 0x%02x)\n", err);
} else {
default_conn = bt_conn_ref(conn);
printk("Connected\n");
@@ -45,7 +45,7 @@ static void connected(struct bt_conn *conn, u8_t err)

static void disconnected(struct bt_conn *conn, u8_t reason)
{
printk("Disconnected (reason %u)\n", reason);
printk("Disconnected (reason 0x%02x)\n", reason);

if (default_conn) {
bt_conn_unref(default_conn);
@@ -48,7 +48,7 @@ static void disconnected(struct bt_conn *conn, u8_t reason)

bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));

printk("Disconnected from %s (reason %u)\n", addr, reason);
printk("Disconnected from %s (reason 0x%02x)\n", addr, reason);
}

static void identity_resolved(struct bt_conn *conn, const bt_addr_le_t *rpa,
@@ -230,7 +230,7 @@ static void connected(struct bt_conn *conn, u8_t err)
struct bt_conn_info info;

if (err) {
printk("Connection failed (err %u)\n", err);
printk("Connection failed (err 0x%02x)\n", err);
return;
}

@@ -255,7 +255,7 @@ static void connected(struct bt_conn *conn, u8_t err)

static void disconnected(struct bt_conn *conn, u8_t reason)
{
printk("Disconnected (reason %u)\n", reason);
printk("Disconnected (reason 0x%02x)\n", reason);

if (default_conn) {
bt_conn_unref(default_conn);
@@ -83,15 +83,15 @@ static void advertise(void)
static void connected(struct bt_conn *conn, u8_t err)
{
if (err) {
printk("Connection failed (err %u)\n", err);
printk("Connection failed (err 0x%02x)\n", err);
} else {
printk("Connected\n");
}
}

static void disconnected(struct bt_conn *conn, u8_t reason)
{
printk("Disconnected (reason %u)\n", reason);
printk("Disconnected (reason 0x%02x)\n", reason);
advertise();
}

@@ -349,7 +349,7 @@ static u8_t att_handle_rsp(struct bt_att *att, void *pdu, u16_t len, u8_t err)
{
bt_att_func_t func;

BT_DBG("err %u len %u: %s", err, len, bt_hex(pdu, len));
BT_DBG("err 0x%02x len %u: %s", err, len, bt_hex(pdu, len));

/* Cancel timeout if ongoing */
k_delayed_work_cancel(&att->timeout_work);

0 comments on commit c1a754f

Please sign in to comment.
You can’t perform that action at this time.