mirror of https://github.com/labapart/gattlib
bluez: Returns GATTLIB_ errors
parent
69fb243fe7
commit
50129fe753
|
@ -175,6 +175,7 @@ static void *connection_thread(void* arg) {
|
|||
g_main_loop_run(loop_thread->loop);
|
||||
g_main_loop_unref(loop_thread->loop);
|
||||
assert(0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static gatt_connection_t *initialize_gattlib_connection(const gchar *src, const gchar *dst,
|
||||
|
@ -489,7 +490,7 @@ int gattlib_disconnect(gatt_connection_t* connection) {
|
|||
pthread_detach(g_gattlib_thread.thread);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return GATTLIB_SUCCESS;
|
||||
}
|
||||
|
||||
GSource* gattlib_watch_connection_full(GIOChannel* io, GIOCondition condition,
|
||||
|
@ -530,10 +531,10 @@ int get_uuid_from_handle(gatt_connection_t* connection, uint16_t handle, uuid_t*
|
|||
for (i = 0; i < conn_context->characteristic_count; i++) {
|
||||
if (conn_context->characteristics[i].value_handle == handle) {
|
||||
memcpy(uuid, &conn_context->characteristics[i].uuid, sizeof(uuid_t));
|
||||
return 0;
|
||||
return GATTLIB_SUCCESS;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
return GATTLIB_NOT_FOUND;
|
||||
}
|
||||
|
||||
int get_handle_from_uuid(gatt_connection_t* connection, const uuid_t* uuid, uint16_t* handle) {
|
||||
|
@ -543,10 +544,10 @@ int get_handle_from_uuid(gatt_connection_t* connection, const uuid_t* uuid, uint
|
|||
for (i = 0; i < conn_context->characteristic_count; i++) {
|
||||
if (gattlib_uuid_cmp(&conn_context->characteristics[i].uuid, uuid) == 0) {
|
||||
*handle = conn_context->characteristics[i].value_handle;
|
||||
return 0;
|
||||
return GATTLIB_SUCCESS;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
return GATTLIB_NOT_FOUND;
|
||||
}
|
||||
|
||||
#if 0 // Disable until https://github.com/labapart/gattlib/issues/75 is resolved
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* GattLib - GATT Library
|
||||
*
|
||||
* Copyright (C) 2016-2017 Olivier Martin <olivier@labapart.org>
|
||||
* Copyright (C) 2016-2019 Olivier Martin <olivier@labapart.org>
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
|
@ -85,7 +85,7 @@ int gattlib_discover_primary(gatt_connection_t* connection, gattlib_primary_serv
|
|||
ret = gatt_discover_primary(conn_context->attrib, NULL, primary_all_cb, &user_data);
|
||||
if (ret == 0) {
|
||||
fprintf(stderr, "Fail to discover primary services.\n");
|
||||
return 1;
|
||||
return GATTLIB_ERROR_BLUEZ;
|
||||
}
|
||||
|
||||
// Wait for completion
|
||||
|
@ -100,7 +100,7 @@ int gattlib_discover_primary(gatt_connection_t* connection, gattlib_primary_serv
|
|||
*services_count = user_data.services_count;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return GATTLIB_SUCCESS;
|
||||
}
|
||||
|
||||
struct characteristic_cb_t {
|
||||
|
@ -157,7 +157,7 @@ int gattlib_discover_char_range(gatt_connection_t* connection, int start, int en
|
|||
ret = gatt_discover_char(conn_context->attrib, start, end, NULL, characteristic_cb, &user_data);
|
||||
if (ret == 0) {
|
||||
fprintf(stderr, "Fail to discover characteristics.\n");
|
||||
return 1;
|
||||
return GATTLIB_ERROR_BLUEZ;
|
||||
}
|
||||
|
||||
// Wait for completion
|
||||
|
@ -167,7 +167,7 @@ int gattlib_discover_char_range(gatt_connection_t* connection, int start, int en
|
|||
*characteristics = user_data.characteristics;
|
||||
*characteristics_count = user_data.characteristics_count;
|
||||
|
||||
return 0;
|
||||
return GATTLIB_SUCCESS;
|
||||
}
|
||||
|
||||
int gattlib_discover_char(gatt_connection_t* connection, gattlib_characteristic_t** characteristics, int* characteristics_count) {
|
||||
|
@ -278,7 +278,7 @@ int gattlib_discover_desc_range(gatt_connection_t* connection, int start, int en
|
|||
#endif
|
||||
if (ret == 0) {
|
||||
fprintf(stderr, "Fail to discover descriptors.\n");
|
||||
return 1;
|
||||
return GATTLIB_ERROR_BLUEZ;
|
||||
}
|
||||
|
||||
// Wait for completion
|
||||
|
|
Loading…
Reference in New Issue