diff --git a/examples/discover/discover.c b/examples/discover/discover.c index b610bc8..c2f9c7e 100644 --- a/examples/discover/discover.c +++ b/examples/discover/discover.c @@ -47,7 +47,7 @@ int main(int argc, char *argv[]) } ret = gattlib_discover_primary(connection, &services, &services_count); - if (ret != 0) { + if (ret != GATTLIB_SUCCESS) { fprintf(stderr, "Fail to discover primary services.\n"); return 1; } @@ -62,7 +62,7 @@ int main(int argc, char *argv[]) free(services); ret = gattlib_discover_char(connection, &characteristics, &characteristics_count); - if (ret != 0) { + if (ret != GATTLIB_SUCCESS) { fprintf(stderr, "Fail to discover characteristics.\n"); return 1; } diff --git a/examples/gatttool/gatttool.c b/examples/gatttool/gatttool.c index a617bac..e339b61 100644 --- a/examples/gatttool/gatttool.c +++ b/examples/gatttool/gatttool.c @@ -159,7 +159,7 @@ static gboolean primary(gpointer user_data) int services_count, i; int ret = gattlib_discover_primary(connection, &services, &services_count); - if (ret == 0) { + if (ret == GATTLIB_SUCCESS) { for (i = 0; i < services_count; i++) { gattlib_uuid_to_string(&services[i].uuid, uuid_str, sizeof(uuid_str)); diff --git a/examples/gatttool/interactive.c b/examples/gatttool/interactive.c index aefcf1c..98b20b8 100644 --- a/examples/gatttool/interactive.c +++ b/examples/gatttool/interactive.c @@ -351,7 +351,7 @@ static void cmd_primary(int argcp, char **argvp) int services_count, ret, i; ret = gattlib_discover_primary(g_connection, &services, &services_count); - if (ret == 0) { + if (ret == GATTLIB_SUCCESS) { for (i = 0; i < services_count; i++) { gattlib_uuid_to_string(&services[i].uuid, uuid_str, sizeof(uuid_str)); @@ -428,7 +428,7 @@ static void cmd_char(int argcp, char **argvp) } ret = gattlib_discover_char_range(g_connection, start, end, &characteristics, &characteristics_count); - if (ret == 0) { + if (ret == GATTLIB_SUCCESS) { for (i = 0; i < characteristics_count; i++) { gattlib_uuid_to_string(&characteristics[i].uuid, uuid_str, sizeof(uuid_str)); @@ -470,7 +470,7 @@ static void cmd_char_desc(int argcp, char **argvp) } ret = gattlib_discover_desc_range(g_connection, start, end, &descriptors, &descriptor_count); - if (ret == 0) { + if (ret == GATTLIB_SUCCESS) { for (i = 0; i < descriptor_count; i++) { char uuid_str[MAX_LEN_UUID_STR + 1]; diff --git a/examples/read_write/read_write.c b/examples/read_write/read_write.c index f8d4624..22f8fd5 100644 --- a/examples/read_write/read_write.c +++ b/examples/read_write/read_write.c @@ -75,15 +75,15 @@ int main(int argc, char *argv[]) { } if (g_operation == READ) { - uint8_t *buffer; + uint8_t *buffer = NULL; ret = gattlib_read_char_by_uuid(connection, &g_uuid, (void **)&buffer, &len); - if (ret == -1) { + if (ret != GATTLIB_SUCCESS) { char uuid_str[MAX_LEN_UUID_STR + 1]; gattlib_uuid_to_string(&g_uuid, uuid_str, sizeof(uuid_str)); - fprintf(stderr, "Could not find GATT Characteristic with UUID %s\n", uuid_str); + fprintf(stderr, "Could not find GATT Characteristic with UUID %s (ret:%d)\n", uuid_str, ret); goto EXIT; } @@ -96,12 +96,12 @@ int main(int argc, char *argv[]) { free(buffer); } else { ret = gattlib_write_char_by_uuid(connection, &g_uuid, &value_data, sizeof(value_data)); - if (ret == -1) { + if (ret != GATTLIB_SUCCESS) { char uuid_str[MAX_LEN_UUID_STR + 1]; gattlib_uuid_to_string(&g_uuid, uuid_str, sizeof(uuid_str)); - fprintf(stderr, "Could not find GATT Characteristic with UUID %s\n", uuid_str); + fprintf(stderr, "Could not find GATT Characteristic with UUID %s (ret:%d)\n", uuid_str, ret); goto EXIT; } }